--- a/make/autoconf/flags-cflags.m4 Mon Sep 17 11:49:20 2018 +0200
+++ b/make/autoconf/flags-cflags.m4 Mon Sep 17 10:53:56 2018 +0200
@@ -373,6 +373,20 @@
FLAGS_SETUP_CFLAGS_CPU_DEP([BUILD], [OPENJDK_BUILD_])
+ COMPILER_FP_CONTRACT_OFF_FLAG="-ffp-contract=off"
+ # Check that the compiler supports -ffp-contract=off flag
+ # Set FDLIBM_CFLAGS to -ffp-contract=off if it does. Empty
+ # otherwise.
+ # These flags are required for GCC-based builds of
+ # fdlibm with optimization without losing precision.
+ # Notably, -ffp-contract=off needs to be added for GCC >= 4.6.
+ if test "x$TOOLCHAIN_TYPE" = xgcc || test "x$TOOLCHAIN_TYPE" = xclang; then
+ FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [${COMPILER_FP_CONTRACT_OFF_FLAG}],
+ IF_TRUE: [FDLIBM_CFLAGS=${COMPILER_FP_CONTRACT_OFF_FLAG}],
+ IF_FALSE: [FDLIBM_CFLAGS=""])
+ fi
+ AC_SUBST(FDLIBM_CFLAGS)
+
# Tests are only ever compiled for TARGET
CFLAGS_TESTLIB="$CFLAGS_JDKLIB"
CXXFLAGS_TESTLIB="$CXXFLAGS_JDKLIB"