Browse Source

* better libc support

peter 27 years ago
parent
commit
17a0eb45d6
2 changed files with 62 additions and 3 deletions
  1. 24 1
      compiler/cobjects.pas
  2. 38 2
      compiler/link.pas

+ 24 - 1
compiler/cobjects.pas

@@ -138,6 +138,7 @@ unit cobjects;
           function get : string;
           function get : string;
           function get_with_tokeninfo(var file_info : tfileposinfo) : string;
           function get_with_tokeninfo(var file_info : tfileposinfo) : string;
 
 
+          function find(const s:string):boolean;
           { deletes all strings }
           { deletes all strings }
           procedure clear;
           procedure clear;
        end;
        end;
@@ -557,6 +558,25 @@ end;
           end;
           end;
       end;
       end;
 
 
+    function tstringcontainer.find(const s:string):boolean;
+      var
+         hp : pstringitem;
+      begin
+        find:=false;
+        hp:=root;
+        while assigned(hp) do
+         begin
+           if hp^.data^=s then
+            begin
+              find:=true;
+              exit;
+            end;
+           hp:=hp^.next;
+
+         end;
+      end;
+
+
 {****************************************************************************
 {****************************************************************************
                             TLINKEDLIST_ITEM
                             TLINKEDLIST_ITEM
  ****************************************************************************}
  ****************************************************************************}
@@ -1122,7 +1142,10 @@ end;
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.12  1998-07-14 14:46:47  peter
+  Revision 1.13  1998-08-12 19:28:16  peter
+    * better libc support
+
+  Revision 1.12  1998/07/14 14:46:47  peter
     * released NEWINPUT
     * released NEWINPUT
 
 
   Revision 1.11  1998/07/07 11:19:54  peter
   Revision 1.11  1998/07/07 11:19:54  peter

+ 38 - 2
compiler/link.pas

@@ -105,11 +105,12 @@ begin
   SharedLibName:='';
   SharedLibName:='';
   StaticLibName:='';
   StaticLibName:='';
   ObjectSearchPath:='';
   ObjectSearchPath:='';
-  LibrarySearchPath:='';
 {$ifdef linux}
 {$ifdef linux}
   DynamicLinker:='/lib/ld-linux.so.1';
   DynamicLinker:='/lib/ld-linux.so.1';
+  LibrarySearchPath:='/lib;/usr/lib';
 {$else}
 {$else}
   DynamicLinker:='';
   DynamicLinker:='';
+  LibrarySearchPath:='';
 {$endif}
 {$endif}
   LinkResName:='link.res';
   LinkResName:='link.res';
 end;
 end;
@@ -279,6 +280,9 @@ Var
   LinkResponse : Text;
   LinkResponse : Text;
   i            : longint;
   i            : longint;
   prtobj,s,s2  : string;
   prtobj,s,s2  : string;
+  found,
+  linklibc     : boolean;
+
 
 
   procedure WriteRes(const s:string);
   procedure WriteRes(const s:string);
   begin
   begin
@@ -289,6 +293,7 @@ Var
 begin
 begin
   WriteResponseFile:=False;
   WriteResponseFile:=False;
 { set special options for some targets }
 { set special options for some targets }
+  linklibc:=SharedLibFiles.Find('c');
   prtobj:='prt0';
   prtobj:='prt0';
   case target_info.target of
   case target_info.target of
 {$ifdef i386}
 {$ifdef i386}
@@ -299,7 +304,14 @@ begin
                        prtobj:='gprt0';
                        prtobj:='gprt0';
                        AddSharedLibrary('gmon');
                        AddSharedLibrary('gmon');
                        AddSharedLibrary('c');
                        AddSharedLibrary('c');
+                       linklibc:=true;
+                     end
+                    else
+                     begin
+                       if linklibc then
+                        prtobj:='cprt0';
                      end;
                      end;
+
                   end;
                   end;
 {$endif i386}
 {$endif i386}
 {$ifdef m68k}
 {$ifdef m68k}
@@ -344,12 +356,33 @@ begin
   { add objectfiles, start with prt0 always }
   { add objectfiles, start with prt0 always }
   if prtobj<>'' then
   if prtobj<>'' then
    WriteRes(FindObjectFile(prtobj));
    WriteRes(FindObjectFile(prtobj));
+  if linklibc then
+   begin
+     s2:=search('crti.o',librarysearchpath,found);
+     if s2<>'' then
+      begin
+        WriteRes(s2+'crti.o');
+        WriteRes(s2+'crtbegin.o');
+      end;
+
+   end;
+
   while not ObjectFiles.Empty do
   while not ObjectFiles.Empty do
    begin
    begin
      s:=ObjectFiles.Get;
      s:=ObjectFiles.Get;
      if s<>'' then
      if s<>'' then
       WriteRes(s);
       WriteRes(s);
    end;
    end;
+  if linklibc then
+   begin
+     if s2<>'' then
+      begin
+        WriteRes(s2+'crtend.o');
+        WriteRes(s2+'crtn.o');
+      end;
+
+   end;
+
 
 
   { Write sharedlibraries like -l<lib> }
   { Write sharedlibraries like -l<lib> }
   While not SharedLibFiles.Empty do
   While not SharedLibFiles.Empty do
@@ -485,7 +518,10 @@ end;
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.15  1998-08-10 14:50:02  peter
+  Revision 1.16  1998-08-12 19:28:15  peter
+    * better libc support
+
+  Revision 1.15  1998/08/10 14:50:02  peter
     + localswitches, moduleswitches, globalswitches splitting
     + localswitches, moduleswitches, globalswitches splitting
 
 
   Revision 1.14  1998/06/17 14:10:13  peter
   Revision 1.14  1998/06/17 14:10:13  peter