소스 검색

* new link writing to the ppu, one .ppu is needed for all link types,
static (.o) is now always created also when smartlinking is used

peter 26 년 전
부모
커밋
58cbc3e795
15개의 변경된 파일762개의 추가작업 그리고 439개의 파일을 삭제
  1. 177 105
      compiler/cobjects.pas
  2. 7 3
      compiler/comprsrc.pas
  3. 259 139
      compiler/files.pas
  4. 7 3
      compiler/globals.pas
  5. 22 5
      compiler/globtype.pas
  6. 8 4
      compiler/lin_targ.pas
  7. 72 10
      compiler/link.pas
  8. 8 4
      compiler/og386dbg.pas
  9. 48 58
      compiler/options.pas
  10. 6 2
      compiler/os2_targ.pas
  11. 20 27
      compiler/pmodules.pas
  12. 24 19
      compiler/ppu.pas
  13. 7 3
      compiler/scandir.inc
  14. 86 52
      compiler/symppu.inc
  15. 11 5
      compiler/symtable.pas

+ 177 - 105
compiler/cobjects.pas

@@ -68,14 +68,6 @@ unit cobjects;
        end;
 
 
-       { some help data types }
-       pstringitem = ^tstringitem;
-       tstringitem = record
-          data : pstring;
-          next : pstringitem;
-          fileinfo : tfileposinfo; { pointer to tinputfile }
-       end;
-
        plinkedlist_item = ^tlinkedlist_item;
        tlinkedlist_item = object
           next,previous : plinkedlist_item;
@@ -125,11 +117,17 @@ unit cobjects;
           function  empty:boolean;
        end;
 
+       { some help data types }
+       pstringqueueitem = ^tstringqueueitem;
+       tstringqueueitem = object
+          data : pstring;
+          next : pstringqueueitem;
+       end;
 
        { String Queue}
        PStringQueue=^TStringQueue;
        TStringQueue=object
-         first,last : PStringItem;
+         first,last : PStringqueueItem;
          constructor Init;
          destructor Done;
          function Empty:boolean;
@@ -139,36 +137,58 @@ unit cobjects;
          procedure Clear;
        end;
 
+       { containeritem }
+       pcontaineritem = ^tcontaineritem;
+       tcontaineritem = object
+          next : pcontaineritem;
+          constructor init;
+          destructor  done;virtual;
+       end;
+
+       { container }
+       pcontainer = ^tcontainer;
+       tcontainer = object
+          root,
+          last    : pcontaineritem;
+          constructor init;
+          destructor  done;
+          { true when the container is empty }
+          function  empty:boolean;
+          { inserts a string }
+          procedure insert(item:pcontaineritem);
+          { gets a string }
+          function  get:pcontaineritem;
+          { deletes all items }
+          procedure clear;
+       end;
+
+       { containeritem }
+       pstringcontaineritem = ^tstringcontaineritem;
+       tstringcontaineritem = object(tcontaineritem)
+          data : pstring;
+          file_info : tfileposinfo;
+          constructor init(const s:string);
+          constructor Init_TokenInfo(const s:string;const pos:tfileposinfo);
+          destructor  done;virtual;
+       end;
 
        { string container }
        pstringcontainer = ^tstringcontainer;
-       tstringcontainer = object
-          root,
-          last    : pstringitem;
+       tstringcontainer = object(tcontainer)
           doubles : boolean;  { if this is set to true, doubles are allowed }
           constructor init;
           constructor init_no_double;
-          destructor done;
-
-          { true when the container is empty }
-          function empty:boolean;
-
-          { inserts a string }
           procedure insert(const s : string);
           procedure insert_with_tokeninfo(const s : string;const file_info : tfileposinfo);
-
           { gets a string }
           function get : string;
           function get_with_tokeninfo(var file_info : tfileposinfo) : string;
-
           { true if string is in the container }
           function find(const s:string):boolean;
-
-          { deletes all strings }
-          procedure clear;
        end;
 
 
+       { namedindexobject for use with dictionary and indexarray }
        Pnamedindexobject=^Tnamedindexobject;
        Tnamedindexobject=object
          indexnr    : longint;
@@ -578,7 +598,7 @@ end;
 
 function TStringQueue.Get:string;
 var
-  newnode : pstringitem;
+  newnode : pstringqueueitem;
 begin
   if first=nil then
    begin
@@ -595,7 +615,7 @@ end;
 
 procedure TStringQueue.Insert(const s:string);
 var
-  newnode : pstringitem;
+  newnode : pstringqueueitem;
 begin
   new(newnode);
   newnode^.next:=first;
@@ -608,7 +628,7 @@ end;
 
 procedure TStringQueue.Concat(const s:string);
 var
-  newnode : pstringitem;
+  newnode : pstringqueueitem;
 begin
   new(newnode);
   newnode^.next:=nil;
@@ -623,7 +643,7 @@ end;
 
 procedure TStringQueue.Clear;
 var
-  newnode : pstringitem;
+  newnode : pstringqueueitem;
 begin
   while (first<>nil) do
    begin
@@ -640,146 +660,194 @@ begin
   Clear;
 end;
 
+
+{****************************************************************************
+                                TContainerItem
+ ****************************************************************************}
+
+constructor TContainerItem.Init;
+begin
+end;
+
+
+destructor TContainerItem.Done;
+begin
+end;
+
+
 {****************************************************************************
-                           TSTRINGCONTAINER
+                             TStringContainerItem
  ****************************************************************************}
 
-    constructor tstringcontainer.init;
-      begin
-         root:=nil;
-         last:=nil;
-         doubles:=true;
-      end;
+constructor TStringContainerItem.Init(const s:string);
+begin
+  inherited Init;
+  data:=stringdup(s);
+  file_info.fileindex:=0;
+  file_info.line:=0;
+  file_info.column:=0;
+end;
 
 
-    constructor tstringcontainer.init_no_double;
+constructor TStringContainerItem.Init_TokenInfo(const s:string;const pos:tfileposinfo);
+begin
+  inherited Init;
+  data:=stringdup(s);
+  file_info:=pos;
+end;
+
+
+destructor TStringContainerItem.Done;
+begin
+  stringdispose(data);
+end;
+
+
+
+{****************************************************************************
+                                   TCONTAINER
+ ****************************************************************************}
+
+    constructor tcontainer.init;
       begin
          root:=nil;
          last:=nil;
-         doubles:=false;
       end;
 
 
-    destructor tstringcontainer.done;
+    destructor tcontainer.done;
       begin
          clear;
       end;
 
 
-    function tstringcontainer.empty:boolean;
+    function tcontainer.empty:boolean;
       begin
         empty:=(root=nil);
       end;
 
 
-    procedure tstringcontainer.insert(const s : string);
+    procedure tcontainer.insert(item:pcontaineritem);
+      begin
+         item^.next:=nil;
+         if root=nil then
+          root:=item
+         else
+          last^.next:=item;
+         last:=item;
+      end;
+
+
+    procedure tcontainer.clear;
       var
-        newnode : pstringitem;
+         newnode : pcontaineritem;
       begin
-         if not(doubles) then
+         newnode:=root;
+         while assigned(newnode) do
            begin
+              root:=newnode^.next;
+              dispose(newnode,done);
               newnode:=root;
-              while assigned(newnode) do
-                begin
-                   if newnode^.data^=s then exit;
-                   newnode:=newnode^.next;
-                end;
            end;
-         new(newnode);
-         newnode^.next:=nil;
-         newnode^.data:=stringdup(s);
-         if root=nil then root:=newnode
-           else last^.next:=newnode;
-         last:=newnode;
+         last:=nil;
+         root:=nil;
       end;
 
 
-    procedure tstringcontainer.insert_with_tokeninfo(const s : string; const file_info : tfileposinfo);
+    function tcontainer.get:pcontaineritem;
+      begin
+         if root=nil then
+          get:=nil
+         else
+          begin
+            get:=root;
+            root:=root^.next;
+          end;
+      end;
+
+
+{****************************************************************************
+                           TSTRINGCONTAINER
+ ****************************************************************************}
+
+    constructor tstringcontainer.init;
+      begin
+         inherited init;
+         doubles:=true;
+      end;
+
+
+    constructor tstringcontainer.init_no_double;
+      begin
+         doubles:=false;
+      end;
+
+
+    procedure tstringcontainer.insert(const s : string);
       var
-         newnode : pstringitem;
+        newnode : pstringcontaineritem;
       begin
-         if not(doubles) then
-           begin
-              newnode:=root;
-              while assigned(newnode) do
-                begin
-                   if newnode^.data^=s then exit;
-                   newnode:=newnode^.next;
-                end;
-           end;
-         new(newnode);
-         newnode^.next:=nil;
-         newnode^.data:=stringdup(s);
-         newnode^.fileinfo:=file_info;
-         if root=nil then root:=newnode
-           else last^.next:=newnode;
-         last:=newnode;
+         if (s='') or
+            ((not doubles) and find(s)) then
+          exit;
+         new(newnode,init(s));
+         inherited insert(newnode);
       end;
 
 
-    procedure tstringcontainer.clear;
+    procedure tstringcontainer.insert_with_tokeninfo(const s : string; const file_info : tfileposinfo);
       var
-         newnode : pstringitem;
+        newnode : pstringcontaineritem;
       begin
-         newnode:=root;
-         while assigned(newnode) do
-           begin
-              stringdispose(newnode^.data);
-              root:=newnode^.next;
-              dispose(newnode);
-              newnode:=root;
-           end;
-         last:=nil;
-         root:=nil;
+         if (not doubles) and find(s) then
+          exit;
+         new(newnode,init_tokeninfo(s,file_info));
+         inherited insert(newnode);
       end;
 
 
     function tstringcontainer.get : string;
       var
-         newnode : pstringitem;
+         p : pstringcontaineritem;
       begin
-         if root=nil then
+         p:=pstringcontaineritem(inherited get);
+         if p=nil then
           get:=''
          else
           begin
-            get:=root^.data^;
-            newnode:=root;
-            root:=root^.next;
-            stringdispose(newnode^.data);
-            dispose(newnode);
+            get:=p^.data^;
+            dispose(p,done);
           end;
       end;
 
 
     function tstringcontainer.get_with_tokeninfo(var file_info : tfileposinfo) : string;
       var
-         newnode : pstringitem;
+         p : pstringcontaineritem;
       begin
-         if root=nil then
+         p:=pstringcontaineritem(inherited get);
+         if p=nil then
           begin
-             get_with_tokeninfo:='';
-             file_info.fileindex:=0;
-             file_info.line:=0;
-             file_info.column:=0;
+            get_with_tokeninfo:='';
+            file_info.fileindex:=0;
+            file_info.line:=0;
+            file_info.column:=0;
           end
          else
           begin
-            get_with_tokeninfo:=root^.data^;
-            newnode:=root;
-            root:=root^.next;
-            stringdispose(newnode^.data);
-            file_info:=newnode^.fileinfo;
-            dispose(newnode);
+            get_with_tokeninfo:=p^.data^;
+            file_info:=p^.file_info;
+            dispose(p,done);
           end;
       end;
 
 
     function tstringcontainer.find(const s:string):boolean;
       var
-         newnode : pstringitem;
+        newnode : pstringcontaineritem;
       begin
         find:=false;
-        newnode:=root;
+        newnode:=pstringcontaineritem(root);
         while assigned(newnode) do
          begin
            if newnode^.data^=s then
@@ -787,7 +855,7 @@ end;
               find:=true;
               exit;
             end;
-           newnode:=newnode^.next;
+           newnode:=pstringcontaineritem(newnode^.next);
          end;
       end;
 
@@ -2136,7 +2204,11 @@ end;
 end.
 {
   $Log$
-  Revision 1.36  1999-06-23 11:13:20  peter
+  Revision 1.37  1999-07-03 00:29:45  peter
+    * new link writing to the ppu, one .ppu is needed for all link types,
+      static (.o) is now always created also when smartlinking is used
+
+  Revision 1.36  1999/06/23 11:13:20  peter
     * fixed linebreak
 
   Revision 1.35  1999/06/23 11:07:23  daniel

+ 7 - 3
compiler/comprsrc.pas

@@ -94,14 +94,14 @@ var
     { Update asmres when externmode is set }
     if cs_link_extern in aktglobalswitches then
       AsmRes.AddLinkCommand(resbin,s,'');
-    current_module^.linkofiles.insert(resobj);
+    current_module^.linkotherofiles.insert(resobj,link_allways);
   end;
 
 begin
   resnr:=0;
   While not Current_module^.ResourceFiles.Empty do
    begin
-     S:=Current_module^.ResourceFiles.Get;
+     S:=Current_module^.ResourceFiles.get;
      CompileResource(s);
    end;
 end;
@@ -110,7 +110,11 @@ end;
 end.
 {
   $Log$
-  Revision 1.4  1999-05-04 21:44:40  florian
+  Revision 1.5  1999-07-03 00:29:46  peter
+    * new link writing to the ppu, one .ppu is needed for all link types,
+      static (.o) is now always created also when smartlinking is used
+
+  Revision 1.4  1999/05/04 21:44:40  florian
     * changes to compile it with Delphi 4.0
 
   Revision 1.3  1999/01/06 14:38:09  michael

+ 259 - 139
compiler/files.pas

@@ -24,9 +24,26 @@
 unit files;
 
 {$ifdef TP}
-{$V+}
+  {$V+}
 {$endif}
 
+{$ifdef TP}
+  {$define SHORTASMPREFIX}
+{$endif}
+{$ifdef go32v1}
+  {$define SHORTASMPREFIX}
+{$endif}
+{$ifdef go32v2}
+  {$define SHORTASMPREFIX}
+{$endif}
+{$ifdef OS2}
+  { Allthough OS/2 supports long filenames I play it safe and
+    use 8.3 filenames, because this allows the compiler to run
+    on a FAT partition. (DM) }
+  {$define SHORTASMPREFIX}
+{$endif}
+
+
   interface
 
     uses
@@ -107,8 +124,23 @@ unit files;
           function  get_file_path(l :longint):string;
        end;
 
+       plinkcontaineritem=^tlinkcontaineritem;
+       tlinkcontaineritem=object(tcontaineritem)
+          data     : pstring;
+          needlink : longint;
+          constructor init(const s:string;m:longint);
+          destructor  done;virtual;
+       end;
+
+       plinkcontainer=^tlinkcontainer;
+       tlinkcontainer=object(tcontainer)
+          constructor Init;
+          procedure insert(const s : string;m:longint);
+          function get(var m:longint) : string;
+          function getusemask(mask:longint) : string;
+          function find(const s:string):boolean;
+       end;
 
-    type
 {$ifndef NEWMAP}
        tunitmap = array[0..maxunits-1] of pointer;
        punitmap = ^tunitmap;
@@ -150,13 +182,18 @@ unit files;
           _exports      : plinkedlist;
 
           sourcefiles   : pfilemanager;
-          resourcefiles,
-          linksharedlibs,
-          linkstaticlibs,
-          linkunitfiles,
-          linkofiles    : tstringcontainer;
-          used_units    : tlinkedlist;
-          dependent_units : tlinkedlist;
+          resourcefiles : tstringcontainer;
+
+          linkunitofiles,
+          linkunitstaticlibs,
+          linkunitsharedlibs,
+          linkotherofiles,           { objects,libs loaded from the source }
+          linkothersharedlibs,       { using $L or $LINKLIB or import lib (for linux) }
+          linkotherstaticlibs  : tlinkcontainer;
+
+          used_units           : tlinkedlist;
+          dependent_units      : tlinkedlist;
+
           localunitsearchpath,           { local searchpaths }
           localobjectsearchpath,
           localincludesearchpath,
@@ -644,6 +681,101 @@ uses
       end;
 
 
+{****************************************************************************
+                             TLinkContainerItem
+ ****************************************************************************}
+
+constructor TLinkContainerItem.Init(const s:string;m:longint);
+begin
+  inherited Init;
+  data:=stringdup(s);
+  needlink:=m;
+end;
+
+
+destructor TLinkContainerItem.Done;
+begin
+  stringdispose(data);
+end;
+
+
+{****************************************************************************
+                           TLinkContainer
+ ****************************************************************************}
+
+    constructor TLinkContainer.Init;
+      begin
+        inherited init;
+      end;
+
+
+    procedure TLinkContainer.insert(const s : string;m:longint);
+      var
+        newnode : plinkcontaineritem;
+      begin
+         if find(s) then
+          exit;
+         new(newnode,init(s,m));
+         inherited insert(newnode);
+      end;
+
+
+    function TLinkContainer.get(var m:longint) : string;
+      var
+        p : plinkcontaineritem;
+      begin
+        p:=plinkcontaineritem(inherited get);
+        if p=nil then
+         begin
+           get:='';
+           m:=0;
+           exit;
+         end;
+        get:=p^.data^;
+        m:=p^.needlink;
+        dispose(p,done);
+      end;
+
+
+    function TLinkContainer.getusemask(mask:longint) : string;
+      var
+         p : plinkcontaineritem;
+         found : boolean;
+      begin
+        found:=false;
+        repeat
+          p:=plinkcontaineritem(inherited get);
+          if p=nil then
+           begin
+             getusemask:='';
+             exit;
+           end;
+          getusemask:=p^.data^;
+          found:=(p^.needlink and mask)<>0;
+          dispose(p,done);
+        until found;
+      end;
+
+
+    function TLinkContainer.find(const s:string):boolean;
+      var
+        newnode : plinkcontaineritem;
+      begin
+        find:=false;
+        newnode:=plinkcontaineritem(root);
+        while assigned(newnode) do
+         begin
+           if newnode^.data^=s then
+            begin
+              find:=true;
+              exit;
+            end;
+           newnode:=plinkcontaineritem(newnode^.next);
+         end;
+      end;
+
+
+
 {****************************************************************************
                                   TMODULE
  ****************************************************************************}
@@ -700,9 +832,9 @@ uses
 
     function tmodule.openppu:boolean;
       var
-         objfiletime,
-         ppufiletime,
-         asmfiletime : longint;
+        objfiletime,
+        ppufiletime,
+        asmfiletime : longint;
       begin
         openppu:=false;
         Message1(unit_t_ppu_loading,ppufilename^);
@@ -762,7 +894,7 @@ uses
         do_compile:=false;
         if (flags and uf_in_library)=0 then
          begin
-           if (flags and (uf_static_linked or uf_smartlink))<>0 then
+           if (flags and uf_smart_linked)<>0 then
             begin
               objfiletime:=getnamedfiletime(staticlibfilename^);
               Message2(unit_u_check_time,staticlibfilename^,filetimestring(objfiletime));
@@ -772,47 +904,34 @@ uses
                   do_compile:=true;
                   exit;
                 end;
-            end
-           else
-            if (flags and uf_shared_linked)<>0 then
-             begin
-               objfiletime:=getnamedfiletime(sharedlibfilename^);
-               Message2(unit_u_check_time,sharedlibfilename^,filetimestring(objfiletime));
-               if (ppufiletime<0) or (objfiletime<0) or (ppufiletime>objfiletime) then
-                begin
-                  Message(unit_u_recompile_sharedlib_is_older);
-                  do_compile:=true;
-                  exit;
-                end;
-             end
-           else
-            if (flags and uf_obj_linked)<>0 then
-             begin
-             { the objectfile should be newer than the ppu file }
-               objfiletime:=getnamedfiletime(objfilename^);
-               Message2(unit_u_check_time,objfilename^,filetimestring(objfiletime));
-               if (ppufiletime<0) or (objfiletime<0) or (ppufiletime>objfiletime) then
-                begin
-                { check if assembler file is older than ppu file }
-                  asmfileTime:=GetNamedFileTime(asmfilename^);
-                  Message2(unit_u_check_time,asmfilename^,filetimestring(asmfiletime));
-                  if (asmfiletime<0) or (ppufiletime>asmfiletime) then
-                   begin
-                     Message(unit_u_recompile_obj_and_asm_older);
-                     do_compile:=true;
-                     exit;
-                   end
-                  else
-                   begin
-                     Message(unit_u_recompile_obj_older_than_asm);
-                     if not(cs_asm_extern in aktglobalswitches) then
-                      begin
-                        do_compile:=true;
-                        exit;
-                      end;
-                   end;
-                end;
-             end;
+            end;
+           if (flags and uf_static_linked)<>0 then
+            begin
+              { the objectfile should be newer than the ppu file }
+              objfiletime:=getnamedfiletime(objfilename^);
+              Message2(unit_u_check_time,objfilename^,filetimestring(objfiletime));
+              if (ppufiletime<0) or (objfiletime<0) or (ppufiletime>objfiletime) then
+               begin
+                 { check if assembler file is older than ppu file }
+                 asmfileTime:=GetNamedFileTime(asmfilename^);
+                 Message2(unit_u_check_time,asmfilename^,filetimestring(asmfiletime));
+                 if (asmfiletime<0) or (ppufiletime>asmfiletime) then
+                  begin
+                    Message(unit_u_recompile_obj_and_asm_older);
+                    do_compile:=true;
+                    exit;
+                  end
+                 else
+                  begin
+                    Message(unit_u_recompile_obj_older_than_asm);
+                    if not(cs_asm_extern in aktglobalswitches) then
+                     begin
+                       do_compile:=true;
+                       exit;
+                     end;
+                  end;
+               end;
+            end;
          end;
         openppu:=true;
       end;
@@ -978,15 +1097,19 @@ uses
         dependent_units.done;
         dependent_units.init;
         resourcefiles.done;
-        resourcefiles.init_no_double;
-        linkunitfiles.done;
-        linkunitfiles.init_no_double;
-        linkofiles.done;
-        linkofiles.init_no_double;
-        linkstaticlibs.done;
-        linkstaticlibs.init_no_double;
-        linksharedlibs.done;
-        linksharedlibs.init_no_double;
+        resourcefiles.init;
+        linkunitofiles.done;
+        linkunitofiles.init;
+        linkunitstaticlibs.done;
+        linkunitstaticlibs.init;
+        linkunitsharedlibs.done;
+        linkunitsharedlibs.init;
+        linkotherofiles.done;
+        linkotherofiles.init;
+        linkotherstaticlibs.done;
+        linkotherstaticlibs.init;
+        linkothersharedlibs.done;
+        linkothersharedlibs.init;
         uses_imports:=false;
         do_assemble:=false;
         do_compile:=false;
@@ -1009,79 +1132,70 @@ uses
         n : namestr;
         e : extstr;
       begin
-         FSplit(s,p,n,e);
+        FSplit(s,p,n,e);
       { Programs have the name program to don't conflict with dup id's }
-         if _is_unit then
-           modulename:=stringdup(Upper(n))
-         else
-           modulename:=stringdup('PROGRAM');
-         mainsource:=stringdup(s);
-         ppufilename:=nil;
-         objfilename:=nil;
-         asmfilename:=nil;
-         staticlibfilename:=nil;
-         sharedlibfilename:=nil;
-         exefilename:=nil;
-         outpath:=nil;
-         { Dos has the famous 8.3 limit :( }
-{$ifdef tp}
-         asmprefix:=stringdup(FixFileName('as'));
+        if _is_unit then
+          modulename:=stringdup(Upper(n))
+        else
+          modulename:=stringdup('PROGRAM');
+        mainsource:=stringdup(s);
+        ppufilename:=nil;
+        objfilename:=nil;
+        asmfilename:=nil;
+        staticlibfilename:=nil;
+        sharedlibfilename:=nil;
+        exefilename:=nil;
+        outpath:=nil;
+        { Dos has the famous 8.3 limit :( }
+{$ifdef SHORTASMPREFIX}
+        asmprefix:=stringdup(FixFileName('as'));
 {$else}
-  {$ifdef go32v2}
-         asmprefix:=stringdup(FixFileName('as'));
-  {$else}
-    {$ifdef OS2}
-         {Allthough OS/2 supports long filenames I play it safe and
-          use 8.3 filenames, because this allows the compiler to run
-          on a FAT partition. (DM)}
-         asmprefix:=stringdup(FixFileName('as'));
-    {$else}
-         asmprefix:=stringdup(FixFileName(n));
-    {$endif}
-  {$endif}
-{$endif tp}
-         path:=nil;
-         setfilename(p+n,true);
-         localunitsearchpath:=nil;
-         localobjectsearchpath:=nil;
-         localincludesearchpath:=nil;
-         locallibrarysearchpath:=nil;
-         used_units.init;
-         dependent_units.init;
-         new(sourcefiles,init);
-         resourcefiles.init_no_double;
-         linkunitfiles.init_no_double;
-         linkofiles.init_no_double;
-         linkstaticlibs.init_no_double;
-         linksharedlibs.init_no_double;
-         ppufile:=nil;
-         scanner:=nil;
-         map:=nil;
-         globalsymtable:=nil;
-         localsymtable:=nil;
-         loaded_from:=nil;
-         flags:=0;
-         crc:=0;
-         interface_crc:=0;
-         do_reload:=false;
-         unitcount:=1;
-         inc(global_unit_count);
-         unit_index:=global_unit_count;
-         do_assemble:=false;
-         do_compile:=false;
-         sources_avail:=true;
-         compiled:=false;
-         in_second_compile:=false;
-         in_implementation:=false;
-         in_global:=true;
-         is_unit:=_is_unit;
-         islibrary:=false;
-         uses_imports:=false;
-         imports:=new(plinkedlist,init);
-         _exports:=new(plinkedlist,init);
-       { search the PPU file if it is an unit }
-         if is_unit then
-          search_unit(modulename^,false);
+        asmprefix:=stringdup(FixFileName(n));
+{$endif}
+        path:=nil;
+        setfilename(p+n,true);
+        localunitsearchpath:=nil;
+        localobjectsearchpath:=nil;
+        localincludesearchpath:=nil;
+        locallibrarysearchpath:=nil;
+        used_units.init;
+        dependent_units.init;
+        new(sourcefiles,init);
+        resourcefiles.init;
+        linkunitofiles.init;
+        linkunitstaticlibs.init;
+        linkunitsharedlibs.init;
+        linkotherofiles.init;
+        linkotherstaticlibs.init;
+        linkothersharedlibs.init;
+        ppufile:=nil;
+        scanner:=nil;
+        map:=nil;
+        globalsymtable:=nil;
+        localsymtable:=nil;
+        loaded_from:=nil;
+        flags:=0;
+        crc:=0;
+        interface_crc:=0;
+        do_reload:=false;
+        unitcount:=1;
+        inc(global_unit_count);
+        unit_index:=global_unit_count;
+        do_assemble:=false;
+        do_compile:=false;
+        sources_avail:=true;
+        compiled:=false;
+        in_second_compile:=false;
+        in_implementation:=false;
+        in_global:=true;
+        is_unit:=_is_unit;
+        islibrary:=false;
+        uses_imports:=false;
+        imports:=new(plinkedlist,init);
+        _exports:=new(plinkedlist,init);
+      { search the PPU file if it is an unit }
+        if is_unit then
+         search_unit(modulename^,false);
       end;
 
 
@@ -1106,10 +1220,12 @@ uses
         used_units.done;
         dependent_units.done;
         resourcefiles.done;
-        linkunitfiles.done;
-        linkofiles.done;
-        linkstaticlibs.done;
-        linksharedlibs.done;
+        linkunitofiles.done;
+        linkunitstaticlibs.done;
+        linkunitsharedlibs.done;
+        linkotherofiles.done;
+        linkotherstaticlibs.done;
+        linkothersharedlibs.done;
         stringdispose(objfilename);
         stringdispose(asmfilename);
         stringdispose(ppufilename);
@@ -1186,7 +1302,11 @@ uses
 end.
 {
   $Log$
-  Revision 1.95  1999-05-13 21:59:25  peter
+  Revision 1.96  1999-07-03 00:29:47  peter
+    * new link writing to the ppu, one .ppu is needed for all link types,
+      static (.o) is now always created also when smartlinking is used
+
+  Revision 1.95  1999/05/13 21:59:25  peter
     * removed oldppu code
     * warning if objpas is loaded from uses
     * first things for new deref writing

+ 7 - 3
compiler/globals.pas

@@ -1121,7 +1121,7 @@ unit globals;
         initoptprocessor:=Class386;
         initlocalswitches:=[];
         initmoduleswitches:=[cs_extsyntax,cs_browser];
-        initglobalswitches:=[cs_check_unit_name];
+        initglobalswitches:=[cs_check_unit_name,cs_link_static];
         initmodeswitches:=fpcmodeswitches;
         initpackenum:=4;
         initpackrecords:=2;
@@ -1133,7 +1133,7 @@ unit globals;
         initoptprocessor:=MC68000;
         initlocalswitches:=[];
         initmoduleswitches:=[cs_extsyntax,cs_browser,cs_fp_emulation];
-        initglobalswitches:=[cs_check_unit_name];
+        initglobalswitches:=[cs_check_unit_name,cs_link_static];
         initmodeswitches:=fpcmodeswitches;
         initpackenum:=4;
         initpackrecords:=2;
@@ -1162,7 +1162,11 @@ begin
 end.
 {
   $Log$
-  Revision 1.8  1999-05-27 19:44:29  peter
+  Revision 1.9  1999-07-03 00:29:48  peter
+    * new link writing to the ppu, one .ppu is needed for all link types,
+      static (.o) is now always created also when smartlinking is used
+
+  Revision 1.8  1999/05/27 19:44:29  peter
     * removed oldasm
     * plabel -> pasmlabel
     * -a switches to source writing automaticly

+ 22 - 5
compiler/globtype.pas

@@ -66,7 +66,7 @@ interface
          { generation }
          cs_profile,cs_debuginfo,cs_browser,cs_local_browser,cs_compilesystem,
          { linking }
-         cs_smartlink,cs_create_sharedlib,cs_create_staticlib
+         cs_smartlink
        );
        tmoduleswitches = set of tmoduleswitch;
 
@@ -89,7 +89,7 @@ interface
          cs_asm_leave,cs_asm_extern,cs_asm_pipe,cs_asm_source,
          cs_asm_regalloc,cs_asm_tempalloc,
          { linking }
-         cs_link_extern,cs_link_shared,cs_link_static,cs_link_deffile
+         cs_link_extern,cs_link_static,cs_link_smart,cs_link_shared,cs_link_deffile
        );
        tglobalswitches = set of tglobalswitch;
 
@@ -107,10 +107,14 @@ interface
        tmodeswitches = set of tmodeswitch;
 
        { win32 sub system }
-       tapptype = (at_gui,at_cui);
+       tapptype = (at_none,
+         at_gui,at_cui
+       );
 
        { currently parsed block type }
-       tblock_type = (bt_general,bt_type,bt_const);
+       tblock_type = (bt_none,
+         bt_general,bt_type,bt_const
+       );
 
        stringid = string[maxidlen];
 
@@ -122,6 +126,15 @@ interface
        pword      = ^word;
        plongint   = ^longint;
 
+    const
+       { link options }
+       link_none    = $0;
+       link_allways = $1;
+       link_static  = $2;
+       link_smart   = $4;
+       link_shared  = $8;
+
+
 implementation
 
 
@@ -129,7 +142,11 @@ begin
 end.
 {
   $Log$
-  Revision 1.10  1999-05-17 14:30:39  pierre
+  Revision 1.11  1999-07-03 00:29:49  peter
+    * new link writing to the ppu, one .ppu is needed for all link types,
+      static (.o) is now always created also when smartlinking is used
+
+  Revision 1.10  1999/05/17 14:30:39  pierre
    + cs_checkpointer
 
   Revision 1.9  1999/05/12 00:19:49  peter

+ 8 - 4
compiler/lin_targ.pas

@@ -39,7 +39,7 @@ interface
 implementation
 
   uses
-    verbose,strings,cobjects,systems,globals,
+    verbose,strings,cobjects,systems,globtype,globals,
     files,aasm,symtable;
 
 
@@ -51,7 +51,7 @@ implementation
     procedure timportliblinux.importprocedure(const func,module : string;index : longint;const name : string);
       begin
         { insert sharedlibrary }
-        current_module^.linksharedlibs.insert(SplitName(module));
+        current_module^.linkothersharedlibs.insert(SplitName(module),link_allways);
         { do nothing with the procedure, only set the mangledname }
         if name<>'' then
           aktprocsym^.definition^.setmangledname(name)
@@ -63,7 +63,7 @@ implementation
     procedure timportliblinux.importvariable(const varname,module:string;const name:string);
       begin
         { insert sharedlibrary }
-        current_module^.linksharedlibs.insert(SplitName(module));
+        current_module^.linkothersharedlibs.insert(SplitName(module),link_allways);
         { reset the mangledname and turn off the dll_var option }
         aktvarsym^.setmangledname(name);
         aktvarsym^.var_options:=aktvarsym^.var_options and (not vo_is_dll_var);
@@ -78,7 +78,11 @@ implementation
 end.
 {
   $Log$
-  Revision 1.3  1999-01-20 14:18:32  pierre
+  Revision 1.4  1999-07-03 00:29:50  peter
+    * new link writing to the ppu, one .ppu is needed for all link types,
+      static (.o) is now always created also when smartlinking is used
+
+  Revision 1.3  1999/01/20 14:18:32  pierre
     * bugs related to mangledname solved
       - linux external without name
       -external procs already used

+ 72 - 10
compiler/link.pas

@@ -74,7 +74,7 @@ uses
   dmisc,
 {$endif Delphi}
   globtype,systems,
-  script,globals,verbose
+  script,globals,verbose,ppu
 {$ifdef i386}
   ,win_targ
 {$endif}
@@ -139,17 +139,69 @@ end;
 
 
 procedure TLinker.AddModuleFiles(hp:pmodule);
+var
+  mask : longint;
 begin
   with hp^ do
    begin
-     while not linkunitfiles.empty do
-      AddObject(linkunitfiles.Get);
-     while not linkofiles.empty do
-      AddObject(linkofiles.Get);
-     while not linksharedlibs.empty do
-      AddSharedLibrary(linksharedlibs.Get);
-     while not linkstaticlibs.empty do
-      AddStaticLibrary(linkstaticlibs.Get);
+     { create mask which unit files need linking }
+     mask:=link_allways;
+     { static linking ? }
+     if (cs_link_static in aktglobalswitches) then
+      begin
+        if (flags and uf_static_linked)=0 then
+          Comment(V_Error,'unit '+modulename^+' can''t be static linked')
+        else
+          mask:=mask or link_static;
+      end;
+     { smart linking ? }
+     if (cs_link_smart in aktglobalswitches) then
+      begin
+        if (flags and uf_smart_linked)=0 then
+         begin
+           { if smart not avail then try static linking }
+           if (flags and uf_static_linked)<>0 then
+            begin
+              Comment(V_Error,'unit '+modulename^+' can''t be smart linked, switching to static linking');
+              mask:=mask or link_static;
+            end
+           else
+            Comment(V_Error,'unit '+modulename^+' can''t be smart or static linked');
+         end
+        else
+         mask:=mask or link_smart;
+      end;
+     { shared linking }
+     if (cs_link_shared in aktglobalswitches) then
+      begin
+        if (flags and uf_shared_linked)=0 then
+         begin
+           { if shared not avail then try static linking }
+           if (flags and uf_static_linked)<>0 then
+            begin
+              Comment(V_Error,'unit '+modulename^+' can''t be shared linked, switching to static linking');
+              mask:=mask or link_static;
+            end
+           else
+            Comment(V_Error,'unit '+modulename^+' can''t be shared or static linked');
+         end
+        else
+         mask:=mask or link_shared;
+      end;
+     { unit files }
+     while not linkunitofiles.empty do
+      AddObject(linkunitofiles.getusemask(mask));
+     while not linkunitstaticlibs.empty do
+      AddStaticLibrary(linkunitstaticlibs.getusemask(mask));
+     while not linkunitsharedlibs.empty do
+      AddSharedLibrary(linkunitsharedlibs.getusemask(mask));
+     { Other needed .o and libs, specified using $L,$LINKLIB,external }
+     while not linkotherofiles.empty do
+      AddObject(linkotherofiles.Getusemask(mask));
+     while not linkotherstaticlibs.empty do
+      AddStaticLibrary(linkotherstaticlibs.Getusemask(mask));
+     while not linkothersharedlibs.empty do
+      AddSharedLibrary(linkothersharedlibs.Getusemask(mask));
    end;
 end;
 
@@ -184,6 +236,9 @@ function TLinker.FindObjectFile(s:string) : string;
 var
   found : boolean;
 begin
+  findobjectfile:='';
+  if s='' then
+   exit;
   if pos('.',s)=0 then
    s:=s+target_info.objext;
   s:=FixFileName(s);
@@ -218,6 +273,9 @@ function TLinker.FindLibraryFile(s:string;const ext:string) : string;
 var
   found : boolean;
 begin
+  findlibraryfile:='';
+  if s='' then
+   exit;
   if pos('.',s)=0 then
    s:=s+ext;
   if FileExists(s) then
@@ -652,7 +710,11 @@ end;
 end.
 {
   $Log$
-  Revision 1.57  1999-06-28 16:02:31  peter
+  Revision 1.58  1999-07-03 00:29:51  peter
+    * new link writing to the ppu, one .ppu is needed for all link types,
+      static (.o) is now always created also when smartlinking is used
+
+  Revision 1.57  1999/06/28 16:02:31  peter
     * merged
 
   Revision 1.54.2.3  1999/06/28 15:55:40  peter

+ 8 - 4
compiler/og386dbg.pas

@@ -37,7 +37,7 @@ unit og386dbg;
        tdbgoutput = object(tobjectoutput)
          nsyms   : longint;
          rawidx  : longint;
-         constructor init;
+         constructor init(smart:boolean);
          destructor  done;virtual;
          procedure initwriting;virtual;
          procedure donewriting;virtual;
@@ -54,9 +54,9 @@ unit og386dbg;
                                 Tdbgoutput
 ****************************************************************************}
 
-    constructor tdbgoutput.init;
+    constructor tdbgoutput.init(smart:boolean);
       begin
-        inherited init;
+        inherited init(smart);
         rawidx:=-1;
         nsyms:=0;
       end;
@@ -182,7 +182,11 @@ unit og386dbg;
 end.
 {
   $Log$
-  Revision 1.3  1999-05-05 17:34:32  peter
+  Revision 1.4  1999-07-03 00:29:53  peter
+    * new link writing to the ppu, one .ppu is needed for all link types,
+      static (.o) is now always created also when smartlinking is used
+
+  Revision 1.3  1999/05/05 17:34:32  peter
     * output is more like as 2.9.1
     * stabs really working for go32v2
 

+ 48 - 58
compiler/options.pas

@@ -388,27 +388,6 @@ begin
                       while j <= length(more) Do
                         Begin
                           case more[j] of
-                            'D' :
-                              begin
-                                If UnsetBool(More, j) then
-                                  Begin
-                                    initmoduleswitches:=initmoduleswitches-[cs_create_sharedlib];
-                                    inc(j)
-                                  End
-                                Else
-                                  Begin
-                                    if target_info.target in [target_i386_GO32V1,target_i386_GO32V2] then
-                                      begin
-                                        Message(option_no_shared_lib_under_dos);
-                                        initmoduleswitches:=initmoduleswitches+[cs_create_staticlib];
-                                      end
-                                    Else
-                                      Begin
-                                        initmoduleswitches:=initmoduleswitches+[cs_create_sharedlib];
-                                        initmoduleswitches:=initmoduleswitches-[cs_create_staticlib]
-                                      End;
-                                  End;
-                               end;
                             'h' :
                                begin
                                  val(copy(more,j+1,length(more)-j),heapsize,code);
@@ -428,18 +407,22 @@ begin
                                       inc(j)
                                     End
                                   Else initglobalswitches:=initglobalswitches+[cs_link_extern];
-                            'o' : If UnsetBool(More, j) then
-                                    Begin
-                                      initlocalswitches:=initlocalswitches-[cs_check_overflow];
-                                      inc(j)
-                                    End
-                                  Else initlocalswitches:=initlocalswitches+[cs_check_overflow];
-                            'r' : If UnsetBool(More, j) then
-                                    Begin
-                                      initlocalswitches:=initlocalswitches-[cs_check_range];
-                                      inc(j)
-                                    End
-                                  Else initlocalswitches:=initlocalswitches+[cs_check_range];
+                            'o' :
+                              If UnsetBool(More, j) then
+                                Begin
+                                  initlocalswitches:=initlocalswitches-[cs_check_overflow];
+                                  inc(j);
+                                End
+                              Else
+                                initlocalswitches:=initlocalswitches+[cs_check_overflow];
+                            'r' :
+                              If UnsetBool(More, j) then
+                                Begin
+                                  initlocalswitches:=initlocalswitches-[cs_check_range];
+                                  inc(j);
+                                End
+                              Else
+                                initlocalswitches:=initlocalswitches+[cs_check_range];
                             's' :
                                begin
                                  val(copy(more,j+1,length(more)-j),stacksize,code);
@@ -447,28 +430,22 @@ begin
                                   IllegalPara(opt);
                                  break;
                                end;
-                            't' : If UnsetBool(More, j) then
-                                    Begin
-                                      initlocalswitches:=initlocalswitches-[cs_check_stack];
-                                      inc(j)
-                                    End
-                                  Else initlocalswitches:=initlocalswitches+[cs_check_stack];
-                            'x' : If UnsetBool(More, j) then
-                                    Begin
-                                      initmoduleswitches:=initmoduleswitches-[cs_smartlink];
-                                      inc(j)
-                                    End
-                                  Else initmoduleswitches:=initmoduleswitches+[cs_smartlink];
-                            'S' : If UnsetBool(More, j) then
-                                    Begin
-                                      initmoduleswitches:=initmoduleswitches-[cs_create_staticlib];
-                                      inc(j)
-                                    End
-                                  Else
-                                    Begin
-                                      initmoduleswitches:=initmoduleswitches+[cs_create_staticlib];
-                                      initmoduleswitches:=initmoduleswitches-[cs_create_sharedlib];
-                                    End
+                            't' :
+                               If UnsetBool(More, j) then
+                                 Begin
+                                   initlocalswitches:=initlocalswitches-[cs_check_stack];
+                                   inc(j)
+                                 End
+                               Else
+                                 initlocalswitches:=initlocalswitches+[cs_check_stack];
+                            'x' :
+                               If UnsetBool(More, j) then
+                                 Begin
+                                   initmoduleswitches:=initmoduleswitches-[cs_smartlink];
+                                   inc(j)
+                                 End
+                               Else
+                                 initmoduleswitches:=initmoduleswitches+[cs_smartlink];
                             else
                                IllegalPara(opt);
                           end;
@@ -701,15 +678,24 @@ begin
                         's' : Linker.Strip:=true;
                         'D' : begin
                                 def_symbol('FPC_LINK_DYNAMIC');
+                                undef_symbol('FPC_LINK_SMART');
                                 undef_symbol('FPC_LINK_STATIC');
                                 initglobalswitches:=initglobalswitches+[cs_link_shared];
-                                initglobalswitches:=initglobalswitches-[cs_link_static];
+                                initglobalswitches:=initglobalswitches-[cs_link_static,cs_link_smart];
                               end;
                         'S' : begin
                                 def_symbol('FPC_LINK_STATIC');
+                                undef_symbol('FPC_LINK_SMART');
                                 undef_symbol('FPC_LINK_DYNAMIC');
-                                initglobalswitches:=initglobalswitches-[cs_link_shared];
                                 initglobalswitches:=initglobalswitches+[cs_link_static];
+                                initglobalswitches:=initglobalswitches-[cs_link_shared,cs_link_smart];
+                              end;
+                        'X' : begin
+                                def_symbol('FPC_LINK_SMART');
+                                undef_symbol('FPC_LINK_STATIC');
+                                undef_symbol('FPC_LINK_DYNAMIC');
+                                initglobalswitches:=initglobalswitches+[cs_link_smart];
+                                initglobalswitches:=initglobalswitches-[cs_link_shared,cs_link_static];
                               end;
                        else
                          IllegalPara(opt);
@@ -1167,7 +1153,11 @@ end;
 end.
 {
   $Log$
-  Revision 1.2  1999-07-01 15:49:19  florian
+  Revision 1.3  1999-07-03 00:29:54  peter
+    * new link writing to the ppu, one .ppu is needed for all link types,
+      static (.o) is now always created also when smartlinking is used
+
+  Revision 1.2  1999/07/01 15:49:19  florian
     * int64/qword type release
     + lo/hi for int64/qword
 

+ 6 - 2
compiler/os2_targ.pas

@@ -264,7 +264,7 @@ const   ar_magic:array[1..8] of char='!<arch>'#10;
 begin
     seq_no:=1;
     if not (cs_smartlink in aktmoduleswitches) then
-        current_module^.linkstaticlibs.insert(s);
+      current_module^.linkotherstaticlibs.insert(s,link_allways);
     assign(out_file,current_module^.path^+s+'.ao2');
     rewrite(out_file,1);
     blockwrite(out_file,ar_magic,sizeof(ar_magic));
@@ -333,7 +333,11 @@ end.
 
 {
   $Log$
-  Revision 1.7  1999-05-04 21:44:52  florian
+  Revision 1.8  1999-07-03 00:29:55  peter
+    * new link writing to the ppu, one .ppu is needed for all link types,
+      static (.o) is now always created also when smartlinking is used
+
+  Revision 1.7  1999/05/04 21:44:52  florian
     * changes to compile it with Delphi 4.0
 
   Revision 1.6  1998/12/11 00:03:25  peter

+ 20 - 27
compiler/pmodules.pas

@@ -49,42 +49,31 @@ unit pmodules;
     procedure create_objectfile;
       begin
         { create the .s file and assemble it }
-        GenerateAsm;
+        GenerateAsm(false);
+
+        { Also create a smartlinked version ? }
+        if (cs_smartlink in aktmoduleswitches) then
+         begin
+           GenerateAsm(true);
+           if target_asm.needar then
+             Linker.MakeStaticLibrary(SmartLinkFilesCnt);
+         end;
 
         { resource files }
         CompileResourceFiles;
-
-        { When creating a library call the linker. And insert the output
-          of the linker files }
-        if (cs_create_sharedlib in aktmoduleswitches) then
-          Linker.MakeSharedLibrary
-        else
-          if (cs_smartlink in aktmoduleswitches) and target_asm.needar then
-            Linker.MakeStaticLibrary(SmartLinkFilesCnt);
       end;
 
 
     procedure insertobjectfile;
     { Insert the used object file for this unit in the used list for this unit }
       begin
-        if (cs_create_sharedlib in aktmoduleswitches) then
-          begin
-            current_module^.linksharedlibs.insert(current_module^.sharedlibfilename^);
-            current_module^.flags:=current_module^.flags or uf_shared_linked;
-          end
-        else
+        current_module^.linkunitofiles.insert(current_module^.objfilename^,link_static);
+        current_module^.flags:=current_module^.flags or uf_static_linked;
+
+        if (cs_smartlink in aktmoduleswitches) then
          begin
-           if (cs_create_staticlib in aktmoduleswitches) or
-              (cs_smartlink in aktmoduleswitches) then
-             begin
-               current_module^.linkstaticlibs.insert(current_module^.staticlibfilename^);
-               current_module^.flags:=current_module^.flags or uf_static_linked;
-             end
-           else
-             begin
-               current_module^.linkunitfiles.insert(current_module^.objfilename^);
-               current_module^.flags:=current_module^.flags or uf_obj_linked;
-             end;
+           current_module^.linkunitstaticlibs.insert(current_module^.staticlibfilename^,link_smart);
+           current_module^.flags:=current_module^.flags or uf_smart_linked;
          end;
       end;
 
@@ -1335,7 +1324,11 @@ unit pmodules;
 end.
 {
   $Log$
-  Revision 1.125  1999-06-15 13:57:32  peter
+  Revision 1.126  1999-07-03 00:29:56  peter
+    * new link writing to the ppu, one .ppu is needed for all link types,
+      static (.o) is now always created also when smartlinking is used
+
+  Revision 1.125  1999/06/15 13:57:32  peter
     * merged
 
   Revision 1.124.2.1  1999/06/15 13:54:26  peter

+ 24 - 19
compiler/ppu.pas

@@ -61,19 +61,21 @@ const
   ibendbrowser        = 254;
   ibend               = 255;
   {general}
-  ibmodulename     = 1;
-  ibsourcefiles    = 2;
-  ibloadunit       = 3;
-  ibinitunit       = 5;
-  iblinkofiles     = 6;
-  iblinksharedlibs = 7;
-  iblinkstaticlibs = 8;
-  ibdbxcount       = 9;
-  ibsymref         = 10;
-  ibdefref         = 11;
-  ibendsymtablebrowser   = 12;
-  ibbeginsymtablebrowser = 13;
-  iblinkunitfiles  = 14;
+  ibmodulename           = 1;
+  ibsourcefiles          = 2;
+  ibloadunit             = 3;
+  ibinitunit             = 4;
+  iblinkunitofiles       = 5;
+  iblinkunitstaticlibs   = 6;
+  iblinkunitsharedlibs   = 7;
+  iblinkotherofiles      = 8;
+  iblinkotherstaticlibs  = 9;
+  iblinkothersharedlibs  = 10;
+  ibdbxcount             = 11;
+  ibsymref               = 12;
+  ibdefref               = 13;
+  ibendsymtablebrowser   = 14;
+  ibbeginsymtablebrowser = 15;
   {syms}
   ibtypesym       = 20;
   ibprocsym       = 21;
@@ -113,12 +115,11 @@ const
   uf_big_endian    = $4;
   uf_has_dbx       = $8;
   uf_has_browser   = $10;
-  uf_smartlink     = $20;  { the ppu is smartlinked }
-  uf_in_library    = $40;  { is the file in another file than <ppufile>.* ? }
-  uf_static_linked = $80;  { the ppu is linked in a static library }
-  uf_shared_linked = $100; { the ppu is linked in a shared library }
+  uf_in_library    = $20;  { is the file in another file than <ppufile>.* ? }
+  uf_smart_linked  = $40;  { the ppu can be smartlinked }
+  uf_static_linked = $80;  { the ppu can be linked static }
+  uf_shared_linked = $100; { the ppu can be linked shared }
   uf_local_browser = $200;
-  uf_obj_linked    = $400; { the ppu is linked in a object file }
 
 type
 {$ifdef m68k}
@@ -868,7 +869,11 @@ end;
 end.
 {
   $Log$
-  Revision 1.33  1999-05-13 21:59:36  peter
+  Revision 1.34  1999-07-03 00:29:57  peter
+    * new link writing to the ppu, one .ppu is needed for all link types,
+      static (.o) is now always created also when smartlinking is used
+
+  Revision 1.33  1999/05/13 21:59:36  peter
     * removed oldppu code
     * warning if objpas is loaded from uses
     * first things for new deref writing

+ 7 - 3
compiler/scandir.inc

@@ -616,7 +616,7 @@ const
       begin
         current_scanner^.skipspace;
         s:=AddExtension(FixFileName(current_scanner^.readcomment),target_info.objext);
-        current_module^.linkofiles.insert(s);
+        current_module^.linkotherofiles.insert(s,link_allways);
       end;
 
 
@@ -637,7 +637,7 @@ const
       begin
         current_scanner^.skipspace;
         current_scanner^.readstring;
-        current_module^.linkSharedLibs.insert(orgpattern);
+        current_module^.linkOtherSharedLibs.insert(orgpattern,link_allways);
       end;
 
 
@@ -1087,7 +1087,11 @@ const
 
 {
   $Log$
-  Revision 1.53  1999-06-02 22:44:18  pierre
+  Revision 1.54  1999-07-03 00:29:58  peter
+    * new link writing to the ppu, one .ppu is needed for all link types,
+      static (.o) is now always created also when smartlinking is used
+
+  Revision 1.53  1999/06/02 22:44:18  pierre
    * previous wrong log corrected
 
   Revision 1.52  1999/06/02 22:25:48  pierre

+ 86 - 52
compiler/symppu.inc

@@ -72,29 +72,6 @@
       end;
 
 
-    procedure writecontainer(var p:tstringcontainer;id:byte;hold,strippath:boolean);
-      var
-        hcontainer : tstringcontainer;
-        s          : string;
-      begin
-        if hold then
-         hcontainer.init;
-        while not p.empty do
-         begin
-           s:=p.get;
-           if strippath then
-            current_ppu^.putstring(SplitFileName(s))
-           else
-            current_ppu^.putstring(s);
-           if hold then
-            hcontainer.insert(s);
-         end;
-        current_ppu^.writeentry(id);
-        if hold then
-         p:=hcontainer;
-      end;
-
-
     procedure writeposinfo(const p:tfileposinfo);
       begin
         current_ppu^.putword(p.fileindex);
@@ -223,6 +200,49 @@
       end;
 
 
+    procedure writelinkcontainer(var p:tlinkcontainer;id:byte;strippath:boolean);
+      var
+        hcontainer : tlinkcontainer;
+        s : string;
+        mask : longint;
+      begin
+        hcontainer.init;
+        while not p.empty do
+         begin
+           s:=p.get(mask);
+           if strippath then
+            current_ppu^.putstring(SplitFileName(s))
+           else
+            current_ppu^.putstring(s);
+           current_ppu^.putlongint(mask);
+           hcontainer.insert(s,mask);
+         end;
+        current_ppu^.writeentry(id);
+        p:=hcontainer;
+      end;
+
+
+{    procedure writelinkother(var p:tstringcontainer;id:byte;strippath:boolean);
+      var
+        hcontainer : tstringcontainer;
+        s : string;
+      begin
+        hcontainer.init;
+        while not p.empty do
+         begin
+           s:=p.get;
+           if strippath then
+            current_ppu^.putstring(SplitFileName(s))
+           else
+            current_ppu^.putstring(s);
+           hcontainer.insert(s);
+         end;
+        current_ppu^.writeentry(id);
+        p:=hcontainer;
+      end; }
+
+
+
     procedure writeunitas(const s : string;unittable : punitsymtable;only_crc : boolean);
       begin
          Message1(unit_u_ppu_write,s);
@@ -230,15 +250,8 @@
        { create unit flags }
          with Current_Module^ do
           begin
-            if (((cs_create_staticlib in aktmoduleswitches) or
-                 (cs_smartlink in aktmoduleswitches)) and
-                (SplitName(ppufilename^)<>SplitName(staticlibfilename^))) or
-
-               ((cs_create_sharedlib in aktmoduleswitches) and
-                (SplitName(ppufilename^)<>SplitName(sharedlibfilename^))) then
-             flags:=flags or uf_in_library;
             if cs_smartlink in aktmoduleswitches then
-             flags:=flags or uf_smartlink;
+             flags:=flags or uf_smart_linked;
 {$ifdef GDB}
             if cs_gdb_dbx in aktglobalswitches then
              flags:=flags or uf_has_dbx;
@@ -373,13 +386,6 @@
       end;
 
 
-    procedure readcontainer(var p:tstringcontainer);
-      begin
-        while not current_ppu^.endofentry do
-         p.insert(current_ppu^.getstring);
-      end;
-
-
     procedure readposinfo(var p:tfileposinfo);
       begin
         p.fileindex:=current_ppu^.getword;
@@ -410,8 +416,6 @@
                 break;
               end;
             derefindex,
-            derefpara,
-            dereflocal,
             derefrecord :
               begin
                 new(p,init(b,current_ppu^.getword));
@@ -553,6 +557,20 @@
       end;
 
 
+    procedure readlinkcontainer(var p:tlinkcontainer);
+      var
+        s : string;
+        m : longint;
+      begin
+        while not current_ppu^.endofentry do
+         begin
+           s:=current_ppu^.getstring;
+           m:=current_ppu^.getlongint;
+           p.insert(s,m);
+         end;
+      end;
+
+
     procedure load_interface;
       var
         b : byte;
@@ -561,17 +579,29 @@
          repeat
            b:=current_ppu^.readentry;
            case b of
-            ibmodulename : begin
-                             stringdispose(current_module^.modulename);
-                             current_module^.modulename:=stringdup(current_ppu^.getstring);
-                           end;
-           ibsourcefiles : readsourcefiles;
-              ibloadunit : readloadunit;
-        iblinksharedlibs : readcontainer(current_module^.LinkSharedLibs);
-        iblinkstaticlibs : readcontainer(current_module^.LinkStaticLibs);
-         iblinkunitfiles : readcontainer(current_module^.LinkUnitFiles);
-            iblinkofiles : readcontainer(current_module^.LinkOFiles);
-          ibendinterface : break;
+             ibmodulename :
+               begin
+                 stringdispose(current_module^.modulename);
+                 current_module^.modulename:=stringdup(current_ppu^.getstring);
+               end;
+             ibsourcefiles :
+               readsourcefiles;
+             ibloadunit :
+               readloadunit;
+             iblinkunitofiles :
+               readlinkcontainer(current_module^.LinkUnitOFiles);
+             iblinkunitstaticlibs :
+               readlinkcontainer(current_module^.LinkUnitStaticLibs);
+             iblinkunitsharedlibs :
+               readlinkcontainer(current_module^.LinkUnitSharedLibs);
+             iblinkotherofiles :
+               readlinkcontainer(current_module^.LinkotherOFiles);
+             iblinkotherstaticlibs :
+               readlinkcontainer(current_module^.LinkotherStaticLibs);
+             iblinkothersharedlibs :
+               readlinkcontainer(current_module^.LinkotherSharedLibs);
+             ibendinterface :
+               break;
            else
              Message1(unit_f_ppu_invalid_entry,tostr(b));
            end;
@@ -580,7 +610,11 @@
 
 {
   $Log$
-  Revision 1.42  1999-06-22 16:24:47  pierre
+  Revision 1.43  1999-07-03 00:30:00  peter
+    * new link writing to the ppu, one .ppu is needed for all link types,
+      static (.o) is now always created also when smartlinking is used
+
+  Revision 1.42  1999/06/22 16:24:47  pierre
    * local browser stuff corrected
 
   Revision 1.41  1999/05/14 17:52:28  peter

+ 11 - 5
compiler/symtable.pas

@@ -1878,10 +1878,12 @@ implementation
         the link.res. All doesn't depend on the crc! It doesn't matter
         if a unit is in a .o or .a file }
         current_ppu^.do_crc:=false;
-        writecontainer(current_module^.linkunitfiles,iblinkunitfiles,true,true);
-        writecontainer(current_module^.linkofiles,iblinkofiles,true,false);
-        writecontainer(current_module^.linksharedlibs,iblinksharedlibs,true,true);
-        writecontainer(current_module^.linkstaticlibs,iblinkstaticlibs,true,true);
+        writelinkcontainer(current_module^.linkunitofiles,iblinkunitofiles,true);
+        writelinkcontainer(current_module^.linkunitstaticlibs,iblinkunitstaticlibs,true);
+        writelinkcontainer(current_module^.linkunitsharedlibs,iblinkunitsharedlibs,true);
+        writelinkcontainer(current_module^.linkotherofiles,iblinkotherofiles,false);
+        writelinkcontainer(current_module^.linkotherstaticlibs,iblinkotherstaticlibs,true);
+        writelinkcontainer(current_module^.linkothersharedlibs,iblinkothersharedlibs,true);
         current_ppu^.do_crc:=true;
 
         current_ppu^.writeentry(ibendinterface);
@@ -2308,7 +2310,11 @@ implementation
 end.
 {
   $Log$
-  Revision 1.23  1999-06-28 17:02:44  pierre
+  Revision 1.24  1999-07-03 00:30:01  peter
+    * new link writing to the ppu, one .ppu is needed for all link types,
+      static (.o) is now always created also when smartlinking is used
+
+  Revision 1.23  1999/06/28 17:02:44  pierre
    merged from v0-99-12 branch
 
   Revision 1.21.2.2  1999/06/28 16:59:55  pierre