https://gcc.gnu.org/g:fde12ce90e7e7a1162dde1f4a1a21c9f2f628092

commit r17-2036-gfde12ce90e7e7a1162dde1f4a1a21c9f2f628092
Author: Rainer Orth <[email protected]>
Date:   Wed Jul 1 09:36:36 2026 +0200

    build: Fix ax_pthread.m4 on Solaris 11.4
    
    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 pthread 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.
    
    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.
    
            cherry picked from approved upstream pull request
    
            AX_PTHREAD: Fix pthread detection on Solaris 11.4
            https://github.com/autoconf-archive/autoconf-archive/pull/341

Diff:
---
 config/ax_pthread.m4  | 17 ++++++++++++++++-
 libgfortran/configure | 25 ++++++++++++++++++++++++-
 2 files changed, 40 insertions(+), 2 deletions(-)

diff --git a/config/ax_pthread.m4 b/config/ax_pthread.m4
index 5fbf9fe0d686..843e83c9bac5 100644
--- 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
index 4555f6f0cf64..7820988523e3 100755
--- 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