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

commit aef0a6f0f0df4c1d91e133145540e0f7e7ff171c
Author: Michael Meissner <meiss...@linux.ibm.com>
Date:   Thu Jul 11 12:54:32 2024 -0400

    Do not build IEEE 128-bit libgcc support if VSX is not available.
    
    In the past, we would build libgcc and eable the float128 libraries by 
adding
    -mvsx -mabi=altivec to build the support libraries.  However, this causes
    problems if the default cpu is a 7450.
    
    With this fix, in order to build the float128 support, the compiler must be
    configured to default to at least power7 to enable using the VSX register 
set,
    which is required for passing float128 values.
    
    If somebody wanted to enable float128 on big endian systems, they would 
need to
    use a compiler that defaults to at least power7.
    
    2024-07-11  Michael Meissner  <meiss...@linux.ibm.com>
    
    libgcc/
    
            PR target/115800
            PR target/113652
            * config.host (powerpc*-*-linux*): Do not enable the float128 
hardware
            and float128 power10 hardware support unless the basic float128 
support
            is added.
            * configure.ac (powerpc*-*-linux*): Don't enable IEEE 128-bit on 
PowerPC
            systems without VSX.
            * configure: Regenerate.

Diff:
---
 libgcc/config.host              | 12 ++++++------
 libgcc/config/rs6000/t-float128 |  2 +-
 libgcc/configure                | 17 +++++++++++------
 libgcc/configure.ac             | 17 +++++++++++------
 4 files changed, 29 insertions(+), 19 deletions(-)

diff --git a/libgcc/config.host b/libgcc/config.host
index 9fae51d4ce7d..261b08859a4d 100644
--- a/libgcc/config.host
+++ b/libgcc/config.host
@@ -1292,14 +1292,14 @@ powerpc*-*-linux*)
 
        if test $libgcc_cv_powerpc_float128 = yes; then
                tmake_file="${tmake_file} rs6000/t-float128"
-       fi
 
-       if test $libgcc_cv_powerpc_float128_hw = yes; then
-               tmake_file="${tmake_file} rs6000/t-float128-hw"
-       fi
+               if test $libgcc_cv_powerpc_float128_hw = yes; then
+                       tmake_file="${tmake_file} rs6000/t-float128-hw"
 
-       if test $libgcc_cv_powerpc_3_1_float128_hw = yes; then
-               tmake_file="${tmake_file} rs6000/t-float128-p10-hw"
+                       if test $libgcc_cv_powerpc_3_1_float128_hw = yes; then
+                               tmake_file="${tmake_file} 
rs6000/t-float128-p10-hw"
+                       fi
+               fi
        fi
 
        extra_parts="$extra_parts ecrti.o ecrtn.o ncrti.o ncrtn.o"
diff --git a/libgcc/config/rs6000/t-float128 b/libgcc/config/rs6000/t-float128
index b09b5664af0e..2d93080f1174 100644
--- a/libgcc/config/rs6000/t-float128
+++ b/libgcc/config/rs6000/t-float128
@@ -74,7 +74,7 @@ fp128_includes                = $(srcdir)/soft-fp/double.h \
                          $(srcdir)/soft-fp/soft-fp.h
 
 # Build the emulator without ISA 3.0 hardware support.
-FP128_CFLAGS_SW                 = -Wno-type-limits -mvsx -mfloat128 \
+FP128_CFLAGS_SW                 = -Wno-type-limits -mfloat128 \
                           -mno-float128-hardware -mno-gnu-attribute \
                           -I$(srcdir)/soft-fp \
                           -I$(srcdir)/config/rs6000 \
diff --git a/libgcc/configure b/libgcc/configure
index a69d314374a3..39193456929a 100755
--- a/libgcc/configure
+++ b/libgcc/configure
@@ -5180,13 +5180,18 @@ esac
 esac
 
 case ${host} in
-# At present, we cannot turn -mfloat128 on via #pragma GCC target, so just
-# check if we have VSX (ISA 2.06) support to build the software libraries, and
-# whether the assembler can handle xsaddqp for hardware support.  Also check if
-# a new glibc is being used so that __builtin_cpu_supports can be used.
+# Check if we can enable float128 support.  Some systems (big endian) do not
+# enable float128 by default, but they can enable it if -mfloat128 is used.
+# However, the compiler must be compiled using at least --with-cpu=power7 to
+# enable VSX support.  If we build a default big endian system without using
+# --with-cpu=power7, do not build the float128 libraries.  VSX support is
+# needed because float128 values are passed in VSX registers.
+#
+# Also check if a new glibc is being used so that __builtin_cpu_supports can be
+# used.
 powerpc*-*-linux*)
   saved_CFLAGS="$CFLAGS"
-  CFLAGS="$CFLAGS -mabi=altivec -mvsx -mfloat128"
+  CFLAGS="$CFLAGS -mfloat128"
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for PowerPC ISA 2.06 to 
build __float128 libraries" >&5
 $as_echo_n "checking for PowerPC ISA 2.06 to build __float128 libraries... " 
>&6; }
 if ${libgcc_cv_powerpc_float128+:} false; then :
@@ -5194,7 +5199,7 @@ if ${libgcc_cv_powerpc_float128+:} false; then :
 else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
-vector double dadd (vector double a, vector double b) { return a + b; }
+__float128 f128_add (__float128 a, __float128 b) { return a+b; }
 _ACEOF
 if ac_fn_c_try_compile "$LINENO"; then :
   libgcc_cv_powerpc_float128=yes
diff --git a/libgcc/configure.ac b/libgcc/configure.ac
index c2749fe09584..dcc866ae5473 100644
--- a/libgcc/configure.ac
+++ b/libgcc/configure.ac
@@ -403,17 +403,22 @@ esac
 esac
 
 case ${host} in
-# At present, we cannot turn -mfloat128 on via #pragma GCC target, so just
-# check if we have VSX (ISA 2.06) support to build the software libraries, and
-# whether the assembler can handle xsaddqp for hardware support.  Also check if
-# a new glibc is being used so that __builtin_cpu_supports can be used.
+# Check if we can enable float128 support.  Some systems (big endian) do not
+# enable float128 by default, but they can enable it if -mfloat128 is used.
+# However, the compiler must be compiled using at least --with-cpu=power7 to
+# enable VSX support.  If we build a default big endian system without using
+# --with-cpu=power7, do not build the float128 libraries.  VSX support is
+# needed because float128 values are passed in VSX registers.
+#
+# Also check if a new glibc is being used so that __builtin_cpu_supports can be
+# used.
 powerpc*-*-linux*)
   saved_CFLAGS="$CFLAGS"
-  CFLAGS="$CFLAGS -mabi=altivec -mvsx -mfloat128"
+  CFLAGS="$CFLAGS -mfloat128"
   AC_CACHE_CHECK([for PowerPC ISA 2.06 to build __float128 libraries],
                 [libgcc_cv_powerpc_float128],
                 [AC_COMPILE_IFELSE(
-    [AC_LANG_SOURCE([vector double dadd (vector double a, vector double b) { 
return a + b; }])],
+    [AC_LANG_SOURCE([__float128 f128_add (__float128 a, __float128 b) { return 
a+b; }])],
     [libgcc_cv_powerpc_float128=yes],
     [libgcc_cv_powerpc_float128=no])])

Reply via email to