diff mbox

Avoid overriding LIB_THREAD_LDFLAGS_SPEC on Solaris 8 (PR target/49541)

Message ID yddvcv6qcns.fsf@manam.CeBiTec.Uni-Bielefeld.DE
State New
Headers show

Commit Message

Rainer Orth July 13, 2011, 6:05 p.m. UTC
As reported in the PR, LIB_THREAD_LDFLAGS_SPEC (effectively
-L/usr/lib/lwp(/64)? -R/usr/lib/lwp(/64)? to make use of the alternate
thread library on Solaris 8, which also provides the only implementation
of __tls_get_addr) could be overridden by the regular -L flags from the
%D spec for 64-bit compilations to find /lib/sparcv9/libthread.so
instead, which lacks that function, causing link failures.

This patch fixes this by moving the -L/-R flags from LIB_SPEC to
LINK_SPEC which is before %D.

Bootstrapped without regressions on sparc-sun-solaris2.8 and
i386-pc-solaris2.8 by myself (though in a branded zone which doesn't
show the problem directly) and by Eric on bare-metal Solaris 8.

Installed on mainline, will backport to the 4.6 branch after testing.

	Rainer


2011-07-08  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

	PR target/49541
	* config/sol2.h (LIB_SPEC): Simplify.
	Move LIB_THREAD_LDFLAGS_SPEC ...
	(LINK_SPEC): ... here.
diff mbox

Patch

diff --git a/gcc/config/sol2.h b/gcc/config/sol2.h
--- a/gcc/config/sol2.h
+++ b/gcc/config/sol2.h
@@ -109,10 +109,8 @@  along with GCC; see the file COPYING3.  
 #undef LIB_SPEC
 #define LIB_SPEC \
   "%{!symbolic:\
-     %{pthreads|pthread:" \
-        LIB_THREAD_LDFLAGS_SPEC " -lpthread " LIB_TLS_SPEC "} \
-     %{fprofile-generate*:" \
-        LIB_THREAD_LDFLAGS_SPEC " " LIB_TLS_SPEC "} \
+     %{pthreads|pthread:-lpthread} \
+     %{pthreads|pthread|fprofile-generate*:" LIB_TLS_SPEC "} \
      %{p|pg:-ldl} -lc}"
 
 #ifndef CROSS_DIRECTORY_STRUCTURE
@@ -175,6 +173,7 @@  along with GCC; see the file COPYING3.  
    %{static:-dn -Bstatic} \
    %{shared:-G -dy %{!mimpure-text:-z text}} \
    %{symbolic:-Bsymbolic -G -dy -z text} \
+   %{pthreads|pthread|fprofile-generate*:" LIB_THREAD_LDFLAGS_SPEC "} \
    %(link_arch) \
    %{Qy:} %{!Qn:-Qy}"