[COMMITTED] config: -pthread shouldn't link with -lpthread on Solaris

Message ID ydd7cus12b4.fsf@CeBiTec.Uni-Bielefeld.DE
State Unresolved
Headers
Series [COMMITTED] config: -pthread shouldn't link with -lpthread on Solaris |

Checks

Context Check Description
snail/gcc-patch-check warning Git am fail log

Commit Message

Rainer Orth April 4, 2023, 8:25 a.m. UTC
  libpthread has been folded into libc since Solaris 10 and replaced by a
filter on libc.  Linking with libpthread thus only creates unnecessary
runtime overhead.

This patch thus removes linking with -lpthread if -pthread/-pthreads is
specified, thus getting rid of the libpthread dependency in libatomic,
libgdruntime, libgomp, libgphobos, and libitm.

Bootstrapped without regressions on i386-pc-solaris2.11 and
sparc-sun-solaris2.11 (both Solaris 11.3 and 11.4).

Committed to trunk.

There are more instances of this issue: both libsanitizer and libgo
unnecessarily link with -lpthread, either unconditionally or due to a
configure test which doesn't check if the library is actually needed.
This can be fixed by consistently using AX_PTHREAD from
config/ax_pthread.m4, but such a fix affects all targets and is clearly
not stage 4 material.

	Rainer
  

Patch

# HG changeset patch
# Parent  5e543e5a54a480b50f3f8534837cb5ec7ad96a07
config: -pthread shouldn't link with -lpthread on Solaris

diff --git a/gcc/config/sol2.h b/gcc/config/sol2.h
--- a/gcc/config/sol2.h
+++ b/gcc/config/sol2.h
@@ -161,7 +161,6 @@  along with GCC; see the file COPYING3.  
 #undef LIB_SPEC
 #define LIB_SPEC \
   "%{!symbolic:\
-     %{pthreads|pthread:-lpthread} \
      %{p|pg:-ldl} -lc}"
 
 #ifndef CROSS_DIRECTORY_STRUCTURE