[glibc/azanella/clang] Use -frounding-math iff compiler supports it

Adhemerval Zanella azanella@sourceware.org
Tue Oct 4 12:59:31 GMT 2022


https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=91bda0ee2596703ff94600339b632c54246e41e5

commit 91bda0ee2596703ff94600339b632c54246e41e5
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Tue Mar 15 16:01:29 2022 -0300

    Use -frounding-math iff compiler supports it

Diff:
---
 Makeconfig   |  2 +-
 configure    | 22 ++++++++++++++++++++++
 configure.ac |  9 +++++++++
 3 files changed, 32 insertions(+), 1 deletion(-)

diff --git a/Makeconfig b/Makeconfig
index 842f49eb58..adb83e6801 100644
--- a/Makeconfig
+++ b/Makeconfig
@@ -874,7 +874,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
diff --git a/configure b/configure
index 5fc7d6f0d4..f777e4fafd 100755
--- a/configure
+++ b/configure
@@ -6520,6 +6520,28 @@ $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 for compiler option -frounding-math" >&5
+$as_echo_n "checking for compiler option -frounding-math... " >&6; }
+if ${libc_cv_cc_rounding_math+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  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=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; }; then :
+  libc_cv_cc_rounding_math=-frounding-math
+else
+  libc_cv_cc_rounding_math=
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_cc_rounding_math" >&5
+$as_echo "$libc_cv_cc_rounding_math" >&6; }
+config_vars="$config_vars
+config-cflags-frounding-math = $libc_cv_cc_rounding_math"
+
 { $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 fb698c3d7d..03e14b13a0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1557,6 +1557,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


More information about the Glibc-cvs mailing list