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

commit bf53eea91a2c76e9fdd21fbb20e1d3528073c826
Author: Michael Meissner <meiss...@linux.ibm.com>
Date:   Tue Jun 18 14:34:52 2024 -0400

    Do not build IEEE 128-bit support if VSX is not available.
    
    2024-06-18  Michael Meissner  <meiss...@linux.ibm.com>
    
    libgfortran/
    
            * configure.ac (powerpc64le*-linux*): Check to see that the compiler
            uses VSX before enabling IEEE 128-bit support.
            * configure: Regenerate.
            * kinds-override.h (GFC_REAL_17): Add check for __VSX__.
            * libgfortran.h (POWER_IEEE128): Likewise.
    
    libstdc++-v3/
    
            * configure.ac (powerpc*-*-linux*): Don't enable IEEE 128-bit on 
PowerPC
            systems without VSX.
            * configure: Regenerate.
            * numeric_traits.h: Don't enable IEEE 128-bit on PowerPC systems 
without
            VSX.

Diff:
---
 libgfortran/configure                     |  7 +++-
 libgfortran/configure.ac                  |  3 ++
 libgfortran/kinds-override.h              |  2 +-
 libgfortran/libgfortran.h                 |  2 +-
 libstdc++-v3/configure                    | 68 ++++++++++++++++++++++---------
 libstdc++-v3/configure.ac                 | 58 ++++++++++++++++----------
 libstdc++-v3/include/ext/numeric_traits.h |  2 +-
 7 files changed, 96 insertions(+), 46 deletions(-)

diff --git a/libgfortran/configure b/libgfortran/configure
index 11a1bc5f0708..2708e5c7eca4 100755
--- a/libgfortran/configure
+++ b/libgfortran/configure
@@ -5981,6 +5981,9 @@ if test "x$GCC" = "xyes"; then
 #if __SIZEOF_LONG_DOUBLE__ != 16
                           #error long double is double
                           #endif
+                          #if !defined(__VSX__)
+                          #error VSX is not available
+                          #endif
 int
 main ()
 {
@@ -12847,7 +12850,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 12850 "configure"
+#line 12853 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -12953,7 +12956,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 12956 "configure"
+#line 12959 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
diff --git a/libgfortran/configure.ac b/libgfortran/configure.ac
index cca1ea0ea970..cfaeb9717ab8 100644
--- a/libgfortran/configure.ac
+++ b/libgfortran/configure.ac
@@ -148,6 +148,9 @@ if test "x$GCC" = "xyes"; then
       AC_PREPROC_IFELSE(
         [AC_LANG_PROGRAM([[#if __SIZEOF_LONG_DOUBLE__ != 16
                           #error long double is double
+                          #endif
+                          #if !defined(__VSX__)
+                          #error VSX is not available
                           #endif]],
                          [[(void) 0;]])],
         [AM_FCFLAGS="$AM_FCFLAGS -mabi=ibmlongdouble -mno-gnu-attribute";
diff --git a/libgfortran/kinds-override.h b/libgfortran/kinds-override.h
index f6b4956c5caa..51f440e53232 100644
--- a/libgfortran/kinds-override.h
+++ b/libgfortran/kinds-override.h
@@ -30,7 +30,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If 
not, see
 #endif
 
 /* Keep these conditions on one line so grep can filter it out.  */
-#if defined(__powerpc64__)  && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__  && 
__SIZEOF_LONG_DOUBLE__ == 16
+#if defined(__powerpc64__)  && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__  && 
__SIZEOF_LONG_DOUBLE__ == 16 && defined(__VSX__)
 typedef _Float128 GFC_REAL_17;
 typedef _Complex _Float128 GFC_COMPLEX_17;
 #define HAVE_GFC_REAL_17
diff --git a/libgfortran/libgfortran.h b/libgfortran/libgfortran.h
index 5c59ec26e16c..236603352435 100644
--- a/libgfortran/libgfortran.h
+++ b/libgfortran/libgfortran.h
@@ -104,7 +104,7 @@ typedef off_t gfc_offset;
 #endif
 
 #if defined(__powerpc64__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ \
-    && defined __GLIBC_PREREQ
+    && defined __GLIBC_PREREQ && defined(__VSX__)
 #if __GLIBC_PREREQ (2, 32)
 #define POWER_IEEE128 1
 #endif
diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure
index 5645e991af7a..daab67f9deea 100755
--- a/libstdc++-v3/configure
+++ b/libstdc++-v3/configure
@@ -51355,8 +51355,31 @@ $as_echo "#define _GLIBCXX_LONG_DOUBLE_COMPAT 1" 
>>confdefs.h
     case "$target" in
       powerpc*-*-linux*)
        LONG_DOUBLE_COMPAT_FLAGS="$LONG_DOUBLE_COMPAT_FLAGS -mno-gnu-attribute"
-        # Check for IEEE128 support in libm:
-        { $as_echo "$as_me:${as_lineno-$LINENO}: checking for __frexpieee128 
in -lm" >&5
+       # Eliminate little endian systems without VSX
+       cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+         #ifndef __VSX__
+         #error "IEEE 128-bit needs VSX"
+         #endif
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_ieee128_possible=yes
+else
+  ac_ieee128_possible=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+       if test $ac_ieee128_possible = yes; then
+          # Check for IEEE128 support in libm:
+          { $as_echo "$as_me:${as_lineno-$LINENO}: checking for __frexpieee128 
in -lm" >&5
 $as_echo_n "checking for __frexpieee128 in -lm... " >&6; }
 if ${ac_cv_lib_m___frexpieee128+:} false; then :
   $as_echo_n "(cached) " >&6
@@ -51401,18 +51424,18 @@ else
   ac_ldbl_ieee128_in_libc=no
 fi
 
-        if test $ac_ldbl_ieee128_in_libc = yes; then
-          # Determine which long double format is the compiler's default:
-          cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+          if test $ac_ldbl_ieee128_in_libc = yes; then
+            # Determine which long double format is the compiler's default:
+            cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
 int
 main ()
 {
 
-            #ifndef __LONG_DOUBLE_IEEE128__
-            #error compiler defaults to ibm128
-            #endif
+              #ifndef __LONG_DOUBLE_IEEE128__
+              #error compiler defaults to ibm128
+              #endif
 
   ;
   return 0;
@@ -51424,21 +51447,28 @@ else
   ac_ldbl_ieee128_default=no
 fi
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-          # Library objects should use default long double format.
-          if test "$ac_ldbl_ieee128_default" = yes; then
-            LONG_DOUBLE_128_FLAGS="-mno-gnu-attribute"
-            # Except for the ones that explicitly use these flags:
-            LONG_DOUBLE_ALT128_COMPAT_FLAGS="-mabi=ibmlongdouble 
-mno-gnu-attribute -Wno-psabi"
-          else
-            LONG_DOUBLE_128_FLAGS="-mno-gnu-attribute"
-            LONG_DOUBLE_ALT128_COMPAT_FLAGS="-mabi=ieeelongdouble 
-mno-gnu-attribute -Wno-psabi"
-          fi
+            # Library objects should use default long double format.
+            if test "$ac_ldbl_ieee128_default" = yes; then
+              LONG_DOUBLE_128_FLAGS="-mno-gnu-attribute"
+              # Except for the ones that explicitly use these flags:
+              LONG_DOUBLE_ALT128_COMPAT_FLAGS="-mabi=ibmlongdouble 
-mno-gnu-attribute -Wno-psabi"
+            else
+              LONG_DOUBLE_128_FLAGS="-mno-gnu-attribute"
+              LONG_DOUBLE_ALT128_COMPAT_FLAGS="-mabi=ieeelongdouble 
-mno-gnu-attribute -Wno-psabi"
+            fi
 
 $as_echo "#define _GLIBCXX_LONG_DOUBLE_ALT128_COMPAT 1" >>confdefs.h
 
-          port_specific_symbol_files="$port_specific_symbol_files 
\$(top_srcdir)/config/os/gnu-linux/ldbl-ieee128-extra.ver"
-          ac_ldbl_alt128_compat=yes
+            port_specific_symbol_files="$port_specific_symbol_files 
\$(top_srcdir)/config/os/gnu-linux/ldbl-ieee128-extra.ver"
+            ac_ldbl_alt128_compat=yes
+          else
+            ac_ldbl_alt128_compat=no
+          fi
+
+        # IEEE 128-bit not possible
         else
+          acl_ldbl_ieee128_in_libc=no
+          acl_ldbl_ieee128_default=no
           ac_ldbl_alt128_compat=no
         fi
        ;;
diff --git a/libstdc++-v3/configure.ac b/libstdc++-v3/configure.ac
index ccb24a82be79..69f795bd453a 100644
--- a/libstdc++-v3/configure.ac
+++ b/libstdc++-v3/configure.ac
@@ -479,31 +479,45 @@ case "$target" in
     case "$target" in
       powerpc*-*-linux*)
        LONG_DOUBLE_COMPAT_FLAGS="$LONG_DOUBLE_COMPAT_FLAGS -mno-gnu-attribute"
-        # Check for IEEE128 support in libm:
-        AC_CHECK_LIB(m, __frexpieee128,
-                     [ac_ldbl_ieee128_in_libc=yes],
-                     [ac_ldbl_ieee128_in_libc=no])
-        if test $ac_ldbl_ieee128_in_libc = yes; then
-          # Determine which long double format is the compiler's default:
-          AC_TRY_COMPILE(, [
-            #ifndef __LONG_DOUBLE_IEEE128__
-            #error compiler defaults to ibm128
-            #endif
-          ], [ac_ldbl_ieee128_default=yes], [ac_ldbl_ieee128_default=no])
-          # Library objects should use default long double format.
-          if test "$ac_ldbl_ieee128_default" = yes; then
-            LONG_DOUBLE_128_FLAGS="-mno-gnu-attribute"
-            # Except for the ones that explicitly use these flags:
-            LONG_DOUBLE_ALT128_COMPAT_FLAGS="-mabi=ibmlongdouble 
-mno-gnu-attribute -Wno-psabi"
+       # Eliminate little endian systems without VSX
+       AC_TRY_COMPILE(, [
+         #ifndef __VSX__
+         #error "IEEE 128-bit needs VSX"
+         #endif
+       ], [ac_ieee128_possible=yes], [ac_ieee128_possible=no])
+       if test $ac_ieee128_possible = yes; then
+          # Check for IEEE128 support in libm:
+          AC_CHECK_LIB(m, __frexpieee128,
+                       [ac_ldbl_ieee128_in_libc=yes],
+                       [ac_ldbl_ieee128_in_libc=no])
+          if test $ac_ldbl_ieee128_in_libc = yes; then
+            # Determine which long double format is the compiler's default:
+            AC_TRY_COMPILE(, [
+              #ifndef __LONG_DOUBLE_IEEE128__
+              #error compiler defaults to ibm128
+              #endif
+            ], [ac_ldbl_ieee128_default=yes], [ac_ldbl_ieee128_default=no])
+            # Library objects should use default long double format.
+            if test "$ac_ldbl_ieee128_default" = yes; then
+              LONG_DOUBLE_128_FLAGS="-mno-gnu-attribute"
+              # Except for the ones that explicitly use these flags:
+              LONG_DOUBLE_ALT128_COMPAT_FLAGS="-mabi=ibmlongdouble 
-mno-gnu-attribute -Wno-psabi"
+            else
+              LONG_DOUBLE_128_FLAGS="-mno-gnu-attribute"
+              LONG_DOUBLE_ALT128_COMPAT_FLAGS="-mabi=ieeelongdouble 
-mno-gnu-attribute -Wno-psabi"
+            fi
+            AC_DEFINE([_GLIBCXX_LONG_DOUBLE_ALT128_COMPAT],1,
+                  [Define if compatibility should be provided for alternative 
128-bit long double formats.])
+            port_specific_symbol_files="$port_specific_symbol_files 
\$(top_srcdir)/config/os/gnu-linux/ldbl-ieee128-extra.ver"
+            ac_ldbl_alt128_compat=yes
           else
-            LONG_DOUBLE_128_FLAGS="-mno-gnu-attribute"
-            LONG_DOUBLE_ALT128_COMPAT_FLAGS="-mabi=ieeelongdouble 
-mno-gnu-attribute -Wno-psabi"
+            ac_ldbl_alt128_compat=no
           fi
-          AC_DEFINE([_GLIBCXX_LONG_DOUBLE_ALT128_COMPAT],1,
-                [Define if compatibility should be provided for alternative 
128-bit long double formats.])
-          port_specific_symbol_files="$port_specific_symbol_files 
\$(top_srcdir)/config/os/gnu-linux/ldbl-ieee128-extra.ver"
-          ac_ldbl_alt128_compat=yes
+        
+        # IEEE 128-bit not possible
         else
+          acl_ldbl_ieee128_in_libc=no
+          acl_ldbl_ieee128_default=no
           ac_ldbl_alt128_compat=no
         fi
        ;;
diff --git a/libstdc++-v3/include/ext/numeric_traits.h 
b/libstdc++-v3/include/ext/numeric_traits.h
index b2723bfabfa5..0f00abb3db66 100644
--- a/libstdc++-v3/include/ext/numeric_traits.h
+++ b/libstdc++-v3/include/ext/numeric_traits.h
@@ -218,7 +218,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     struct __numeric_traits<__ibm128>
     : public __numeric_traits_floating<__ibm128>
     { };
-# elif defined __LONG_DOUBLE_IBM128__
+# elif defined __LONG_DOUBLE_IBM128__ && defined __VSX__
   // long double is __ibm128, define traits for __ieee128
   template<>
     struct __numeric_traits_floating<__ieee128>

Reply via email to