1 #
   2 # Copyright (c) 2011, 2019, 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="-g1"
 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       WARNINGS_ENABLE_ALL="-W3"
 166       DISABLED_WARNINGS="4800"
 167       ;;
 168 
 169     solstudio)
 170       DISABLE_WARNING_PREFIX="-erroff="
 171       CFLAGS_WARNINGS_ARE_ERRORS="-errwarn=%all"
 172 
 173       WARNINGS_ENABLE_ALL_CFLAGS="-v"
 174       WARNINGS_ENABLE_ALL_CXXFLAGS="+w"
 175 
 176       DISABLED_WARNINGS_C=""
 177       DISABLED_WARNINGS_CXX=""
 178       ;;
 179 
 180     gcc)
 181       DISABLE_WARNING_PREFIX="-Wno-"
 182       CFLAGS_WARNINGS_ARE_ERRORS="-Werror"
 183 
 184       # Additional warnings that are not activated by -Wall and -Wextra
 185       WARNINGS_ENABLE_ADDITIONAL="-Wpointer-arith -Wsign-compare \
 186           -Wunused-function -Wundef -Wunused-value -Wreturn-type \
 187           -Wtrampolines"
 188       WARNINGS_ENABLE_ADDITIONAL_CXX="-Woverloaded-virtual -Wreorder"
 189       WARNINGS_ENABLE_ALL_CFLAGS="-Wall -Wextra -Wformat=2 $WARNINGS_ENABLE_ADDITIONAL"
 190       WARNINGS_ENABLE_ALL_CXXFLAGS="$WARNINGS_ENABLE_ALL_CFLAGS $WARNINGS_ENABLE_ADDITIONAL_CXX"
 191 
 192       DISABLED_WARNINGS="unused-parameter unused"
 193 
 194       # Repeate the check for the BUILD_CC and BUILD_CXX. Need to also reset
 195       # CFLAGS since any target specific flags will likely not work with the
 196       # build compiler
 197       CC_OLD="$CC"
 198       CXX_OLD="$CXX"
 199       CC="$BUILD_CC"
 200       CXX="$BUILD_CXX"
 201       CFLAGS_OLD="$CFLAGS"
 202       CFLAGS=""
 203       BUILD_CC_DISABLE_WARNING_PREFIX="-Wno-"
 204       CC="$CC_OLD"
 205       CXX="$CXX_OLD"
 206       CFLAGS="$CFLAGS_OLD"
 207       ;;
 208 
 209     clang)
 210       DISABLE_WARNING_PREFIX="-Wno-"
 211       CFLAGS_WARNINGS_ARE_ERRORS="-Werror"
 212 
 213       # Additional warnings that are not activated by -Wall and -Wextra
 214       WARNINGS_ENABLE_ADDITIONAL="-Wpointer-arith -Wsign-compare -Wreorder \
 215           -Wunused-function -Wundef -Wunused-value -Woverloaded-virtual"
 216       WARNINGS_ENABLE_ALL="-Wall -Wextra -Wformat=2 $WARNINGS_ENABLE_ADDITIONAL"
 217 
 218       DISABLED_WARNINGS="unknown-warning-option unused-parameter unused"
 219 
 220       if test "x$OPENJDK_TARGET_OS" = xmacosx; then
 221         # missing-method-return-type triggers in JavaNativeFoundation framework
 222         DISABLED_WARNINGS="$DISABLED_WARNINGS missing-method-return-type"
 223       fi
 224 
 225       ;;
 226 
 227     xlc)
 228       DISABLE_WARNING_PREFIX="-Wno-"
 229       CFLAGS_WARNINGS_ARE_ERRORS="-qhalt=w"
 230 
 231       # Possibly a better subset than "all" is "lan:trx:ret:zea:cmp:ret"
 232       WARNINGS_ENABLE_ALL="-qinfo=all -qformat=all"
 233       DISABLED_WARNINGS=""
 234       ;;
 235   esac
 236   AC_SUBST(DISABLE_WARNING_PREFIX)
 237   AC_SUBST(BUILD_CC_DISABLE_WARNING_PREFIX)
 238   AC_SUBST(CFLAGS_WARNINGS_ARE_ERRORS)
 239   AC_SUBST(DISABLED_WARNINGS)
 240   AC_SUBST(DISABLED_WARNINGS_C)
 241   AC_SUBST(DISABLED_WARNINGS_CXX)
 242 ])
 243 
 244 AC_DEFUN([FLAGS_SETUP_QUALITY_CHECKS],
 245 [
 246   # bounds, memory and behavior checking options
 247   if test "x$TOOLCHAIN_TYPE" = xgcc; then
 248     case $DEBUG_LEVEL in
 249     release )
 250       # no adjustment
 251       ;;
 252     fastdebug )
 253       # no adjustment
 254       ;;
 255     slowdebug )
 256       # FIXME: By adding this to C(XX)FLAGS_DEBUG_OPTIONS/JVM_CFLAGS_SYMBOLS it
 257       # get's added conditionally on whether we produce debug symbols or not.
 258       # This is most likely not really correct.
 259 
 260       # Add runtime stack smashing and undefined behavior checks.
 261       CFLAGS_DEBUG_OPTIONS="-fstack-protector-all --param ssp-buffer-size=1"
 262       CXXFLAGS_DEBUG_OPTIONS="-fstack-protector-all --param ssp-buffer-size=1"
 263 
 264       JVM_CFLAGS_SYMBOLS="$JVM_CFLAGS_SYMBOLS -fstack-protector-all --param ssp-buffer-size=1"
 265       ;;
 266     esac
 267   fi
 268 ])
 269 
 270 AC_DEFUN([FLAGS_SETUP_OPTIMIZATION],
 271 [
 272   if test "x$TOOLCHAIN_TYPE" = xsolstudio; then
 273     CC_HIGHEST="-fns -fsimple -fsingle -xbuiltin=%all -xdepend -xrestrict -xlibmil"
 274 
 275     C_O_FLAG_HIGHEST_JVM="-xO4"
 276     C_O_FLAG_DEBUG_JVM=""
 277     C_O_FLAG_SIZE=""
 278     C_O_FLAG_DEBUG=""
 279     C_O_FLAG_NONE=""
 280     if test "x$OPENJDK_TARGET_CPU_ARCH" = "xx86"; then
 281       C_O_FLAG_HIGHEST="-xO4 -Wu,-O4~yz $CC_HIGHEST"
 282       C_O_FLAG_HI="-xO4 -Wu,-O4~yz"
 283       C_O_FLAG_NORM="-xO2 -Wu,-O2~yz"
 284     elif test "x$OPENJDK_TARGET_CPU_ARCH" = "xsparc"; then
 285       C_O_FLAG_HIGHEST="-xO4 -Wc,-Qrm-s -Wc,-Qiselect-T0 \
 286           -xprefetch=auto,explicit $CC_HIGHEST"
 287       C_O_FLAG_HI="-xO4 -Wc,-Qrm-s -Wc,-Qiselect-T0"
 288       C_O_FLAG_NORM="-xO2 -Wc,-Qrm-s -Wc,-Qiselect-T0"
 289     fi
 290   elif test "x$TOOLCHAIN_TYPE" = xgcc; then
 291     C_O_FLAG_HIGHEST_JVM="-O3"
 292     C_O_FLAG_HIGHEST="-O3"
 293     C_O_FLAG_HI="-O3"
 294     C_O_FLAG_NORM="-O2"
 295     C_O_FLAG_SIZE="-Os"
 296     C_O_FLAG_DEBUG="-O0"
 297     C_O_FLAG_DEBUG_JVM="-O0"
 298     C_O_FLAG_NONE="-O0"
 299     # -D_FORTIFY_SOURCE=2 hardening option needs optimization (at least -O1) enabled
 300     # set for lower O-levels -U_FORTIFY_SOURCE to overwrite previous settings
 301     if test "x$OPENJDK_TARGET_OS" = xlinux -a "x$DEBUG_LEVEL" = "xfastdebug"; then
 302       ENABLE_FORTIFY_CFLAGS="-D_FORTIFY_SOURCE=2"
 303       DISABLE_FORTIFY_CFLAGS="-U_FORTIFY_SOURCE"
 304       C_O_FLAG_HIGHEST_JVM="${C_O_FLAG_HIGHEST_JVM} ${ENABLE_FORTIFY_CFLAGS}"
 305       C_O_FLAG_HIGHEST="${C_O_FLAG_HIGHEST} ${ENABLE_FORTIFY_CFLAGS}"
 306       C_O_FLAG_HI="${C_O_FLAG_HI} ${ENABLE_FORTIFY_CFLAGS}"
 307       C_O_FLAG_NORM="${C_O_FLAG_NORM} ${ENABLE_FORTIFY_CFLAGS}"
 308       C_O_FLAG_SIZE="${C_O_FLAG_SIZE} ${DISABLE_FORTIFY_CFLAGS}"
 309       C_O_FLAG_DEBUG="${C_O_FLAG_DEBUG} ${DISABLE_FORTIFY_CFLAGS}"
 310       C_O_FLAG_DEBUG_JVM="${C_O_FLAG_DEBUG_JVM} ${DISABLE_FORTIFY_CFLAGS}"
 311       C_O_FLAG_NONE="${C_O_FLAG_NONE} ${DISABLE_FORTIFY_CFLAGS}"
 312     fi
 313   elif test "x$TOOLCHAIN_TYPE" = xclang; then
 314     if test "x$OPENJDK_TARGET_OS" = xmacosx; then
 315       # On MacOSX we optimize for size, something
 316       # we should do for all platforms?
 317       C_O_FLAG_HIGHEST_JVM="-Os"
 318       C_O_FLAG_HIGHEST="-Os"
 319       C_O_FLAG_HI="-Os"
 320       C_O_FLAG_NORM="-Os"
 321       C_O_FLAG_DEBUG_JVM=""
 322     else
 323       C_O_FLAG_HIGHEST_JVM="-O3"
 324       C_O_FLAG_HIGHEST="-O3"
 325       C_O_FLAG_HI="-O3"
 326       C_O_FLAG_NORM="-O2"
 327       C_O_FLAG_DEBUG_JVM="-O0"
 328     fi
 329     C_O_FLAG_SIZE="-Os"
 330     C_O_FLAG_DEBUG="-O0"
 331     C_O_FLAG_NONE="-O0"
 332   elif test "x$TOOLCHAIN_TYPE" = xxlc; then
 333     C_O_FLAG_HIGHEST_JVM="-O3 -qhot=level=1 -qinline -qinlglue"
 334     C_O_FLAG_HIGHEST="-O3 -qhot=level=1 -qinline -qinlglue"
 335     C_O_FLAG_HI="-O3 -qinline -qinlglue"
 336     C_O_FLAG_NORM="-O2"
 337     C_O_FLAG_DEBUG="-qnoopt"
 338     # FIXME: Value below not verified.
 339     C_O_FLAG_DEBUG_JVM=""
 340     C_O_FLAG_NONE="-qnoopt"
 341   elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
 342     C_O_FLAG_HIGHEST_JVM="-O2 -Oy-"
 343     C_O_FLAG_HIGHEST="-O2"
 344     C_O_FLAG_HI="-O1"
 345     C_O_FLAG_NORM="-O1"
 346     C_O_FLAG_DEBUG="-Od"
 347     C_O_FLAG_DEBUG_JVM=""
 348     C_O_FLAG_NONE="-Od"
 349     C_O_FLAG_SIZE="-Os"
 350   fi
 351 
 352   # Now copy to C++ flags
 353   CXX_O_FLAG_HIGHEST_JVM="$C_O_FLAG_HIGHEST_JVM"
 354   CXX_O_FLAG_HIGHEST="$C_O_FLAG_HIGHEST"
 355   CXX_O_FLAG_HI="$C_O_FLAG_HI"
 356   CXX_O_FLAG_NORM="$C_O_FLAG_NORM"
 357   CXX_O_FLAG_DEBUG="$C_O_FLAG_DEBUG"
 358   CXX_O_FLAG_DEBUG_JVM="$C_O_FLAG_DEBUG_JVM"
 359   CXX_O_FLAG_NONE="$C_O_FLAG_NONE"
 360   CXX_O_FLAG_SIZE="$C_O_FLAG_SIZE"
 361 
 362   if test "x$TOOLCHAIN_TYPE" = xsolstudio; then
 363     # In solstudio, also add this to C (but not C++) flags...
 364     C_O_FLAG_HIGHEST="$C_O_FLAG_HIGHEST -xalias_level=basic"
 365   fi
 366 
 367   # Adjust optimization flags according to debug level.
 368   case $DEBUG_LEVEL in
 369     release )
 370       # no adjustment
 371       ;;
 372     fastdebug )
 373       # Not quite so much optimization
 374       C_O_FLAG_HI="$C_O_FLAG_NORM"
 375       CXX_O_FLAG_HI="$CXX_O_FLAG_NORM"
 376       ;;
 377     slowdebug )
 378       # Disable optimization
 379       C_O_FLAG_HIGHEST_JVM="$C_O_FLAG_DEBUG_JVM"
 380       C_O_FLAG_HIGHEST="$C_O_FLAG_DEBUG"
 381       C_O_FLAG_HI="$C_O_FLAG_DEBUG"
 382       C_O_FLAG_NORM="$C_O_FLAG_DEBUG"
 383       C_O_FLAG_SIZE="$C_O_FLAG_DEBUG"
 384       CXX_O_FLAG_HIGHEST_JVM="$CXX_O_FLAG_DEBUG_JVM"
 385       CXX_O_FLAG_HIGHEST="$CXX_O_FLAG_DEBUG"
 386       CXX_O_FLAG_HI="$CXX_O_FLAG_DEBUG"
 387       CXX_O_FLAG_NORM="$CXX_O_FLAG_DEBUG"
 388       CXX_O_FLAG_SIZE="$CXX_O_FLAG_DEBUG"
 389       ;;
 390   esac
 391 
 392   AC_SUBST(C_O_FLAG_HIGHEST_JVM)
 393   AC_SUBST(C_O_FLAG_HIGHEST)
 394   AC_SUBST(C_O_FLAG_HI)
 395   AC_SUBST(C_O_FLAG_NORM)
 396   AC_SUBST(C_O_FLAG_NONE)
 397   AC_SUBST(C_O_FLAG_SIZE)
 398   AC_SUBST(CXX_O_FLAG_HIGHEST_JVM)
 399   AC_SUBST(CXX_O_FLAG_HIGHEST)
 400   AC_SUBST(CXX_O_FLAG_HI)
 401   AC_SUBST(CXX_O_FLAG_NORM)
 402   AC_SUBST(CXX_O_FLAG_NONE)
 403   AC_SUBST(CXX_O_FLAG_SIZE)
 404 ])
 405 
 406 AC_DEFUN([FLAGS_SETUP_CFLAGS],
 407 [
 408   ### CFLAGS
 409 
 410   FLAGS_SETUP_CFLAGS_HELPER
 411 
 412   FLAGS_OS=$OPENJDK_TARGET_OS
 413   FLAGS_OS_TYPE=$OPENJDK_TARGET_OS_TYPE
 414   FLAGS_CPU=$OPENJDK_TARGET_CPU
 415   FLAGS_CPU_ARCH=$OPENJDK_TARGET_CPU_ARCH
 416   FLAGS_CPU_BITS=$OPENJDK_TARGET_CPU_BITS
 417   FLAGS_CPU_ENDIAN=$OPENJDK_TARGET_CPU_ENDIAN
 418   FLAGS_CPU_LEGACY=$OPENJDK_TARGET_CPU_LEGACY
 419   FLAGS_CPU_LEGACY_LIB=$OPENJDK_TARGET_CPU_LEGACY_LIB
 420 
 421   FLAGS_SETUP_CFLAGS_CPU_DEP([TARGET])
 422 
 423   FLAGS_OS=$OPENJDK_BUILD_OS
 424   FLAGS_OS_TYPE=$OPENJDK_BUILD_OS_TYPE
 425   FLAGS_CPU=$OPENJDK_BUILD_CPU
 426   FLAGS_CPU_ARCH=$OPENJDK_BUILD_CPU_ARCH
 427   FLAGS_CPU_BITS=$OPENJDK_BUILD_CPU_BITS
 428   FLAGS_CPU_ENDIAN=$OPENJDK_BUILD_CPU_ENDIAN
 429   FLAGS_CPU_LEGACY=$OPENJDK_BUILD_CPU_LEGACY
 430   FLAGS_CPU_LEGACY_LIB=$OPENJDK_BUILD_CPU_LEGACY_LIB
 431 
 432   FLAGS_SETUP_CFLAGS_CPU_DEP([BUILD], [OPENJDK_BUILD_], [BUILD_])
 433 ])
 434 
 435 ################################################################################
 436 # platform independent
 437 AC_DEFUN([FLAGS_SETUP_CFLAGS_HELPER],
 438 [
 439   #### OS DEFINES, these should be independent on toolchain
 440   if test "x$OPENJDK_TARGET_OS" = xlinux; then
 441     CFLAGS_OS_DEF_JVM="-DLINUX"
 442     CFLAGS_OS_DEF_JDK="-D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE"
 443   elif test "x$OPENJDK_TARGET_OS" = xsolaris; then
 444     CFLAGS_OS_DEF_JVM="-DSOLARIS"
 445     CFLAGS_OS_DEF_JDK="-D__solaris__"
 446   elif test "x$OPENJDK_TARGET_OS" = xmacosx; then
 447     CFLAGS_OS_DEF_JVM="-D_ALLBSD_SOURCE -D_DARWIN_C_SOURCE -D_XOPEN_SOURCE"
 448     CFLAGS_OS_DEF_JDK="-D_ALLBSD_SOURCE -D_DARWIN_UNLIMITED_SELECT"
 449   elif test "x$OPENJDK_TARGET_OS" = xaix; then
 450     CFLAGS_OS_DEF_JVM="-DAIX"
 451   elif test "x$OPENJDK_TARGET_OS" = xbsd; then
 452     CFLAGS_OS_DEF_JDK="-D_ALLBSD_SOURCE"
 453   elif test "x$OPENJDK_TARGET_OS" = xwindows; then
 454     CFLAGS_OS_DEF_JVM="-D_WINDOWS -DWIN32 -D_JNI_IMPLEMENTATION_"
 455   fi
 456 
 457   CFLAGS_OS_DEF_JDK="$CFLAGS_OS_DEF_JDK -D$OPENJDK_TARGET_OS_UPPERCASE"
 458 
 459   #### GLOBAL DEFINES
 460   # Set some common defines. These works for all compilers, but assume
 461   # -D is universally accepted.
 462 
 463   # Always enable optional macros for VM.
 464   ALWAYS_CFLAGS_JVM="-D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS"
 465 
 466   # Setup some hard coded includes
 467   ALWAYS_CFLAGS_JDK=" \
 468       -I\$(SUPPORT_OUTPUTDIR)/modules_include/java.base \
 469       -I\$(SUPPORT_OUTPUTDIR)/modules_include/java.base/\$(OPENJDK_TARGET_OS_INCLUDE_SUBDIR) \
 470       -I${TOPDIR}/src/java.base/share/native/libjava \
 471       -I${TOPDIR}/src/java.base/$OPENJDK_TARGET_OS_TYPE/native/libjava \
 472       -I${TOPDIR}/src/hotspot/share/include \
 473       -I${TOPDIR}/src/hotspot/os/${HOTSPOT_TARGET_OS_TYPE}/include"
 474 
 475   ###############################################################################
 476 
 477   # Adjust flags according to debug level.
 478   # Setup debug/release defines
 479   if test "x$DEBUG_LEVEL" = xrelease; then
 480     DEBUG_CFLAGS_JDK="-DNDEBUG"
 481     if test "x$OPENJDK_TARGET_OS" = xsolaris; then
 482       DEBUG_CFLAGS_JDK="$DEBUG_CFLAGS_JDK -DTRIMMED"
 483     fi
 484   else
 485     DEBUG_CFLAGS_JDK="-DDEBUG"
 486 
 487     if test "x$TOOLCHAIN_TYPE" = xxlc; then
 488       # We need '-qminimaltoc' or '-qpic=large -bbigtoc' if the TOC overflows.
 489       # Hotspot now overflows its 64K TOC (currently only for debug),
 490       # so for debug we build with '-qpic=large -bbigtoc'.
 491       DEBUG_CFLAGS_JVM="-qpic=large"
 492     fi
 493   fi
 494 
 495   if test "x$DEBUG_LEVEL" != xrelease; then
 496     DEBUG_OPTIONS_FLAGS_JDK="$CFLAGS_DEBUG_OPTIONS"
 497     DEBUG_SYMBOLS_CFLAGS_JDK="$CFLAGS_DEBUG_SYMBOLS"
 498   fi
 499 
 500   #### TOOLCHAIN DEFINES
 501 
 502   if test "x$TOOLCHAIN_TYPE" = xgcc; then
 503     ALWAYS_DEFINES_JVM="-D_GNU_SOURCE -D_REENTRANT"
 504   elif test "x$TOOLCHAIN_TYPE" = xclang; then
 505     ALWAYS_DEFINES_JVM="-D_GNU_SOURCE"
 506   elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
 507     ALWAYS_DEFINES_JVM="-DSPARC_WORKS -D_Crun_inline_placement"
 508     ALWAYS_DEFINES_JDK="-DTRACING -DMACRO_MEMSYS_OPS -DBREAKPTS"
 509     ALWAYS_DEFINES_JDK_CXXONLY="-DCC_NOEX"
 510   elif test "x$TOOLCHAIN_TYPE" = xxlc; then
 511     ALWAYS_DEFINES_JVM="-D_REENTRANT"
 512     ALWAYS_DEFINES_JDK="-D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE -DSTDC"
 513   elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
 514     ALWAYS_DEFINES_JDK="-DWIN32_LEAN_AND_MEAN -D_CRT_SECURE_NO_DEPRECATE \
 515         -D_CRT_NONSTDC_NO_DEPRECATE -DWIN32 -DIAL"
 516     ALWAYS_DEFINES_JVM="-DNOMINMAX -DWIN32_LEAN_AND_MEAN"
 517   fi
 518 
 519   ###############################################################################
 520   #
 521   #
 522   # CFLAGS BASIC
 523   if test "x$TOOLCHAIN_TYPE" = xgcc || test "x$TOOLCHAIN_TYPE" = xclang; then
 524     # COMMON to gcc and clang
 525     TOOLCHAIN_CFLAGS_JVM="-pipe -fno-rtti -fno-exceptions \
 526         -fvisibility=hidden -fno-strict-aliasing -fno-omit-frame-pointer"
 527   fi
 528 
 529   if test "x$TOOLCHAIN_TYPE" = xgcc; then
 530     TOOLCHAIN_CFLAGS_JVM="$TOOLCHAIN_CFLAGS_JVM -fcheck-new -fstack-protector"
 531     TOOLCHAIN_CFLAGS_JDK="-pipe -fstack-protector"
 532     # technically NOT for CXX (but since this gives *worse* performance, use
 533     # no-strict-aliasing everywhere!)
 534     TOOLCHAIN_CFLAGS_JDK_CONLY="-fno-strict-aliasing"
 535 
 536   elif test "x$TOOLCHAIN_TYPE" = xclang; then
 537     # Restrict the debug information created by Clang to avoid
 538     # too big object files and speed the build up a little bit
 539     # (see http://llvm.org/bugs/show_bug.cgi?id=7554)
 540     TOOLCHAIN_CFLAGS_JVM="$TOOLCHAIN_CFLAGS_JVM -flimit-debug-info"
 541 
 542     # In principle the stack alignment below is cpu- and ABI-dependent and
 543     # should agree with values of StackAlignmentInBytes in various
 544     # src/hotspot/cpu/*/globalDefinitions_*.hpp files, but this value currently
 545     # works for all platforms.
 546     TOOLCHAIN_CFLAGS_JVM="$TOOLCHAIN_CFLAGS_JVM -mno-omit-leaf-frame-pointer -mstack-alignment=16"
 547 
 548     if test "x$OPENJDK_TARGET_OS" = xlinux; then
 549       if test "x$DEBUG_LEVEL" = xrelease; then
 550         # Clang does not inline as much as GCC does for functions with "inline" keyword by default.
 551         # This causes noticeable slowdown in pause time for G1, and possibly in other areas.
 552         # Increasing the inline hint threshold avoids the slowdown for Clang-built JVM.
 553         TOOLCHAIN_CFLAGS_JVM="$TOOLCHAIN_CFLAGS_JVM -mllvm -inlinehint-threshold=100000"
 554       fi
 555       TOOLCHAIN_CFLAGS_JDK="-pipe"
 556       TOOLCHAIN_CFLAGS_JDK_CONLY="-fno-strict-aliasing" # technically NOT for CXX
 557     fi
 558   elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
 559     TOOLCHAIN_FLAGS="-errtags -errfmt"
 560     TOOLCHAIN_CFLAGS="-errshort=tags"
 561 
 562     TOOLCHAIN_CFLAGS_JDK="-mt $TOOLCHAIN_FLAGS"
 563     TOOLCHAIN_CFLAGS_JDK_CONLY="-W0,-noglobal $TOOLCHAIN_CFLAGS" # C only
 564     TOOLCHAIN_CFLAGS_JDK_CXXONLY="-features=no%except -norunpath -xnolib" # CXX only
 565     TOOLCHAIN_CFLAGS_JVM="-template=no%extdef -features=no%split_init \
 566         -library=stlport4 -mt -features=no%except $TOOLCHAIN_FLAGS"
 567     if test "x$DEBUG_LEVEL" = xslowdebug; then
 568       # Previously -g was used instead of -g0 for slowdebug; this is equivalent
 569       # to setting +d.
 570       TOOLCHAIN_CFLAGS_JVM="$TOOLCHAIN_CFLAGS_JVM +d"
 571     fi
 572 
 573   elif test "x$TOOLCHAIN_TYPE" = xxlc; then
 574     # Suggested additions: -qsrcmsg to get improved error reporting
 575     # set -qtbtable=full for a better traceback table/better stacks in hs_err when xlc16 is used
 576     TOOLCHAIN_CFLAGS_JDK="-qtbtable=full -qchars=signed -qfullpath -qsaveopt -qstackprotect"  # add on both CFLAGS
 577     TOOLCHAIN_CFLAGS_JVM="-qtbtable=full -qtune=balanced \
 578         -qalias=noansi -qstrict -qtls=default -qnortti -qnoeh -qignerrno -qstackprotect"
 579   elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
 580     TOOLCHAIN_CFLAGS_JVM="-nologo -MD -MP"
 581     TOOLCHAIN_CFLAGS_JDK="-nologo -MD -Zc:wchar_t-"
 582   fi
 583 
 584   # CFLAGS C language level for JDK sources (hotspot only uses C++)
 585   # Ideally we would have a common level across all toolchains so that all sources
 586   # are sure to conform to the same standard. Unfortunately neither our sources nor
 587   # our toolchains are in a condition to support that. But what we loosely aim for is
 588   # C99 level.
 589   if test "x$TOOLCHAIN_TYPE" = xgcc || test "x$TOOLCHAIN_TYPE" = xclang || test "x$TOOLCHAIN_TYPE" = xxlc; then
 590     # This raises the language level for older 4.8 gcc, while lowering it for later
 591     # versions. clang and xlclang support the same flag.
 592     LANGSTD_CFLAGS="-std=c99"
 593   elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
 594     # We can't turn on -std=c99 without breaking compilation of the splashscreen/png
 595     # utilities. But we can enable c99 as below (previously achieved by using -Xa).
 596     # It is the no_lib that makes the difference.
 597     LANGSTD_CFLAGS="-xc99=all,no_lib"
 598   elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
 599     # MSVC doesn't support C99/C11 explicitly, unless you compile as C++:
 600     # LANGSTD_CFLAGS="/TP"
 601     # but that requires numerous changes to the sources files. So we are limited
 602     # to C89/C90 plus whatever extensions Visual Studio has decided to implement.
 603     # This is the lowest bar for shared code.
 604     LANGSTD_CFLAGS=""
 605   fi
 606   TOOLCHAIN_CFLAGS_JDK_CONLY="$LANGSTD_CFLAGS $TOOLCHAIN_CFLAGS_JDK_CONLY"
 607 
 608   # CFLAGS WARNINGS STUFF
 609   # Set JVM_CFLAGS warning handling
 610   if test "x$TOOLCHAIN_TYPE" = xgcc; then
 611     WARNING_CFLAGS_JDK_CONLY="$WARNINGS_ENABLE_ALL_CFLAGS"
 612     WARNING_CFLAGS_JDK_CXXONLY="$WARNINGS_ENABLE_ALL_CXXFLAGS"
 613     WARNING_CFLAGS_JVM="$WARNINGS_ENABLE_ALL_CXXFLAGS"
 614 
 615   elif test "x$TOOLCHAIN_TYPE" = xclang; then
 616     WARNING_CFLAGS="$WARNINGS_ENABLE_ALL"
 617 
 618   elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
 619     WARNING_CFLAGS_JDK_CONLY="$WARNINGS_ENABLE_ALL_CFLAGS"
 620     WARNING_CFLAGS_JDK_CXXONLY="$WARNINGS_ENABLE_ALL_CXXFLAGS"
 621     WARNING_CFLAGS_JVM="$WARNINGS_ENABLE_ALL_CXXFLAGS"
 622 
 623   elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
 624     WARNING_CFLAGS="$WARNINGS_ENABLE_ALL"
 625 
 626   elif test "x$TOOLCHAIN_TYPE" = xxlc; then
 627     WARNING_CFLAGS=""  # currently left empty
 628   fi
 629 
 630   # Set some additional per-OS defines.
 631 
 632   # Additional macosx handling
 633   if test "x$OPENJDK_TARGET_OS" = xmacosx; then
 634     OS_CFLAGS="-DMAC_OS_X_VERSION_MIN_REQUIRED=$MACOSX_VERSION_MIN_NODOTS \
 635         -mmacosx-version-min=$MACOSX_VERSION_MIN"
 636 
 637     if test -n "$MACOSX_VERSION_MAX"; then
 638         OS_CFLAGS="$OS_CFLAGS \
 639             -DMAC_OS_X_VERSION_MAX_ALLOWED=$MACOSX_VERSION_MAX_NODOTS"
 640     fi
 641   fi
 642 
 643   # Where does this really belong??
 644   if test "x$TOOLCHAIN_TYPE" = xgcc || test "x$TOOLCHAIN_TYPE" = xclang; then
 645     PICFLAG="-fPIC"
 646   elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
 647     PICFLAG="-KPIC"
 648   elif test "x$TOOLCHAIN_TYPE" = xxlc; then
 649     # '-qpic' defaults to 'qpic=small'. This means that the compiler generates only
 650     # one instruction for accessing the TOC. If the TOC grows larger than 64K, the linker
 651     # will have to patch this single instruction with a call to some out-of-order code which
 652     # does the load from the TOC. This is of course slower, and we also would have
 653     # to use '-bbigtoc' for linking anyway so we could also change the PICFLAG to 'qpic=large'.
 654     # With 'qpic=large' the compiler will by default generate a two-instruction sequence which
 655     # can be patched directly by the linker and does not require a jump to out-of-order code.
 656     #
 657     # Since large TOC causes perf. overhead, only pay it where we must. Currently this is
 658     # for all libjvm variants (both gtest and normal) but no other binaries. So, build
 659     # libjvm with -qpic=large and link with -bbigtoc.
 660     JVM_PICFLAG="-qpic=large"
 661     JDK_PICFLAG="-qpic"
 662   elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
 663     PICFLAG=""
 664   fi
 665 
 666   if test "x$TOOLCHAIN_TYPE" != xxlc; then
 667     JVM_PICFLAG="$PICFLAG"
 668     JDK_PICFLAG="$PICFLAG"
 669   fi
 670 
 671   if test "x$OPENJDK_TARGET_OS" = xmacosx; then
 672     # Linking is different on MacOSX
 673     JDK_PICFLAG=''
 674     if test "x$STATIC_BUILD" = xtrue; then
 675       JVM_PICFLAG=""
 676     fi
 677   fi
 678 
 679   # Optional POSIX functionality needed by the JVM
 680   #
 681   # Check if clock_gettime is available and in which library. This indicates
 682   # availability of CLOCK_MONOTONIC for hotspot. But we don't need to link, so
 683   # don't let it update LIBS.
 684   save_LIBS="$LIBS"
 685   AC_SEARCH_LIBS(clock_gettime, rt, [HAS_CLOCK_GETTIME=true], [])
 686   if test "x$LIBS" = "x-lrt "; then
 687     CLOCK_GETTIME_IN_LIBRT=true
 688   fi
 689   LIBS="$save_LIBS"
 690 
 691   if test "x$HAS_CLOCK_GETTIME" = "xtrue"; then
 692     OS_CFLAGS_JVM="$OS_CFLAGS_JVM -DSUPPORTS_CLOCK_MONOTONIC"
 693     if test "x$CLOCK_GETTIME_IN_LIBRT" = "xtrue"; then
 694       OS_CFLAGS_JVM="$OS_CFLAGS_JVM -DNEEDS_LIBRT"
 695     fi
 696   fi
 697 ])
 698 
 699 ################################################################################
 700 # $1 - Either BUILD or TARGET to pick the correct OS/CPU variables to check
 701 #      conditionals against.
 702 # $2 - Optional prefix for each variable defined.
 703 # $3 - Optional prefix for compiler variables (either BUILD_ or nothing).
 704 AC_DEFUN([FLAGS_SETUP_CFLAGS_CPU_DEP],
 705 [
 706   #### CPU DEFINES, these should (in theory) be independent on toolchain
 707 
 708   # Setup target CPU
 709   # Setup endianness
 710   if test "x$FLAGS_CPU_ENDIAN" = xlittle; then
 711     $1_DEFINES_CPU_JVM="-DVM_LITTLE_ENDIAN"
 712   fi
 713   if test "x$TOOLCHAIN_TYPE" = xsolstudio; then
 714     # The macro _LITTLE_ENDIAN needs to be defined the same to avoid the
 715     #   Sun C compiler warning message: warning: macro redefined: _LITTLE_ENDIAN
 716     if test "x$FLAGS_CPU_ENDIAN" = xlittle; then
 717       $1_DEFINES_CPU_JDK="-D_LITTLE_ENDIAN="
 718     else
 719       $1_DEFINES_CPU_JDK="-D_BIG_ENDIAN="
 720     fi
 721   else
 722     if test "x$FLAGS_CPU_ENDIAN" = xlittle; then
 723       $1_DEFINES_CPU_JDK="-D_LITTLE_ENDIAN"
 724     else
 725       $1_DEFINES_CPU_JDK="-D_BIG_ENDIAN"
 726     fi
 727   fi
 728 
 729   # setup CPU bit size
 730   $1_DEFINES_CPU_JDK="${$1_DEFINES_CPU_JDK} -DARCH='\"$FLAGS_CPU_LEGACY\"' \
 731       -D$FLAGS_CPU_LEGACY"
 732 
 733   if test "x$FLAGS_CPU_BITS" = x64; then
 734     # -D_LP64=1 is only set on linux and mac. Setting on windows causes diff in
 735     # unpack200.exe.
 736     if test "x$FLAGS_OS" = xlinux || test "x$FLAGS_OS" = xmacosx; then
 737       $1_DEFINES_CPU_JDK="${$1_DEFINES_CPU_JDK} -D_LP64=1"
 738     fi
 739     if test "x$FLAGS_OS" != xsolaris && test "x$FLAGS_OS" != xaix; then
 740       # Solaris does not have _LP64=1 in the old build.
 741       # xlc on AIX defines _LP64=1 by default and issues a warning if we redefine it.
 742       $1_DEFINES_CPU_JVM="${$1_DEFINES_CPU_JVM} -D_LP64=1"
 743     fi
 744   fi
 745 
 746   # toolchain dependend, per-cpu
 747   if test "x$TOOLCHAIN_TYPE" = xsolstudio; then
 748     if test "x$FLAGS_CPU_ARCH" = xx86; then
 749       $1_DEFINES_CPU_JDK="${$1_DEFINES_CPU_JDK} -DcpuIntel -Di586 -D$FLAGS_CPU_LEGACY_LIB"
 750     fi
 751   elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
 752     if test "x$FLAGS_CPU" = xx86_64; then
 753       $1_DEFINES_CPU_JDK="${$1_DEFINES_CPU_JDK} -D_AMD64_ -Damd64"
 754     else
 755       $1_DEFINES_CPU_JDK="${$1_DEFINES_CPU_JDK} -D_X86_ -Dx86"
 756     fi
 757   fi
 758 
 759   # CFLAGS PER CPU
 760   if test "x$TOOLCHAIN_TYPE" = xgcc || test "x$TOOLCHAIN_TYPE" = xclang; then
 761     # COMMON to gcc and clang
 762     if test "x$FLAGS_CPU" = xx86; then
 763       # Force compatibility with i586 on 32 bit intel platforms.
 764       $1_CFLAGS_CPU="-march=i586"
 765     fi
 766   fi
 767 
 768   if test "x$TOOLCHAIN_TYPE" = xgcc; then
 769     if test "x$FLAGS_CPU" = xarm; then
 770       # -Wno-psabi to get rid of annoying "note: the mangling of 'va_list' has changed in GCC 4.4"
 771       $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)\"'"
 772       $1_CFLAGS_CPU_JVM="-DARM"
 773     elif test "x$FLAGS_CPU_ARCH" = xppc; then
 774       $1_CFLAGS_CPU_JVM="-minsert-sched-nops=regroup_exact -mno-multiple -mno-string"
 775       if test "x$FLAGS_CPU" = xppc64; then
 776         # -mminimal-toc fixes `relocation truncated to fit' error for gcc 4.1.
 777         # Use ppc64 instructions, but schedule for power5
 778         $1_CFLAGS_CPU_JVM="${$1_CFLAGS_CPU_JVM} -mminimal-toc -mcpu=powerpc64 -mtune=power5"
 779       elif test "x$FLAGS_CPU" = xppc64le; then
 780         # Little endian machine uses ELFv2 ABI.
 781         # Use Power8, this is the first CPU to support PPC64 LE with ELFv2 ABI.
 782         $1_CFLAGS_CPU_JVM="${$1_CFLAGS_CPU_JVM} -DABI_ELFv2 -mcpu=power8 -mtune=power8"
 783       fi
 784     elif test "x$FLAGS_CPU" = xs390x; then
 785       $1_CFLAGS_CPU="-mbackchain -march=z10"
 786     fi
 787 
 788     if test "x$FLAGS_CPU_ARCH" != xarm &&  test "x$FLAGS_CPU_ARCH" != xppc; then
 789       # for all archs except arm and ppc, prevent gcc to omit frame pointer
 790       $1_CFLAGS_CPU_JDK="${$1_CFLAGS_CPU_JDK} -fno-omit-frame-pointer"
 791     fi
 792 
 793     $1_CXXSTD_CXXFLAG="-std=gnu++98"
 794     FLAGS_CXX_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [${$1_CXXSTD_CXXFLAG} -Werror],
 795         PREFIX: $3, IF_FALSE: [$1_CXXSTD_CXXFLAG=""])
 796     $1_TOOLCHAIN_CFLAGS_JDK_CXXONLY="${$1_CXXSTD_CXXFLAG}"
 797     $1_TOOLCHAIN_CFLAGS_JVM="${$1_TOOLCHAIN_CFLAGS_JVM} ${$1_CXXSTD_CXXFLAG}"
 798     $2ADLC_CXXFLAG="${$1_CXXSTD_CXXFLAG}"
 799 
 800   elif test "x$TOOLCHAIN_TYPE" = xclang; then
 801     if test "x$FLAGS_OS" = xlinux; then
 802       # ppc test not really needed for clang
 803       if test "x$FLAGS_CPU_ARCH" != xarm &&  test "x$FLAGS_CPU_ARCH" != xppc; then
 804         # for all archs except arm and ppc, prevent gcc to omit frame pointer
 805         $1_CFLAGS_CPU_JDK="${$1_CFLAGS_CPU_JDK} -fno-omit-frame-pointer"
 806       fi
 807     fi
 808 
 809   elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
 810     if test "x$FLAGS_CPU" = xx86_64; then
 811       # NOTE: -xregs=no%frameptr is supposed to be default on x64
 812       $1_CFLAGS_CPU_JDK="-xregs=no%frameptr"
 813     elif test "x$FLAGS_CPU" = xsparcv9; then
 814       $1_CFLAGS_CPU_JVM="-xarch=sparc"
 815       $1_CFLAGS_CPU_JDK_LIBONLY="-xregs=no%appl"
 816     fi
 817 
 818   elif test "x$TOOLCHAIN_TYPE" = xxlc; then
 819     if test "x$FLAGS_CPU" = xppc64; then
 820       $1_CFLAGS_CPU_JVM="-qarch=ppc64"
 821     fi
 822 
 823   elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
 824     if test "x$FLAGS_CPU" = xx86; then
 825       $1_CFLAGS_CPU_JVM="-arch:IA32"
 826     elif test "x$OPENJDK_TARGET_CPU" = xx86_64; then
 827       if test "x$DEBUG_LEVEL" != xrelease; then
 828         # NOTE: This is probably redundant; -homeparams is default on
 829         # non-release builds.
 830         $1_CFLAGS_CPU_JVM="-homeparams"
 831       fi
 832     fi
 833   fi
 834 
 835   if test "x$TOOLCHAIN_TYPE" = xgcc; then
 836     FLAGS_SETUP_GCC6_COMPILER_FLAGS($1, $3)
 837     $1_TOOLCHAIN_CFLAGS="${$1_GCC6_CFLAGS}"
 838 
 839     $1_WARNING_CFLAGS_JVM="-Wno-format-zero-length -Wtype-limits -Wuninitialized"
 840   fi
 841 
 842   if test "x$TOOLCHAIN_TYPE" = xgcc || test "x$TOOLCHAIN_TYPE" = xclang; then
 843     # Check if compiler supports -fmacro-prefix-map. If so, use that to make
 844     # the __FILE__ macro resolve to paths relative to the workspace root.
 845     workspace_root_trailing_slash="${WORKSPACE_ROOT%/}/"
 846     FILE_MACRO_CFLAGS="-fmacro-prefix-map=${workspace_root_trailing_slash}="
 847     FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [${FILE_MACRO_CFLAGS}],
 848         PREFIX: $3,
 849         IF_FALSE: [
 850             FILE_MACRO_CFLAGS=
 851         ]
 852     )
 853   fi
 854 
 855   # EXPORT to API
 856   CFLAGS_JVM_COMMON="$ALWAYS_CFLAGS_JVM $ALWAYS_DEFINES_JVM \
 857       $TOOLCHAIN_CFLAGS_JVM ${$1_TOOLCHAIN_CFLAGS_JVM} \
 858       $OS_CFLAGS $OS_CFLAGS_JVM $CFLAGS_OS_DEF_JVM $DEBUG_CFLAGS_JVM \
 859       $WARNING_CFLAGS $WARNING_CFLAGS_JVM $JVM_PICFLAG $FILE_MACRO_CFLAGS"
 860 
 861   CFLAGS_JDK_COMMON="$ALWAYS_CFLAGS_JDK $ALWAYS_DEFINES_JDK $TOOLCHAIN_CFLAGS_JDK \
 862       $OS_CFLAGS $CFLAGS_OS_DEF_JDK $DEBUG_CFLAGS_JDK $DEBUG_OPTIONS_FLAGS_JDK \
 863       $WARNING_CFLAGS $WARNING_CFLAGS_JDK $DEBUG_SYMBOLS_CFLAGS_JDK \
 864       $FILE_MACRO_CFLAGS"
 865 
 866   # Use ${$2EXTRA_CFLAGS} to block EXTRA_CFLAGS to be added to build flags.
 867   # (Currently we don't have any OPENJDK_BUILD_EXTRA_CFLAGS, but that might
 868   # change in the future.)
 869 
 870   CFLAGS_JDK_COMMON_CONLY="$TOOLCHAIN_CFLAGS_JDK_CONLY  \
 871       $WARNING_CFLAGS_JDK_CONLY ${$2EXTRA_CFLAGS}"
 872   CFLAGS_JDK_COMMON_CXXONLY="$ALWAYS_DEFINES_JDK_CXXONLY \
 873       $TOOLCHAIN_CFLAGS_JDK_CXXONLY \
 874       ${$1_TOOLCHAIN_CFLAGS_JDK_CXXONLY} \
 875       $WARNING_CFLAGS_JDK_CXXONLY ${$2EXTRA_CXXFLAGS}"
 876 
 877   $1_CFLAGS_JVM="${$1_DEFINES_CPU_JVM} ${$1_CFLAGS_CPU} ${$1_CFLAGS_CPU_JVM} ${$1_TOOLCHAIN_CFLAGS} ${$1_WARNING_CFLAGS_JVM}"
 878   $1_CFLAGS_JDK="${$1_DEFINES_CPU_JDK} ${$1_CFLAGS_CPU} ${$1_CFLAGS_CPU_JDK} ${$1_TOOLCHAIN_CFLAGS}"
 879 
 880   $2JVM_CFLAGS="$CFLAGS_JVM_COMMON ${$1_CFLAGS_JVM} ${$2EXTRA_CXXFLAGS}"
 881 
 882   $2CFLAGS_JDKEXE="$CFLAGS_JDK_COMMON $CFLAGS_JDK_COMMON_CONLY ${$1_CFLAGS_JDK}"
 883   $2CXXFLAGS_JDKEXE="$CFLAGS_JDK_COMMON $CFLAGS_JDK_COMMON_CXXONLY ${$1_CFLAGS_JDK}"
 884   $2CFLAGS_JDKLIB="${$2CFLAGS_JDKEXE} $JDK_PICFLAG ${$1_CFLAGS_CPU_JDK_LIBONLY}"
 885   $2CXXFLAGS_JDKLIB="${$2CXXFLAGS_JDKEXE} $JDK_PICFLAG ${$1_CFLAGS_CPU_JDK_LIBONLY}"
 886 
 887   AC_SUBST($2JVM_CFLAGS)
 888   AC_SUBST($2CFLAGS_JDKLIB)
 889   AC_SUBST($2CFLAGS_JDKEXE)
 890   AC_SUBST($2CXXFLAGS_JDKLIB)
 891   AC_SUBST($2CXXFLAGS_JDKEXE)
 892   AC_SUBST($2ADLC_CXXFLAG)
 893 
 894   COMPILER_FP_CONTRACT_OFF_FLAG="-ffp-contract=off"
 895   # Check that the compiler supports -ffp-contract=off flag
 896   # Set FDLIBM_CFLAGS to -ffp-contract=off if it does. Empty
 897   # otherwise.
 898   # These flags are required for GCC-based builds of
 899   # fdlibm with optimization without losing precision.
 900   # Notably, -ffp-contract=off needs to be added for GCC >= 4.6.
 901   if test "x$TOOLCHAIN_TYPE" = xgcc || test "x$TOOLCHAIN_TYPE" = xclang; then
 902     FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [${COMPILER_FP_CONTRACT_OFF_FLAG}],
 903         PREFIX: $3,
 904         IF_TRUE: [$2FDLIBM_CFLAGS=${COMPILER_FP_CONTRACT_OFF_FLAG}],
 905         IF_FALSE: [$2FDLIBM_CFLAGS=""])
 906   fi
 907   AC_SUBST($2FDLIBM_CFLAGS)
 908 ])
 909 
 910 # FLAGS_SETUP_GCC6_COMPILER_FLAGS([PREFIX])
 911 # Arguments:
 912 # $1 - Prefix for each variable defined.
 913 # $2 - Prefix for compiler variables (either BUILD_ or nothing).
 914 AC_DEFUN([FLAGS_SETUP_GCC6_COMPILER_FLAGS],
 915 [
 916   # These flags are required for GCC 6 builds as undefined behaviour in OpenJDK code
 917   # runs afoul of the more aggressive versions of these optimisations.
 918   # Notably, value range propagation now assumes that the this pointer of C++
 919   # member functions is non-null.
 920   NO_DELETE_NULL_POINTER_CHECKS_CFLAG="-fno-delete-null-pointer-checks"
 921   FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [$NO_DELETE_NULL_POINTER_CHECKS_CFLAG -Werror],
 922       PREFIX: $2, IF_FALSE: [NO_DELETE_NULL_POINTER_CHECKS_CFLAG=""])
 923   NO_LIFETIME_DSE_CFLAG="-fno-lifetime-dse"
 924   FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [$NO_LIFETIME_DSE_CFLAG -Werror],
 925       PREFIX: $2, IF_FALSE: [NO_LIFETIME_DSE_CFLAG=""])
 926   $1_GCC6_CFLAGS="${NO_DELETE_NULL_POINTER_CHECKS_CFLAG} ${NO_LIFETIME_DSE_CFLAG}"
 927 ])
 928 
 929 # Documentation on common flags used for solstudio in HIGHEST.
 930 #
 931 # WARNING: Use of OPTIMIZATION_LEVEL=HIGHEST in your Makefile needs to be
 932 #          done with care, there are some assumptions below that need to
 933 #          be understood about the use of pointers, and IEEE behavior.
 934 #
 935 # -fns: Use non-standard floating point mode (not IEEE 754)
 936 # -fsimple: Do some simplification of floating point arithmetic (not IEEE 754)
 937 # -fsingle: Use single precision floating point with 'float'
 938 # -xalias_level=basic: Assume memory references via basic pointer types do not alias
 939 #   (Source with excessing pointer casting and data access with mixed
 940 #    pointer types are not recommended)
 941 # -xbuiltin=%all: Use intrinsic or inline versions for math/std functions
 942 #   (If you expect perfect errno behavior, do not use this)
 943 # -xdepend: Loop data dependency optimizations (need -xO3 or higher)
 944 # -xrestrict: Pointer parameters to functions do not overlap
 945 #   (Similar to -xalias_level=basic usage, but less obvious sometimes.
 946 #    If you pass in multiple pointers to the same data, do not use this)
 947 # -xlibmil: Inline some library routines
 948 #   (If you expect perfect errno behavior, do not use this)
 949 # -xlibmopt: Use optimized math routines (CURRENTLY DISABLED)
 950 #   (If you expect perfect errno behavior, do not use this)
 951 #  Can cause undefined external on Solaris 8 X86 on __sincos, removing for now