[PATCH 08/39] x86: Include test-flt-eval-method-387 if -mfpmath=387 works

Sam James sam@gentoo.org
Sun Dec 22 02:47:08 GMT 2024


"H.J. Lu" <hjl.tools@gmail.com> writes:

> On x86, include test-flt-eval-method-387 only if -mfpmath=387 works.

The commit message should mention why (Clang not supporting it), OK with
that fixed.

Reviewed-by: Sam James <sam@gentoo.org>

>
> Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
> ---
>  sysdeps/x86/configure    | 34 ++++++++++++++++++++++++++++++++++
>  sysdeps/x86/configure.ac | 10 ++++++++++
>  sysdeps/x86/fpu/Makefile |  4 +++-
>  3 files changed, 47 insertions(+), 1 deletion(-)
>
> diff --git a/sysdeps/x86/configure b/sysdeps/x86/configure
> index a6d37778d1..c7ea9ac6ad 100644
> --- a/sysdeps/x86/configure
> +++ b/sysdeps/x86/configure
> @@ -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
>  
>  
> diff --git a/sysdeps/x86/configure.ac b/sysdeps/x86/configure.ac
> index 8a259d3971..031f91719d 100644
> --- a/sysdeps/x86/configure.ac
> +++ b/sysdeps/x86/configure.ac
> @@ -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)
> diff --git a/sysdeps/x86/fpu/Makefile b/sysdeps/x86/fpu/Makefile
> index 705dd9d715..91b2444f3a 100644
> --- a/sysdeps/x86/fpu/Makefile
> +++ b/sysdeps/x86/fpu/Makefile
> @@ -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


More information about the Libc-alpha mailing list