Disable use of -fsignaling-nans if compiler does not support it

Reviewed-by: Fangrui Song <maskray@google.com>
This commit is contained in:
Adhemerval Zanella 2022-03-07 15:09:53 -03:00
parent 6ee5a9767a
commit 5c5a8b99cf
16 changed files with 86 additions and 31 deletions

View File

@ -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

22
configure vendored
View File

@ -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 \

View File

@ -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

View File

@ -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),\

View File

@ -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),

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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>

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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