about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>2022-03-24 15:02:05 -0300
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>2024-04-17 16:12:40 -0300
commit942eea75573c400fb9d9c51f7cbcbdf38b603fe2 (patch)
tree9169f744531521e5b0fc81708db8dcf9930e5e99
parent22997a0a53a8d400bf0e62019f14f633383437a5 (diff)
downloadglibc-942eea75573c400fb9d9c51f7cbcbdf38b603fe2.tar.gz
glibc-942eea75573c400fb9d9c51f7cbcbdf38b603fe2.tar.xz
glibc-942eea75573c400fb9d9c51f7cbcbdf38b603fe2.zip
x86: Use -mfpmath=387 iff compiler supports it
-rw-r--r--sysdeps/x86/configure24
-rw-r--r--sysdeps/x86/configure.ac10
-rw-r--r--sysdeps/x86/fpu/Makefile5
3 files changed, 38 insertions, 1 deletions
diff --git a/sysdeps/x86/configure b/sysdeps/x86/configure
index 2a5421bb31..01f0285222 100644
--- a/sysdeps/x86/configure
+++ b/sysdeps/x86/configure
@@ -158,6 +158,30 @@ x86-isa-level-3-or-above = 3 4"
 config_vars="$config_vars
 enable-x86-isa-level = $libc_cv_include_x86_isa_level"
 
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if compiler supports -mpfmath=387" >&5
+printf %s "checking if compiler supports -mpfmath=387... " >&6; }
+if test ${libc_cv_cc_mfpmath_387+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  if { ac_try='${CC-cc} -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_cc_mfpmath_387="-mfpmath=387"
+else $as_nop
+  libc_cv_cc_mfpmath_387=
+fi
+
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libc_cv_cc_mfpmath_387" >&5
+printf "%s\n" "$libc_cv_cc_mfpmath_387" >&6; }
+config_vars="$config_vars
+config-cflags-mfpath-387 = $libc_cv_cc_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 78ff7c8f41..26aad5d648 100644
--- a/sysdeps/x86/configure.ac
+++ b/sysdeps/x86/configure.ac
@@ -109,5 +109,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 Determine if compiler supports -mfpmath=387
+AC_CACHE_CHECK([if compiler supports -mpfmath=387],
+	       libc_cv_cc_mfpmath_387, [dnl
+LIBC_TRY_CC_OPTION([-Werror -mfpmath=387],
+		   [libc_cv_cc_mfpmath_387="-mfpmath=387"],
+		   [libc_cv_cc_mfpmath_387=])
+])
+LIBC_CONFIG_VAR([config-cflags-mfpath-387],
+		[$libc_cv_cc_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 68bd42cdd3..2d584dbfeb 100644
--- a/sysdeps/x86/fpu/Makefile
+++ b/sysdeps/x86/fpu/Makefile
@@ -4,7 +4,10 @@ CPPFLAGS += -I../soft-fp
 
 libm-support += powl_helper
 tests += test-fenv-sse test-fenv-clear-sse test-fenv-x87 test-fenv-sse-2 \
-	 test-flt-eval-method-387 test-flt-eval-method-sse
+	 test-flt-eval-method-sse
+ifneq ($(config-cflags-mfpath-387),)
+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