[libgomp] Link libgomp with -lpthread on FreeBSD

Rainer Orth ro@CeBiTec.Uni-Bielefeld.DE
Fri Jan 7 19:36:00 GMT 2011


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



More information about the Gcc-patches mailing list