Browse Source

* fixed linking for units without linking necessary

peter 26 years ago
parent
commit
0d38c66ff0
3 changed files with 64 additions and 46 deletions
  1. 51 43
      compiler/link.pas
  2. 7 2
      compiler/pmodules.pas
  3. 6 1
      compiler/ppu.pas

+ 51 - 43
compiler/link.pas

@@ -144,58 +144,63 @@ var
 begin
   with hp^ do
    begin
-     { 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
+   { link unit files }
+     if (flags and uf_no_link)=0 then
       begin
-        if (flags and uf_smart_linked)=0 then
+        { 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 smart not avail then try static linking }
-           if (flags and uf_static_linked)<>0 then
+           if (flags and uf_smart_linked)=0 then
             begin
-              Comment(V_Error,'unit '+modulename^+' can''t be smart linked, switching to static linking');
-              mask:=mask or link_static;
+              { 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
-            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
+            mask:=mask or link_smart;
+         end;
+        { shared linking }
+        if (cs_link_shared in aktglobalswitches) then
          begin
-           { if shared not avail then try static linking }
-           if (flags and uf_static_linked)<>0 then
+           if (flags and uf_shared_linked)=0 then
             begin
-              Comment(V_Error,'unit '+modulename^+' can''t be shared linked, switching to static linking');
-              mask:=mask or link_static;
+              { 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
-            Comment(V_Error,'unit '+modulename^+' can''t be shared or static linked');
-         end
-        else
-         mask:=mask or link_shared;
+            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));
       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 }
+   { Other needed .o and libs, specified using $L,$LINKLIB,external }
+     mask:=link_allways;
      while not linkotherofiles.empty do
       AddObject(linkotherofiles.Getusemask(mask));
      while not linkotherstaticlibs.empty do
@@ -710,7 +715,10 @@ end;
 end.
 {
   $Log$
-  Revision 1.58  1999-07-03 00:29:51  peter
+  Revision 1.59  1999-07-05 16:21:26  peter
+    * fixed linking for units without linking necessary
+
+  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
 

+ 7 - 2
compiler/pmodules.pas

@@ -1097,7 +1097,9 @@ unit pmodules;
          { insert own objectfile, or say that it's in a library
            (no check for an .o when loading) }
          if is_assembler_generated then
-           insertobjectfile;
+           insertobjectfile
+         else
+           current_module^.flags:=current_module^.flags or uf_no_link;
 
          if cs_local_browser in aktmoduleswitches then
            current_module^.localsymtable:=refsymtable;
@@ -1324,7 +1326,10 @@ unit pmodules;
 end.
 {
   $Log$
-  Revision 1.126  1999-07-03 00:29:56  peter
+  Revision 1.127  1999-07-05 16:21:27  peter
+    * fixed linking for units without linking necessary
+
+  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
 

+ 6 - 1
compiler/ppu.pas

@@ -120,6 +120,8 @@ const
   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_no_link       = $400; { unit has no .o generated, but can still have
+                             external linking! }
 
 type
 {$ifdef m68k}
@@ -869,7 +871,10 @@ end;
 end.
 {
   $Log$
-  Revision 1.34  1999-07-03 00:29:57  peter
+  Revision 1.35  1999-07-05 16:21:30  peter
+    * fixed linking for units without linking necessary
+
+  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