Browse Source

* -Xt option to link staticly against c libs

peter 25 years ago
parent
commit
1612077d8d
3 changed files with 24 additions and 6 deletions
  1. 5 2
      compiler/globtype.pas
  2. 5 1
      compiler/options.pas
  3. 14 3
      compiler/t_linux.pas

+ 5 - 2
compiler/globtype.pas

@@ -105,7 +105,7 @@ interface
          cs_asm_regalloc,cs_asm_tempalloc,
          cs_asm_regalloc,cs_asm_tempalloc,
          { linking }
          { linking }
          cs_link_extern,cs_link_static,cs_link_smart,cs_link_shared,cs_link_deffile,
          cs_link_extern,cs_link_static,cs_link_smart,cs_link_shared,cs_link_deffile,
-         cs_link_strip,cs_link_toc
+         cs_link_strip,cs_link_toc,cs_link_staticflag
        );
        );
        tglobalswitches = set of tglobalswitch;
        tglobalswitches = set of tglobalswitch;
 
 
@@ -180,7 +180,10 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.26  2000-02-06 17:20:52  peter
+  Revision 1.27  2000-02-09 10:35:48  peter
+    * -Xt option to link staticly against c libs
+
+  Revision 1.26  2000/02/06 17:20:52  peter
     * -gl switch for auto lineinfo including
     * -gl switch for auto lineinfo including
 
 
   Revision 1.25  2000/01/07 01:14:27  peter
   Revision 1.25  2000/01/07 01:14:27  peter

+ 5 - 1
compiler/options.pas

@@ -796,6 +796,7 @@ begin
                        case More[j] of
                        case More[j] of
                         'c' : initglobalswitches:=initglobalswitches+[cs_link_toc];
                         'c' : initglobalswitches:=initglobalswitches+[cs_link_toc];
                         's' : initglobalswitches:=initglobalswitches+[cs_link_strip];
                         's' : initglobalswitches:=initglobalswitches+[cs_link_strip];
+                        't' : initglobalswitches:=initglobalswitches+[cs_link_staticflag];
                         'D' : begin
                         'D' : begin
                                 def_symbol('FPC_LINK_DYNAMIC');
                                 def_symbol('FPC_LINK_DYNAMIC');
                                 undef_symbol('FPC_LINK_SMART');
                                 undef_symbol('FPC_LINK_SMART');
@@ -1428,7 +1429,10 @@ end;
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.57  2000-02-06 17:20:52  peter
+  Revision 1.58  2000-02-09 10:35:48  peter
+    * -Xt option to link staticly against c libs
+
+  Revision 1.57  2000/02/06 17:20:52  peter
     * -gl switch for auto lineinfo including
     * -gl switch for auto lineinfo including
 
 
   Revision 1.56  2000/01/31 15:55:42  peter
   Revision 1.56  2000/01/31 15:55:42  peter

+ 14 - 3
compiler/t_linux.pas

@@ -208,7 +208,7 @@ begin
   Glibc21:=false;
   Glibc21:=false;
   with Info do
   with Info do
    begin
    begin
-     ExeCmd[1]:='ld $OPT $DYNLINK $STRIP -L. -o $EXE $RES';
+     ExeCmd[1]:='ld $OPT $DYNLINK $STATIC $STRIP -L. -o $EXE $RES';
      DllCmd[1]:='ld $OPT -shared -L. -o $EXE $RES';
      DllCmd[1]:='ld $OPT -shared -L. -o $EXE $RES';
      DllCmd[2]:='strip --strip-unneeded $EXE';
      DllCmd[2]:='strip --strip-unneeded $EXE';
      { first try glibc2 }
      { first try glibc2 }
@@ -348,6 +348,9 @@ begin
      { be sure that libc is the last lib }
      { be sure that libc is the last lib }
      if linklibc then
      if linklibc then
       LinkRes.Add('-lc');
       LinkRes.Add('-lc');
+     { when we have -static for the linker the we also need libgcc }
+     if (cs_link_staticflag in aktglobalswitches) then
+      LinkRes.Add('-lgcc');
      if linkdynamic and (Info.DynamicLinker<>'') then
      if linkdynamic and (Info.DynamicLinker<>'') then
       LinkRes.AddFileName(Info.DynamicLinker);
       LinkRes.AddFileName(Info.DynamicLinker);
      LinkRes.Add(')');
      LinkRes.Add(')');
@@ -366,14 +369,18 @@ var
   cmdstr  : string;
   cmdstr  : string;
   success : boolean;
   success : boolean;
   DynLinkStr : string[60];
   DynLinkStr : string[60];
+  StaticStr,
   StripStr   : string[40];
   StripStr   : string[40];
 begin
 begin
   if not(cs_link_extern in aktglobalswitches) then
   if not(cs_link_extern in aktglobalswitches) then
    Message1(exec_i_linking,current_module^.exefilename^);
    Message1(exec_i_linking,current_module^.exefilename^);
 
 
 { Create some replacements }
 { Create some replacements }
+  StaticStr:='';
   StripStr:='';
   StripStr:='';
   DynLinkStr:='';
   DynLinkStr:='';
+  if (cs_link_staticflag in aktglobalswitches) then
+   StaticStr:='-static';
   if (cs_link_strip in aktglobalswitches) then
   if (cs_link_strip in aktglobalswitches) then
    StripStr:='-s';
    StripStr:='-s';
   If (cs_profile in aktmoduleswitches) or
   If (cs_profile in aktmoduleswitches) or
@@ -388,6 +395,7 @@ begin
   Replace(cmdstr,'$EXE',current_module^.exefilename^);
   Replace(cmdstr,'$EXE',current_module^.exefilename^);
   Replace(cmdstr,'$OPT',Info.ExtraOptions);
   Replace(cmdstr,'$OPT',Info.ExtraOptions);
   Replace(cmdstr,'$RES',outputexedir+Info.ResName);
   Replace(cmdstr,'$RES',outputexedir+Info.ResName);
+  Replace(cmdstr,'$STATIC',StaticStr);
   Replace(cmdstr,'$STRIP',StripStr);
   Replace(cmdstr,'$STRIP',StripStr);
   Replace(cmdstr,'$DYNLINK',DynLinkStr);
   Replace(cmdstr,'$DYNLINK',DynLinkStr);
   success:=DoExec(FindUtil(BinStr),CmdStr,true,false);
   success:=DoExec(FindUtil(BinStr),CmdStr,true,false);
@@ -439,7 +447,10 @@ end;
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.8  2000-01-11 09:52:07  peter
+  Revision 1.9  2000-02-09 10:35:48  peter
+    * -Xt option to link staticly against c libs
+
+  Revision 1.8  2000/01/11 09:52:07  peter
     * fixed placing of .sl directories
     * fixed placing of .sl directories
     * use -b again for base-file selection
     * use -b again for base-file selection
     * fixed group writing for linux with smartlinking
     * fixed group writing for linux with smartlinking
@@ -468,4 +479,4 @@ end.
     * redesigned linker object
     * redesigned linker object
     + library support for linux (only procedures can be exported)
     + library support for linux (only procedures can be exported)
 
 
-}
+}