Use -frounding-math iff compiler supports it

This commit is contained in:
Adhemerval Zanella 2022-03-15 16:01:29 -03:00
parent 5e40fc5900
commit 58f8b01276
3 changed files with 34 additions and 1 deletions

View File

@ -872,7 +872,7 @@ endif
# We have to assume that glibc functions are called in any rounding
# mode and also change the rounding mode in a few functions. So,
# disable any optimization that assume default rounding mode.
+math-flags = -frounding-math
+math-flags = $(config-cflags-frounding-math)
# Logically only "libnldbl", "nonlib" and "testsuite" should be using
# -fno-math-errno. However due to GCC bug #88576, only "libm" can use

24
configure vendored
View File

@ -7344,6 +7344,30 @@ printf "%s\n" "$libc_cv_cc_signaling_nans" >&6; }
config_vars="$config_vars
config-cflags-signaling-nans = $libc_cv_cc_signaling_nans"
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for compiler option -frounding-math" >&5
printf %s "checking for compiler option -frounding-math... " >&6; }
if test ${libc_cv_cc_rounding_math+y}
then :
printf %s "(cached) " >&6
else $as_nop
if { ac_try='${CC-cc} -Werror -frounding-math -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_rounding_math=-frounding-math
else $as_nop
libc_cv_cc_rounding_math=
fi
fi
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libc_cv_cc_rounding_math" >&5
printf "%s\n" "$libc_cv_cc_rounding_math" >&6; }
config_vars="$config_vars
config-cflags-frounding-math = $libc_cv_cc_rounding_math"
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $CC accepts -fno-tree-loop-distribute-patterns with \
__attribute__ ((__optimize__))" >&5
printf %s "checking if $CC accepts -fno-tree-loop-distribute-patterns with \

View File

@ -1472,6 +1472,15 @@ LIBC_TRY_CC_OPTION([-Werror -fsignaling-nans],
LIBC_CONFIG_VAR([config-cflags-signaling-nans],
[$libc_cv_cc_signaling_nans])
dnl Determina if compiler support -frounding-math
AC_CACHE_CHECK([for compiler option -frounding-math], libc_cv_cc_rounding_math, [dnl
LIBC_TRY_CC_OPTION([-Werror -frounding-math],
[libc_cv_cc_rounding_math=-frounding-math],
[libc_cv_cc_rounding_math=])
])
LIBC_CONFIG_VAR([config-cflags-frounding-math],
[$libc_cv_cc_rounding_math])
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