aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>2022-03-07 15:09:53 -0300
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>2022-11-01 09:46:08 -0300
commit5c5a8b99cf96b71940e36a9db66d3a61bc315016 (patch)
tree7396885b3487d9383bf477219a79ebcf68b64d9f
parent6ee5a9767a245455720d39eeaa3ce136825e8a42 (diff)
downloadglibc-5c5a8b99cf96b71940e36a9db66d3a61bc315016.zip
glibc-5c5a8b99cf96b71940e36a9db66d3a61bc315016.tar.gz
glibc-5c5a8b99cf96b71940e36a9db66d3a61bc315016.tar.bz2
Disable use of -fsignaling-nans if compiler does not support it
Reviewed-by: Fangrui Song <maskray@google.com>
-rw-r--r--benchtests/Makefile6
-rwxr-xr-xconfigure22
-rw-r--r--configure.ac10
-rw-r--r--math/Makefile19
-rw-r--r--math/libm-test-fpclassify.inc2
-rw-r--r--math/libm-test-isfinite.inc2
-rw-r--r--math/libm-test-isinf.inc2
-rw-r--r--math/libm-test-isnan.inc2
-rw-r--r--math/libm-test-isnormal.inc2
-rw-r--r--math/libm-test-issubnormal.inc2
-rw-r--r--math/libm-test-iszero.inc2
-rw-r--r--math/test-snan.c10
-rw-r--r--sysdeps/powerpc/nofpu/Makefile24
-rw-r--r--sysdeps/powerpc/powerpc32/power4/fpu/multiarch/Makefile4
-rw-r--r--sysdeps/powerpc/powerpc64/be/fpu/multiarch/Makefile4
-rw-r--r--sysdeps/powerpc/powerpc64/le/fpu/multiarch/Makefile4
16 files changed, 86 insertions, 31 deletions
diff --git a/benchtests/Makefile b/benchtests/Makefile
index fc1cda7..292976b 100644
--- a/benchtests/Makefile
+++ b/benchtests/Makefile
@@ -268,9 +268,9 @@ CFLAGS-bench-trunc.c += -fno-builtin
CFLAGS-bench-truncf.c += -fno-builtin
CFLAGS-bench-roundeven.c += -fno-builtin
CFLAGS-bench-roundevenf.c += -fno-builtin
-CFLAGS-bench-isnan.c += -fsignaling-nans
-CFLAGS-bench-isinf.c += -fsignaling-nans
-CFLAGS-bench-isfinite.c += -fsignaling-nans
+CFLAGS-bench-isnan.c += $(config-cflags-signaling-nans)
+CFLAGS-bench-isinf.c += $(config-cflags-signaling-nans)
+CFLAGS-bench-isfinite.c += $(config-cflags-signaling-nans)
ifeq (${BENCHSET},)
bench-malloc := malloc-thread malloc-simple
diff --git a/configure b/configure
index 82e5e9f..adf263d 100755
--- a/configure
+++ b/configure
@@ -6486,6 +6486,28 @@ $as_echo "$libc_cv_cc_submachine" >&6; }
fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for compiler option that -fsignaling-nans" >&5
+$as_echo_n "checking for compiler option that -fsignaling-nans... " >&6; }
+if ${libc_cv_cc_signaling_nans+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if { ac_try='${CC-cc} -Werror -fsignaling-nans -xc /dev/null -S -o /dev/null'
+ { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; }; then :
+ libc_cv_cc_signaling_nans=-fsignaling-nans
+else
+ libc_cv_cc_signaling_nans=
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_cc_signaling_nans" >&5
+$as_echo "$libc_cv_cc_signaling_nans" >&6; }
+config_vars="$config_vars
+config-cflags-signaling-nans = $libc_cv_cc_signaling_nans"
+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC accepts -fno-tree-loop-distribute-patterns with \
__attribute__ ((__optimize__))" >&5
$as_echo_n "checking if $CC accepts -fno-tree-loop-distribute-patterns with \
diff --git a/configure.ac b/configure.ac
index 973fe59..c5c4b38 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1488,6 +1488,16 @@ if test -n "$submachine"; then
fi
AC_SUBST(libc_cv_cc_submachine)
+dnl Determine if compiler supports -fsignaling-nans
+AC_CACHE_CHECK([for compiler option that -fsignaling-nans],
+ libc_cv_cc_signaling_nans, [dnl
+LIBC_TRY_CC_OPTION([-Werror -fsignaling-nans],
+ [libc_cv_cc_signaling_nans=-fsignaling-nans],
+ [libc_cv_cc_signaling_nans=])
+])
+LIBC_CONFIG_VAR([config-cflags-signaling-nans],
+ [$libc_cv_cc_signaling_nans])
+
AC_CACHE_CHECK(if $CC accepts -fno-tree-loop-distribute-patterns with \
__attribute__ ((__optimize__)), libc_cv_cc_loop_to_function, [dnl
cat > conftest.c <<EOF
diff --git a/math/Makefile b/math/Makefile
index b3dae4e..35a4014 100644
--- a/math/Makefile
+++ b/math/Makefile
@@ -248,8 +248,11 @@ tests = test-matherr-3 test-fenv basic-test \
test-femode-traps test-iszero-excess-precision \
test-iseqsig-excess-precision test-flt-eval-method \
test-fp-ilogb-constants test-fp-llogb-constants \
- test-fe-snans-always-signal test-narrow-macros \
+ test-narrow-macros \
test-nan-const $(tests-static)
+ifneq ($(config-cflags-signaling-nans),)
+tests += test-fe-snans-always-signal
+endif
tests-static = test-fpucw-static test-fpucw-ieee-static \
test-signgam-uchar-static test-signgam-uchar-init-static \
test-signgam-uint-static test-signgam-uint-init-static \
@@ -421,7 +424,7 @@ CFLAGS-test-float-vlen16-wrappers.c += $(float-vlen16-arch-ext-cflags)
# exceptions. Thus both versions of the classification macros are
# validated.
libm-test-no-inline-cflags = -fno-inline -ffloat-store -fno-builtin \
- -fsignaling-nans
+ $(config-cflags-signaling-nans)
CFLAGS-test-tgmath.c += -fno-builtin
# The following testcase uses very long lines (>3 million), so it may take a
# while to compile it. See: http://llvm.org/bugs/show_bug.cgi?id=14106 and
@@ -430,7 +433,7 @@ CFLAGS-test-tgmath2.c += -fno-builtin
CFLAGS-test-tgmath-ret.c += -fno-builtin
CFLAGS-test-powl.c += -fno-builtin
-CFLAGS-test-snan.c += -fsignaling-nans
+CFLAGS-test-snan.c += $(config-cflags-signaling-nans)
CFLAGS-test-signgam-uchar.c += -std=c99
CFLAGS-test-signgam-uchar-init.c += -std=c99
@@ -456,7 +459,7 @@ CFLAGS-test-iszero-excess-precision.c += -fexcess-precision=standard
CFLAGS-test-iseqsig-excess-precision.c += -fexcess-precision=standard
CFLAGS-test-flt-eval-method.c += -fexcess-precision=standard
-CFLAGS-test-fe-snans-always-signal.c += -fsignaling-nans
+CFLAGS-test-fe-snans-always-signal.c += $(config-cflags-signaling-nans)
CFLAGS-test-nan-const.c += -fno-builtin
@@ -1001,10 +1004,10 @@ CFLAGS-s_ynf.c += -fno-builtin-ynf32
# These files quiet sNaNs in a way that is optimized away without
# -fsignaling-nans.
-CFLAGS-s_modf.c += -fsignaling-nans
-CFLAGS-s_modff.c += -fsignaling-nans
-CFLAGS-s_modfl.c += -fsignaling-nans
-CFLAGS-s_modff128.c += -fsignaling-nans
+CFLAGS-s_modf.c += $(config-cflags-signaling-nans)
+CFLAGS-s_modff.c += $(config-cflags-signaling-nans)
+CFLAGS-s_modfl.c += $(config-cflags-signaling-nans)
+CFLAGS-s_modff128.c += $(config-cflags-signaling-nans)
$(addprefix $(objpfx),\
$(filter-out $(tests-static) $(libm-tests-vector),\
diff --git a/math/libm-test-fpclassify.inc b/math/libm-test-fpclassify.inc
index f805ad5..dafb1fc 100644
--- a/math/libm-test-fpclassify.inc
+++ b/math/libm-test-fpclassify.inc
@@ -22,8 +22,10 @@ static const struct test_f_i_data fpclassify_test_data[] =
{
TEST_f_i (fpclassify, qnan_value, FP_NAN, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
TEST_f_i (fpclassify, -qnan_value, FP_NAN, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+#ifdef __SUPPORT_SNAN__
TEST_f_i (fpclassify, snan_value, FP_NAN, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
TEST_f_i (fpclassify, -snan_value, FP_NAN, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+#endif
TEST_f_i (fpclassify, plus_infty, FP_INFINITE, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
TEST_f_i (fpclassify, minus_infty, FP_INFINITE, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
TEST_f_i (fpclassify, plus_zero, FP_ZERO, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
diff --git a/math/libm-test-isfinite.inc b/math/libm-test-isfinite.inc
index 37a4ca4..5b22dbc 100644
--- a/math/libm-test-isfinite.inc
+++ b/math/libm-test-isfinite.inc
@@ -33,8 +33,10 @@ static const struct test_f_i_data isfinite_test_data[] =
TEST_f_b (isfinite, minus_infty, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
TEST_f_b (isfinite, qnan_value, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
TEST_f_b (isfinite, -qnan_value, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+#ifdef __SUPPORT_SNAN__
TEST_f_b (isfinite, snan_value, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
TEST_f_b (isfinite, -snan_value, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+#endif
};
static void
diff --git a/math/libm-test-isinf.inc b/math/libm-test-isinf.inc
index 2654872..990babf 100644
--- a/math/libm-test-isinf.inc
+++ b/math/libm-test-isinf.inc
@@ -33,8 +33,10 @@ static const struct test_f_i_data isinf_test_data[] =
TEST_f_b (isinf, minus_infty, 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
TEST_f_b (isinf, qnan_value, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
TEST_f_b (isinf, -qnan_value, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+#ifdef __SUPPORT_SNAN__
TEST_f_b (isinf, snan_value, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
TEST_f_b (isinf, -snan_value, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+#endif
};
#if TEST_COND_intel96
diff --git a/math/libm-test-isnan.inc b/math/libm-test-isnan.inc
index 026b61c..2edfd7c 100644
--- a/math/libm-test-isnan.inc
+++ b/math/libm-test-isnan.inc
@@ -33,8 +33,10 @@ static const struct test_f_i_data isnan_test_data[] =
TEST_f_b (isnan, minus_infty, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
TEST_f_b (isnan, qnan_value, 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
TEST_f_b (isnan, -qnan_value, 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+#ifdef __SUPPORT_SNAN__
TEST_f_b (isnan, snan_value, 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
TEST_f_b (isnan, -snan_value, 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+#endif
};
#if TEST_COND_intel96
diff --git a/math/libm-test-isnormal.inc b/math/libm-test-isnormal.inc
index e1e8a3b..e4f6a8f 100644
--- a/math/libm-test-isnormal.inc
+++ b/math/libm-test-isnormal.inc
@@ -33,8 +33,10 @@ static const struct test_f_i_data isnormal_test_data[] =
TEST_f_b (isnormal, minus_infty, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
TEST_f_b (isnormal, qnan_value, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
TEST_f_b (isnormal, -qnan_value, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+#ifdef __SUPPORT_SNAN__
TEST_f_b (isnormal, snan_value, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
TEST_f_b (isnormal, -snan_value, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+#endif
};
static void
diff --git a/math/libm-test-issubnormal.inc b/math/libm-test-issubnormal.inc
index 38564f2..cc04543 100644
--- a/math/libm-test-issubnormal.inc
+++ b/math/libm-test-issubnormal.inc
@@ -33,8 +33,10 @@ static const struct test_f_i_data issubnormal_test_data[] =
TEST_f_b (issubnormal, minus_infty, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
TEST_f_b (issubnormal, qnan_value, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
TEST_f_b (issubnormal, -qnan_value, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+#ifdef __SUPPORT_SNAN__
TEST_f_b (issubnormal, snan_value, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
TEST_f_b (issubnormal, -snan_value, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+#endif
};
static void
diff --git a/math/libm-test-iszero.inc b/math/libm-test-iszero.inc
index cfd3d1f..e56eac4 100644
--- a/math/libm-test-iszero.inc
+++ b/math/libm-test-iszero.inc
@@ -33,8 +33,10 @@ static const struct test_f_i_data iszero_test_data[] =
TEST_f_b (iszero, minus_infty, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
TEST_f_b (iszero, qnan_value, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
TEST_f_b (iszero, -qnan_value, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+#ifdef __SUPPORT_SNAN__
TEST_f_b (iszero, snan_value, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
TEST_f_b (iszero, -snan_value, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+#endif
};
static void
diff --git a/math/test-snan.c b/math/test-snan.c
index 4d7bd54..fadde89 100644
--- a/math/test-snan.c
+++ b/math/test-snan.c
@@ -25,8 +25,10 @@
#include <setjmp.h>
#include <math-tests.h>
+#include <support/check.h>
+#ifdef __SUPPORT_SNAN__
static sigjmp_buf sigfpe_buf;
static void
@@ -123,10 +125,12 @@ NAME (void) \
TEST_FUNC (float_test, float, f)
TEST_FUNC (double_test, double, )
TEST_FUNC (ldouble_test, long double, l)
+#endif
static int
do_test (void)
{
+#ifdef __SUPPORT_SNAN__
signal (SIGFPE, &myFPsighandler);
float_test ();
@@ -134,7 +138,9 @@ do_test (void)
ldouble_test ();
return errors != 0;
+#else
+ FAIL_UNSUPPORTED ("compiler does not support -fsignaling-nans");
+#endif
}
-#define TEST_FUNCTION do_test ()
-#include "../test-skeleton.c"
+#include <support/test-driver.c>
diff --git a/sysdeps/powerpc/nofpu/Makefile b/sysdeps/powerpc/nofpu/Makefile
index 3b51ff6..fa46233 100644
--- a/sysdeps/powerpc/nofpu/Makefile
+++ b/sysdeps/powerpc/nofpu/Makefile
@@ -27,18 +27,18 @@ CPPFLAGS += -I../soft-fp/
CFLAGS-e_atan2l.c += -fno-builtin-fabsl
CFLAGS-e_hypotl.c += -fno-builtin-fabsl
CFLAGS-e_powl.c += -fno-builtin-fabsl
-CFLAGS-s_cacosl.c += -fsignaling-nans
-CFLAGS-s_cacoshl.c += -fsignaling-nans
-CFLAGS-s_casinhl.c += -fsignaling-nans
-CFLAGS-s_catanl.c += -fsignaling-nans
-CFLAGS-s_catanhl.c += -fsignaling-nans
-CFLAGS-s_ccoshl.c += -fno-builtin-fabsl -fsignaling-nans
-CFLAGS-s_cexpl.c += -fsignaling-nans
-CFLAGS-s_csinhl.c += -fno-builtin-fabsl -fsignaling-nans
-CFLAGS-s_clogl.c += -fno-builtin-fabsl -fsignaling-nans
-CFLAGS-s_clog10l.c += -fno-builtin-fabsl -fsignaling-nans
-CFLAGS-s_csinl.c += -fno-builtin-fabsl -fsignaling-nans
-CFLAGS-s_csqrtl.c += -fno-builtin-fabsl -fsignaling-nans
+CFLAGS-s_cacosl.c += $(config-cflags-signaling-nans)
+CFLAGS-s_cacoshl.c += $(config-cflags-signaling-nans)
+CFLAGS-s_casinhl.c += $(config-cflags-signaling-nans)
+CFLAGS-s_catanl.c += $(config-cflags-signaling-nans)
+CFLAGS-s_catanhl.c += $(config-cflags-signaling-nans)
+CFLAGS-s_ccoshl.c += -fno-builtin-fabsl $(config-cflags-signaling-nans)
+CFLAGS-s_cexpl.c += $(config-cflags-signaling-nans)
+CFLAGS-s_csinhl.c += -fno-builtin-fabsl $(config-cflags-signaling-nans)
+CFLAGS-s_clogl.c += -fno-builtin-fabsl $(config-cflags-signaling-nans)
+CFLAGS-s_clog10l.c += -fno-builtin-fabsl $(config-cflags-signaling-nans)
+CFLAGS-s_csinl.c += -fno-builtin-fabsl $(config-cflags-signaling-nans)
+CFLAGS-s_csqrtl.c += -fno-builtin-fabsl $(config-cflags-signaling-nans)
CFLAGS-w_acosl_compat.c += -fno-builtin-fabsl
CFLAGS-w_asinl_compat.c += -fno-builtin-fabsl
CFLAGS-w_atanhl_compat.c += -fno-builtin-fabsl
diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/Makefile b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/Makefile
index 1de0f9b..6431750 100644
--- a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/Makefile
+++ b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/Makefile
@@ -37,6 +37,6 @@ CFLAGS-s_logbf-power7.c = -mcpu=power7
# These files quiet sNaNs in a way that is optimized away without
# -fsignaling-nans.
-CFLAGS-s_modf-ppc32.c += -fsignaling-nans
-CFLAGS-s_modff-ppc32.c += -fsignaling-nans
+CFLAGS-s_modf-ppc32.c += $(config-cflags-signaling-nans)
+CFLAGS-s_modff-ppc32.c += $(config-cflags-signaling-nans)
endif
diff --git a/sysdeps/powerpc/powerpc64/be/fpu/multiarch/Makefile b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/Makefile
index b27bad3..36f4006 100644
--- a/sysdeps/powerpc/powerpc64/be/fpu/multiarch/Makefile
+++ b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/Makefile
@@ -62,6 +62,6 @@ CFLAGS-s_logb-power7.c = -mcpu=power7
# These files quiet sNaNs in a way that is optimized away without
# -fsignaling-nans.
-CFLAGS-s_modf-ppc64.c += -fsignaling-nans
-CFLAGS-s_modff-ppc64.c += -fsignaling-nans
+CFLAGS-s_modf-ppc64.c += $(config-cflags-signaling-nans)
+CFLAGS-s_modff-ppc64.c += $(config-cflags-signaling-nans)
endif
diff --git a/sysdeps/powerpc/powerpc64/le/fpu/multiarch/Makefile b/sysdeps/powerpc/powerpc64/le/fpu/multiarch/Makefile
index 8580614..b59c4b2 100644
--- a/sysdeps/powerpc/powerpc64/le/fpu/multiarch/Makefile
+++ b/sysdeps/powerpc/powerpc64/le/fpu/multiarch/Makefile
@@ -130,8 +130,8 @@ generated += $(f128-march-routines)
CFLAGS-float128-ifunc.c += $(type-float128-CFLAGS) $(no-gnu-attribute-CFLAGS)
# Copy special CFLAGS for some functions
-CFLAGS-s_modff128-power9.c += -fsignaling-nans
-CFLAGS-m_modff128-power9.c += -fsignaling-nans
+CFLAGS-s_modff128-power9.c += $(config-cflags-signaling-nans)
+CFLAGS-m_modff128-power9.c += $(config-cflags-signaling-nans)
# Generate ifunc wrapper files and target specific wrappers around
# each routine above. Note, m_%.c files are fixed up to include