[PATCH] Add test-config-cflags-float-store for -ffloat-store
H.J. Lu
hjl.tools@gmail.com
Wed Dec 18 19:21:22 GMT 2024
Clang doesn't support -ffloat-store:
clang: error: optimization flag '-ffloat-store' is not supported [-Werror,-Wignored-optimization-argument]
Define test-config-cflags-float-store for -ffloat-store and use it in
math/Makefile for testing.
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
---
aclocal.m4 | 11 +++++++++++
configure | 33 +++++++++++++++++++++++++++++++++
configure.ac | 9 +++++++++
math/Makefile | 6 ++++--
4 files changed, 57 insertions(+), 2 deletions(-)
diff --git a/aclocal.m4 b/aclocal.m4
index fb4c1ef1c4..915bcf4601 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -447,3 +447,14 @@ LIBC_CHECK_TEST_CXX(
fi])
)
rm -f conftest*])
+
+dnl Test a TEST_CC compiler option or options with an empty input file.
+dnl LIBC_TRY_TEST_CC_OPTION([message], [options],
+dnl [TEST_CC-cache-id], [TEST_CC-action-if-true], [TEST_CC-action-if-false])
+AC_DEFUN([LIBC_TRY_TEST_CC_OPTION],
+[
+LIBC_CHECK_TEST_CC(
+ AC_CACHE_CHECK([$1 in testing], $3,
+ [LIBC_TRY_CC_OPTION([$2], [$4], [$5])])
+ )
+])
diff --git a/configure b/configure
index c231507721..30e95f0838 100755
--- a/configure
+++ b/configure
@@ -7681,6 +7681,39 @@ config_vars="$config_vars
config-cflags-signaling-nans = $libc_cv_cc_signaling_nans"
+
+
+saved_CC="$CC"
+CC="$TEST_CC"
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for -ffloat-store in testing" >&5
+printf %s "checking for -ffloat-store in testing... " >&6; }
+if test ${libc_cv_test_cc_float_store+y}
+then :
+ printf %s "(cached) " >&6
+else case e in #(
+ e) if { ac_try='${CC-cc} -Werror -ffloat-store -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_test_cc_float_store="-ffloat-store"
+else case e in #(
+ e) libc_cv_test_cc_float_store= ;;
+esac
+fi ;;
+esac
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libc_cv_test_cc_float_store" >&5
+printf "%s\n" "$libc_cv_test_cc_float_store" >&6; }
+
+CC="$saved_CC"
+
+
+config_vars="$config_vars
+test-config-cflags-float-store = $libc_cv_test_cc_float_store"
+
{ 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 cc1c76f5c8..e1d7c28eba 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1498,6 +1498,15 @@ LIBC_CONFIG_VAR([config-cflags-signaling-nans],
[$libc_cv_cc_signaling_nans])
AC_SUBST(libc_cv_test_cc_signaling_nans)
+dnl Determine if TEST_CC supports -ffloat-store.
+LIBC_TRY_TEST_CC_OPTION([for -ffloat-store],
+ [-Werror -ffloat-store],
+ libc_cv_test_cc_float_store,
+ [libc_cv_test_cc_float_store="-ffloat-store"],
+ [libc_cv_test_cc_float_store=])
+LIBC_CONFIG_VAR([test-config-cflags-float-store],
+ [$libc_cv_test_cc_float_store])
+
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
diff --git a/math/Makefile b/math/Makefile
index 798d71dc47..722af52e1e 100644
--- a/math/Makefile
+++ b/math/Makefile
@@ -1070,7 +1070,8 @@ endif
libm-test-fast-math-cflags = -fno-builtin -D__FAST_MATH__ -DTEST_FAST_MATH
libm-test-vec-cflags = $(libm-test-fast-math-cflags) -fno-inline \
- -ffloat-store -D_OPENMP=201307 -Wno-unknown-pragmas
+ $(test-config-cflags-float-store) \
+ -D_OPENMP=201307 -Wno-unknown-pragmas
CFLAGS-test-double-vlen4-wrappers.c += $(double-vlen4-arch-ext-cflags)
@@ -1086,7 +1087,8 @@ CFLAGS-test-float-vlen16-wrappers.c += $(float-vlen16-arch-ext-cflags)
# raise spurious exceptions for sNaNs, but also do not test for
# exceptions. Thus both versions of the classification macros are
# validated.
-libm-test-no-inline-cflags = -fno-inline -ffloat-store -fno-builtin \
+libm-test-no-inline-cflags = -fno-inline -fno-builtin \
+ $(test-config-cflags-float-store) \
$(config-cflags-signaling-nans)
CFLAGS-test-tgmath.c += -fno-builtin
# The following testcase uses very long lines (>3 million), so it may take a
--
2.47.1
More information about the Libc-alpha
mailing list