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.
#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}"
%{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 }, \
#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() \
Pass -z text to linker.
pthread
-Driver
+Ignore
pthreads
-Driver
+Ignore
rdynamic
Driver
@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}
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