瀏覽代碼

* 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

+ 177 - 105
compiler/cobjects.pas

@@ -68,14 +68,6 @@ unit cobjects;
        end;
        end;
 
 
 
 
-       { some help data types }
-       pstringitem = ^tstringitem;
-       tstringitem = record
-          data : pstring;
-          next : pstringitem;
-          fileinfo : tfileposinfo; { pointer to tinputfile }
-       end;
-
        plinkedlist_item = ^tlinkedlist_item;
        plinkedlist_item = ^tlinkedlist_item;
        tlinkedlist_item = object
        tlinkedlist_item = object
           next,previous : plinkedlist_item;
           next,previous : plinkedlist_item;
@@ -125,11 +117,17 @@ unit cobjects;
           function  empty:boolean;
           function  empty:boolean;
        end;
        end;
 
 
+       { some help data types }
+       pstringqueueitem = ^tstringqueueitem;
+       tstringqueueitem = object
+          data : pstring;
+          next : pstringqueueitem;
+       end;
 
 
        { String Queue}
        { String Queue}
        PStringQueue=^TStringQueue;
        PStringQueue=^TStringQueue;
        TStringQueue=object
        TStringQueue=object
-         first,last : PStringItem;
+         first,last : PStringqueueItem;
          constructor Init;
          constructor Init;
          destructor Done;
          destructor Done;
          function Empty:boolean;
          function Empty:boolean;
@@ -139,36 +137,58 @@ unit cobjects;
          procedure Clear;
          procedure Clear;
        end;
        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 }
        { string container }
        pstringcontainer = ^tstringcontainer;
        pstringcontainer = ^tstringcontainer;
-       tstringcontainer = object
-          root,
-          last    : pstringitem;
+       tstringcontainer = object(tcontainer)
           doubles : boolean;  { if this is set to true, doubles are allowed }
           doubles : boolean;  { if this is set to true, doubles are allowed }
           constructor init;
           constructor init;
           constructor init_no_double;
           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(const s : string);
           procedure insert_with_tokeninfo(const s : string;const file_info : tfileposinfo);
           procedure insert_with_tokeninfo(const s : string;const file_info : tfileposinfo);
-
           { gets a string }
           { gets a string }
           function get : string;
           function get : string;
           function get_with_tokeninfo(var file_info : tfileposinfo) : string;
           function get_with_tokeninfo(var file_info : tfileposinfo) : string;
-
           { true if string is in the container }
           { true if string is in the container }
           function find(const s:string):boolean;
           function find(const s:string):boolean;
-
-          { deletes all strings }
-          procedure clear;
        end;
        end;
 
 
 
 
+       { namedindexobject for use with dictionary and indexarray }
        Pnamedindexobject=^Tnamedindexobject;
        Pnamedindexobject=^Tnamedindexobject;
        Tnamedindexobject=object
        Tnamedindexobject=object
          indexnr    : longint;
          indexnr    : longint;
@@ -578,7 +598,7 @@ end;
 
 
 function TStringQueue.Get:string;
 function TStringQueue.Get:string;
 var
 var
-  newnode : pstringitem;
+  newnode : pstringqueueitem;
 begin
 begin
   if first=nil then
   if first=nil then
    begin
    begin
@@ -595,7 +615,7 @@ end;
 
 
 procedure TStringQueue.Insert(const s:string);
 procedure TStringQueue.Insert(const s:string);
 var
 var
-  newnode : pstringitem;
+  newnode : pstringqueueitem;
 begin
 begin
   new(newnode);
   new(newnode);
   newnode^.next:=first;
   newnode^.next:=first;
@@ -608,7 +628,7 @@ end;
 
 
 procedure TStringQueue.Concat(const s:string);
 procedure TStringQueue.Concat(const s:string);
 var
 var
-  newnode : pstringitem;
+  newnode : pstringqueueitem;
 begin
 begin
   new(newnode);
   new(newnode);
   newnode^.next:=nil;
   newnode^.next:=nil;
@@ -623,7 +643,7 @@ end;
 
 
 procedure TStringQueue.Clear;
 procedure TStringQueue.Clear;
 var
 var
-  newnode : pstringitem;
+  newnode : pstringqueueitem;
 begin
 begin
   while (first<>nil) do
   while (first<>nil) do
    begin
    begin
@@ -640,146 +660,194 @@ begin
   Clear;
   Clear;
 end;
 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
       begin
          root:=nil;
          root:=nil;
          last:=nil;
          last:=nil;
-         doubles:=false;
       end;
       end;
 
 
 
 
-    destructor tstringcontainer.done;
+    destructor tcontainer.done;
       begin
       begin
          clear;
          clear;
       end;
       end;
 
 
 
 
-    function tstringcontainer.empty:boolean;
+    function tcontainer.empty:boolean;
       begin
       begin
         empty:=(root=nil);
         empty:=(root=nil);
       end;
       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
       var
-        newnode : pstringitem;
+         newnode : pcontaineritem;
       begin
       begin
-         if not(doubles) then
+         newnode:=root;
+         while assigned(newnode) do
            begin
            begin
+              root:=newnode^.next;
+              dispose(newnode,done);
               newnode:=root;
               newnode:=root;
-              while assigned(newnode) do
-                begin
-                   if newnode^.data^=s then exit;
-                   newnode:=newnode^.next;
-                end;
            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;
       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
       var
-         newnode : pstringitem;
+        newnode : pstringcontaineritem;
       begin
       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;
       end;
 
 
 
 
-    procedure tstringcontainer.clear;
+    procedure tstringcontainer.insert_with_tokeninfo(const s : string; const file_info : tfileposinfo);
       var
       var
-         newnode : pstringitem;
+        newnode : pstringcontaineritem;
       begin
       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;
       end;
 
 
 
 
     function tstringcontainer.get : string;
     function tstringcontainer.get : string;
       var
       var
-         newnode : pstringitem;
+         p : pstringcontaineritem;
       begin
       begin
-         if root=nil then
+         p:=pstringcontaineritem(inherited get);
+         if p=nil then
           get:=''
           get:=''
          else
          else
           begin
           begin
-            get:=root^.data^;
-            newnode:=root;
-            root:=root^.next;
-            stringdispose(newnode^.data);
-            dispose(newnode);
+            get:=p^.data^;
+            dispose(p,done);
           end;
           end;
       end;
       end;
 
 
 
 
     function tstringcontainer.get_with_tokeninfo(var file_info : tfileposinfo) : string;
     function tstringcontainer.get_with_tokeninfo(var file_info : tfileposinfo) : string;
       var
       var
-         newnode : pstringitem;
+         p : pstringcontaineritem;
       begin
       begin
-         if root=nil then
+         p:=pstringcontaineritem(inherited get);
+         if p=nil then
           begin
           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
           end
          else
          else
           begin
           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;
       end;
       end;
 
 
 
 
     function tstringcontainer.find(const s:string):boolean;
     function tstringcontainer.find(const s:string):boolean;
       var
       var
-         newnode : pstringitem;
+        newnode : pstringcontaineritem;
       begin
       begin
         find:=false;
         find:=false;
-        newnode:=root;
+        newnode:=pstringcontaineritem(root);
         while assigned(newnode) do
         while assigned(newnode) do
          begin
          begin
            if newnode^.data^=s then
            if newnode^.data^=s then
@@ -787,7 +855,7 @@ end;
               find:=true;
               find:=true;
               exit;
               exit;
             end;
             end;
-           newnode:=newnode^.next;
+           newnode:=pstringcontaineritem(newnode^.next);
          end;
          end;
       end;
       end;
 
 
@@ -2136,7 +2204,11 @@ end;
 end.
 end.
 {
 {
   $Log$
   $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
     * fixed linebreak
 
 
   Revision 1.35  1999/06/23 11:07:23  daniel
   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 }
     { Update asmres when externmode is set }
     if cs_link_extern in aktglobalswitches then
     if cs_link_extern in aktglobalswitches then
       AsmRes.AddLinkCommand(resbin,s,'');
       AsmRes.AddLinkCommand(resbin,s,'');
-    current_module^.linkofiles.insert(resobj);
+    current_module^.linkotherofiles.insert(resobj,link_allways);
   end;
   end;
 
 
 begin
 begin
   resnr:=0;
   resnr:=0;
   While not Current_module^.ResourceFiles.Empty do
   While not Current_module^.ResourceFiles.Empty do
    begin
    begin
-     S:=Current_module^.ResourceFiles.Get;
+     S:=Current_module^.ResourceFiles.get;
      CompileResource(s);
      CompileResource(s);
    end;
    end;
 end;
 end;
@@ -110,7 +110,11 @@ end;
 end.
 end.
 {
 {
   $Log$
   $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
     * changes to compile it with Delphi 4.0
 
 
   Revision 1.3  1999/01/06 14:38:09  michael
   Revision 1.3  1999/01/06 14:38:09  michael

+ 259 - 139
compiler/files.pas

@@ -24,9 +24,26 @@
 unit files;
 unit files;
 
 
 {$ifdef TP}
 {$ifdef TP}
-{$V+}
+  {$V+}
 {$endif}
 {$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
   interface
 
 
     uses
     uses
@@ -107,8 +124,23 @@ unit files;
           function  get_file_path(l :longint):string;
           function  get_file_path(l :longint):string;
        end;
        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}
 {$ifndef NEWMAP}
        tunitmap = array[0..maxunits-1] of pointer;
        tunitmap = array[0..maxunits-1] of pointer;
        punitmap = ^tunitmap;
        punitmap = ^tunitmap;
@@ -150,13 +182,18 @@ unit files;
           _exports      : plinkedlist;
           _exports      : plinkedlist;
 
 
           sourcefiles   : pfilemanager;
           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 }
           localunitsearchpath,           { local searchpaths }
           localobjectsearchpath,
           localobjectsearchpath,
           localincludesearchpath,
           localincludesearchpath,
@@ -644,6 +681,101 @@ uses
       end;
       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
                                   TMODULE
  ****************************************************************************}
  ****************************************************************************}
@@ -700,9 +832,9 @@ uses
 
 
     function tmodule.openppu:boolean;
     function tmodule.openppu:boolean;
       var
       var
-         objfiletime,
-         ppufiletime,
-         asmfiletime : longint;
+        objfiletime,
+        ppufiletime,
+        asmfiletime : longint;
       begin
       begin
         openppu:=false;
         openppu:=false;
         Message1(unit_t_ppu_loading,ppufilename^);
         Message1(unit_t_ppu_loading,ppufilename^);
@@ -762,7 +894,7 @@ uses
         do_compile:=false;
         do_compile:=false;
         if (flags and uf_in_library)=0 then
         if (flags and uf_in_library)=0 then
          begin
          begin
-           if (flags and (uf_static_linked or uf_smartlink))<>0 then
+           if (flags and uf_smart_linked)<>0 then
             begin
             begin
               objfiletime:=getnamedfiletime(staticlibfilename^);
               objfiletime:=getnamedfiletime(staticlibfilename^);
               Message2(unit_u_check_time,staticlibfilename^,filetimestring(objfiletime));
               Message2(unit_u_check_time,staticlibfilename^,filetimestring(objfiletime));
@@ -772,47 +904,34 @@ uses
                   do_compile:=true;
                   do_compile:=true;
                   exit;
                   exit;
                 end;
                 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;
          end;
         openppu:=true;
         openppu:=true;
       end;
       end;
@@ -978,15 +1097,19 @@ uses
         dependent_units.done;
         dependent_units.done;
         dependent_units.init;
         dependent_units.init;
         resourcefiles.done;
         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;
         uses_imports:=false;
         do_assemble:=false;
         do_assemble:=false;
         do_compile:=false;
         do_compile:=false;
@@ -1009,79 +1132,70 @@ uses
         n : namestr;
         n : namestr;
         e : extstr;
         e : extstr;
       begin
       begin
-         FSplit(s,p,n,e);
+        FSplit(s,p,n,e);
       { Programs have the name program to don't conflict with dup id's }
       { 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}
 {$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;
       end;
 
 
 
 
@@ -1106,10 +1220,12 @@ uses
         used_units.done;
         used_units.done;
         dependent_units.done;
         dependent_units.done;
         resourcefiles.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(objfilename);
         stringdispose(asmfilename);
         stringdispose(asmfilename);
         stringdispose(ppufilename);
         stringdispose(ppufilename);
@@ -1186,7 +1302,11 @@ uses
 end.
 end.
 {
 {
   $Log$
   $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
     * removed oldppu code
     * warning if objpas is loaded from uses
     * warning if objpas is loaded from uses
     * first things for new deref writing
     * first things for new deref writing

+ 7 - 3
compiler/globals.pas

@@ -1121,7 +1121,7 @@ unit globals;
         initoptprocessor:=Class386;
         initoptprocessor:=Class386;
         initlocalswitches:=[];
         initlocalswitches:=[];
         initmoduleswitches:=[cs_extsyntax,cs_browser];
         initmoduleswitches:=[cs_extsyntax,cs_browser];
-        initglobalswitches:=[cs_check_unit_name];
+        initglobalswitches:=[cs_check_unit_name,cs_link_static];
         initmodeswitches:=fpcmodeswitches;
         initmodeswitches:=fpcmodeswitches;
         initpackenum:=4;
         initpackenum:=4;
         initpackrecords:=2;
         initpackrecords:=2;
@@ -1133,7 +1133,7 @@ unit globals;
         initoptprocessor:=MC68000;
         initoptprocessor:=MC68000;
         initlocalswitches:=[];
         initlocalswitches:=[];
         initmoduleswitches:=[cs_extsyntax,cs_browser,cs_fp_emulation];
         initmoduleswitches:=[cs_extsyntax,cs_browser,cs_fp_emulation];
-        initglobalswitches:=[cs_check_unit_name];
+        initglobalswitches:=[cs_check_unit_name,cs_link_static];
         initmodeswitches:=fpcmodeswitches;
         initmodeswitches:=fpcmodeswitches;
         initpackenum:=4;
         initpackenum:=4;
         initpackrecords:=2;
         initpackrecords:=2;
@@ -1162,7 +1162,11 @@ begin
 end.
 end.
 {
 {
   $Log$
   $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
     * removed oldasm
     * plabel -> pasmlabel
     * plabel -> pasmlabel
     * -a switches to source writing automaticly
     * -a switches to source writing automaticly

+ 22 - 5
compiler/globtype.pas

@@ -66,7 +66,7 @@ interface
          { generation }
          { generation }
          cs_profile,cs_debuginfo,cs_browser,cs_local_browser,cs_compilesystem,
          cs_profile,cs_debuginfo,cs_browser,cs_local_browser,cs_compilesystem,
          { linking }
          { linking }
-         cs_smartlink,cs_create_sharedlib,cs_create_staticlib
+         cs_smartlink
        );
        );
        tmoduleswitches = set of tmoduleswitch;
        tmoduleswitches = set of tmoduleswitch;
 
 
@@ -89,7 +89,7 @@ interface
          cs_asm_leave,cs_asm_extern,cs_asm_pipe,cs_asm_source,
          cs_asm_leave,cs_asm_extern,cs_asm_pipe,cs_asm_source,
          cs_asm_regalloc,cs_asm_tempalloc,
          cs_asm_regalloc,cs_asm_tempalloc,
          { linking }
          { 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;
        tglobalswitches = set of tglobalswitch;
 
 
@@ -107,10 +107,14 @@ interface
        tmodeswitches = set of tmodeswitch;
        tmodeswitches = set of tmodeswitch;
 
 
        { win32 sub system }
        { win32 sub system }
-       tapptype = (at_gui,at_cui);
+       tapptype = (at_none,
+         at_gui,at_cui
+       );
 
 
        { currently parsed block type }
        { 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];
        stringid = string[maxidlen];
 
 
@@ -122,6 +126,15 @@ interface
        pword      = ^word;
        pword      = ^word;
        plongint   = ^longint;
        plongint   = ^longint;
 
 
+    const
+       { link options }
+       link_none    = $0;
+       link_allways = $1;
+       link_static  = $2;
+       link_smart   = $4;
+       link_shared  = $8;
+
+
 implementation
 implementation
 
 
 
 
@@ -129,7 +142,11 @@ begin
 end.
 end.
 {
 {
   $Log$
   $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
    + cs_checkpointer
 
 
   Revision 1.9  1999/05/12 00:19:49  peter
   Revision 1.9  1999/05/12 00:19:49  peter

+ 8 - 4
compiler/lin_targ.pas

@@ -39,7 +39,7 @@ interface
 implementation
 implementation
 
 
   uses
   uses
-    verbose,strings,cobjects,systems,globals,
+    verbose,strings,cobjects,systems,globtype,globals,
     files,aasm,symtable;
     files,aasm,symtable;
 
 
 
 
@@ -51,7 +51,7 @@ implementation
     procedure timportliblinux.importprocedure(const func,module : string;index : longint;const name : string);
     procedure timportliblinux.importprocedure(const func,module : string;index : longint;const name : string);
       begin
       begin
         { insert sharedlibrary }
         { 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 }
         { do nothing with the procedure, only set the mangledname }
         if name<>'' then
         if name<>'' then
           aktprocsym^.definition^.setmangledname(name)
           aktprocsym^.definition^.setmangledname(name)
@@ -63,7 +63,7 @@ implementation
     procedure timportliblinux.importvariable(const varname,module:string;const name:string);
     procedure timportliblinux.importvariable(const varname,module:string;const name:string);
       begin
       begin
         { insert sharedlibrary }
         { 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 }
         { reset the mangledname and turn off the dll_var option }
         aktvarsym^.setmangledname(name);
         aktvarsym^.setmangledname(name);
         aktvarsym^.var_options:=aktvarsym^.var_options and (not vo_is_dll_var);
         aktvarsym^.var_options:=aktvarsym^.var_options and (not vo_is_dll_var);
@@ -78,7 +78,11 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $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
     * bugs related to mangledname solved
       - linux external without name
       - linux external without name
       -external procs already used
       -external procs already used

+ 72 - 10
compiler/link.pas

@@ -74,7 +74,7 @@ uses
   dmisc,
   dmisc,
 {$endif Delphi}
 {$endif Delphi}
   globtype,systems,
   globtype,systems,
-  script,globals,verbose
+  script,globals,verbose,ppu
 {$ifdef i386}
 {$ifdef i386}
   ,win_targ
   ,win_targ
 {$endif}
 {$endif}
@@ -139,17 +139,69 @@ end;
 
 
 
 
 procedure TLinker.AddModuleFiles(hp:pmodule);
 procedure TLinker.AddModuleFiles(hp:pmodule);
+var
+  mask : longint;
 begin
 begin
   with hp^ do
   with hp^ do
    begin
    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;
 end;
 end;
 
 
@@ -184,6 +236,9 @@ function TLinker.FindObjectFile(s:string) : string;
 var
 var
   found : boolean;
   found : boolean;
 begin
 begin
+  findobjectfile:='';
+  if s='' then
+   exit;
   if pos('.',s)=0 then
   if pos('.',s)=0 then
    s:=s+target_info.objext;
    s:=s+target_info.objext;
   s:=FixFileName(s);
   s:=FixFileName(s);
@@ -218,6 +273,9 @@ function TLinker.FindLibraryFile(s:string;const ext:string) : string;
 var
 var
   found : boolean;
   found : boolean;
 begin
 begin
+  findlibraryfile:='';
+  if s='' then
+   exit;
   if pos('.',s)=0 then
   if pos('.',s)=0 then
    s:=s+ext;
    s:=s+ext;
   if FileExists(s) then
   if FileExists(s) then
@@ -652,7 +710,11 @@ end;
 end.
 end.
 {
 {
   $Log$
   $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
     * merged
 
 
   Revision 1.54.2.3  1999/06/28 15:55:40  peter
   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)
        tdbgoutput = object(tobjectoutput)
          nsyms   : longint;
          nsyms   : longint;
          rawidx  : longint;
          rawidx  : longint;
-         constructor init;
+         constructor init(smart:boolean);
          destructor  done;virtual;
          destructor  done;virtual;
          procedure initwriting;virtual;
          procedure initwriting;virtual;
          procedure donewriting;virtual;
          procedure donewriting;virtual;
@@ -54,9 +54,9 @@ unit og386dbg;
                                 Tdbgoutput
                                 Tdbgoutput
 ****************************************************************************}
 ****************************************************************************}
 
 
-    constructor tdbgoutput.init;
+    constructor tdbgoutput.init(smart:boolean);
       begin
       begin
-        inherited init;
+        inherited init(smart);
         rawidx:=-1;
         rawidx:=-1;
         nsyms:=0;
         nsyms:=0;
       end;
       end;
@@ -182,7 +182,11 @@ unit og386dbg;
 end.
 end.
 {
 {
   $Log$
   $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
     * output is more like as 2.9.1
     * stabs really working for go32v2
     * stabs really working for go32v2
 
 

+ 48 - 58
compiler/options.pas

@@ -388,27 +388,6 @@ begin
                       while j <= length(more) Do
                       while j <= length(more) Do
                         Begin
                         Begin
                           case more[j] of
                           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' :
                             'h' :
                                begin
                                begin
                                  val(copy(more,j+1,length(more)-j),heapsize,code);
                                  val(copy(more,j+1,length(more)-j),heapsize,code);
@@ -428,18 +407,22 @@ begin
                                       inc(j)
                                       inc(j)
                                     End
                                     End
                                   Else initglobalswitches:=initglobalswitches+[cs_link_extern];
                                   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' :
                             's' :
                                begin
                                begin
                                  val(copy(more,j+1,length(more)-j),stacksize,code);
                                  val(copy(more,j+1,length(more)-j),stacksize,code);
@@ -447,28 +430,22 @@ begin
                                   IllegalPara(opt);
                                   IllegalPara(opt);
                                  break;
                                  break;
                                end;
                                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
                             else
                                IllegalPara(opt);
                                IllegalPara(opt);
                           end;
                           end;
@@ -701,15 +678,24 @@ begin
                         's' : Linker.Strip:=true;
                         's' : Linker.Strip:=true;
                         'D' : begin
                         'D' : begin
                                 def_symbol('FPC_LINK_DYNAMIC');
                                 def_symbol('FPC_LINK_DYNAMIC');
+                                undef_symbol('FPC_LINK_SMART');
                                 undef_symbol('FPC_LINK_STATIC');
                                 undef_symbol('FPC_LINK_STATIC');
                                 initglobalswitches:=initglobalswitches+[cs_link_shared];
                                 initglobalswitches:=initglobalswitches+[cs_link_shared];
-                                initglobalswitches:=initglobalswitches-[cs_link_static];
+                                initglobalswitches:=initglobalswitches-[cs_link_static,cs_link_smart];
                               end;
                               end;
                         'S' : begin
                         'S' : begin
                                 def_symbol('FPC_LINK_STATIC');
                                 def_symbol('FPC_LINK_STATIC');
+                                undef_symbol('FPC_LINK_SMART');
                                 undef_symbol('FPC_LINK_DYNAMIC');
                                 undef_symbol('FPC_LINK_DYNAMIC');
-                                initglobalswitches:=initglobalswitches-[cs_link_shared];
                                 initglobalswitches:=initglobalswitches+[cs_link_static];
                                 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;
                               end;
                        else
                        else
                          IllegalPara(opt);
                          IllegalPara(opt);
@@ -1167,7 +1153,11 @@ end;
 end.
 end.
 {
 {
   $Log$
   $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
     * int64/qword type release
     + lo/hi for int64/qword
     + 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
 begin
     seq_no:=1;
     seq_no:=1;
     if not (cs_smartlink in aktmoduleswitches) then
     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');
     assign(out_file,current_module^.path^+s+'.ao2');
     rewrite(out_file,1);
     rewrite(out_file,1);
     blockwrite(out_file,ar_magic,sizeof(ar_magic));
     blockwrite(out_file,ar_magic,sizeof(ar_magic));
@@ -333,7 +333,11 @@ end.
 
 
 {
 {
   $Log$
   $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
     * changes to compile it with Delphi 4.0
 
 
   Revision 1.6  1998/12/11 00:03:25  peter
   Revision 1.6  1998/12/11 00:03:25  peter

+ 20 - 27
compiler/pmodules.pas

@@ -49,42 +49,31 @@ unit pmodules;
     procedure create_objectfile;
     procedure create_objectfile;
       begin
       begin
         { create the .s file and assemble it }
         { 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 }
         { resource files }
         CompileResourceFiles;
         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;
       end;
 
 
 
 
     procedure insertobjectfile;
     procedure insertobjectfile;
     { Insert the used object file for this unit in the used list for this unit }
     { Insert the used object file for this unit in the used list for this unit }
       begin
       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
          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;
       end;
       end;
 
 
@@ -1335,7 +1324,11 @@ unit pmodules;
 end.
 end.
 {
 {
   $Log$
   $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
     * merged
 
 
   Revision 1.124.2.1  1999/06/15 13:54:26  peter
   Revision 1.124.2.1  1999/06/15 13:54:26  peter

+ 24 - 19
compiler/ppu.pas

@@ -61,19 +61,21 @@ const
   ibendbrowser        = 254;
   ibendbrowser        = 254;
   ibend               = 255;
   ibend               = 255;
   {general}
   {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}
   {syms}
   ibtypesym       = 20;
   ibtypesym       = 20;
   ibprocsym       = 21;
   ibprocsym       = 21;
@@ -113,12 +115,11 @@ const
   uf_big_endian    = $4;
   uf_big_endian    = $4;
   uf_has_dbx       = $8;
   uf_has_dbx       = $8;
   uf_has_browser   = $10;
   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_local_browser = $200;
-  uf_obj_linked    = $400; { the ppu is linked in a object file }
 
 
 type
 type
 {$ifdef m68k}
 {$ifdef m68k}
@@ -868,7 +869,11 @@ end;
 end.
 end.
 {
 {
   $Log$
   $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
     * removed oldppu code
     * warning if objpas is loaded from uses
     * warning if objpas is loaded from uses
     * first things for new deref writing
     * first things for new deref writing

+ 7 - 3
compiler/scandir.inc

@@ -616,7 +616,7 @@ const
       begin
       begin
         current_scanner^.skipspace;
         current_scanner^.skipspace;
         s:=AddExtension(FixFileName(current_scanner^.readcomment),target_info.objext);
         s:=AddExtension(FixFileName(current_scanner^.readcomment),target_info.objext);
-        current_module^.linkofiles.insert(s);
+        current_module^.linkotherofiles.insert(s,link_allways);
       end;
       end;
 
 
 
 
@@ -637,7 +637,7 @@ const
       begin
       begin
         current_scanner^.skipspace;
         current_scanner^.skipspace;
         current_scanner^.readstring;
         current_scanner^.readstring;
-        current_module^.linkSharedLibs.insert(orgpattern);
+        current_module^.linkOtherSharedLibs.insert(orgpattern,link_allways);
       end;
       end;
 
 
 
 
@@ -1087,7 +1087,11 @@ const
 
 
 {
 {
   $Log$
   $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
    * previous wrong log corrected
 
 
   Revision 1.52  1999/06/02 22:25:48  pierre
   Revision 1.52  1999/06/02 22:25:48  pierre

+ 86 - 52
compiler/symppu.inc

@@ -72,29 +72,6 @@
       end;
       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);
     procedure writeposinfo(const p:tfileposinfo);
       begin
       begin
         current_ppu^.putword(p.fileindex);
         current_ppu^.putword(p.fileindex);
@@ -223,6 +200,49 @@
       end;
       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);
     procedure writeunitas(const s : string;unittable : punitsymtable;only_crc : boolean);
       begin
       begin
          Message1(unit_u_ppu_write,s);
          Message1(unit_u_ppu_write,s);
@@ -230,15 +250,8 @@
        { create unit flags }
        { create unit flags }
          with Current_Module^ do
          with Current_Module^ do
           begin
           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
             if cs_smartlink in aktmoduleswitches then
-             flags:=flags or uf_smartlink;
+             flags:=flags or uf_smart_linked;
 {$ifdef GDB}
 {$ifdef GDB}
             if cs_gdb_dbx in aktglobalswitches then
             if cs_gdb_dbx in aktglobalswitches then
              flags:=flags or uf_has_dbx;
              flags:=flags or uf_has_dbx;
@@ -373,13 +386,6 @@
       end;
       end;
 
 
 
 
-    procedure readcontainer(var p:tstringcontainer);
-      begin
-        while not current_ppu^.endofentry do
-         p.insert(current_ppu^.getstring);
-      end;
-
-
     procedure readposinfo(var p:tfileposinfo);
     procedure readposinfo(var p:tfileposinfo);
       begin
       begin
         p.fileindex:=current_ppu^.getword;
         p.fileindex:=current_ppu^.getword;
@@ -410,8 +416,6 @@
                 break;
                 break;
               end;
               end;
             derefindex,
             derefindex,
-            derefpara,
-            dereflocal,
             derefrecord :
             derefrecord :
               begin
               begin
                 new(p,init(b,current_ppu^.getword));
                 new(p,init(b,current_ppu^.getword));
@@ -553,6 +557,20 @@
       end;
       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;
     procedure load_interface;
       var
       var
         b : byte;
         b : byte;
@@ -561,17 +579,29 @@
          repeat
          repeat
            b:=current_ppu^.readentry;
            b:=current_ppu^.readentry;
            case b of
            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
            else
              Message1(unit_f_ppu_invalid_entry,tostr(b));
              Message1(unit_f_ppu_invalid_entry,tostr(b));
            end;
            end;
@@ -580,7 +610,11 @@
 
 
 {
 {
   $Log$
   $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
    * local browser stuff corrected
 
 
   Revision 1.41  1999/05/14 17:52:28  peter
   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
         the link.res. All doesn't depend on the crc! It doesn't matter
         if a unit is in a .o or .a file }
         if a unit is in a .o or .a file }
         current_ppu^.do_crc:=false;
         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^.do_crc:=true;
 
 
         current_ppu^.writeentry(ibendinterface);
         current_ppu^.writeentry(ibendinterface);
@@ -2308,7 +2310,11 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $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
    merged from v0-99-12 branch
 
 
   Revision 1.21.2.2  1999/06/28 16:59:55  pierre
   Revision 1.21.2.2  1999/06/28 16:59:55  pierre