As uncovered by PR testsuite/125310, libcaf_shmem isn't built on
Solaris.  This happens because the AX_PTHREAD autoconf macro erroneously
thinks that Solaris lacks pthreads support.

The problem is that the macros expects _REENTRANT to be defined in
multithreaded programs.  However, as described in
https://gcc.gnu.org/gcc-16/porting_to.html#solaris the Solaris 11.4
system headers no longer reference _REENTRANT, so GCC 16 doesn't define
it any longer.

The issue is still present in current ax_pthread.m4 (serial 31) in the
autoconf archive.  This patch fixes this by only requiring _REENTRANT in
older Solaris versions that still need it by checking for pre-XPG7
system headers.

Bootstrapped without regressions on i386-pc-solaris2.11 and
sparc-sun-solaris2.11.  Also tested manually on Solaris 11.3.

Ok for trunk?

        Rainer

-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University


2026-05-14  Rainer Orth  <[email protected]>

        config:
        * ax_pthread.m4 (ax_pthread_check_macro) <solaris*>: Only require
        _REENTRANT before Solaris 11.4

        libgfortran:
        * configure: Regenerate.

# HG changeset patch
# Parent  8ee4b3f549ede67c2b3e8c7e5c6cf3e1ec99fd7f
config: Fix ax_pthread.m4 on Solaris 11.4

diff --git a/config/ax_pthread.m4 b/config/ax_pthread.m4
--- a/config/ax_pthread.m4
+++ b/config/ax_pthread.m4
@@ -208,7 +208,22 @@ AS_IF([test "x$GCC" = "xyes"],
 # correctly enabled
 
 case $host_os in
-        darwin* | hpux* | linux* | osf* | solaris*)
+        solaris*)
+        # Solaris 11.4 introduced XPG7 support and did away with the need for
+        # _REENTRANT.
+
+        AC_EGREP_CPP([AX_PTHREAD_SOLARIS__REENTRANT],
+            [
+#            undef _XOPEN_SOURCE
+#            include <sys/feature_tests.h>
+#            if _XOPEN_VERSION < 700
+             AX_PTHREAD_SOLARIS__REENTRANT
+#            endif
+            ],
+            [ax_pthread_check_macro="_REENTRANT"],
+            [ax_pthread_check_macro="--"])
+        ;;
+        darwin* | hpux* | linux* | osf*)
         ax_pthread_check_macro="_REENTRANT"
         ;;
 
diff --git a/libgfortran/configure b/libgfortran/configure
--- a/libgfortran/configure
+++ b/libgfortran/configure
@@ -17917,7 +17917,30 @@ fi
 # correctly enabled
 
 case $host_os in
-        darwin* | hpux* | linux* | osf* | solaris*)
+        solaris*)
+        # Solaris 11.4 introduced XPG7 support and did away with the need for
+        # _REENTRANT.
+
+        cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#            undef _XOPEN_SOURCE
+#            include <sys/feature_tests.h>
+#            if _XOPEN_VERSION < 700
+             AX_PTHREAD_SOLARIS__REENTRANT
+#            endif
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "AX_PTHREAD_SOLARIS__REENTRANT" >/dev/null 2>&1; then :
+  ax_pthread_check_macro="_REENTRANT"
+else
+  ax_pthread_check_macro="--"
+fi
+rm -f conftest*
+
+        ;;
+        darwin* | hpux* | linux* | osf*)
         ax_pthread_check_macro="_REENTRANT"
         ;;
 

Reply via email to