public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Adhemerval Zanella <azanella@sourceware.org>
To: glibc-cvs@sourceware.org
Subject: [glibc/azanella/clang] Use -frounding-math iff compiler supports it
Date: Fri, 28 Oct 2022 17:41:40 +0000 (GMT)	[thread overview]
Message-ID: <20221028174140.32083382DE2E@sourceware.org> (raw)

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

commit f2543b764a6555a272c9ae572b84a661843171e5
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 08a869cd11..d80db88190 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 8e0894742c..ef1557ef6d 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 67af290952..043b6973e0 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

             reply	other threads:[~2022-10-28 17:41 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-28 17:41 Adhemerval Zanella [this message]
  -- strict thread matches above, loose matches on Subject: below --
2024-02-09 17:31 Adhemerval Zanella
2024-02-07 14:06 Adhemerval Zanella
2024-01-29 17:56 Adhemerval Zanella
2023-12-21 18:53 Adhemerval Zanella
2023-09-28 17:51 Adhemerval Zanella
2023-08-30 12:36 Adhemerval Zanella
2023-02-09 19:48 Adhemerval Zanella
2022-10-04 12:59 Adhemerval Zanella
2022-06-09 21:21 Adhemerval Zanella
2022-06-09 13:17 Adhemerval Zanella
2022-06-03 14:06 Adhemerval Zanella
2022-05-13 14:20 Adhemerval Zanella
2022-05-12 19:34 Adhemerval Zanella
2022-05-10 18:24 Adhemerval Zanella
2022-04-29 14:04 Adhemerval Zanella
2022-04-04 12:55 Adhemerval Zanella
2022-03-31 19:07 Adhemerval Zanella
2022-03-29 20:30 Adhemerval Zanella
2022-03-16 18:04 Adhemerval Zanella

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221028174140.32083382DE2E@sourceware.org \
    --to=azanella@sourceware.org \
    --cc=glibc-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).