mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-14 07:09:23 +02:00
* linkordering for Linux
git-svn-id: trunk@3911 -
This commit is contained in:
parent
35bc0b8160
commit
0dc6fb52ea
@ -55,6 +55,7 @@ interface
|
|||||||
function MakeExecutable:boolean;override;
|
function MakeExecutable:boolean;override;
|
||||||
function MakeSharedLibrary:boolean;override;
|
function MakeSharedLibrary:boolean;override;
|
||||||
function postprocessexecutable(const fn : string;isdll:boolean):boolean;
|
function postprocessexecutable(const fn : string;isdll:boolean):boolean;
|
||||||
|
procedure LoadPredefinedLibraryOrder; override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -310,6 +311,20 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
procedure TLinkerLinux.LoadPredefinedLibraryOrder;
|
||||||
|
// put your linkorder/linkalias overrides here.
|
||||||
|
// Note: assumes only called when reordering/aliasing is used.
|
||||||
|
Begin
|
||||||
|
if not (cs_link_no_default_lib_order in aktglobalswitches) Then
|
||||||
|
Begin
|
||||||
|
LinkLibraryOrder.add('gcc','',15);
|
||||||
|
LinkLibraryOrder.add('c','',100);
|
||||||
|
LinkLibraryOrder.add('gmon','',120);
|
||||||
|
LinkLibraryOrder.add('dl','',140);
|
||||||
|
LinkLibraryOrder.add('pthread','',160);
|
||||||
|
end;
|
||||||
|
End;
|
||||||
|
|
||||||
Function TLinkerLinux.WriteResponseFile(isdll:boolean) : Boolean;
|
Function TLinkerLinux.WriteResponseFile(isdll:boolean) : Boolean;
|
||||||
Var
|
Var
|
||||||
linkres : TLinkRes;
|
linkres : TLinkRes;
|
||||||
@ -321,11 +336,13 @@ Var
|
|||||||
s,s1,s2 : string;
|
s,s1,s2 : string;
|
||||||
found1,
|
found1,
|
||||||
found2,
|
found2,
|
||||||
|
Reorder,
|
||||||
linklibc : boolean;
|
linklibc : boolean;
|
||||||
begin
|
begin
|
||||||
result:=False;
|
result:=False;
|
||||||
{ set special options for some targets }
|
{ set special options for some targets }
|
||||||
linklibc:=(SharedLibFiles.Find('c')<>nil);
|
linklibc:=(SharedLibFiles.Find('c')<>nil);
|
||||||
|
reorder := linklibc and ReOrderEntries;
|
||||||
if isdll then
|
if isdll then
|
||||||
begin
|
begin
|
||||||
prtobj:='dllprt0';
|
prtobj:='dllprt0';
|
||||||
@ -416,15 +433,22 @@ begin
|
|||||||
Add(')');
|
Add(')');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
// we must reorder here because the result could empty sharedlibfiles
|
||||||
|
if reorder Then
|
||||||
|
ExpandAndApplyOrder(SharedLibFiles);
|
||||||
|
// after this point addition of shared libs not allowed.
|
||||||
|
|
||||||
{ Write sharedlibraries like -l<lib>, also add the needed dynamic linker
|
{ Write sharedlibraries like -l<lib>, also add the needed dynamic linker
|
||||||
here to be sure that it gets linked this is needed for glibc2 systems (PFV) }
|
here to be sure that it gets linked this is needed for glibc2 systems (PFV) }
|
||||||
|
|
||||||
if not SharedLibFiles.Empty then
|
if not SharedLibFiles.Empty then
|
||||||
begin
|
begin
|
||||||
|
|
||||||
Add('INPUT(');
|
Add('INPUT(');
|
||||||
While not SharedLibFiles.Empty do
|
While not SharedLibFiles.Empty do
|
||||||
begin
|
begin
|
||||||
S:=SharedLibFiles.GetFirst;
|
S:=SharedLibFiles.GetFirst;
|
||||||
if s<>'c' then
|
if (s<>'c') or reorder then
|
||||||
begin
|
begin
|
||||||
i:=Pos(target_info.sharedlibext,S);
|
i:=Pos(target_info.sharedlibext,S);
|
||||||
if i>0 then
|
if i>0 then
|
||||||
@ -437,7 +461,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
{ be sure that libc is the last lib }
|
{ be sure that libc is the last lib }
|
||||||
if linklibc then
|
if linklibc and not reorder then
|
||||||
Add('-lc');
|
Add('-lc');
|
||||||
{ when we have -static for the linker the we also need libgcc }
|
{ when we have -static for the linker the we also need libgcc }
|
||||||
if (cs_link_staticflag in aktglobalswitches) then
|
if (cs_link_staticflag in aktglobalswitches) then
|
||||||
|
Loading…
Reference in New Issue
Block a user