Bug#760211: gnat-4.9: on some archs, a library using Task_Attributes needs -lpthread
Package: gnat-4.9
Version: 4.9.1-1
Severity: normal
On armel armhf hurd-i386 kfreebsd-amd64 s390x, the following scenario
complains about the "pthread_getspecific" symbol being undefined.
Adding "-lpthread" to library_options (used at the end of the link
command) fixes the problem, but gnat should not expect the end user to
know that inlining adds a dependency.
mkdir lib
cat > pack.ads <<EOF
with Ada.Task_Attributes;
package Pack is new Ada.Task_Attributes (Integer, 0);
EOF
cat > pack.gpr <<EOF
library project Proj is
for Library_Name use "pack";
for Library_Version use "libpack.so.1";
for Source_Dirs use (".");
for Library_Dir use "lib";
for Library_Kind use "dynamic";
for Library_Options use ("-Wl,-z,defs"); -- Fail on undefined symbols.
package Compiler is
for Switches ("Ada") use ("-O1", "-gnatn");
end Compiler;
end Proj;
EOF
gnatmake -v -Ppack.gpr
For the record, here are two sensible work-arounds:
* in linker options:
-Wl,--as-needed -lpthread -Wl,--no-as-needed
* in a GNAT project:
case External ("NEEDS_PTHREAD") is
when "yes" =>
for Library_Options use project'library_options & ("-lpthread");
when "no" =>
null;
end case;
Checked on zelenka.debian.org (s390x).
Most probably related to #717014.
Reply to: