1 #
   2 # Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
   3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4 #
   5 # This code is free software; you can redistribute it and/or modify it
   6 # under the terms of the GNU General Public License version 2 only, as
   7 # published by the Free Software Foundation.  Oracle designates this
   8 # particular file as subject to the "Classpath" exception as provided
   9 # by Oracle in the LICENSE file that accompanied this code.
  10 #
  11 # This code is distributed in the hope that it will be useful, but WITHOUT
  12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13 # FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14 # version 2 for more details (a copy is included in the LICENSE file that
  15 # accompanied this code).
  16 #
  17 # You should have received a copy of the GNU General Public License version
  18 # 2 along with this work; if not, write to the Free Software Foundation,
  19 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20 #
  21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22 # or visit www.oracle.com if you need additional information or have any
  23 # questions.
  24 #
  25 
  26 ################################################################################
  27 #
  28 # Setup flags for C/C++ compiler
  29 #
  30 
  31 ###############################################################################
  32 #
  33 # How to compile shared libraries.
  34 #
  35 AC_DEFUN([FLAGS_SETUP_SHARED_LIBS],
  36 [
  37   if test "x$TOOLCHAIN_TYPE" = xgcc; then
  38     C_FLAG_REORDER=''
  39 
  40     # Default works for linux, might work on other platforms as well.
  41     SHARED_LIBRARY_FLAGS='-shared'
  42     SET_EXECUTABLE_ORIGIN='-Wl,-rpath,\$$ORIGIN[$]1'
  43     SET_SHARED_LIBRARY_ORIGIN="-Wl,-z,origin $SET_EXECUTABLE_ORIGIN"
  44     SET_SHARED_LIBRARY_NAME='-Wl,-soname=[$]1'
  45     SET_SHARED_LIBRARY_MAPFILE='-Wl,-version-script=[$]1'
  46 
  47   elif test "x$TOOLCHAIN_TYPE" = xclang; then
  48     C_FLAG_REORDER=''
  49 
  50     if test "x$OPENJDK_TARGET_OS" = xmacosx; then
  51       # Linking is different on MacOSX
  52       SHARED_LIBRARY_FLAGS="-dynamiclib -compatibility_version 1.0.0 -current_version 1.0.0"
  53       SET_EXECUTABLE_ORIGIN='-Wl,-rpath,@loader_path$(or [$]1,/.)'
  54       SET_SHARED_LIBRARY_ORIGIN="$SET_EXECUTABLE_ORIGIN"
  55       SET_SHARED_LIBRARY_NAME='-Wl,-install_name,@rpath/[$]1'
  56       SET_SHARED_LIBRARY_MAPFILE='-Wl,-exported_symbols_list,[$]1'
  57 
  58     else
  59       # Default works for linux, might work on other platforms as well.
  60       SHARED_LIBRARY_FLAGS='-shared'
  61       SET_EXECUTABLE_ORIGIN='-Wl,-rpath,\$$ORIGIN[$]1'
  62       SET_SHARED_LIBRARY_NAME='-Wl,-soname=[$]1'
  63       SET_SHARED_LIBRARY_MAPFILE='-Wl,-version-script=[$]1'
  64 
  65       # arm specific settings
  66       if test "x$OPENJDK_TARGET_CPU" = "xarm"; then
  67         # '-Wl,-z,origin' isn't used on arm.
  68         SET_SHARED_LIBRARY_ORIGIN='-Wl,-rpath,\$$$$ORIGIN[$]1'
  69       else
  70         SET_SHARED_LIBRARY_ORIGIN="-Wl,-z,origin $SET_EXECUTABLE_ORIGIN"
  71       fi
  72     fi
  73 
  74   elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
  75     C_FLAG_REORDER='-xF'
  76     SHARED_LIBRARY_FLAGS="-G"
  77     SET_EXECUTABLE_ORIGIN='-R\$$ORIGIN[$]1'
  78     SET_SHARED_LIBRARY_ORIGIN="$SET_EXECUTABLE_ORIGIN"
  79     SET_SHARED_LIBRARY_NAME='-h [$]1'
  80     SET_SHARED_LIBRARY_MAPFILE='-M[$]1'
  81 
  82   elif test "x$TOOLCHAIN_TYPE" = xxlc; then
  83     C_FLAG_REORDER=''
  84     SHARED_LIBRARY_FLAGS="-qmkshrobj -bM:SRE -bnoentry"
  85     SET_EXECUTABLE_ORIGIN=""
  86     SET_SHARED_LIBRARY_ORIGIN=''
  87     SET_SHARED_LIBRARY_NAME=''
  88     SET_SHARED_LIBRARY_MAPFILE=''
  89 
  90   elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
  91     C_FLAG_REORDER=''
  92     SHARED_LIBRARY_FLAGS="-dll"
  93     SET_EXECUTABLE_ORIGIN=''
  94     SET_SHARED_LIBRARY_ORIGIN=''
  95     SET_SHARED_LIBRARY_NAME=''
  96     SET_SHARED_LIBRARY_MAPFILE='-def:[$]1'
  97   fi
  98 
  99   AC_SUBST(C_FLAG_REORDER)
 100   AC_SUBST(SET_EXECUTABLE_ORIGIN)
 101   AC_SUBST(SET_SHARED_LIBRARY_ORIGIN)
 102   AC_SUBST(SET_SHARED_LIBRARY_NAME)
 103   AC_SUBST(SET_SHARED_LIBRARY_MAPFILE)
 104   AC_SUBST(SHARED_LIBRARY_FLAGS)
 105 ])
 106 
 107 AC_DEFUN([FLAGS_SETUP_DEBUG_SYMBOLS],
 108 [
 109   # By default don't set any specific assembler debug
 110   # info flags for toolchains unless we know they work.
 111   # See JDK-8207057.
 112   ASFLAGS_DEBUG_SYMBOLS=""
 113   # Debug symbols
 114   if test "x$TOOLCHAIN_TYPE" = xgcc; then
 115     CFLAGS_DEBUG_SYMBOLS="-g"
 116     ASFLAGS_DEBUG_SYMBOLS="-g"
 117   elif test "x$TOOLCHAIN_TYPE" = xclang; then
 118     CFLAGS_DEBUG_SYMBOLS="-g"
 119     ASFLAGS_DEBUG_SYMBOLS="-g"
 120   elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
 121     # -g0 enables debug symbols without disabling inlining.
 122     CFLAGS_DEBUG_SYMBOLS="-g0 -xs"
 123   elif test "x$TOOLCHAIN_TYPE" = xxlc; then
 124     CFLAGS_DEBUG_SYMBOLS="-g"
 125   elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
 126     CFLAGS_DEBUG_SYMBOLS="-Z7 -d2Zi+"
 127   fi
 128 
 129   AC_SUBST(CFLAGS_DEBUG_SYMBOLS)
 130   AC_SUBST(ASFLAGS_DEBUG_SYMBOLS)
 131 ])
 132 
 133 AC_DEFUN([FLAGS_SETUP_WARNINGS],
 134 [
 135   AC_ARG_ENABLE([warnings-as-errors], [AS_HELP_STRING([--disable-warnings-as-errors],
 136       [do not consider native warnings to be an error @<:@enabled@:>@])])
 137 
 138   # Set default value.
 139   if test "x$TOOLCHAIN_TYPE" = xxlc; then
 140     WARNINGS_AS_ERRORS=false
 141   else
 142     WARNINGS_AS_ERRORS=true
 143   fi
 144 
 145   AC_MSG_CHECKING([if native warnings are errors])
 146   if test "x$enable_warnings_as_errors" = "xyes"; then
 147     AC_MSG_RESULT([yes (explicitly set)])
 148     WARNINGS_AS_ERRORS=true
 149   elif test "x$enable_warnings_as_errors" = "xno"; then
 150     AC_MSG_RESULT([no (explicitly set)])
 151     WARNINGS_AS_ERRORS=false
 152   elif test "x$enable_warnings_as_errors" = "x"; then
 153     AC_MSG_RESULT([${WARNINGS_AS_ERRORS} (default)])
 154   else
 155     AC_MSG_ERROR([--enable-warnings-as-errors accepts no argument])
 156   fi
 157 
 158   AC_SUBST(WARNINGS_AS_ERRORS)
 159 
 160   case "${TOOLCHAIN_TYPE}" in
 161     microsoft)
 162       DISABLE_WARNING_PREFIX="-wd"
 163       CFLAGS_WARNINGS_ARE_ERRORS="-WX"
 164       ;;
 165     solstudio)
 166       DISABLE_WARNING_PREFIX="-erroff="
 167       CFLAGS_WARNINGS_ARE_ERRORS="-errtags -errwarn=%all"
 168       ;;
 169     gcc)
 170       DISABLE_WARNING_PREFIX="-Wno-"
 171       CFLAGS_WARNINGS_ARE_ERRORS="-Werror"
 172       # Repeate the check for the BUILD_CC and BUILD_CXX. Need to also reset
 173       # CFLAGS since any target specific flags will likely not work with the
 174       # build compiler
 175       CC_OLD="$CC"
 176       CXX_OLD="$CXX"
 177       CC="$BUILD_CC"
 178       CXX="$BUILD_CXX"
 179       CFLAGS_OLD="$CFLAGS"
 180       CFLAGS=""
 181       BUILD_CC_DISABLE_WARNING_PREFIX="-Wno-"
 182       CC="$CC_OLD"
 183       CXX="$CXX_OLD"
 184       CFLAGS="$CFLAGS_OLD"
 185       ;;
 186     clang)
 187       DISABLE_WARNING_PREFIX="-Wno-"
 188       CFLAGS_WARNINGS_ARE_ERRORS="-Werror"
 189       ;;
 190     xlc)
 191       DISABLE_WARNING_PREFIX="-qsuppress="
 192       CFLAGS_WARNINGS_ARE_ERRORS="-qhalt=w"
 193       ;;
 194   esac
 195   AC_SUBST(DISABLE_WARNING_PREFIX)
 196   AC_SUBST(BUILD_CC_DISABLE_WARNING_PREFIX)
 197   AC_SUBST(CFLAGS_WARNINGS_ARE_ERRORS)
 198 ])
 199 
 200 AC_DEFUN([FLAGS_SETUP_QUALITY_CHECKS],
 201 [
 202   # bounds, memory and behavior checking options
 203   if test "x$TOOLCHAIN_TYPE" = xgcc; then
 204     case $DEBUG_LEVEL in
 205     release )
 206       # no adjustment
 207       ;;
 208     fastdebug )
 209       # no adjustment
 210       ;;
 211     slowdebug )
 212       # FIXME: By adding this to C(XX)FLAGS_DEBUG_OPTIONS/JVM_CFLAGS_SYMBOLS it
 213       # get's added conditionally on whether we produce debug symbols or not.
 214       # This is most likely not really correct.
 215 
 216       # Add runtime stack smashing and undefined behavior checks.
 217       CFLAGS_DEBUG_OPTIONS="-fstack-protector-all --param ssp-buffer-size=1"
 218       CXXFLAGS_DEBUG_OPTIONS="-fstack-protector-all --param ssp-buffer-size=1"
 219 
 220       JVM_CFLAGS_SYMBOLS="$JVM_CFLAGS_SYMBOLS -fstack-protector-all --param ssp-buffer-size=1"
 221       ;;
 222     esac
 223   fi
 224 ])
 225 
 226 AC_DEFUN([FLAGS_SETUP_OPTIMIZATION],
 227 [
 228   if test "x$TOOLCHAIN_TYPE" = xsolstudio; then
 229     CC_HIGHEST="-fns -fsimple -fsingle -xbuiltin=%all -xdepend -xrestrict -xlibmil"
 230 
 231     C_O_FLAG_HIGHEST_JVM="-xO4"
 232     C_O_FLAG_DEBUG_JVM=""
 233     C_O_FLAG_SIZE=""
 234     C_O_FLAG_DEBUG=""
 235     C_O_FLAG_NONE=""
 236     if test "x$OPENJDK_TARGET_CPU_ARCH" = "xx86"; then
 237       C_O_FLAG_HIGHEST="-xO4 -Wu,-O4~yz $CC_HIGHEST"
 238       C_O_FLAG_HI="-xO4 -Wu,-O4~yz"
 239       C_O_FLAG_NORM="-xO2 -Wu,-O2~yz"
 240     elif test "x$OPENJDK_TARGET_CPU_ARCH" = "xsparc"; then
 241       C_O_FLAG_HIGHEST="-xO4 -Wc,-Qrm-s -Wc,-Qiselect-T0 \
 242           -xprefetch=auto,explicit $CC_HIGHEST"
 243       C_O_FLAG_HI="-xO4 -Wc,-Qrm-s -Wc,-Qiselect-T0"
 244       C_O_FLAG_NORM="-xO2 -Wc,-Qrm-s -Wc,-Qiselect-T0"
 245     fi
 246   elif test "x$TOOLCHAIN_TYPE" = xgcc; then
 247     C_O_FLAG_HIGHEST_JVM="-O3"
 248     C_O_FLAG_HIGHEST="-O3"
 249     C_O_FLAG_HI="-O3"
 250     C_O_FLAG_NORM="-O2"
 251     C_O_FLAG_SIZE="-Os"
 252     C_O_FLAG_DEBUG="-O0"
 253     C_O_FLAG_DEBUG_JVM="-O0"
 254     C_O_FLAG_NONE="-O0"
 255   elif test "x$TOOLCHAIN_TYPE" = xclang; then
 256     if test "x$OPENJDK_TARGET_OS" = xmacosx; then
 257       # On MacOSX we optimize for size, something
 258       # we should do for all platforms?
 259       C_O_FLAG_HIGHEST_JVM="-Os"
 260       C_O_FLAG_HIGHEST="-Os"
 261       C_O_FLAG_HI="-Os"
 262       C_O_FLAG_NORM="-Os"
 263       C_O_FLAG_DEBUG_JVM=""
 264     else
 265       C_O_FLAG_HIGHEST_JVM="-O3"
 266       C_O_FLAG_HIGHEST="-O3"
 267       C_O_FLAG_HI="-O3"
 268       C_O_FLAG_NORM="-O2"
 269       C_O_FLAG_DEBUG_JVM="-O0"
 270     fi
 271     C_O_FLAG_SIZE="-Os"
 272     C_O_FLAG_DEBUG="-O0"
 273     C_O_FLAG_NONE="-O0"
 274   elif test "x$TOOLCHAIN_TYPE" = xxlc; then
 275     C_O_FLAG_HIGHEST_JVM="-O3 -qhot=level=1 -qinline -qinlglue"
 276     C_O_FLAG_HIGHEST="-O3 -qhot=level=1 -qinline -qinlglue"
 277     C_O_FLAG_HI="-O3 -qinline -qinlglue"
 278     C_O_FLAG_NORM="-O2"
 279     C_O_FLAG_DEBUG="-qnoopt"
 280     # FIXME: Value below not verified.
 281     C_O_FLAG_DEBUG_JVM=""
 282     C_O_FLAG_NONE="-qnoopt"
 283   elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
 284     C_O_FLAG_HIGHEST_JVM="-O2 -Oy-"
 285     C_O_FLAG_HIGHEST="-O2"
 286     C_O_FLAG_HI="-O1"
 287     C_O_FLAG_NORM="-O1"
 288     C_O_FLAG_DEBUG="-Od"
 289     C_O_FLAG_DEBUG_JVM=""
 290     C_O_FLAG_NONE="-Od"
 291     C_O_FLAG_SIZE="-Os"
 292   fi
 293 
 294   # Now copy to C++ flags
 295   CXX_O_FLAG_HIGHEST_JVM="$C_O_FLAG_HIGHEST_JVM"
 296   CXX_O_FLAG_HIGHEST="$C_O_FLAG_HIGHEST"
 297   CXX_O_FLAG_HI="$C_O_FLAG_HI"
 298   CXX_O_FLAG_NORM="$C_O_FLAG_NORM"
 299   CXX_O_FLAG_DEBUG="$C_O_FLAG_DEBUG"
 300   CXX_O_FLAG_DEBUG_JVM="$C_O_FLAG_DEBUG_JVM"
 301   CXX_O_FLAG_NONE="$C_O_FLAG_NONE"
 302   CXX_O_FLAG_SIZE="$C_O_FLAG_SIZE"
 303 
 304   if test "x$TOOLCHAIN_TYPE" = xsolstudio; then
 305     # In solstudio, also add this to C (but not C++) flags...
 306     C_O_FLAG_HIGHEST="$C_O_FLAG_HIGHEST -xalias_level=basic"
 307   fi
 308 
 309   # Adjust optimization flags according to debug level.
 310   case $DEBUG_LEVEL in
 311     release )
 312       # no adjustment
 313       ;;
 314     fastdebug )
 315       # Not quite so much optimization
 316       C_O_FLAG_HI="$C_O_FLAG_NORM"
 317       CXX_O_FLAG_HI="$CXX_O_FLAG_NORM"
 318       ;;
 319     slowdebug )
 320       # Disable optimization
 321       C_O_FLAG_HIGHEST_JVM="$C_O_FLAG_DEBUG_JVM"
 322       C_O_FLAG_HIGHEST="$C_O_FLAG_DEBUG"
 323       C_O_FLAG_HI="$C_O_FLAG_DEBUG"
 324       C_O_FLAG_NORM="$C_O_FLAG_DEBUG"
 325       C_O_FLAG_SIZE="$C_O_FLAG_DEBUG"
 326       CXX_O_FLAG_HIGHEST_JVM="$CXX_O_FLAG_DEBUG_JVM"
 327       CXX_O_FLAG_HIGHEST="$CXX_O_FLAG_DEBUG"
 328       CXX_O_FLAG_HI="$CXX_O_FLAG_DEBUG"
 329       CXX_O_FLAG_NORM="$CXX_O_FLAG_DEBUG"
 330       CXX_O_FLAG_SIZE="$CXX_O_FLAG_DEBUG"
 331       ;;
 332   esac
 333 
 334   AC_SUBST(C_O_FLAG_HIGHEST_JVM)
 335   AC_SUBST(C_O_FLAG_HIGHEST)
 336   AC_SUBST(C_O_FLAG_HI)
 337   AC_SUBST(C_O_FLAG_NORM)
 338   AC_SUBST(C_O_FLAG_NONE)
 339   AC_SUBST(C_O_FLAG_SIZE)
 340   AC_SUBST(CXX_O_FLAG_HIGHEST_JVM)
 341   AC_SUBST(CXX_O_FLAG_HIGHEST)
 342   AC_SUBST(CXX_O_FLAG_HI)
 343   AC_SUBST(CXX_O_FLAG_NORM)
 344   AC_SUBST(CXX_O_FLAG_NONE)
 345   AC_SUBST(CXX_O_FLAG_SIZE)
 346 ])
 347 
 348 AC_DEFUN([FLAGS_SETUP_CFLAGS],
 349 [
 350   ### CFLAGS
 351 
 352   FLAGS_SETUP_CFLAGS_HELPER
 353 
 354   FLAGS_OS=$OPENJDK_TARGET_OS
 355   FLAGS_OS_TYPE=$OPENJDK_TARGET_OS_TYPE
 356   FLAGS_CPU=$OPENJDK_TARGET_CPU
 357   FLAGS_CPU_ARCH=$OPENJDK_TARGET_CPU_ARCH
 358   FLAGS_CPU_BITS=$OPENJDK_TARGET_CPU_BITS
 359   FLAGS_CPU_ENDIAN=$OPENJDK_TARGET_CPU_ENDIAN
 360   FLAGS_CPU_LEGACY=$OPENJDK_TARGET_CPU_LEGACY
 361   FLAGS_CPU_LEGACY_LIB=$OPENJDK_TARGET_CPU_LEGACY_LIB
 362 
 363   FLAGS_SETUP_CFLAGS_CPU_DEP([TARGET])
 364 
 365   FLAGS_OS=$OPENJDK_BUILD_OS
 366   FLAGS_OS_TYPE=$OPENJDK_BUILD_OS_TYPE
 367   FLAGS_CPU=$OPENJDK_BUILD_CPU
 368   FLAGS_CPU_ARCH=$OPENJDK_BUILD_CPU_ARCH
 369   FLAGS_CPU_BITS=$OPENJDK_BUILD_CPU_BITS
 370   FLAGS_CPU_ENDIAN=$OPENJDK_BUILD_CPU_ENDIAN
 371   FLAGS_CPU_LEGACY=$OPENJDK_BUILD_CPU_LEGACY
 372   FLAGS_CPU_LEGACY_LIB=$OPENJDK_BUILD_CPU_LEGACY_LIB
 373 
 374   FLAGS_SETUP_CFLAGS_CPU_DEP([BUILD], [OPENJDK_BUILD_])
 375 
 376   COMPILER_FP_CONTRACT_OFF_FLAG="-ffp-contract=off"
 377   # Check that the compiler supports -ffp-contract=off flag
 378   # Set FDLIBM_CFLAGS to -ffp-contract=off if it does. Empty
 379   # otherwise.
 380   # These flags are required for GCC-based builds of
 381   # fdlibm with optimization without losing precision.
 382   # Notably, -ffp-contract=off needs to be added for GCC >= 4.6.
 383   if test "x$TOOLCHAIN_TYPE" = xgcc || test "x$TOOLCHAIN_TYPE" = xclang; then
 384     FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [${COMPILER_FP_CONTRACT_OFF_FLAG}],
 385         IF_TRUE: [FDLIBM_CFLAGS=${COMPILER_FP_CONTRACT_OFF_FLAG}],
 386         IF_FALSE: [FDLIBM_CFLAGS=""])
 387   fi
 388   AC_SUBST(FDLIBM_CFLAGS)
 389 
 390   # Tests are only ever compiled for TARGET
 391   CFLAGS_TESTLIB="$CFLAGS_JDKLIB"
 392   CXXFLAGS_TESTLIB="$CXXFLAGS_JDKLIB"
 393   CFLAGS_TESTEXE="$CFLAGS_JDKEXE"
 394   CXXFLAGS_TESTEXE="$CXXFLAGS_JDKEXE"
 395 
 396   AC_SUBST(CFLAGS_TESTLIB)
 397   AC_SUBST(CFLAGS_TESTEXE)
 398   AC_SUBST(CXXFLAGS_TESTLIB)
 399   AC_SUBST(CXXFLAGS_TESTEXE)
 400 ])
 401 
 402 ################################################################################
 403 # platform independent
 404 AC_DEFUN([FLAGS_SETUP_CFLAGS_HELPER],
 405 [
 406   #### OS DEFINES, these should be independent on toolchain
 407   if test "x$OPENJDK_TARGET_OS" = xlinux; then
 408     CFLAGS_OS_DEF_JVM="-DLINUX"
 409     CFLAGS_OS_DEF_JDK="-D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE"
 410   elif test "x$OPENJDK_TARGET_OS" = xsolaris; then
 411     CFLAGS_OS_DEF_JVM="-DSOLARIS"
 412     CFLAGS_OS_DEF_JDK="-D__solaris__"
 413   elif test "x$OPENJDK_TARGET_OS" = xmacosx; then
 414     CFLAGS_OS_DEF_JVM="-D_ALLBSD_SOURCE -D_DARWIN_C_SOURCE -D_XOPEN_SOURCE"
 415     CFLAGS_OS_DEF_JDK="-D_ALLBSD_SOURCE -D_DARWIN_UNLIMITED_SELECT"
 416   elif test "x$OPENJDK_TARGET_OS" = xaix; then
 417     CFLAGS_OS_DEF_JVM="-DAIX"
 418   elif test "x$OPENJDK_TARGET_OS" = xbsd; then
 419     CFLAGS_OS_DEF_JDK="-D_ALLBSD_SOURCE"
 420   elif test "x$OPENJDK_TARGET_OS" = xwindows; then
 421     CFLAGS_OS_DEF_JVM="-D_WINDOWS -DWIN32 -D_JNI_IMPLEMENTATION_"
 422   fi
 423 
 424   CFLAGS_OS_DEF_JDK="$CFLAGS_OS_DEF_JDK -D$OPENJDK_TARGET_OS_UPPERCASE"
 425 
 426   #### GLOBAL DEFINES
 427   # Set some common defines. These works for all compilers, but assume
 428   # -D is universally accepted.
 429 
 430   # Always enable optional macros for VM.
 431   ALWAYS_CFLAGS_JVM="-D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS"
 432 
 433   # Setup some hard coded includes
 434   ALWAYS_CFLAGS_JDK=" \
 435       -I\$(SUPPORT_OUTPUTDIR)/modules_include/java.base \
 436       -I\$(SUPPORT_OUTPUTDIR)/modules_include/java.base/\$(OPENJDK_TARGET_OS_INCLUDE_SUBDIR) \
 437       -I${TOPDIR}/src/java.base/share/native/libjava \
 438       -I${TOPDIR}/src/java.base/$OPENJDK_TARGET_OS_TYPE/native/libjava \
 439       -I${TOPDIR}/src/hotspot/share/include \
 440       -I${TOPDIR}/src/hotspot/os/${HOTSPOT_TARGET_OS_TYPE}/include"
 441 
 442   ###############################################################################
 443 
 444   # Adjust flags according to debug level.
 445   # Setup debug/release defines
 446   if test "x$DEBUG_LEVEL" = xrelease; then
 447     DEBUG_CFLAGS_JDK="-DNDEBUG"
 448     if test "x$OPENJDK_TARGET_OS" = xsolaris; then
 449       DEBUG_CFLAGS_JDK="$DEBUG_CFLAGS_JDK -DTRIMMED"
 450     fi
 451   else
 452     DEBUG_CFLAGS_JDK="-DDEBUG"
 453 
 454     if test "x$TOOLCHAIN_TYPE" = xxlc; then
 455       # We need '-qminimaltoc' or '-qpic=large -bbigtoc' if the TOC overflows.
 456       # Hotspot now overflows its 64K TOC (currently only for debug),
 457       # so for debug we build with '-qpic=large -bbigtoc'.
 458       DEBUG_CFLAGS_JVM="-qpic=large"
 459     fi
 460   fi
 461 
 462   if test "x$DEBUG_LEVEL" != xrelease; then
 463     DEBUG_OPTIONS_FLAGS_JDK="$CFLAGS_DEBUG_OPTIONS"
 464     DEBUG_SYMBOLS_CFLAGS_JDK="$CFLAGS_DEBUG_SYMBOLS"
 465   fi
 466 
 467   #### TOOLCHAIN DEFINES
 468 
 469   if test "x$TOOLCHAIN_TYPE" = xgcc; then
 470     ALWAYS_DEFINES_JVM="-D_GNU_SOURCE -D_REENTRANT"
 471   elif test "x$TOOLCHAIN_TYPE" = xclang; then
 472     ALWAYS_DEFINES_JVM="-D_GNU_SOURCE"
 473   elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
 474     ALWAYS_DEFINES_JVM="-DSPARC_WORKS -D_Crun_inline_placement"
 475     ALWAYS_DEFINES_JDK="-DTRACING -DMACRO_MEMSYS_OPS -DBREAKPTS"
 476     ALWAYS_DEFINES_JDK_CXXONLY="-DCC_NOEX"
 477   elif test "x$TOOLCHAIN_TYPE" = xxlc; then
 478     ALWAYS_DEFINES_JVM="-D_REENTRANT"
 479     ALWAYS_DEFINES_JDK="-D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE -DSTDC"
 480   elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
 481     ALWAYS_DEFINES_JDK="-DWIN32_LEAN_AND_MEAN -D_CRT_SECURE_NO_DEPRECATE \
 482         -D_CRT_NONSTDC_NO_DEPRECATE -DWIN32 -DIAL"
 483     ALWAYS_DEFINES_JVM="-DNOMINMAX -DWIN32_LEAN_AND_MEAN"
 484   fi
 485 
 486   ###############################################################################
 487   #
 488   #
 489   # CFLAGS BASIC
 490   if test "x$TOOLCHAIN_TYPE" = xgcc || test "x$TOOLCHAIN_TYPE" = xclang; then
 491     # COMMON to gcc and clang
 492     TOOLCHAIN_CFLAGS_JVM="-pipe -fno-rtti -fno-exceptions \
 493         -fvisibility=hidden -fno-strict-aliasing -fno-omit-frame-pointer"
 494   fi
 495 
 496   if test "x$TOOLCHAIN_TYPE" = xgcc; then
 497     TOOLCHAIN_CFLAGS_JVM="$TOOLCHAIN_CFLAGS_JVM -fcheck-new -fstack-protector"
 498     TOOLCHAIN_CFLAGS_JDK="-pipe -fstack-protector"
 499     # reduce lib size on s390x in link step, this needs also special compile flags
 500     if test "x$OPENJDK_TARGET_CPU" = xs390x; then
 501       TOOLCHAIN_CFLAGS_JVM="$TOOLCHAIN_CFLAGS_JVM -ffunction-sections -fdata-sections"
 502       TOOLCHAIN_CFLAGS_JDK="$TOOLCHAIN_CFLAGS_JDK -ffunction-sections -fdata-sections"
 503     fi
 504     TOOLCHAIN_CFLAGS_JDK_CONLY="-fno-strict-aliasing" # technically NOT for CXX (but since this gives *worse* performance, use no-strict-aliasing everywhere!)
 505 
 506     CXXSTD_CXXFLAG="-std=gnu++98"
 507     FLAGS_CXX_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [$CXXSTD_CXXFLAG -Werror],
 508                                                  IF_FALSE: [CXXSTD_CXXFLAG=""])
 509     TOOLCHAIN_CFLAGS_JDK_CXXONLY="$CXXSTD_CXXFLAG"
 510     TOOLCHAIN_CFLAGS_JVM="$TOOLCHAIN_CFLAGS_JVM $CXXSTD_CXXFLAG"
 511     ADLC_CXXFLAG="$CXXSTD_CXXFLAG"
 512 
 513 
 514   elif test "x$TOOLCHAIN_TYPE" = xclang; then
 515     # Restrict the debug information created by Clang to avoid
 516     # too big object files and speed the build up a little bit
 517     # (see http://llvm.org/bugs/show_bug.cgi?id=7554)
 518     TOOLCHAIN_CFLAGS_JVM="$TOOLCHAIN_CFLAGS_JVM -flimit-debug-info"
 519 
 520     # In principle the stack alignment below is cpu- and ABI-dependent and
 521     # should agree with values of StackAlignmentInBytes in various
 522     # src/hotspot/cpu/*/globalDefinitions_*.hpp files, but this value currently
 523     # works for all platforms.
 524     TOOLCHAIN_CFLAGS_JVM="$TOOLCHAIN_CFLAGS_JVM -mno-omit-leaf-frame-pointer -mstack-alignment=16"
 525 
 526     if test "x$OPENJDK_TARGET_OS" = xlinux; then
 527       TOOLCHAIN_CFLAGS_JDK="-pipe"
 528       TOOLCHAIN_CFLAGS_JDK_CONLY="-fno-strict-aliasing" # technically NOT for CXX
 529     fi
 530   elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
 531     TOOLCHAIN_CFLAGS_JDK="-mt"
 532     TOOLCHAIN_CFLAGS_JDK_CONLY="-xCC -Xa -v -W0,-noglobal" # C only
 533     TOOLCHAIN_CFLAGS_JDK_CXXONLY="-features=no%except -norunpath -xnolib" # CXX only
 534     TOOLCHAIN_CFLAGS_JVM="-template=no%extdef -features=no%split_init \
 535         -library=stlport4 -mt -features=no%except"
 536     if test "x$DEBUG_LEVEL" = xslowdebug; then
 537       # Previously -g was used instead of -g0 for slowdebug; this is equivalent
 538       # to setting +d.
 539       TOOLCHAIN_CFLAGS_JVM="$TOOLCHAIN_CFLAGS_JVM +d"
 540     fi
 541 
 542   elif test "x$TOOLCHAIN_TYPE" = xxlc; then
 543     TOOLCHAIN_CFLAGS_JDK="-qchars=signed -qfullpath -qsaveopt"  # add on both CFLAGS
 544     TOOLCHAIN_CFLAGS_JVM="-qtune=balanced \
 545         -qalias=noansi -qstrict -qtls=default -qlanglvl=c99vla \
 546         -qlanglvl=noredefmac -qnortti -qnoeh -qignerrno"
 547   elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
 548     TOOLCHAIN_CFLAGS_JVM="-nologo -MD -MP"
 549     TOOLCHAIN_CFLAGS_JDK="-nologo -MD -Zc:wchar_t-"
 550   fi
 551 
 552   # CFLAGS WARNINGS STUFF
 553   # Set JVM_CFLAGS warning handling
 554   if test "x$TOOLCHAIN_TYPE" = xgcc || test "x$TOOLCHAIN_TYPE" = xclang; then
 555     # COMMON to gcc and clang
 556     WARNING_CFLAGS_JVM="-Wpointer-arith -Wsign-compare -Wunused-function"
 557     if ! HOTSPOT_CHECK_JVM_VARIANT(zero); then
 558       # Non-zero builds have stricter warnings
 559       WARNING_CFLAGS_JVM="$WARNING_CFLAGS_JVM -Wundef -Wformat=2"
 560     fi
 561 
 562   fi
 563   if test "x$TOOLCHAIN_TYPE" = xgcc; then
 564     WARNING_CFLAGS_JDK="-Wall -Wextra -Wno-unused -Wno-unused-parameter -Wformat=2"
 565     WARNING_CFLAGS_JVM="$WARNING_CFLAGS_JVM -Wunused-value -Woverloaded-virtual"
 566 
 567     if ! HOTSPOT_CHECK_JVM_VARIANT(zero); then
 568       # Non-zero builds have stricter warnings
 569       WARNING_CFLAGS_JVM="$WARNING_CFLAGS_JVM -Wreturn-type"
 570     fi
 571   elif test "x$TOOLCHAIN_TYPE" = xclang; then
 572     WARNING_CFLAGS_JVM="$WARNING_CFLAGS_JVM -Wno-deprecated"
 573     if test "x$OPENJDK_TARGET_OS" = xlinux; then
 574       WARNING_CFLAGS_JVM="$WARNING_CFLAGS_JVM -Wno-sometimes-uninitialized"
 575       WARNING_CFLAGS_JDK="-Wall -Wextra -Wno-unused -Wno-unused-parameter -Wformat=2"
 576     fi
 577   elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
 578     WARNING_CFLAGS_JDK_CONLY="-errshort=tags"
 579     WARNING_CFLAGS_JDK_CXXONLY="+w"
 580     WARNING_CFLAGS_JDK="-errtags=yes -errfmt"
 581   elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
 582     WARNING_CFLAGS="-W3"
 583     WARNING_CFLAGS_JDK="-wd4800"
 584     WARNING_CFLAGS_JVM="-wd4800"
 585   fi
 586 
 587   # Set some additional per-OS defines.
 588 
 589   # Additional macosx handling
 590   if test "x$OPENJDK_TARGET_OS" = xmacosx; then
 591     OS_CFLAGS="-DMAC_OS_X_VERSION_MIN_REQUIRED=$MACOSX_VERSION_MIN_NODOTS \
 592         -mmacosx-version-min=$MACOSX_VERSION_MIN"
 593 
 594     if test -n "$MACOSX_VERSION_MAX"; then
 595         OS_CFLAGS="$OS_CFLAGS \
 596             -DMAC_OS_X_VERSION_MAX_ALLOWED=$MACOSX_VERSION_MAX_NODOTS"
 597     fi
 598   fi
 599 
 600   # Where does this really belong??
 601   if test "x$TOOLCHAIN_TYPE" = xgcc || test "x$TOOLCHAIN_TYPE" = xclang; then
 602     PICFLAG="-fPIC"
 603   elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
 604     PICFLAG="-KPIC"
 605   elif test "x$TOOLCHAIN_TYPE" = xxlc; then
 606     # '-qpic' defaults to 'qpic=small'. This means that the compiler generates only
 607     # one instruction for accessing the TOC. If the TOC grows larger than 64K, the linker
 608     # will have to patch this single instruction with a call to some out-of-order code which
 609     # does the load from the TOC. This is of course slower, and we also would have
 610     # to use '-bbigtoc' for linking anyway so we could also change the PICFLAG to 'qpic=large'.
 611     # With 'qpic=large' the compiler will by default generate a two-instruction sequence which
 612     # can be patched directly by the linker and does not require a jump to out-of-order code.
 613     #
 614     # Since large TOC causes perf. overhead, only pay it where we must. Currently this is
 615     # for all libjvm variants (both gtest and normal) but no other binaries. So, build
 616     # libjvm with -qpic=large and link with -bbigtoc.
 617     JVM_PICFLAG="-qpic=large"
 618     JDK_PICFLAG="-qpic"
 619   elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
 620     PICFLAG=""
 621   fi
 622 
 623   if test "x$TOOLCHAIN_TYPE" != xxlc; then
 624     JVM_PICFLAG="$PICFLAG"
 625     JDK_PICFLAG="$PICFLAG"
 626   fi
 627 
 628   if test "x$OPENJDK_TARGET_OS" = xmacosx; then
 629     # Linking is different on MacOSX
 630     JDK_PICFLAG=''
 631     if test "x$STATIC_BUILD" = xtrue; then
 632       JVM_PICFLAG=""
 633     fi
 634   fi
 635 
 636   # Optional POSIX functionality needed by the JVM
 637   #
 638   # Check if clock_gettime is available and in which library. This indicates
 639   # availability of CLOCK_MONOTONIC for hotspot. But we don't need to link, so
 640   # don't let it update LIBS.
 641   save_LIBS="$LIBS"
 642   AC_SEARCH_LIBS(clock_gettime, rt, [HAS_CLOCK_GETTIME=true], [])
 643   if test "x$LIBS" = "x-lrt "; then
 644     CLOCK_GETTIME_IN_LIBRT=true
 645   fi
 646   LIBS="$save_LIBS"
 647 
 648   if test "x$HAS_CLOCK_GETTIME" = "xtrue"; then
 649     OS_CFLAGS_JVM="$OS_CFLAGS_JVM -DSUPPORTS_CLOCK_MONOTONIC"
 650     if test "x$CLOCK_GETTIME_IN_LIBRT" = "xtrue"; then
 651       OS_CFLAGS_JVM="$OS_CFLAGS_JVM -DNEEDS_LIBRT"
 652     fi
 653   fi
 654 
 655   # EXPORT
 656   AC_SUBST(ADLC_CXXFLAG)
 657 ])
 658 
 659 ################################################################################
 660 # $1 - Either BUILD or TARGET to pick the correct OS/CPU variables to check
 661 #      conditionals against.
 662 # $2 - Optional prefix for each variable defined.
 663 AC_DEFUN([FLAGS_SETUP_CFLAGS_CPU_DEP],
 664 [
 665   #### CPU DEFINES, these should (in theory) be independent on toolchain
 666 
 667   # Setup target CPU
 668   # Setup endianness
 669   if test "x$FLAGS_CPU_ENDIAN" = xlittle; then
 670     $1_DEFINES_CPU_JVM="-DVM_LITTLE_ENDIAN"
 671   fi
 672   if test "x$TOOLCHAIN_TYPE" = xsolstudio; then
 673     # The macro _LITTLE_ENDIAN needs to be defined the same to avoid the
 674     #   Sun C compiler warning message: warning: macro redefined: _LITTLE_ENDIAN
 675     if test "x$FLAGS_CPU_ENDIAN" = xlittle; then
 676       $1_DEFINES_CPU_JDK="-D_LITTLE_ENDIAN="
 677     else
 678       $1_DEFINES_CPU_JDK="-D_BIG_ENDIAN="
 679     fi
 680   else
 681     if test "x$FLAGS_CPU_ENDIAN" = xlittle; then
 682       $1_DEFINES_CPU_JDK="-D_LITTLE_ENDIAN"
 683     else
 684       $1_DEFINES_CPU_JDK="-D_BIG_ENDIAN"
 685     fi
 686   fi
 687 
 688   # setup CPU bit size
 689   $1_DEFINES_CPU_JDK="${$1_DEFINES_CPU_JDK} -DARCH='\"$FLAGS_CPU_LEGACY\"' \
 690       -D$FLAGS_CPU_LEGACY"
 691 
 692   if test "x$FLAGS_CPU_BITS" = x64; then
 693     # -D_LP64=1 is only set on linux and mac. Setting on windows causes diff in
 694     # unpack200.exe.
 695     if test "x$FLAGS_OS" = xlinux || test "x$FLAGS_OS" = xmacosx; then
 696       $1_DEFINES_CPU_JDK="${$1_DEFINES_CPU_JDK} -D_LP64=1"
 697     fi
 698     if test "x$FLAGS_OS" != xsolaris && test "x$FLAGS_OS" != xaix; then
 699       # Solaris does not have _LP64=1 in the old build.
 700       # xlc on AIX defines _LP64=1 by default and issues a warning if we redefine it.
 701       $1_DEFINES_CPU_JVM="${$1_DEFINES_CPU_JVM} -D_LP64=1"
 702     fi
 703   fi
 704 
 705   # toolchain dependend, per-cpu
 706   if test "x$TOOLCHAIN_TYPE" = xsolstudio; then
 707     if test "x$FLAGS_CPU_ARCH" = xx86; then
 708       $1_DEFINES_CPU_JDK="${$1_DEFINES_CPU_JDK} -DcpuIntel -Di586 -D$FLAGS_CPU_LEGACY_LIB"
 709     fi
 710   elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
 711     if test "x$FLAGS_CPU" = xx86_64; then
 712       $1_DEFINES_CPU_JDK="${$1_DEFINES_CPU_JDK} -D_AMD64_ -Damd64"
 713     else
 714       $1_DEFINES_CPU_JDK="${$1_DEFINES_CPU_JDK} -D_X86_ -Dx86"
 715     fi
 716   fi
 717 
 718   # CFLAGS PER CPU
 719   if test "x$TOOLCHAIN_TYPE" = xgcc || test "x$TOOLCHAIN_TYPE" = xclang; then
 720     # COMMON to gcc and clang
 721     if test "x$FLAGS_CPU" = xx86; then
 722       # Force compatibility with i586 on 32 bit intel platforms.
 723       $1_CFLAGS_CPU="-march=i586"
 724     fi
 725   fi
 726 
 727   if test "x$TOOLCHAIN_TYPE" = xgcc; then
 728     if test "x$FLAGS_CPU" = xarm; then
 729       # -Wno-psabi to get rid of annoying "note: the mangling of 'va_list' has changed in GCC 4.4"
 730       $1_CFLAGS_CPU="-fsigned-char -Wno-psabi $ARM_ARCH_TYPE_FLAGS $ARM_FLOAT_TYPE_FLAGS -DJDK_ARCH_ABI_PROP_NAME='\"\$(JDK_ARCH_ABI_PROP_NAME)\"'"
 731       $1_CFLAGS_CPU_JVM="-DARM"
 732     elif test "x$FLAGS_CPU" = xaarch64; then
 733       if test "x$HOTSPOT_TARGET_CPU_PORT" = xarm64; then
 734         $1_CFLAGS_CPU_JVM="-fsigned-char -DARM"
 735       fi
 736     elif test "x$FLAGS_CPU_ARCH" = xppc; then
 737       $1_CFLAGS_CPU_JVM="-minsert-sched-nops=regroup_exact -mno-multiple -mno-string"
 738       if test "x$FLAGS_CPU" = xppc64; then
 739         # -mminimal-toc fixes `relocation truncated to fit' error for gcc 4.1.
 740         # Use ppc64 instructions, but schedule for power5
 741         $1_CFLAGS_CPU_JVM="${$1_CFLAGS_CPU_JVM} -mminimal-toc -mcpu=powerpc64 -mtune=power5"
 742       elif test "x$FLAGS_CPU" = xppc64le; then
 743         # Little endian machine uses ELFv2 ABI.
 744         # Use Power8, this is the first CPU to support PPC64 LE with ELFv2 ABI.
 745         $1_CFLAGS_CPU_JVM="${$1_CFLAGS_CPU_JVM} -DABI_ELFv2 -mcpu=power8 -mtune=power8"
 746       fi
 747     elif test "x$FLAGS_CPU" = xs390x; then
 748       $1_CFLAGS_CPU="-mbackchain -march=z10"
 749     fi
 750 
 751     if test "x$FLAGS_CPU_ARCH" != xarm &&  test "x$FLAGS_CPU_ARCH" != xppc; then
 752       # for all archs except arm and ppc, prevent gcc to omit frame pointer
 753       $1_CFLAGS_CPU_JDK="${$1_CFLAGS_CPU_JDK} -fno-omit-frame-pointer"
 754     fi
 755 
 756   elif test "x$TOOLCHAIN_TYPE" = xclang; then
 757     if test "x$FLAGS_OS" = xlinux; then
 758       # ppc test not really needed for clang
 759       if test "x$FLAGS_CPU_ARCH" != xarm &&  test "x$FLAGS_CPU_ARCH" != xppc; then
 760         # for all archs except arm and ppc, prevent gcc to omit frame pointer
 761         $1_CFLAGS_CPU_JDK="${$1_CFLAGS_CPU_JDK} -fno-omit-frame-pointer"
 762       fi
 763     fi
 764 
 765   elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
 766     if test "x$FLAGS_CPU" = xx86_64; then
 767       # NOTE: -xregs=no%frameptr is supposed to be default on x64
 768       $1_CFLAGS_CPU_JDK="-xregs=no%frameptr"
 769     elif test "x$FLAGS_CPU" = xsparcv9; then
 770       $1_CFLAGS_CPU_JVM="-xarch=sparc"
 771       $1_CFLAGS_CPU_JDK_LIBONLY="-xregs=no%appl"
 772     fi
 773 
 774   elif test "x$TOOLCHAIN_TYPE" = xxlc; then
 775     if test "x$FLAGS_CPU" = xppc64; then
 776       $1_CFLAGS_CPU_JVM="-qarch=ppc64"
 777     fi
 778 
 779   elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
 780     if test "x$FLAGS_CPU" = xx86; then
 781       $1_CFLAGS_CPU_JVM="-arch:IA32"
 782     elif test "x$OPENJDK_TARGET_CPU" = xx86_64; then
 783       if test "x$DEBUG_LEVEL" != xrelease; then
 784         # NOTE: This is probably redundant; -homeparams is default on
 785         # non-release builds.
 786         $1_CFLAGS_CPU_JVM="-homeparams"
 787       fi
 788     fi
 789   fi
 790 
 791   if test "x$TOOLCHAIN_TYPE" = xgcc; then
 792     TOOLCHAIN_CHECK_COMPILER_VERSION(VERSION: 6, PREFIX: $2, IF_AT_LEAST: FLAGS_SETUP_GCC6_COMPILER_FLAGS($1))
 793     $1_TOOLCHAIN_CFLAGS="${$1_GCC6_CFLAGS}"
 794 
 795     $1_WARNING_CFLAGS_JVM="-Wno-format-zero-length -Wtype-limits -Wuninitialized"
 796   fi
 797 
 798   # EXPORT to API
 799   CFLAGS_JVM_COMMON="$ALWAYS_CFLAGS_JVM $ALWAYS_DEFINES_JVM $TOOLCHAIN_CFLAGS_JVM \
 800       $OS_CFLAGS $OS_CFLAGS_JVM $CFLAGS_OS_DEF_JVM $DEBUG_CFLAGS_JVM \
 801       $WARNING_CFLAGS $WARNING_CFLAGS_JVM $JVM_PICFLAG"
 802 
 803   CFLAGS_JDK_COMMON="$ALWAYS_CFLAGS_JDK $ALWAYS_DEFINES_JDK $TOOLCHAIN_CFLAGS_JDK \
 804       $OS_CFLAGS $CFLAGS_OS_DEF_JDK $DEBUG_CFLAGS_JDK $DEBUG_OPTIONS_FLAGS_JDK \
 805       $WARNING_CFLAGS $WARNING_CFLAGS_JDK $DEBUG_SYMBOLS_CFLAGS_JDK"
 806 
 807   # Use ${$2EXTRA_CFLAGS} to block EXTRA_CFLAGS to be added to build flags.
 808   # (Currently we don't have any OPENJDK_BUILD_EXTRA_CFLAGS, but that might
 809   # change in the future.)
 810 
 811   CFLAGS_JDK_COMMON_CONLY="$TOOLCHAIN_CFLAGS_JDK_CONLY  \
 812       $WARNING_CFLAGS_JDK_CONLY ${$2EXTRA_CFLAGS}"
 813   CFLAGS_JDK_COMMON_CXXONLY="$ALWAYS_DEFINES_JDK_CXXONLY $TOOLCHAIN_CFLAGS_JDK_CXXONLY \
 814       $WARNING_CFLAGS_JDK_CXXONLY ${$2EXTRA_CXXFLAGS}"
 815 
 816   $1_CFLAGS_JVM="${$1_DEFINES_CPU_JVM} ${$1_CFLAGS_CPU} ${$1_CFLAGS_CPU_JVM} ${$1_TOOLCHAIN_CFLAGS} ${$1_WARNING_CFLAGS_JVM}"
 817   $1_CFLAGS_JDK="${$1_DEFINES_CPU_JDK} ${$1_CFLAGS_CPU} ${$1_CFLAGS_CPU_JDK} ${$1_TOOLCHAIN_CFLAGS}"
 818 
 819   $2JVM_CFLAGS="$CFLAGS_JVM_COMMON ${$1_CFLAGS_JVM} ${$2EXTRA_CXXFLAGS}"
 820 
 821   $2CFLAGS_JDKEXE="$CFLAGS_JDK_COMMON $CFLAGS_JDK_COMMON_CONLY ${$1_CFLAGS_JDK}"
 822   $2CXXFLAGS_JDKEXE="$CFLAGS_JDK_COMMON $CFLAGS_JDK_COMMON_CXXONLY ${$1_CFLAGS_JDK}"
 823   $2CFLAGS_JDKLIB="${$2CFLAGS_JDKEXE} $JDK_PICFLAG ${$1_CFLAGS_CPU_JDK_LIBONLY}"
 824   $2CXXFLAGS_JDKLIB="${$2CXXFLAGS_JDKEXE} $JDK_PICFLAG ${$1_CFLAGS_CPU_JDK_LIBONLY}"
 825 
 826   AC_SUBST($2JVM_CFLAGS)
 827   AC_SUBST($2CFLAGS_JDKLIB)
 828   AC_SUBST($2CFLAGS_JDKEXE)
 829   AC_SUBST($2CXXFLAGS_JDKLIB)
 830   AC_SUBST($2CXXFLAGS_JDKEXE)
 831 ])
 832 
 833 # FLAGS_SETUP_GCC6_COMPILER_FLAGS([PREFIX])
 834 # Arguments:
 835 # $1 - Prefix for each variable defined.
 836 AC_DEFUN([FLAGS_SETUP_GCC6_COMPILER_FLAGS],
 837 [
 838   # These flags are required for GCC 6 builds as undefined behaviour in OpenJDK code
 839   # runs afoul of the more aggressive versions of these optimisations.
 840   # Notably, value range propagation now assumes that the this pointer of C++
 841   # member functions is non-null.
 842   NO_DELETE_NULL_POINTER_CHECKS_CFLAG="-fno-delete-null-pointer-checks"
 843   dnl Argument check is disabled until FLAGS_COMPILER_CHECK_ARGUMENTS handles cross-compilation
 844   dnl FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [$NO_DELETE_NULL_POINTER_CHECKS_CFLAG -Werror],
 845   dnl                                        IF_FALSE: [NO_DELETE_NULL_POINTER_CHECKS_CFLAG=""])
 846   NO_LIFETIME_DSE_CFLAG="-fno-lifetime-dse"
 847   dnl Argument check is disabled until FLAGS_COMPILER_CHECK_ARGUMENTS handles cross-compilation
 848   dnl FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [$NO_LIFETIME_DSE_CFLAG -Werror],
 849   dnl                                        IF_FALSE: [NO_LIFETIME_DSE_CFLAG=""])
 850   AC_MSG_NOTICE([GCC >= 6 detected; adding ${NO_DELETE_NULL_POINTER_CHECKS_CFLAG} and ${NO_LIFETIME_DSE_CFLAG}])
 851   $1_GCC6_CFLAGS="${NO_DELETE_NULL_POINTER_CHECKS_CFLAG} ${NO_LIFETIME_DSE_CFLAG}"
 852 ])
 853 
 854 # Documentation on common flags used for solstudio in HIGHEST.
 855 #
 856 # WARNING: Use of OPTIMIZATION_LEVEL=HIGHEST in your Makefile needs to be
 857 #          done with care, there are some assumptions below that need to
 858 #          be understood about the use of pointers, and IEEE behavior.
 859 #
 860 # -fns: Use non-standard floating point mode (not IEEE 754)
 861 # -fsimple: Do some simplification of floating point arithmetic (not IEEE 754)
 862 # -fsingle: Use single precision floating point with 'float'
 863 # -xalias_level=basic: Assume memory references via basic pointer types do not alias
 864 #   (Source with excessing pointer casting and data access with mixed
 865 #    pointer types are not recommended)
 866 # -xbuiltin=%all: Use intrinsic or inline versions for math/std functions
 867 #   (If you expect perfect errno behavior, do not use this)
 868 # -xdepend: Loop data dependency optimizations (need -xO3 or higher)
 869 # -xrestrict: Pointer parameters to functions do not overlap
 870 #   (Similar to -xalias_level=basic usage, but less obvious sometimes.
 871 #    If you pass in multiple pointers to the same data, do not use this)
 872 # -xlibmil: Inline some library routines
 873 #   (If you expect perfect errno behavior, do not use this)
 874 # -xlibmopt: Use optimized math routines (CURRENTLY DISABLED)
 875 #   (If you expect perfect errno behavior, do not use this)
 876 #  Can cause undefined external on Solaris 8 X86 on __sincos, removing for now