https://gcc.gnu.org/g:832de2f102fb988ebe4a304635a796854978d880

commit r16-6903-g832de2f102fb988ebe4a304635a796854978d880
Author: Rainer Orth <[email protected]>
Date:   Mon Jan 19 21:51:28 2026 +0100

    Silently ignore -pthread etc. on Solaris
    
    gcc supports -pthread/-pthreads on Solaris to provide a way to
    transparently handle the platform-specific needs of multitheaded
    programs.  In the past, this used to link with -lpthread.  However, this
    has been removed in
    
            config: -pthread shouldn't link with -lpthread on Solaris
            https://gcc.gnu.org/pipermail/gcc-patches/2023-April/615080.html
    
    since libpthread had been folded into libc.
    
    The only thing these options do now is to define _REENTRANT and
    _PTHREADS.  In Solaris 11.4, the system headers no longer reference the
    former.  Checking gnulib as an important source of portability
    information, I find that _REENTRANT is used for two purposes:
    
    * Ensure that strerror_r, localtime_r and gmtime_r are declared.
      However, these declarations are no longer guarded by _REENTRANT, so
      this is moot.
    
    * Besides, _REENTRANT is defined on Solaris in general, but this has no
      longer any effect.
    
    There's no reference _PTHREADS at all, so this seems to be an ancient
    relic no longer needed at all.
    
    This patch silently ignores both options, keeping them for portability's
    sake.
    
    Bootstrapped without regressions on i386-pc-solaris2.11 and
    sparc-sun-solaris2.11.
    
    2026-01-14  Rainer Orth  <[email protected]>
    
            gcc:
            * config/sol2.h (CPP_SUBTARGET_SPEC): Remove.
            * config/sol2.opt (pthread): Ignore.
            (pthreads): Likewise.
            * config/i386/sol2.h (CPP_SPEC): Remove.
            (SUBTARGET_CPU_EXTRA_SPECS): Remove cpp_subtarget.
            * doc/invoke.texi (Solaris 2 Options, pthread): Remove.

Diff:
---
 gcc/config/i386/sol2.h |  4 ----
 gcc/config/sol2.h      |  4 ----
 gcc/config/sol2.opt    |  4 ++--
 gcc/doc/invoke.texi    | 13 +------------
 4 files changed, 3 insertions(+), 22 deletions(-)

diff --git a/gcc/config/i386/sol2.h b/gcc/config/i386/sol2.h
index d727eea41e69..1fb07750b0a6 100644
--- a/gcc/config/i386/sol2.h
+++ b/gcc/config/i386/sol2.h
@@ -51,9 +51,6 @@ along with GCC; see the file COPYING3.  If not see
 #undef TARGET_SUN_TLS
 #define TARGET_SUN_TLS 1
 
-#undef CPP_SPEC
-#define CPP_SPEC "%(cpp_subtarget)"
-
 #undef CC1_SPEC
 #define CC1_SPEC "%(cc1_cpu) " ASAN_CC1_SPEC SCTF_CC1_SPEC \
   " %{mx32:%e-mx32 is not supported on Solaris}"
@@ -101,7 +98,6 @@ along with GCC; see the file COPYING3.  If not see
    %{mpc80:crtprec80.o%s}"
 
 #define SUBTARGET_CPU_EXTRA_SPECS \
-  { "cpp_subtarget",    CPP_SUBTARGET_SPEC },          \
   { "asm_cpu",          ASM_CPU_SPEC },                \
   { "asm_cpu_default",  ASM_CPU_DEFAULT_SPEC },        \
 
diff --git a/gcc/config/sol2.h b/gcc/config/sol2.h
index 0c078299badf..489c650495fb 100644
--- a/gcc/config/sol2.h
+++ b/gcc/config/sol2.h
@@ -81,10 +81,6 @@ along with GCC; see the file COPYING3.  If not see
 #define INTPTR_TYPE (LONG_TYPE_SIZE == 64 ? "long int" : "int")
 #define UINTPTR_TYPE (LONG_TYPE_SIZE == 64 ? "long unsigned int" : "unsigned 
int")
 
-#undef CPP_SUBTARGET_SPEC
-#define CPP_SUBTARGET_SPEC "\
-%{pthreads|pthread:-D_REENTRANT -D_PTHREADS}"
-
 /* Names to predefine in the preprocessor for this target machine.  */
 #define TARGET_SUB_OS_CPP_BUILTINS()
 #define TARGET_OS_CPP_BUILTINS()                       \
diff --git a/gcc/config/sol2.opt b/gcc/config/sol2.opt
index c0dbb524a00a..e8b44d2917ee 100644
--- a/gcc/config/sol2.opt
+++ b/gcc/config/sol2.opt
@@ -40,10 +40,10 @@ Target
 Pass -z text to linker.
 
 pthread
-Driver
+Ignore
 
 pthreads
-Driver
+Ignore
 
 rdynamic
 Driver
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 39c7aee99d78..ba26986bd874 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -1457,7 +1457,7 @@ See RS/6000 and PowerPC Options.
 
 @emph{Solaris 2 Options} (@ref{Solaris 2 Options})
 @gccoptlist{-mclear-hwcap  -mno-clear-hwcap  -mimpure-text  -mno-impure-text
--gsctf  -pthread  -pthreads}
+-gsctf}
 
 @emph{SPARC Options} (@ref{SPARC Options})
 @gccoptlist{-mcpu=@var{cpu-type}
@@ -34974,17 +34974,6 @@ Generate Solaris CTF.  Needs to be used both for 
compilation and
 linking.  See @command{ctf(7)} for more information.  This is only
 supported since Solaris 11.4 SRU 84 where the necessary toolchain
 support was added.
-
-@opindex pthread
-@opindex pthreads
-@item -pthread
-@itemx -pthreads
-On Solaris targets, these both options define the preprocessor symbols
-@code{_REENTRANT} and @code{_PTHREADS}.  In modern versions of Solaris
-these symbols are no longer used in system headers and these options are
-unnecessary unless user code references them.  Additionally, since
-POSIX thread support is provided directly by the Solaris C library, it is
-not necessary to use @option{-pthread} for linking.
 @end table
 
 @node SPARC Options

Reply via email to