aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMarius Hillenbrand <mhillen@linux.ibm.com>2020-12-04 10:38:58 +0100
committerMarius Hillenbrand <mhillen@linux.ibm.com>2020-12-17 11:47:23 +0100
commit33f925094d02ce40872d494d384d4494a4313779 (patch)
tree38dbb5b156c90f3c7b9ec9eb5ba894f3cc8a8329 /gcc
parent2f49508599f548f4b2e5f2c876be7247a1c5f8ff (diff)
downloadgcc-33f925094d02ce40872d494d384d4494a4313779.zip
gcc-33f925094d02ce40872d494d384d4494a4313779.tar.gz
gcc-33f925094d02ce40872d494d384d4494a4313779.tar.bz2
IBM Z: Detect libc's float_t behavior on cross compiles
When cross-compiling GCC with target libc headers available and configure option --enable-s390-excess-float-precision has been omitted, identify whether they clamp float_t to double or respect __FLT_EVAL_METHOD__ via a compile test that coerces the build-system compiler to use the target headers. Then derive the setting from that. gcc/ChangeLog: 2020-12-16 Marius Hillenbrand <mhillen@linux.ibm.com> * configure.ac: Change --enable-s390-excess-float-precision default behavior for cross compiles with target headers. * configure: Regenerate. * doc/install.texi: Adjust documentation.
Diffstat (limited to 'gcc')
-rwxr-xr-xgcc/configure67
-rw-r--r--gcc/configure.ac52
-rw-r--r--gcc/doc/install.texi7
3 files changed, 85 insertions, 41 deletions
diff --git a/gcc/configure b/gcc/configure
index fe649b2..fbe9208 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -31855,9 +31855,9 @@ $as_echo "$ld_pushpopstate_support" >&6; }
# gcc describes its behavior via the macro __FLT_EVAL_METHOD__ and glibc derives
# float_t from that, this behavior can be configured with
# --enable-s390-excess-float-precision. When given as enabled, that flag selects
-# the old model. When omitted, native builds will derive the flag from the
-# behavior of glibc. When glibc clamps float_t to double, gcc follows the old
-# model. In any other case, it defaults to the new model.
+# the old model. When omitted, native builds and cross compiles that have target
+# libc headers will detect whether libc clamps float_t to double and in that
+# case maintain the old model. Otherwise, they will default to the new model.
# Check whether --enable-s390-excess-float-precision was given.
if test "${enable_s390_excess_float_precision+set}" = set; then :
enableval=$enable_s390_excess_float_precision;
@@ -31868,42 +31868,63 @@ fi
case $target in
s390*-linux*)
- if test "$target" = "$host" -a "$host" = "$build" -a \
- x"$enable_s390_excess_float_precision" = xauto; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for glibc clamping float_t to double" >&5
+ if test x"$enable_s390_excess_float_precision" = xauto; then
+ # Can we autodetect the behavior of the target libc?
+ if test "$target" = "$host" -a "$host" = "$build"; then
+ enable_s390_excess_float_precision=autodetect
+ elif test "x$with_headers" != xno; then
+ # cross build. are target headers available?
+ # carefully coerce the build-system compiler to use target headers
+ saved_CXXFLAGS="$CXXFLAGS"
+ CROSS_TEST_CXXFLAGS="-nostdinc ${XGCC_FLAGS_FOR_TARGET//-B/-idirafter/}"
+ CXXFLAGS="$CROSS_TEST_CXXFLAGS"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+#include <math.h>
+
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+ enable_s390_excess_float_precision=autodetect
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ CXXFLAGS="$saved_CXXFLAGS"
+ fi
+
+ if test x"$enable_s390_excess_float_precision" = xautodetect; then
+ saved_CXXFLAGS="$CXXFLAGS"
+ if ! test "$target" = "$host" -a "$host" = "$build"; then
+ CXXFLAGS="$CROSS_TEST_CXXFLAGS"
+ unset CROSS_TEST_CXXFLAGS
+ fi
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for glibc clamping float_t to double" >&5
$as_echo_n "checking for glibc clamping float_t to double... " >&6; }
if ${gcc_cv_float_t_clamped_to_double+:} false; then :
$as_echo_n "(cached) " >&6
else
- if test "$cross_compiling" = yes; then :
- { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error $? "cannot run test program while cross compiling
-See \`config.log' for more details" "$LINENO" 5; }
-else
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#define __FLT_EVAL_METHOD__ 0
#include <math.h>
-int main() {
- return !(sizeof(float_t) == sizeof(double));
-}
+int dummy[sizeof(float_t) == sizeof(double) ? 1 : -1];
+
_ACEOF
-if ac_fn_cxx_try_run "$LINENO"; then :
+if ac_fn_cxx_try_compile "$LINENO"; then :
gcc_cv_float_t_clamped_to_double=yes
else
gcc_cv_float_t_clamped_to_double=no
fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
- conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_float_t_clamped_to_double" >&5
$as_echo "$gcc_cv_float_t_clamped_to_double" >&6; }
- if test x"$gcc_cv_float_t_clamped_to_double" = xyes; then
- enable_s390_excess_float_precision=yes
+ CXXFLAGS="$saved_CXXFLAGS"
+ enable_s390_excess_float_precision="$gcc_cv_float_t_clamped_to_double"
+ else
+ # no way to detect behavior of target libc, default to new model
+ enable_s390_excess_float_precision=no
fi
fi
diff --git a/gcc/configure.ac b/gcc/configure.ac
index 3755722..89b9981 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -7375,9 +7375,9 @@ AC_MSG_RESULT($ld_pushpopstate_support)
# gcc describes its behavior via the macro __FLT_EVAL_METHOD__ and glibc derives
# float_t from that, this behavior can be configured with
# --enable-s390-excess-float-precision. When given as enabled, that flag selects
-# the old model. When omitted, native builds will derive the flag from the
-# behavior of glibc. When glibc clamps float_t to double, gcc follows the old
-# model. In any other case, it defaults to the new model.
+# the old model. When omitted, native builds and cross compiles that have target
+# libc headers will detect whether libc clamps float_t to double and in that
+# case maintain the old model. Otherwise, they will default to the new model.
AC_ARG_ENABLE(s390-excess-float-precision,
[AS_HELP_STRING([--enable-s390-excess-float-precision],
[on s390 targets, evaluate float with double precision
@@ -7386,20 +7386,42 @@ AC_ARG_ENABLE(s390-excess-float-precision,
case $target in
s390*-linux*)
- if test "$target" = "$host" -a "$host" = "$build" -a \
- x"$enable_s390_excess_float_precision" = xauto; then
- AC_CACHE_CHECK([for glibc clamping float_t to double],
- gcc_cv_float_t_clamped_to_double,
- [AC_RUN_IFELSE([AC_LANG_SOURCE([
+ if test x"$enable_s390_excess_float_precision" = xauto; then
+ # Can we autodetect the behavior of the target libc?
+ if test "$target" = "$host" -a "$host" = "$build"; then
+ enable_s390_excess_float_precision=autodetect
+ elif test "x$with_headers" != xno; then
+ # cross build. are target headers available?
+ # carefully coerce the build-system compiler to use target headers
+ saved_CXXFLAGS="$CXXFLAGS"
+ CROSS_TEST_CXXFLAGS="-nostdinc ${XGCC_FLAGS_FOR_TARGET//-B/-idirafter/}"
+ CXXFLAGS="$CROSS_TEST_CXXFLAGS"
+ AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
+#include <math.h>
+]])], [enable_s390_excess_float_precision=autodetect], [])
+ CXXFLAGS="$saved_CXXFLAGS"
+ fi
+
+ if test x"$enable_s390_excess_float_precision" = xautodetect; then
+ saved_CXXFLAGS="$CXXFLAGS"
+ if ! test "$target" = "$host" -a "$host" = "$build"; then
+ CXXFLAGS="$CROSS_TEST_CXXFLAGS"
+ unset CROSS_TEST_CXXFLAGS
+ fi
+ AC_CACHE_CHECK([for glibc clamping float_t to double],
+ gcc_cv_float_t_clamped_to_double, [
+ AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
#define __FLT_EVAL_METHOD__ 0
#include <math.h>
-int main() {
- return !(sizeof(float_t) == sizeof(double));
-}])],
- [gcc_cv_float_t_clamped_to_double=yes],
- [gcc_cv_float_t_clamped_to_double=no])])
- if test x"$gcc_cv_float_t_clamped_to_double" = xyes; then
- enable_s390_excess_float_precision=yes
+int dummy[sizeof(float_t) == sizeof(double) ? 1 : -1];
+]])],
+ [gcc_cv_float_t_clamped_to_double=yes],
+ [gcc_cv_float_t_clamped_to_double=no])])
+ CXXFLAGS="$saved_CXXFLAGS"
+ enable_s390_excess_float_precision="$gcc_cv_float_t_clamped_to_double"
+ else
+ # no way to detect behavior of target libc, default to new model
+ enable_s390_excess_float_precision=no
fi
fi
diff --git a/gcc/doc/install.texi b/gcc/doc/install.texi
index a38ca3e..e30d2fc 100644
--- a/gcc/doc/install.texi
+++ b/gcc/doc/install.texi
@@ -2277,9 +2277,10 @@ On s390(x) targets, enable treatment of float expressions with double precision
when in standards-compliant mode (e.g., when @code{--std=c99} or
@code{-fexcess-precision=standard} are given).
-For a native build, the option's default is derived from glibc's behavior. When
-glibc clamps float_t to double, gcc follows and enables the option. In all other
-cases, it defaults to off.
+For a native build and cross compiles that have target headers, the option's
+default is derived from glibc's behavior. When glibc clamps float_t to double,
+GCC follows and enables the option. For other cross compiles, the default is
+disabled.
@end table
@subheading Cross-Compiler-Specific Options