This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[libgomp] Link libgomp with -lpthread on FreeBSD
- From: Gerald Pfeifer <gerald at pfeifer dot com>
- To: Rainer Orth <ro at CeBiTec dot Uni-Bielefeld dot DE>, Loren James Rittle <rittle at labs dot mot dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Sun, 2 Jan 2011 00:46:54 +0100 (CET)
- Subject: [libgomp] Link libgomp with -lpthread on FreeBSD
- References: <yddwrnu3idf.fsf@manam.CeBiTec.Uni-Bielefeld.DE>
On Tue, 30 Nov 2010, Rainer Orth wrote:
> Four libgomp testcases are currently failing on mips-sgi-irix6.5:
>
> FAIL: libgomp.fortran/condinc2.f -O execution test
> FAIL: libgomp.fortran/condinc4.f90 -O execution test
> FAIL: libgomp.fortran/omp_cond2.f -O execution test
> FAIL: libgomp.fortran/omp_cond4.F90 -O execution test
>
> The failure is like this:
>
> 342447:./condinc2.exe: rld: Error: unresolvable symbol in /var/gcc/regression/trunk/6.5-gcc/build/mips-sgi-irix6.5/./libgomp/.libs/libgomp.so.2: pthread_setspecific
This sounded familiar, and indeed the very same four failures have
been there on FreeBSD.
> While IRIX 6 has many pthread functions in libc, some are missing and
> one needs to link with -lpthread to get them. This is exactly what the
> following patch does.
>
> Tested by rebuilding libgomp and running make check for both multilibs.
What I don't understand is why you cannot just add -pthread to XLDFLAGS.
I tried, on FreeBSD, and indeed it does not work, whereas -lpthread does.
In any case, the patch below fixes the issue on FreeBSD as my tests show
http://gcc.gnu.org/ml/gcc-testresults/2011-01/msg00048.html (before)
http://gcc.gnu.org/ml/gcc-testresults/2011-01/msg00076.html (after)
and I'd like to apply this to mainline and GCC 4.5 (possibly 4.4, though
I don't think that's too important).
Gerald
Index: configure.tgt
===================================================================
--- configure.tgt (revision 168391)
+++ configure.tgt (working copy)
@@ -124,6 +124,12 @@
config_path="bsd posix"
;;
+ *-*-freebsd*)
+ # Need to link with -lpthread so libgomp.so is self-contained.
+ XLDFLAGS="${XLDFLAGS} -lpthread"
+ ;;
+
mips-sgi-irix6*)
# Need to link with -lpthread so libgomp.so is self-contained.
XLDFLAGS="${XLDFLAGS} -lpthread"