https://gcc.gnu.org/g:097f2463d8c78602186feb731fd8732dce9f3e7c
commit 097f2463d8c78602186feb731fd8732dce9f3e7c Author: Michael Meissner <meiss...@linux.ibm.com> Date: Fri Jul 12 20:04:37 2024 -0400 Add checks for building the 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. This patch checks to see if can link a program using the options, and if we can't link the program, do not build the float128 libraries. 2024-07-12 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*): Check whether the linker and assembler will be able to build the float128 libraries. * configure: Regenerate. Diff: --- libgcc/config.host | 12 ++++----- libgcc/configure | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++--- libgcc/configure.ac | 17 +++++++++++-- 3 files changed, 88 insertions(+), 12 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/configure b/libgcc/configure index a69d314374a3..bb196c8e7b84 100755 --- a/libgcc/configure +++ b/libgcc/configure @@ -1802,6 +1802,52 @@ $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_header_preproc + +# ac_fn_c_try_link LINENO +# ----------------------- +# Try to link conftest.$ac_ext, and return whether this succeeded. +ac_fn_c_try_link () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + rm -f conftest.$ac_objext conftest$ac_exeext + if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && { + test "$cross_compiling" = yes || + test -x conftest$ac_exeext + }; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information + # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would + # interfere with the next link command; also delete a directory that is + # left behind by Apple's compiler. We do this before executing the actions. + rm -rf conftest.dSYM conftest_ipa8_conftest.oo + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_c_try_link cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. @@ -5184,6 +5230,12 @@ case ${host} in # 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. +# +# We use AC_LINK_IFELSE to verify that the assembler will not abort if given +# the -mvsx -mabi=altivec options to compile the float128 support with VSX. +# Otherwise if the default CPU is something like the 7450, the assembler will +# complain when we build the float128 support. + powerpc*-*-linux*) saved_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -mabi=altivec -mvsx -mfloat128" @@ -5192,16 +5244,27 @@ $as_echo_n "checking for PowerPC ISA 2.06 to build __float128 libraries... " >&6 if ${libgcc_cv_powerpc_float128+:} false; then : $as_echo_n "(cached) " >&6 else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + if test x$gcc_no_link = xyes; then + as_fn_error $? "Link tests are not allowed after GCC_NO_EXECUTABLES." "$LINENO" 5 +fi +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -vector double dadd (vector double a, vector double b) { return a + b; } +volatile vector double a; + volatile vector double b = { 1.0, 2.0 }; + volatile vector double c = { 3.0, 4.0 }; + int main (void) + { + a = b + c; + return 0; + } _ACEOF -if ac_fn_c_try_compile "$LINENO"; then : +if ac_fn_c_try_link "$LINENO"; then : libgcc_cv_powerpc_float128=yes else libgcc_cv_powerpc_float128=no fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $libgcc_cv_powerpc_float128" >&5 $as_echo "$libgcc_cv_powerpc_float128" >&6; } diff --git a/libgcc/configure.ac b/libgcc/configure.ac index c2749fe09584..7a30db9977bd 100644 --- a/libgcc/configure.ac +++ b/libgcc/configure.ac @@ -407,13 +407,26 @@ case ${host} in # 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. +# +# We use AC_LINK_IFELSE to verify that the assembler will not abort if given +# the -mvsx -mabi=altivec options to compile the float128 support with VSX. +# Otherwise if the default CPU is something like the 7450, the assembler will +# complain when we build the float128 support. + powerpc*-*-linux*) saved_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -mabi=altivec -mvsx -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_LINK_IFELSE( + [AC_LANG_SOURCE([volatile vector double a; + volatile vector double b = { 1.0, 2.0 }; + volatile vector double c = { 3.0, 4.0 }; + int main (void) + { + a = b + c; + return 0; + }])], [libgcc_cv_powerpc_float128=yes], [libgcc_cv_powerpc_float128=no])])