This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[committed] Link against libpthread in shared links on hppa-hpux
- From: "John David Anglin" <dave at hiauly1 dot hia dot nrc dot ca>
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 16 Jan 2008 23:20:18 -0500 (EST)
- Subject: [committed] Link against libpthread in shared links on hppa-hpux
This change adds "-lpthread" in shared links on hpux11 when "-pthread"
is specified. There are a couple of reasons to do this:
1) libc contains pthread stub functions. As a result of the load
orders used by the dynamic loader (32 and 64-bit behaviors are
different), it is possible that libc will be loaded before
libpthread leading to a non-functional application. This might
still happen on 64-bit target because a breadth first load order
is used.
2) We want to ensure that -lpthread occurs after -lgcc_s. This again
helps to ensure that the thread routines in libgcc_s resolve to
the real POSIX thread functions when the library uses POSIX threads.
3) Sometimes final executables are not linked with "-pthread", but
one of the shared libraries uses POSIX threads.
4) This is the current behavior on sparc.
The change has been tested on hppa2.0w-hpux11.11 and hppa64-hp-hpux11.11
with no observed regressions. There are still a few thread related
fails in the libjava and libgomp testsuites that I'm investigating.
Committed to trunk.
Dave
--
J. David Anglin dave.anglin@nrc-cnrc.gc.ca
National Research Council of Canada (613) 990-0752 (FAX: 952-6602)
2008-01-16 John David Anglin <dave.anglin@nrc-cnrc.gc.ca>
* pa64-hpux.h (LIB_SPEC): Add "-lpthread" in shared links if "-mt" or
"-pthread" is specified.
* pa-hpux11.h (LIB_SPEC): Likewise.
Index: config/pa/pa64-hpux.h
===================================================================
--- config/pa/pa64-hpux.h (revision 131440)
+++ config/pa/pa64-hpux.h (working copy)
@@ -64,7 +64,8 @@
%{static:%{!nolibdld:-a shared -ldld -a archive -lc}}}}\
%{pg:%{static:%{!mhp-ld:-a shared}%{mhp-ld:-a archive_shared}}\
-lgprof %{static:-a archive} %{static|mt|pthread:-lpthread} -lc\
- %{static:%{!nolibdld:-a shared -ldld -a archive -lc}}}}"
+ %{static:%{!nolibdld:-a shared -ldld -a archive -lc}}}}\
+ %{shared:%{mt|pthread:-lpthread}}"
#else
#define LIB_SPEC \
"%{!shared:\
@@ -75,7 +76,8 @@
%{static:%{!nolibdld:-a shared -ldld -a archive -lc}}}}\
%{pg:%{static:%{mgnu-ld:-a shared}%{!mgnu-ld:-a archive_shared}}\
-lgprof %{static:-a archive} %{static|mt|pthread:-lpthread} -lc\
- %{static:%{!nolibdld:-a shared -ldld -a archive -lc}}}}"
+ %{static:%{!nolibdld:-a shared -ldld -a archive -lc}}}}\
+ %{shared:%{mt|pthread:-lpthread}}"
#endif
/* The libgcc_stub.a and milli.a libraries need to come last. */
Index: config/pa/pa-hpux11.h
===================================================================
--- config/pa/pa-hpux11.h (revision 131440)
+++ config/pa/pa-hpux11.h (working copy)
@@ -136,7 +123,8 @@
#define LIB_SPEC \
"%{!shared:\
%{mt|pthread:-lpthread} -lc \
- %{static:%{!nolibdld:-a shared -ldld -a archive -lpthread -lc}}}"
+ %{static:%{!nolibdld:-a shared -ldld -a archive -lpthread -lc}}}\
+ %{shared:%{mt|pthread:-lpthread}}"
#undef STARTFILE_SPEC
#define STARTFILE_SPEC \