浏览代码

Correctly handle external functions that are used from other units.

pkgutil.pas, createimportlibfromexternals:
  * processasmsyms: also check the import name when checking for duplicates (just for safety, the cache check should have caught these already)
  * processimportedsyms: if we have a routine imported from a library of whihc the symbol resides in a unit loaded from a package we need to import the routine ourselves instead of trying to import it from the package; also add an entry in the cache to speed up finding it again in processasmsyms()

git-svn-id: branches/svenbarth/packages@32639 -
svenbarth 9 年之前
父节点
当前提交
0818fe56d2
共有 1 个文件被更改,包括 20 次插入2 次删除
  1. 20 2
      compiler/pkgutil.pas

+ 20 - 2
compiler/pkgutil.pas

@@ -48,7 +48,9 @@ implementation
     aasmbase,aasmdata,aasmtai,
     aasmbase,aasmdata,aasmtai,
     symtype,symconst,symsym,symdef,symbase,symtable,
     symtype,symconst,symsym,symdef,symbase,symtable,
     ppu,entfile,fpcp,
     ppu,entfile,fpcp,
+    psub,pdecsub,
     ncgutil,
     ncgutil,
+    ogbase,
     export;
     export;
 
 
   procedure procexport(const s : string);
   procedure procexport(const s : string);
@@ -646,7 +648,11 @@ implementation
                       for k:=0 to tprocsym(psym).procdeflist.count-1 do
                       for k:=0 to tprocsym(psym).procdeflist.count-1 do
                         begin
                         begin
                           pd:=tprocdef(tprocsym(psym).procdeflist[k]);
                           pd:=tprocdef(tprocsym(psym).procdeflist[k]);
-                          if has_alias_name(pd,symname) then
+                          if has_alias_name(pd,symname) or
+                              (
+                                ([po_external,po_has_importdll]*pd.procoptions=[po_external,po_has_importdll]) and
+                                (symname=proc_get_importname(pd))
+                              ) then
                             begin
                             begin
                               found:=true;
                               found:=true;
                               break;
                               break;
@@ -717,6 +723,7 @@ implementation
           labind : tasmsymbol;
           labind : tasmsymbol;
           pd : tprocdef;
           pd : tprocdef;
           list : tasmlist;
           list : tasmlist;
+          centry : pcacheentry;
         begin
         begin
           for i:=0 to syms.count-1 do
           for i:=0 to syms.count-1 do
             begin
             begin
@@ -766,7 +773,18 @@ implementation
                                 for l:=0 to tprocsym(sym).procdeflist.count-1 do
                                 for l:=0 to tprocsym(sym).procdeflist.count-1 do
                                   begin
                                   begin
                                     pd:=tprocdef(tprocsym(sym).procdeflist[l]);
                                     pd:=tprocdef(tprocsym(sym).procdeflist[l]);
-                                    import_proc_symbol(pd,pkgentry^.package);
+                                    if [po_external,po_has_importdll]*pd.procoptions=[po_external,po_has_importdll] then
+                                      begin
+                                        { if we use an external procedure of another unit we
+                                          need to import it ourselves from the correct library }
+                                        import_external_proc(pd);
+                                        New(centry);
+                                        centry^.sym:=nil;
+                                        centry^.pkg:=pkgentry^.package;
+                                        cache.add(proc_get_importname(pd),centry);
+                                      end
+                                    else
+                                      import_proc_symbol(pd,pkgentry^.package);
                                   end;
                                   end;
                               end;
                               end;
                             else
                             else