mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-14 11:09:19 +02:00
* Xtensa-freeRTOS: fix linking against libc
git-svn-id: trunk@46782 -
This commit is contained in:
parent
8ef6372340
commit
aea85fcd66
@ -96,10 +96,10 @@ begin
|
|||||||
prtobj:='';
|
prtobj:='';
|
||||||
{$else}
|
{$else}
|
||||||
prtobj:='prt0';
|
prtobj:='prt0';
|
||||||
{$endif}
|
|
||||||
cprtobj:='cprt0';
|
cprtobj:='cprt0';
|
||||||
if linklibc then
|
if linklibc then
|
||||||
prtobj:=cprtobj;
|
prtobj:=cprtobj;
|
||||||
|
{$endif}
|
||||||
|
|
||||||
{ Open link.res file }
|
{ Open link.res file }
|
||||||
LinkRes:=TLinkRes.Create(outputexedir+Info.ResName,true);
|
LinkRes:=TLinkRes.Create(outputexedir+Info.ResName,true);
|
||||||
@ -132,14 +132,18 @@ begin
|
|||||||
LinkRes.AddFileName(s);
|
LinkRes.AddFileName(s);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ try to add crti and crtbegin if linking to C }
|
{ xtensa FreeRTOS links always against libc, the runtime needs it }
|
||||||
if linklibc then
|
if not(target_info.system in [system_xtensa_freertos]) then
|
||||||
begin
|
begin
|
||||||
if librarysearchpath.FindFile('crtbegin.o',false,s) then
|
{ try to add crti and crtbegin if linking to C }
|
||||||
LinkRes.AddFileName(s);
|
if linklibc then
|
||||||
if librarysearchpath.FindFile('crti.o',false,s) then
|
begin
|
||||||
LinkRes.AddFileName(s);
|
if librarysearchpath.FindFile('crtbegin.o',false,s) then
|
||||||
end;
|
LinkRes.AddFileName(s);
|
||||||
|
if librarysearchpath.FindFile('crti.o',false,s) then
|
||||||
|
LinkRes.AddFileName(s);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
while not ObjectFiles.Empty do
|
while not ObjectFiles.Empty do
|
||||||
begin
|
begin
|
||||||
@ -165,49 +169,57 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
LinkRes.Add(')');
|
{ xtensa FreeRTOS links always against libc, the runtime needs it }
|
||||||
|
if not(target_info.system in [system_xtensa_freertos]) then
|
||||||
{ 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) }
|
|
||||||
linklibc:=false;
|
|
||||||
while not SharedLibFiles.Empty do
|
|
||||||
begin
|
begin
|
||||||
S:=SharedLibFiles.GetFirst;
|
{ Write sharedlibraries like -l<lib>, also add the needed dynamic linker
|
||||||
if s<>'c' then
|
here to be sure that it gets linked this is needed for glibc2 systems (PFV) }
|
||||||
|
linklibc:=false;
|
||||||
|
while not SharedLibFiles.Empty do
|
||||||
begin
|
begin
|
||||||
i:=Pos(target_info.sharedlibext,S);
|
S:=SharedLibFiles.GetFirst;
|
||||||
if i>0 then
|
if s<>'c' then
|
||||||
Delete(S,i,255);
|
begin
|
||||||
LinkRes.Add('-l'+s);
|
i:=Pos(target_info.sharedlibext,S);
|
||||||
end
|
if i>0 then
|
||||||
else
|
Delete(S,i,255);
|
||||||
|
LinkRes.Add('-l'+s);
|
||||||
|
end
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
LinkRes.Add('-l'+s);
|
||||||
|
linklibc:=true;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
{ be sure that libc&libgcc is the last lib }
|
||||||
|
if linklibc then
|
||||||
begin
|
begin
|
||||||
LinkRes.Add('-l'+s);
|
LinkRes.Add('-lc');
|
||||||
linklibc:=true;
|
LinkRes.Add('-lgcc');
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
{ be sure that libc&libgcc is the last lib }
|
|
||||||
if linklibc then
|
|
||||||
begin
|
|
||||||
LinkRes.Add('-lc');
|
|
||||||
LinkRes.Add('-lgcc');
|
|
||||||
end;
|
|
||||||
|
|
||||||
{ objects which must be at the end }
|
LinkRes.Add(')');
|
||||||
if linklibc then
|
|
||||||
begin
|
{ xtensa FreeRTOS links always against libc }
|
||||||
found1:=librarysearchpath.FindFile('crtend.o',false,s1);
|
if not(target_info.system in [system_xtensa_freertos]) then
|
||||||
found2:=librarysearchpath.FindFile('crtn.o',false,s2);
|
begin
|
||||||
if found1 or found2 then
|
{ objects which must be at the end }
|
||||||
begin
|
if linklibc then
|
||||||
LinkRes.Add('INPUT(');
|
begin
|
||||||
if found1 then
|
found1:=librarysearchpath.FindFile('crtend.o',false,s1);
|
||||||
LinkRes.AddFileName(s1);
|
found2:=librarysearchpath.FindFile('crtn.o',false,s2);
|
||||||
if found2 then
|
if found1 or found2 then
|
||||||
LinkRes.AddFileName(s2);
|
begin
|
||||||
LinkRes.Add(')');
|
LinkRes.Add('INPUT(');
|
||||||
end;
|
if found1 then
|
||||||
end;
|
LinkRes.AddFileName(s1);
|
||||||
|
if found2 then
|
||||||
|
LinkRes.AddFileName(s2);
|
||||||
|
LinkRes.Add(')');
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
{$ifdef ARM}
|
{$ifdef ARM}
|
||||||
with embedded_controllers[current_settings.controllertype] do
|
with embedded_controllers[current_settings.controllertype] do
|
||||||
|
Loading…
Reference in New Issue
Block a user