Browse Source

+ Committed patch from peter

michael 24 years ago
parent
commit
6f56bc2312
2 changed files with 67 additions and 5 deletions
  1. 16 3
      compiler/pmodules.pas
  2. 51 2
      compiler/targets/t_win32.pas

+ 16 - 3
compiler/pmodules.pas

@@ -36,7 +36,7 @@ implementation
 
     uses
        globtype,version,systems,tokens,
-       cutils,comphook,
+       cutils,cclasses,comphook,
        globals,verbose,fmodule,finput,fppu,
        symconst,symbase,symppu,symdef,symsym,symtable,aasm,
        cgbase,
@@ -52,6 +52,7 @@ implementation
       var
         DLLScanner      : TDLLScanner;
         s               : string;
+        KeepShared      : TStringList;
       begin
         { try to create import entries from system dlls }
         if target_info.DllScanSupported and
@@ -62,11 +63,13 @@ implementation
             DLLScanner:=CDLLScanner[target_info.target].Create
            else
             internalerror(200104121);
+           KeepShared:=TStringList.Create;
            { Walk all shared libs }
            While not current_module.linkOtherSharedLibs.Empty do
             begin
               S:=current_module.linkOtherSharedLibs.Getusemask(link_allways);
-              DLLScanner.scan(s)
+              if not DLLScanner.scan(s) then
+               KeepShared.Insert(s);
             end;
            DLLscanner.Free;
            { Recreate import section }
@@ -78,6 +81,13 @@ implementation
                importssection:=taasmoutput.Create;
               importlib.generatelib;
             end;
+           { Readd the not processed files }
+           while not KeepShared.Empty do
+            begin
+              s:=KeepShared.GetFirst;
+              current_module.linkOtherSharedLibs.add(s,link_allways);
+            end;
+           KeepShared.Free;
          end;
 
         { create the .s file and assemble it }
@@ -1329,7 +1339,10 @@ implementation
 end.
 {
   $Log$
-  Revision 1.45  2001-08-26 13:36:46  florian
+  Revision 1.46  2001-09-13 14:47:47  michael
+  + Committed patch from peter
+
+  Revision 1.45  2001/08/26 13:36:46  florian
     * some cg reorganisation
     * some PPC updates
 

+ 51 - 2
compiler/targets/t_win32.pas

@@ -723,9 +723,13 @@ Function TLinkerWin32.WriteResponseFile(isdll:boolean) : Boolean;
 Var
   linkres : TLinkRes;
   HPath   : TStringListItem;
-  s       : string;
+  s,s2    : string;
+  i       : integer;
+  linklibc,
+  found   : boolean;
 begin
   WriteResponseFile:=False;
+  linklibc:=false;
 
   { Open link.res file }
   LinkRes:=TLinkRes.Create(outputexedir+Info.ResName);
@@ -776,6 +780,47 @@ begin
      LinkRes.Add(')');
    end;
 
+  { Write sharedlibraries }
+  if not SharedLibFiles.Empty then
+   begin
+     LinkRes.Add('INPUT(') ;
+     While not SharedLibFiles.Empty do
+      begin
+        S:=SharedLibFiles.GetFirst;
+        if pos('.',s)=0 then
+          { we never directly link a DLL
+            its allways through an import library PM }
+          { libraries created by C compilers have .a extensions }
+          s2:=s+'.a'{ target_os.sharedlibext }
+        else
+          s2:=s;
+        s2:=FindLibraryFile(s2,'',found);
+        if found then
+          begin
+            LinkRes.Add(GetShortName(s2));
+            continue;
+          end;
+        if pos(target_info.sharedlibprefix,s)=1 then
+          s:=copy(s,length(target_info.sharedlibprefix)+1,255);
+        if s<>'c' then
+         begin
+           i:=Pos(target_info.sharedlibext,S);
+           if i>0 then
+            Delete(S,i,255);
+           LinkRes.Add('-l'+s);
+         end
+        else
+         begin
+           LinkRes.Add('-l'+s);
+           linklibc:=true;
+         end;
+      end;
+     { be sure that libc is the last lib }
+     if linklibc then
+      LinkRes.Add('-lc');
+     LinkRes.Add(')');
+   end;
+
 { Write and Close response }
   linkres.writetodisk;
   LinkRes.Free;
@@ -1367,6 +1412,7 @@ function tDLLScannerWin32.scan(const binname:string):longbool;
  var
   OldFileMode:longint;
  begin
+   Scan:=false;
   if not FindDll(DLLName(binname),impname) then
    exit;
   assign(f,impname);
@@ -1477,7 +1523,10 @@ initialization
 end.
 {
   $Log$
-  Revision 1.15  2001-08-07 18:47:15  peter
+  Revision 1.16  2001-09-13 14:47:19  michael
+  + Committed patch from peter
+
+  Revision 1.15  2001/08/07 18:47:15  peter
     * merged netbsd start
     * profile for win32