]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
x86: Include test-flt-eval-method-387 if -mfpmath=387 works
authorH.J. Lu <hjl.tools@gmail.com>
Thu, 19 Dec 2024 04:08:00 +0000 (12:08 +0800)
committerH.J. Lu <hjl.tools@gmail.com>
Sun, 22 Dec 2024 04:54:44 +0000 (12:54 +0800)
Since Clang doesn't support -mfpmath=387 on x86-64, on x86, include
test-flt-eval-method-387 only if -mfpmath=387 works.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
sysdeps/x86/configure
sysdeps/x86/configure.ac
sysdeps/x86/fpu/Makefile

index a6d37778d1960386befee9d29fbb0a08fe216c9e..c7ea9ac6adff19e47e0f6c11affc7e2d6b26d3d4 100644 (file)
@@ -175,6 +175,40 @@ x86-isa-level-3-or-above = 3 4"
 config_vars="$config_vars
 enable-x86-isa-level = $libc_cv_include_x86_isa_level"
 
+
+
+saved_CC="$CC"
+CC="$TEST_CC"
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if -mfpmath=387 works in testing" >&5
+printf %s "checking if -mfpmath=387 works in testing... " >&6; }
+if test ${libc_cv_have_test_cc_cflags_mfpmath_387+y}
+then :
+  printf %s "(cached) " >&6
+else case e in #(
+  e) if { ac_try='${CC-cc} -c -Werror -mfpmath=387 -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_have_test_cc_cflags_mfpmath_387=yes
+else case e in #(
+  e) libc_cv_have_test_cc_cflags_mfpmath_387=no
+ ;;
+esac
+fi ;;
+esac
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libc_cv_have_test_cc_cflags_mfpmath_387" >&5
+printf "%s\n" "$libc_cv_have_test_cc_cflags_mfpmath_387" >&6; }
+
+CC="$saved_CC"
+
+
+config_vars="$config_vars
+have-test-cc-cflags-mfpmath-387 = $libc_cv_have_test_cc_cflags_mfpmath_387"
+
 printf "%s\n" "#define SUPPORT_STATIC_PIE 1" >>confdefs.h
 
 
index 8a259d3971488e4b86a00017a8ccde49596f81c9..031f91719d0b47655f5c483c5d4be0f7b38c13e2 100644 (file)
@@ -120,5 +120,15 @@ LIBC_CONFIG_VAR([have-x86-isa-level], [$libc_cv_have_x86_isa_level])
 LIBC_CONFIG_VAR([x86-isa-level-3-or-above], [3 4])
 LIBC_CONFIG_VAR([enable-x86-isa-level], [$libc_cv_include_x86_isa_level])
 
+dnl Check if TEST_CC supports -mfpmath=387
+LIBC_TRY_TEST_CC_OPTION([if -mfpmath=387 works],
+  [-c -Werror -mfpmath=387],
+  libc_cv_have_test_cc_cflags_mfpmath_387,
+  [libc_cv_have_test_cc_cflags_mfpmath_387=yes],
+  [libc_cv_have_test_cc_cflags_mfpmath_387=no]
+)
+LIBC_CONFIG_VAR(have-test-cc-cflags-mfpmath-387,
+               $libc_cv_have_test_cc_cflags_mfpmath_387)
+
 dnl Static PIE is supported.
 AC_DEFINE(SUPPORT_STATIC_PIE)
index 705dd9d7157a20b29f540f6e4841d7e646e8f843..91b2444f3a3fa778ded7bf03df2acb3007a9cf7d 100644 (file)
@@ -8,9 +8,11 @@ tests += \
   test-fenv-sse \
   test-fenv-sse-2 \
   test-fenv-x87 \
-  test-flt-eval-method-387 \
   test-flt-eval-method-sse \
 # tests
+ifeq ($(have-test-cc-cflags-mfpmath-387),yes)
+tests += test-flt-eval-method-387
+endif
 CFLAGS-test-fenv-sse.c += -msse2 -mfpmath=sse
 CFLAGS-test-fenv-clear-sse.c += -msse2 -mfpmath=sse
 CFLAGS-test-fenv-sse-2.c += -msse2 -mfpmath=sse