x86: Include test-flt-eval-method-387 if -mfpmath=387 works

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>
This commit is contained in:
H.J. Lu 2024-12-19 12:08:00 +08:00
parent 9151ecbb5e
commit f5fb9fa011
3 changed files with 47 additions and 1 deletions

34
sysdeps/x86/configure vendored
View 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

View 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)

View 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