This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [libgomp] Link libgomp with -lpthread on FreeBSD
- From: Rainer Orth <ro at CeBiTec dot Uni-Bielefeld dot DE>
- To: Gerald Pfeifer <gerald at pfeifer dot com>
- Cc: Loren James Rittle <rittle at labs dot mot dot com>, gcc-patches at gcc dot gnu dot org
- Date: Fri, 07 Jan 2011 20:22:31 +0100
- Subject: Re: [libgomp] Link libgomp with -lpthread on FreeBSD
- References: <yddwrnu3idf.fsf@manam.CeBiTec.Uni-Bielefeld.DE> <alpine.LNX.2.00.1101020042000.4999@gerinyyl.fvgr>
Gerald Pfeifer <gerald@pfeifer.com> writes:
>> 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.
I've wondered that myself for some time, at first blaming libtool
(always an easy target :-), but the answer is simple: many specs (like
FBSD_LIB_SPEC in config/freebsd-spec.h) have
#define FBSD_LIB_SPEC " \
%{!shared: \
%{!pg: %{pthread:-lpthread} -lc} \
%{pg: %{pthread:-lpthread_p} -lc_p} \
}"
No idea why, and I strongly believe this is far more trouble than it's
worth. Consider the complicated contortions you have to go through to
get working TLS support on Solaris 8 and 9. I consider it insane that
this would only for when creating an executable, but to have to
duplicate it manually when building a shared object.
Rainer
--
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University