From f57803d67af7ed68131b526f053d646675f91379 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A1roly=20Balogh?= Date: Mon, 25 Apr 2005 15:58:59 +0000 Subject: [PATCH] * static linking fixes --- compiler/systems/t_morph.pas | 74 ++++++++++++++++++++++-------------- 1 file changed, 46 insertions(+), 28 deletions(-) diff --git a/compiler/systems/t_morph.pas b/compiler/systems/t_morph.pas index 3d15b65cc0..ae07bcd869 100644 --- a/compiler/systems/t_morph.pas +++ b/compiler/systems/t_morph.pas @@ -137,45 +137,60 @@ begin { Write staticlibraries } if not StaticLibFiles.Empty then begin - { vlink doesn't need, and doesn't support GROUP } - if (cs_link_on_target in aktglobalswitches) then begin + { vlink doesn't need, and doesn't support GROUP } + if (cs_link_on_target in aktglobalswitches) then + begin LinkRes.Add(')'); LinkRes.Add('GROUP('); end; - while not StaticLibFiles.Empty do + while not StaticLibFiles.Empty do begin - S:=StaticLibFiles.GetFirst; - LinkRes.AddFileName(maybequoted(s)); + S:=StaticLibFiles.GetFirst; + LinkRes.AddFileName(maybequoted(s)); end; end; - LinkRes.Add(')'); + + if (cs_link_on_target in aktglobalswitches) then + begin + LinkRes.Add(')'); - { Write sharedlibraries like -l, also add the needed dynamic linker - here to be sure that it gets linked this is needed for glibc2 systems (PFV) } - linklibc:=false; - while not SharedLibFiles.Empty do - begin - S:=SharedLibFiles.GetFirst; - if s<>'c' then + { Write sharedlibraries like -l, also add the needed dynamic linker + here to be sure that it gets linked this is needed for glibc2 systems (PFV) } + linklibc:=false; + while not SharedLibFiles.Empty do begin - i:=Pos(target_info.sharedlibext,S); - if i>0 then - Delete(S,i,255); - LinkRes.Add('-l'+s); - end - else - begin - LinkRes.Add('-l'+s); - linklibc:=true; + S:=SharedLibFiles.GetFirst; + if s<>'c' then + begin + i:=Pos(target_info.sharedlibext,S); + if i>0 then + Delete(S,i,255); + LinkRes.Add('-l'+s); + end + else + begin + LinkRes.Add('-l'+s); + linklibc:=true; + end; end; - end; - { be sure that libc&libgcc is the last lib } - if linklibc then + { be sure that libc&libgcc is the last lib } + if linklibc then + begin + LinkRes.Add('-lc'); + LinkRes.Add('-lgcc'); + end; + end + else begin - LinkRes.Add('-lc'); - LinkRes.Add('-lgcc'); + while not SharedLibFiles.Empty do + begin + S:=SharedLibFiles.GetFirst; + LinkRes.Add('lib'+s+target_info.staticlibext); + end; + LinkRes.Add(')'); end; + { Write and Close response } linkres.writetodisk; linkres.free; @@ -255,7 +270,10 @@ initialization end. { $Log$ - Revision 1.13 2005-02-14 17:13:10 peter + Revision 1.14 2005-04-25 15:58:59 karoly + * static linking fixes + + Revision 1.13 2005/02/14 17:13:10 peter * truncate log Revision 1.12 2005/02/11 07:23:22 karoly