mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-14 10:09:20 +02:00
* fixed static linking under Linux for ppc64; test still crashes under
linux/i386 and linux/x86_64 (but at least it links now, mantis #14265) git-svn-id: trunk@13584 -
This commit is contained in:
parent
c2c68ddb8f
commit
9a84dee059
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -8066,6 +8066,7 @@ tests/test/packages/webtbs/tw10045.pp svneol=native#text/plain
|
|||||||
tests/test/packages/webtbs/tw11142.pp svneol=native#text/plain
|
tests/test/packages/webtbs/tw11142.pp svneol=native#text/plain
|
||||||
tests/test/packages/webtbs/tw11570.pp svneol=native#text/plain
|
tests/test/packages/webtbs/tw11570.pp svneol=native#text/plain
|
||||||
tests/test/packages/webtbs/tw12830.pp svneol=native#text/plain
|
tests/test/packages/webtbs/tw12830.pp svneol=native#text/plain
|
||||||
|
tests/test/packages/webtbs/tw14265.pp svneol=native#text/plain
|
||||||
tests/test/packages/webtbs/tw1808.pp svneol=native#text/plain
|
tests/test/packages/webtbs/tw1808.pp svneol=native#text/plain
|
||||||
tests/test/packages/webtbs/tw3820.pp svneol=native#text/plain
|
tests/test/packages/webtbs/tw3820.pp svneol=native#text/plain
|
||||||
tests/test/packages/win-base/tdispvar1.pp svneol=native#text/plain
|
tests/test/packages/win-base/tdispvar1.pp svneol=native#text/plain
|
||||||
|
@ -380,6 +380,10 @@ begin
|
|||||||
{ try to add crti and crtbegin if linking to C }
|
{ try to add crti and crtbegin if linking to C }
|
||||||
if linklibc and (libctype<>uclibc) then
|
if linklibc and (libctype<>uclibc) then
|
||||||
begin
|
begin
|
||||||
|
{ crti.o must come first }
|
||||||
|
if librarysearchpath.FindFile('crti.o',false,s) then
|
||||||
|
AddFileName(s);
|
||||||
|
{ then the crtbegin* }
|
||||||
{ x86_64 requires this to use entry/exit code with pic,
|
{ x86_64 requires this to use entry/exit code with pic,
|
||||||
see also issue #8210 regarding a discussion
|
see also issue #8210 regarding a discussion
|
||||||
no idea about the other non i386 CPUs (FK)
|
no idea about the other non i386 CPUs (FK)
|
||||||
@ -392,10 +396,11 @@ begin
|
|||||||
end
|
end
|
||||||
else
|
else
|
||||||
{$endif x86_64}
|
{$endif x86_64}
|
||||||
if librarysearchpath.FindFile('crtbegin.o',false,s) then
|
if (cs_link_staticflag in current_settings.globalswitches) and
|
||||||
|
librarysearchpath.FindFile('crtbeginT.o',false,s) then
|
||||||
|
AddFileName(s)
|
||||||
|
else if librarysearchpath.FindFile('crtbegin.o',false,s) then
|
||||||
AddFileName(s);
|
AddFileName(s);
|
||||||
if librarysearchpath.FindFile('crti.o',false,s) then
|
|
||||||
AddFileName(s);
|
|
||||||
end;
|
end;
|
||||||
{ main objectfiles }
|
{ main objectfiles }
|
||||||
while not ObjectFiles.Empty do
|
while not ObjectFiles.Empty do
|
||||||
@ -429,29 +434,44 @@ begin
|
|||||||
if not SharedLibFiles.Empty then
|
if not SharedLibFiles.Empty then
|
||||||
begin
|
begin
|
||||||
|
|
||||||
Add('INPUT(');
|
if (SharedLibFiles.Count<>1) or
|
||||||
While not SharedLibFiles.Empty do
|
(TCmdStrListItem(SharedLibFiles.First).Str<>'c') or
|
||||||
begin
|
reorder then
|
||||||
S:=SharedLibFiles.GetFirst;
|
begin
|
||||||
if (s<>'c') or reorder then
|
Add('INPUT(');
|
||||||
begin
|
While not SharedLibFiles.Empty do
|
||||||
i:=Pos(target_info.sharedlibext,S);
|
begin
|
||||||
if i>0 then
|
S:=SharedLibFiles.GetFirst;
|
||||||
Delete(S,i,255);
|
if (s<>'c') or reorder then
|
||||||
Add('-l'+s);
|
begin
|
||||||
end
|
i:=Pos(target_info.sharedlibext,S);
|
||||||
else
|
if i>0 then
|
||||||
begin
|
Delete(S,i,255);
|
||||||
linklibc:=true;
|
Add('-l'+s);
|
||||||
end;
|
end
|
||||||
end;
|
else
|
||||||
{ be sure that libc is the last lib }
|
begin
|
||||||
if linklibc and not reorder then
|
linklibc:=true;
|
||||||
Add('-lc');
|
end;
|
||||||
{ when we have -static for the linker the we also need libgcc }
|
end;
|
||||||
if (cs_link_staticflag in current_settings.globalswitches) then
|
Add(')');
|
||||||
Add('-lgcc');
|
end;
|
||||||
Add(')');
|
if (cs_link_staticflag in current_settings.globalswitches) or
|
||||||
|
(linklibc and not reorder) then
|
||||||
|
begin
|
||||||
|
Add('GROUP(');
|
||||||
|
{ when we have -static for the linker the we also need libgcc }
|
||||||
|
if (cs_link_staticflag in current_settings.globalswitches) then
|
||||||
|
begin
|
||||||
|
Add('-lgcc');
|
||||||
|
if librarysearchpath.FindFile('libgcc_eh.a',false,s1) then
|
||||||
|
Add('-lgcc_eh');
|
||||||
|
end;
|
||||||
|
{ be sure that libc is the last lib }
|
||||||
|
if linklibc and not reorder then
|
||||||
|
Add('-lc');
|
||||||
|
Add(')');
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ objects which must be at the end }
|
{ objects which must be at the end }
|
||||||
|
48
tests/test/packages/webtbs/tw14265.pp
Normal file
48
tests/test/packages/webtbs/tw14265.pp
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
{ %target=linux }
|
||||||
|
{ %opt=-Xt }
|
||||||
|
|
||||||
|
program phello;
|
||||||
|
{$linklib c}
|
||||||
|
|
||||||
|
{$packrecords c}
|
||||||
|
|
||||||
|
uses
|
||||||
|
ctypes, unixtype, pthreads;
|
||||||
|
|
||||||
|
const N = 2;
|
||||||
|
var
|
||||||
|
res:array[1..N] of Integer;
|
||||||
|
|
||||||
|
function Hello(arg: pointer): longint; cdecl;
|
||||||
|
begin
|
||||||
|
// writeln('Hello from thread #', PInteger(arg)^);
|
||||||
|
res[PInteger(arg)^] := PInteger(arg)^;
|
||||||
|
Hello := 0;
|
||||||
|
pthread_exit(pointer(Hello));
|
||||||
|
end;
|
||||||
|
|
||||||
|
var
|
||||||
|
i: Integer;
|
||||||
|
ret: Pointer;
|
||||||
|
arg: array[1..N] of Integer;
|
||||||
|
threads: array[1..N] of TThreadID;
|
||||||
|
attr: TThreadAttr;
|
||||||
|
begin
|
||||||
|
Writeln('Testing simple thread creation');
|
||||||
|
pthread_attr_init(attr);
|
||||||
|
for i := 1 to N do
|
||||||
|
begin
|
||||||
|
Writeln('Creating thread #',i);
|
||||||
|
arg[i] := i;
|
||||||
|
if pthread_create(threads[i], attr, @Hello, @arg[i]) <> 0 then
|
||||||
|
Writeln('Failed to create thread');
|
||||||
|
end;
|
||||||
|
for i := 1 to N do
|
||||||
|
begin
|
||||||
|
Write('Waiting for thread #',i, ' ... ');
|
||||||
|
pthread_join(threads[i], ret);
|
||||||
|
Writeln('result: ', res[i]);
|
||||||
|
end;
|
||||||
|
end.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user