summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>2025-11-20 15:30:10 -0300
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>2025-11-21 13:13:10 -0300
commit25de0771ecac240a54f03ab55247d92457e4c310 (patch)
tree48aa0f95867b15b68c069f80c4e5e791644df544
parent2885d8a3ab7658033b9933022099ae5e1c3479d4 (diff)
configure: Only use -fno-fp-int-builtin-inexact if compiler supports it
Checked on x86_64-linux-gnu. Reviewed-by: Sam James <sam@gentoo.org>
-rwxr-xr-xconfigure60
-rw-r--r--configure.ac11
-rw-r--r--math/Makefile32
3 files changed, 87 insertions, 16 deletions
diff --git a/configure b/configure
index d5bd639586..d2d83b40c0 100755
--- a/configure
+++ b/configure
@@ -9210,6 +9210,66 @@ have-cc-gcs = $libc_cv_cc_gcs"
config_vars="$config_vars
have-test-cc-gcs = $libc_cv_test_cc_gcs"
+# Check if compiler supports -fno-fp-int-builtin-inexact
+
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if compiler supports -fno-fp-int-builtin-inexact" >&5
+printf %s "checking if compiler supports -fno-fp-int-builtin-inexact... " >&6; }
+if test ${libc_cv_cc_no_fp_builtin_inexact+y}
+then :
+ printf %s "(cached) " >&6
+else case e in #(
+ e) if { ac_try='${CC-cc} -Werror -fno-fp-int-builtin-inexact -xc /dev/null -S -o /dev/null'
+ { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; }
+then :
+ libc_cv_cc_no_fp_builtin_inexact=-fno-fp-int-builtin-inexact
+else case e in #(
+ e) libc_cv_cc_no_fp_builtin_inexact= ;;
+esac
+fi ;;
+esac
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libc_cv_cc_no_fp_builtin_inexact" >&5
+printf "%s\n" "$libc_cv_cc_no_fp_builtin_inexact" >&6; }
+if test "$TEST_CC" = "$CC"; then
+ libc_cv_test_cc_no_fp_builtin_inexact=$libc_cv_cc_no_fp_builtin_inexact
+else
+
+saved_CC="$CC"
+CC="$TEST_CC"
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if compiler supports -fno-fp-int-builtin-inexact in testing" >&5
+printf %s "checking if compiler supports -fno-fp-int-builtin-inexact in testing... " >&6; }
+if test ${libc_cv_test_cc_no_fp_builtin_inexact+y}
+then :
+ printf %s "(cached) " >&6
+else case e in #(
+ e) if { ac_try='${CC-cc} -Werror -fno-fp-int-builtin-inexact -xc /dev/null -S -o /dev/null'
+ { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; }
+then :
+ libc_cv_test_cc_no_fp_builtin_inexact=-fno-fp-int-builtin-inexact
+else case e in #(
+ e) libc_cv_test_cc_no_fp_builtin_inexact= ;;
+esac
+fi ;;
+esac
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libc_cv_test_cc_no_fp_builtin_inexact" >&5
+printf "%s\n" "$libc_cv_test_cc_no_fp_builtin_inexact" >&6; }
+
+CC="$saved_CC"
+
+fi
+
+config_vars="$config_vars
+config-cflags-no-fp-builtin-inexact = $libc_cv_cc_no_fp_builtin_inexact"
+
# Check if linker supports GCS marking
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for linker that supports -z gcs=always" >&5
printf %s "checking for linker that supports -z gcs=always... " >&6; }
diff --git a/configure.ac b/configure.ac
index aaf686494a..3b9f3688f1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2061,6 +2061,17 @@ LIBC_TRY_CC_AND_TEST_CC_OPTION([if compiler supports -mbranch-protection=gcs],
LIBC_CONFIG_VAR([have-cc-gcs], [$libc_cv_cc_gcs])
LIBC_CONFIG_VAR([have-test-cc-gcs], [$libc_cv_test_cc_gcs])
+# Check if compiler supports -fno-fp-int-builtin-inexact
+LIBC_TRY_CC_AND_TEST_CC_OPTION([if compiler supports -fno-fp-int-builtin-inexact],
+ [-Werror -fno-fp-int-builtin-inexact],
+ libc_cv_cc_no_fp_builtin_inexact,
+ [libc_cv_cc_no_fp_builtin_inexact=-fno-fp-int-builtin-inexact],
+ [libc_cv_cc_no_fp_builtin_inexact=],
+ libc_cv_test_cc_no_fp_builtin_inexact,
+ [libc_cv_test_cc_no_fp_builtin_inexact=-fno-fp-int-builtin-inexact],
+ [libc_cv_test_cc_no_fp_builtin_inexact=])
+LIBC_CONFIG_VAR([config-cflags-no-fp-builtin-inexact], [$libc_cv_cc_no_fp_builtin_inexact])
+
# Check if linker supports GCS marking
LIBC_LINKER_FEATURE([-z gcs=always], [-Wl,-z,gcs=always],
[libc_cv_ld_gcs=yes], [libc_cv_ld_gcs=no])
diff --git a/math/Makefile b/math/Makefile
index d05108def1..f7a1d9016c 100644
--- a/math/Makefile
+++ b/math/Makefile
@@ -1827,22 +1827,22 @@ CFLAGS-s_modff128.c += $(config-cflags-signaling-nans)
# These files rely on C23 semantics for avoiding "inexact" exceptions
# from rounding functions. These settings can be removed when glibc
# builds with -std=gnu23 or later.
-CFLAGS-s_fromfp.c += -fno-fp-int-builtin-inexact
-CFLAGS-s_fromfpx.c += -fno-fp-int-builtin-inexact
-CFLAGS-s_ufromfp.c += -fno-fp-int-builtin-inexact
-CFLAGS-s_ufromfpx.c += -fno-fp-int-builtin-inexact
-CFLAGS-s_fromfpf.c += -fno-fp-int-builtin-inexact
-CFLAGS-s_fromfpxf.c += -fno-fp-int-builtin-inexact
-CFLAGS-s_ufromfpf.c += -fno-fp-int-builtin-inexact
-CFLAGS-s_ufromfpxf.c += -fno-fp-int-builtin-inexact
-CFLAGS-s_fromfpl.c += -fno-fp-int-builtin-inexact
-CFLAGS-s_fromfpxl.c += -fno-fp-int-builtin-inexact
-CFLAGS-s_ufromfpl.c += -fno-fp-int-builtin-inexact
-CFLAGS-s_ufromfpxl.c += -fno-fp-int-builtin-inexact
-CFLAGS-s_fromfpf128.c += -fno-fp-int-builtin-inexact
-CFLAGS-s_fromfpxf128.c += -fno-fp-int-builtin-inexact
-CFLAGS-s_ufromfpf128.c += -fno-fp-int-builtin-inexact
-CFLAGS-s_ufromfpxf128.c += -fno-fp-int-builtin-inexact
+CFLAGS-s_fromfp.c += $(config-cflags-no-fp-builtin-inexact)
+CFLAGS-s_fromfpx.c += $(config-cflags-no-fp-builtin-inexact)
+CFLAGS-s_ufromfp.c += $(config-cflags-no-fp-builtin-inexact)
+CFLAGS-s_ufromfpx.c += $(config-cflags-no-fp-builtin-inexact)
+CFLAGS-s_fromfpf.c += $(config-cflags-no-fp-builtin-inexact)
+CFLAGS-s_fromfpxf.c += $(config-cflags-no-fp-builtin-inexact)
+CFLAGS-s_ufromfpf.c += $(config-cflags-no-fp-builtin-inexact)
+CFLAGS-s_ufromfpxf.c += $(config-cflags-no-fp-builtin-inexact)
+CFLAGS-s_fromfpl.c += $(config-cflags-no-fp-builtin-inexact)
+CFLAGS-s_fromfpxl.c += $(config-cflags-no-fp-builtin-inexact)
+CFLAGS-s_ufromfpl.c += $(config-cflags-no-fp-builtin-inexact)
+CFLAGS-s_ufromfpxl.c += $(config-cflags-no-fp-builtin-inexact)
+CFLAGS-s_fromfpf128.c += $(config-cflags-no-fp-builtin-inexact)
+CFLAGS-s_fromfpxf128.c += $(config-cflags-no-fp-builtin-inexact)
+CFLAGS-s_ufromfpf128.c += $(config-cflags-no-fp-builtin-inexact)
+CFLAGS-s_ufromfpxf128.c += $(config-cflags-no-fp-builtin-inexact)
$(addprefix $(objpfx),\
$(filter-out $(tests-static) $(libm-tests-vector),\