common/autoconf/flags.m4

changeset 2424
3a2c8d0a600d
parent 2401
7d134528324e
child 2445
ef88239d3d16
     1.1 --- a/common/autoconf/flags.m4	Wed May 01 06:16:32 2019 +0100
     1.2 +++ b/common/autoconf/flags.m4	Mon Apr 29 14:23:21 2019 +0200
     1.3 @@ -450,6 +450,7 @@
     1.4    # Later we will also have CFLAGS and LDFLAGS for the hotspot subrepo build.
     1.5    #
     1.6  
     1.7 +  FDLIBM_CFLAGS=""
     1.8    # Setup compiler/platform specific flags to CFLAGS_JDK,
     1.9    # CXXFLAGS_JDK and CCXXFLAGS_JDK (common to C and CXX?)
    1.10    if test "x$TOOLCHAIN_TYPE" = xgcc; then
    1.11 @@ -474,6 +475,37 @@
    1.12          ;;
    1.13      esac
    1.14      TOOLCHAIN_CHECK_COMPILER_VERSION(6, FLAGS_SETUP_GCC6_COMPILER_FLAGS)
    1.15 +
    1.16 +    # Check that the compiler supports -ffp-contract=off flag
    1.17 +    # Set FDLIBM_CFLAGS to -ffp-contract=off if it does.
    1.18 +    # For GCC < 4.6, on x86, x86_64 and ppc check for
    1.19 +    # -mno-fused-madd and -fno-strict-aliasing. If they exist,
    1.20 +    # use them as a substitute for -ffp-contract=off.
    1.21 +    #
    1.22 +    # These flags are required for GCC-based builds of
    1.23 +    # fdlibm with optimization without losing precision.
    1.24 +    # Notably, -ffp-contract=off needs to be added for GCC >= 4.6,
    1.25 +    #          -mno-fused-madd -fno-strict-aliasing for GCC < 4.6
    1.26 +    COMPILER_FP_CONTRACT_OFF_FLAG="-ffp-contract=off"
    1.27 +    FLAGS_CXX_COMPILER_CHECK_ARGUMENTS([[$]COMPILER_FP_CONTRACT_OFF_FLAG -Werror],
    1.28 +                                       [], [COMPILER_FP_CONTRACT_OFF_FLAG=""])
    1.29 +    if test "x$COMPILER_FP_CONTRACT_OFF_FLAG" = x; then
    1.30 +      if test "$OPENJDK_TARGET_CPU_ARCH" = "x86" ||
    1.31 +         test "$OPENJDK_TARGET_CPU_ARCH" = "x86_64" ||
    1.32 +         test "$OPENJDK_TARGET_CPU_ARCH" = "ppc"; then
    1.33 +        M_NO_FUSED_ADD_FLAG="-mno-fused-madd"
    1.34 +        FLAGS_CXX_COMPILER_CHECK_ARGUMENTS([[$]M_NO_FUSED_ADD_FLAG -Werror],
    1.35 +                                           [], [M_NO_FUSED_ADD_FLAG=""])
    1.36 +        NO_STRICT_ALIASING_FLAG="-fno-strict-aliasing"
    1.37 +        FLAGS_CXX_COMPILER_CHECK_ARGUMENTS([[$]NO_STRICT_ALIASING_FLAG -Werror],
    1.38 +                                           [], [NO_STRICT_ALIASING_FLAG=""])
    1.39 +        if test "x$M_NO_FUSED_ADD_FLAG" != "x" && test "x$NO_STRICT_ALIASING_FLAG" != "x"; then
    1.40 +          FDLIBM_CFLAGS="$M_NO_FUSED_ADD_FLAG $NO_STRICT_ALIASING_FLAG"
    1.41 +        fi
    1.42 +      fi
    1.43 +    else
    1.44 +      FDLIBM_CFLAGS="$COMPILER_FP_CONTRACT_OFF_FLAG"
    1.45 +    fi
    1.46    elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
    1.47      CCXXFLAGS_JDK="$CCXXFLAGS $CCXXFLAGS_JDK -DTRACING -DMACRO_MEMSYS_OPS -DBREAKPTS"
    1.48      if test "x$OPENJDK_TARGET_CPU_ARCH" = xx86; then
    1.49 @@ -505,6 +537,7 @@
    1.50            -D_STATIC_CPPLIB -D_DISABLE_DEPRECATE_STATIC_CPPLIB"
    1.51      fi
    1.52    fi
    1.53 +  AC_SUBST(FDLIBM_CFLAGS)
    1.54  
    1.55    ###############################################################################
    1.56  

mercurial