]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Silently ignore -pthread etc. on Solaris
authorRainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
Mon, 19 Jan 2026 20:51:28 +0000 (21:51 +0100)
committerRainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
Mon, 19 Jan 2026 20:51:28 +0000 (21:51 +0100)
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  <ro@CeBiTec.Uni-Bielefeld.DE>

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.

gcc/config/i386/sol2.h
gcc/config/sol2.h
gcc/config/sol2.opt
gcc/doc/invoke.texi

index d727eea41e69f65626c4b1ad69e333cba3a17e32..1fb07750b0a68c284f7cf62de4699d0f2aa7a104 100644 (file)
@@ -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 },        \
 
index 0c078299badfe1b7be09d1959ed876705213349d..489c650495fb6f1583273a6a14be8785daffef64 100644 (file)
@@ -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()                       \
index c0dbb524a00a12285be24f9a70247d0e5373793b..e8b44d2917ee9942ea7b30511582d0f0d3a1a966 100644 (file)
@@ -40,10 +40,10 @@ Target
 Pass -z text to linker.
 
 pthread
-Driver
+Ignore
 
 pthreads
-Driver
+Ignore
 
 rdynamic
 Driver
index 39c7aee99d780f3e0954e7cc11265379fc76fedf..ba26986bd874f33643cafd998771b51188c70ad1 100644 (file)
@@ -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