From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1791) id E22C33858403; Fri, 9 Feb 2024 17:31:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E22C33858403 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1707499872; bh=pSgnyAkoVk+Bmqq4jhMb0vVLXel48iMPm3LGnAxFlaM=; h=From:To:Subject:Date:From; b=kg2kAeoN4ryl0OqXxwW6+YxM2/W8mdgUKXBA7NNM7A7AcYXV+doHMSBbC6lfhZv06 i4hjBqObAP79x6gUn4t+Q2ab0Dc2wRH+DW+bQii+iTUITEMzlOfEEbKNDgOplJHa13 +nPuRqpeTh+mbHEPxMIxl965jfEd5KU1CNp9h83o= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Adhemerval Zanella To: glibc-cvs@sourceware.org Subject: [glibc/azanella/clang] Use -frounding-math iff compiler supports it X-Act-Checkin: glibc X-Git-Author: Adhemerval Zanella X-Git-Refname: refs/heads/azanella/clang X-Git-Oldrev: 0f01a551a9d114c929261df8263eda2462786229 X-Git-Newrev: 478f60ee74804c4ab9521104379ea44622dd8470 Message-Id: <20240209173112.E22C33858403@sourceware.org> Date: Fri, 9 Feb 2024 17:31:12 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=478f60ee74804c4ab9521104379ea44622dd8470 commit 478f60ee74804c4ab9521104379ea44622dd8470 Author: Adhemerval Zanella Date: Tue Mar 15 16:01:29 2022 -0300 Use -frounding-math iff compiler supports it Diff: --- Makeconfig | 2 +- configure | 24 ++++++++++++++++++++++++ configure.ac | 9 +++++++++ 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/Makeconfig b/Makeconfig index 85e00cef94..acde47e99c 100644 --- a/Makeconfig +++ b/Makeconfig @@ -870,7 +870,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 b7c591dfaa..624662bd62 100755 --- a/configure +++ b/configure @@ -7341,6 +7341,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 \ diff --git a/configure.ac b/configure.ac index 591f7ee84d..b5cc1aa9eb 100644 --- a/configure.ac +++ b/configure.ac @@ -1469,6 +1469,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 <