1 #
   2 # Copyright (c) 2011, 2016, 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 ABI profile (for arm)
  29 #
  30 AC_DEFUN([SETUP_ABI_PROFILE],
  31 [
  32   AC_ARG_WITH(abi-profile, [AS_HELP_STRING([--with-abi-profile],
  33       [specify ABI profile (for arm)])])
  34 
  35   if test "x$with_abi_profile" != x; then
  36     if test "x$OPENJDK_TARGET_CPU" != xarm && \
  37         test "x$OPENJDK_TARGET_CPU" != xaarch64; then
  38       AC_MSG_ERROR([--with-abi-profile only available on arm/aarch64])
  39     fi
  40 
  41     OPENJDK_TARGET_ABI_PROFILE=$with_abi_profile
  42     AC_MSG_CHECKING([for ABI profle])
  43     AC_MSG_RESULT([$OPENJDK_TARGET_ABI_PROFILE])
  44 
  45     if test "x$OPENJDK_TARGET_ABI_PROFILE" = xarm-vfp-sflt; then
  46       ARM_FLOAT_TYPE=vfp-sflt
  47       ARM_ARCH_TYPE_FLAGS='-march=armv7-a -mthumb'
  48     elif test "x$OPENJDK_TARGET_ABI_PROFILE" = xarm-vfp-hflt; then
  49       ARM_FLOAT_TYPE=vfp-hflt
  50       ARM_ARCH_TYPE_FLAGS='-march=armv7-a -mthumb'
  51     elif test "x$OPENJDK_TARGET_ABI_PROFILE" = xarm-sflt; then
  52       ARM_FLOAT_TYPE=sflt
  53       ARM_ARCH_TYPE_FLAGS='-march=armv5t -marm'
  54     elif test "x$OPENJDK_TARGET_ABI_PROFILE" = xarmv5-vfp-sflt; then
  55       ARM_FLOAT_TYPE=vfp-sflt
  56       ARM_ARCH_TYPE_FLAGS='-march=armv5t -marm'
  57     elif test "x$OPENJDK_TARGET_ABI_PROFILE" = xarmv6-vfp-hflt; then
  58       ARM_FLOAT_TYPE=vfp-hflt
  59       ARM_ARCH_TYPE_FLAGS='-march=armv6 -marm'
  60     elif test "x$OPENJDK_TARGET_ABI_PROFILE" = xarm64; then
  61       # No special flags, just need to trigger setting JDK_ARCH_ABI_PROP_NAME
  62       ARM_FLOAT_TYPE=
  63       ARM_ARCH_TYPE_FLAGS=
  64     elif test "x$OPENJDK_TARGET_ABI_PROFILE" = xaarch64; then
  65       # No special flags, just need to trigger setting JDK_ARCH_ABI_PROP_NAME
  66       ARM_FLOAT_TYPE=
  67       ARM_ARCH_TYPE_FLAGS=
  68     else
  69       AC_MSG_ERROR([Invalid ABI profile: "$OPENJDK_TARGET_ABI_PROFILE"])
  70     fi
  71 
  72     if test "x$ARM_FLOAT_TYPE" = xvfp-sflt; then
  73       ARM_FLOAT_TYPE_FLAGS='-mfloat-abi=softfp -mfpu=vfp -DFLOAT_ARCH=-vfp-sflt'
  74     elif test "x$ARM_FLOAT_TYPE" = xvfp-hflt; then
  75       ARM_FLOAT_TYPE_FLAGS='-mfloat-abi=hard -mfpu=vfp -DFLOAT_ARCH=-vfp-hflt'
  76     elif test "x$ARM_FLOAT_TYPE" = xsflt; then
  77       ARM_FLOAT_TYPE_FLAGS='-msoft-float -mfpu=vfp'
  78     fi
  79     AC_MSG_CHECKING([for $ARM_FLOAT_TYPE floating point flags])
  80     AC_MSG_RESULT([$ARM_FLOAT_TYPE_FLAGS])
  81 
  82     AC_MSG_CHECKING([for arch type flags])
  83     AC_MSG_RESULT([$ARM_ARCH_TYPE_FLAGS])
  84 
  85     # Now set JDK_ARCH_ABI_PROP_NAME. This is equivalent to the last part of the
  86     # autoconf target triplet.
  87     [ JDK_ARCH_ABI_PROP_NAME=`$ECHO $OPENJDK_TARGET_AUTOCONF_NAME | $SED -e 's/.*-\([^-]*\)$/\1/'` ]
  88     # Sanity check that it is a known ABI.
  89     if test "x$JDK_ARCH_ABI_PROP_NAME" != xgnu && \
  90         test "x$JDK_ARCH_ABI_PROP_NAME" != xgnueabi  && \
  91         test "x$JDK_ARCH_ABI_PROP_NAME" != xgnueabihf; then
  92           AC_MSG_WARN([Unknown autoconf target triplet ABI: "$JDK_ARCH_ABI_PROP_NAME"])
  93     fi
  94     AC_MSG_CHECKING([for ABI property name])
  95     AC_MSG_RESULT([$JDK_ARCH_ABI_PROP_NAME])
  96     AC_SUBST(JDK_ARCH_ABI_PROP_NAME)
  97 
  98     # Pass these on to the open part of configure as if they were set using
  99     # --with-extra-c[xx]flags.
 100     with_extra_cflags="$ARM_ARCH_TYPE_FLAGS $ARM_FLOAT_TYPE_FLAGS $with_extra_cflags"
 101     with_extra_cxxflags="$ARM_ARCH_TYPE_FLAGS $ARM_FLOAT_TYPE_FLAGS $with_extra_cxxflags"
 102     # Get rid of annoying "note: the mangling of 'va_list' has changed in GCC 4.4"
 103     # FIXME: This should not really be set using extra_cflags.
 104     if test "x$OPENJDK_TARGET_CPU" = xarm; then
 105         with_extra_cflags="-Wno-psabi $with_extra_cflags"
 106         with_extra_cxxflags="-Wno-psabi $with_extra_cxxflags"
 107     fi
 108     # Also add JDK_ARCH_ABI_PROP_NAME define, but only to CFLAGS.
 109     with_extra_cflags="-DJDK_ARCH_ABI_PROP_NAME='\"\$(JDK_ARCH_ABI_PROP_NAME)\"' $with_extra_cflags"
 110     # And pass the architecture flags to the linker as well
 111     with_extra_ldflags="$ARM_ARCH_TYPE_FLAGS $ARM_FLOAT_TYPE_FLAGS $with_extra_ldflags"
 112   fi
 113 
 114   # When building with an abi profile, the name of that profile is appended on the
 115   # bundle platform, which is used in bundle names.
 116   if test "x$OPENJDK_TARGET_ABI_PROFILE" != x; then
 117     OPENJDK_TARGET_BUNDLE_PLATFORM="$OPENJDK_TARGET_OS_BUNDLE-$OPENJDK_TARGET_ABI_PROFILE"
 118   fi
 119   AC_SUBST(OPENJDK_TARGET_ABI_PROFILE)
 120 ])
 121 
 122 # Reset the global CFLAGS/LDFLAGS variables and initialize them with the
 123 # corresponding configure arguments instead
 124 AC_DEFUN_ONCE([FLAGS_SETUP_USER_SUPPLIED_FLAGS],
 125 [
 126   if test "x$CFLAGS" != "x${ADDED_CFLAGS}"; then
 127     AC_MSG_WARN([Ignoring CFLAGS($CFLAGS) found in environment. Use --with-extra-cflags])
 128   fi
 129 
 130   if test "x$CXXFLAGS" != "x${ADDED_CXXFLAGS}"; then
 131     AC_MSG_WARN([Ignoring CXXFLAGS($CXXFLAGS) found in environment. Use --with-extra-cxxflags])
 132   fi
 133 
 134   if test "x$LDFLAGS" != "x${ADDED_LDFLAGS}"; then
 135     AC_MSG_WARN([Ignoring LDFLAGS($LDFLAGS) found in environment. Use --with-extra-ldflags])
 136   fi
 137 
 138   AC_ARG_WITH(extra-cflags, [AS_HELP_STRING([--with-extra-cflags],
 139       [extra flags to be used when compiling jdk c-files])])
 140 
 141   AC_ARG_WITH(extra-cxxflags, [AS_HELP_STRING([--with-extra-cxxflags],
 142       [extra flags to be used when compiling jdk c++-files])])
 143 
 144   AC_ARG_WITH(extra-ldflags, [AS_HELP_STRING([--with-extra-ldflags],
 145       [extra flags to be used when linking jdk])])
 146 
 147   EXTRA_CFLAGS="$with_extra_cflags"
 148   EXTRA_CXXFLAGS="$with_extra_cxxflags"
 149   EXTRA_LDFLAGS="$with_extra_ldflags"
 150 
 151   # Hotspot needs these set in their legacy form
 152   LEGACY_EXTRA_CFLAGS="$LEGACY_EXTRA_CFLAGS $EXTRA_CFLAGS"
 153   LEGACY_EXTRA_CXXFLAGS="$LEGACY_EXTRA_CXXFLAGS $EXTRA_CXXFLAGS"
 154   LEGACY_EXTRA_LDFLAGS="$LEGACY_EXTRA_LDFLAGS $EXTRA_LDFLAGS"
 155 
 156   AC_SUBST(LEGACY_EXTRA_CFLAGS)
 157   AC_SUBST(LEGACY_EXTRA_CXXFLAGS)
 158   AC_SUBST(LEGACY_EXTRA_LDFLAGS)
 159 
 160   AC_SUBST(EXTRA_CFLAGS)
 161   AC_SUBST(EXTRA_CXXFLAGS)
 162   AC_SUBST(EXTRA_LDFLAGS)
 163 
 164   # The global CFLAGS and LDLAGS variables are used by configure tests and
 165   # should include the extra parameters
 166   CFLAGS="$EXTRA_CFLAGS"
 167   CXXFLAGS="$EXTRA_CXXFLAGS"
 168   LDFLAGS="$EXTRA_LDFLAGS"
 169   CPPFLAGS=""
 170 ])
 171 
 172 # Setup the sysroot flags and add them to global CFLAGS and LDFLAGS so
 173 # that configure can use them while detecting compilers.
 174 # TOOLCHAIN_TYPE is available here.
 175 # Param 1 - Optional prefix to all variables. (e.g BUILD_)
 176 AC_DEFUN([FLAGS_SETUP_SYSROOT_FLAGS],
 177 [
 178   if test "x[$]$1SYSROOT" != "x"; then
 179     if test "x$TOOLCHAIN_TYPE" = xsolstudio; then
 180       if test "x$OPENJDK_TARGET_OS" = xsolaris; then
 181         # Solaris Studio does not have a concept of sysroot. Instead we must
 182         # make sure the default include and lib dirs are appended to each
 183         # compile and link command line. Must also add -I-xbuiltin to enable
 184         # inlining of system functions and intrinsics.
 185         $1SYSROOT_CFLAGS="-I-xbuiltin -I[$]$1SYSROOT/usr/include"
 186         $1SYSROOT_LDFLAGS="-L[$]$1SYSROOT/usr/lib$OPENJDK_TARGET_CPU_ISADIR \
 187             -L[$]$1SYSROOT/lib$OPENJDK_TARGET_CPU_ISADIR \
 188             -L[$]$1SYSROOT/usr/ccs/lib$OPENJDK_TARGET_CPU_ISADIR"
 189       fi
 190     elif test "x$TOOLCHAIN_TYPE" = xgcc; then
 191       $1SYSROOT_CFLAGS="--sysroot=[$]$1SYSROOT"
 192       $1SYSROOT_LDFLAGS="--sysroot=[$]$1SYSROOT"
 193     elif test "x$TOOLCHAIN_TYPE" = xclang; then
 194       $1SYSROOT_CFLAGS="-isysroot [$]$1SYSROOT"
 195       $1SYSROOT_LDFLAGS="-isysroot [$]$1SYSROOT"
 196     fi
 197     # Propagate the sysroot args to hotspot
 198     $1LEGACY_EXTRA_CFLAGS="[$]$1LEGACY_EXTRA_CFLAGS [$]$1SYSROOT_CFLAGS"
 199     $1LEGACY_EXTRA_CXXFLAGS="[$]$1LEGACY_EXTRA_CXXFLAGS [$]$1SYSROOT_CFLAGS"
 200     $1LEGACY_EXTRA_LDFLAGS="[$]$1LEGACY_EXTRA_LDFLAGS [$]$1SYSROOT_LDFLAGS"
 201     # The global CFLAGS and LDFLAGS variables need these for configure to function
 202     $1CFLAGS="[$]$1CFLAGS [$]$1SYSROOT_CFLAGS"
 203     $1CPPFLAGS="[$]$1CPPFLAGS [$]$1SYSROOT_CFLAGS"
 204     $1CXXFLAGS="[$]$1CXXFLAGS [$]$1SYSROOT_CFLAGS"
 205     $1LDFLAGS="[$]$1LDFLAGS [$]$1SYSROOT_LDFLAGS"
 206   fi
 207 
 208   if test "x$OPENJDK_TARGET_OS" = xmacosx; then
 209     # We also need -iframework<path>/System/Library/Frameworks
 210     $1SYSROOT_CFLAGS="[$]$1SYSROOT_CFLAGS -iframework [$]$1SYSROOT/System/Library/Frameworks"
 211     $1SYSROOT_LDFLAGS="[$]$1SYSROOT_LDFLAGS -iframework [$]$1SYSROOT/System/Library/Frameworks"
 212     # These always need to be set, or we can't find the frameworks embedded in JavaVM.framework
 213     # set this here so it doesn't have to be peppered throughout the forest
 214     $1SYSROOT_CFLAGS="[$]$1SYSROOT_CFLAGS -F [$]$1SYSROOT/System/Library/Frameworks/JavaVM.framework/Frameworks"
 215     $1SYSROOT_LDFLAGS="[$]$1SYSROOT_LDFLAGS -F [$]$1SYSROOT/System/Library/Frameworks/JavaVM.framework/Frameworks"
 216   fi
 217 
 218   AC_SUBST($1SYSROOT_CFLAGS)
 219   AC_SUBST($1SYSROOT_LDFLAGS)
 220 ])
 221 
 222 AC_DEFUN_ONCE([FLAGS_SETUP_INIT_FLAGS],
 223 [
 224   # COMPILER_TARGET_BITS_FLAG  : option for selecting 32- or 64-bit output
 225   # COMPILER_COMMAND_FILE_FLAG : option for passing a command file to the compiler
 226   # COMPILER_BINDCMD_FILE_FLAG : option for specifying a file which saves the binder
 227   #                              commands produced by the link step (currently AIX only)
 228   if test "x$TOOLCHAIN_TYPE" = xxlc; then
 229     COMPILER_TARGET_BITS_FLAG="-q"
 230     COMPILER_COMMAND_FILE_FLAG="-f"
 231     COMPILER_BINDCMD_FILE_FLAG="-bloadmap:"
 232   else
 233     COMPILER_TARGET_BITS_FLAG="-m"
 234     COMPILER_COMMAND_FILE_FLAG="@"
 235     COMPILER_BINDCMD_FILE_FLAG=""
 236 
 237     # The solstudio linker does not support @-files.
 238     if test "x$TOOLCHAIN_TYPE" = xsolstudio; then
 239       COMPILER_COMMAND_FILE_FLAG=
 240     fi
 241 
 242     # Check if @file is supported by gcc
 243     if test "x$TOOLCHAIN_TYPE" = xgcc; then
 244       AC_MSG_CHECKING([if @file is supported by gcc])
 245       # Extra emtpy "" to prevent ECHO from interpreting '--version' as argument
 246       $ECHO "" "--version" > command.file
 247       if $CXX @command.file 2>&AS_MESSAGE_LOG_FD >&AS_MESSAGE_LOG_FD; then
 248         AC_MSG_RESULT(yes)
 249         COMPILER_COMMAND_FILE_FLAG="@"
 250       else
 251         AC_MSG_RESULT(no)
 252         COMPILER_COMMAND_FILE_FLAG=
 253       fi
 254       $RM command.file
 255     fi
 256   fi
 257   AC_SUBST(COMPILER_TARGET_BITS_FLAG)
 258   AC_SUBST(COMPILER_COMMAND_FILE_FLAG)
 259   AC_SUBST(COMPILER_BINDCMD_FILE_FLAG)
 260 
 261   # FIXME: figure out if we should select AR flags depending on OS or toolchain.
 262   if test "x$OPENJDK_TARGET_OS" = xmacosx; then
 263     ARFLAGS="-r"
 264   elif test "x$OPENJDK_TARGET_OS" = xaix; then
 265     ARFLAGS="-X64"
 266   elif test "x$OPENJDK_TARGET_OS" = xwindows; then
 267     # lib.exe is used as AR to create static libraries.
 268     ARFLAGS="-nologo -NODEFAULTLIB:MSVCRT"
 269   else
 270     ARFLAGS=""
 271   fi
 272   AC_SUBST(ARFLAGS)
 273 
 274   ## Setup strip.
 275   # FIXME: should this really be per platform, or should it be per toolchain type?
 276   # strip is not provided by clang or solstudio; so guessing platform makes most sense.
 277   # FIXME: we should really only export STRIPFLAGS from here, not POST_STRIP_CMD.
 278   if test "x$OPENJDK_TARGET_OS" = xlinux; then
 279     STRIPFLAGS="-g"
 280   elif test "x$OPENJDK_TARGET_OS" = xsolaris; then
 281     STRIPFLAGS="-x"
 282   elif test "x$OPENJDK_TARGET_OS" = xmacosx; then
 283     STRIPFLAGS="-S"
 284   elif test "x$OPENJDK_TARGET_OS" = xaix; then
 285     STRIPFLAGS="-X32_64"
 286   fi
 287 
 288   AC_SUBST(STRIPFLAGS)
 289 
 290   if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
 291     CC_OUT_OPTION=-Fo
 292     EXE_OUT_OPTION=-out:
 293     LD_OUT_OPTION=-out:
 294     AR_OUT_OPTION=-out:
 295   else
 296     # The option used to specify the target .o,.a or .so file.
 297     # When compiling, how to specify the to be created object file.
 298     CC_OUT_OPTION='-o$(SPACE)'
 299     # When linking, how to specify the to be created executable.
 300     EXE_OUT_OPTION='-o$(SPACE)'
 301     # When linking, how to specify the to be created dynamically linkable library.
 302     LD_OUT_OPTION='-o$(SPACE)'
 303     # When archiving, how to specify the to be create static archive for object files.
 304     AR_OUT_OPTION='rcs$(SPACE)'
 305   fi
 306   AC_SUBST(CC_OUT_OPTION)
 307   AC_SUBST(EXE_OUT_OPTION)
 308   AC_SUBST(LD_OUT_OPTION)
 309   AC_SUBST(AR_OUT_OPTION)
 310 
 311   # On Windows, we need to set RC flags.
 312   if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
 313     RC_FLAGS="-nologo -l0x409"
 314     JVM_RCFLAGS="-nologo"
 315     if test "x$DEBUG_LEVEL" = xrelease; then
 316       RC_FLAGS="$RC_FLAGS -DNDEBUG"
 317       JVM_RCFLAGS="$JVM_RCFLAGS -DNDEBUG"
 318     fi
 319 
 320     # The version variables used to create RC_FLAGS may be overridden
 321     # in a custom configure script, or possibly the command line.
 322     # Let those variables be expanded at make time in spec.gmk.
 323     # The \$ are escaped to the shell, and the $(...) variables
 324     # are evaluated by make.
 325     RC_FLAGS="$RC_FLAGS \
 326         -D\"JDK_VERSION_STRING=\$(VERSION_STRING)\" \
 327         -D\"JDK_COMPANY=\$(COMPANY_NAME)\" \
 328         -D\"JDK_COMPONENT=\$(PRODUCT_NAME) \$(JDK_RC_PLATFORM_NAME) binary\" \
 329         -D\"JDK_VER=\$(VERSION_NUMBER)\" \
 330         -D\"JDK_COPYRIGHT=Copyright \xA9 $COPYRIGHT_YEAR\" \
 331         -D\"JDK_NAME=\$(PRODUCT_NAME) \$(JDK_RC_PLATFORM_NAME) \$(VERSION_MAJOR)\" \
 332         -D\"JDK_FVER=\$(subst .,\$(COMMA),\$(VERSION_NUMBER_FOUR_POSITIONS))\""
 333 
 334     JVM_RCFLAGS="$JVM_RCFLAGS \
 335         -D\"HS_BUILD_ID=\$(VERSION_STRING)\" \
 336         -D\"HS_COMPANY=\$(COMPANY_NAME)\" \
 337         -D\"JDK_DOTVER=\$(VERSION_NUMBER_FOUR_POSITIONS)\" \
 338         -D\"HS_COPYRIGHT=Copyright $COPYRIGHT_YEAR\" \
 339         -D\"HS_NAME=\$(PRODUCT_NAME) \$(VERSION_SHORT)\" \
 340         -D\"JDK_VER=\$(subst .,\$(COMMA),\$(VERSION_NUMBER_FOUR_POSITIONS))\" \
 341         -D\"HS_FNAME=jvm.dll\" \
 342         -D\"HS_INTERNAL_NAME=jvm\""
 343   fi
 344   AC_SUBST(RC_FLAGS)
 345   AC_SUBST(JVM_RCFLAGS)
 346 
 347   if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
 348     # silence copyright notice and other headers.
 349     COMMON_CCXXFLAGS="$COMMON_CCXXFLAGS -nologo"
 350   fi
 351 ])
 352 
 353 AC_DEFUN([FLAGS_SETUP_COMPILER_FLAGS_FOR_LIBS],
 354 [
 355   ###############################################################################
 356   #
 357   # How to compile shared libraries.
 358   #
 359 
 360   if test "x$TOOLCHAIN_TYPE" = xgcc; then
 361     PICFLAG="-fPIC"
 362     C_FLAG_REORDER=''
 363     CXX_FLAG_REORDER=''
 364 
 365     if test "x$OPENJDK_TARGET_OS" = xmacosx; then
 366       # Linking is different on MacOSX
 367       if test "x$STATIC_BUILD" = xtrue; then
 368         SHARED_LIBRARY_FLAGS ='-undefined dynamic_lookup'
 369       else
 370         SHARED_LIBRARY_FLAGS="-dynamiclib -compatibility_version 1.0.0 -current_version 1.0.0 $PICFLAG"
 371         JVM_CFLAGS="$JVM_CFLAGS $PICFLAG"
 372       fi
 373       SET_EXECUTABLE_ORIGIN='-Wl,-rpath,@loader_path/.'
 374       SET_SHARED_LIBRARY_ORIGIN="$SET_EXECUTABLE_ORIGIN"
 375       SET_SHARED_LIBRARY_NAME='-Wl,-install_name,@rpath/[$]1'
 376       SET_SHARED_LIBRARY_MAPFILE='-Wl,-exported_symbols_list,[$]1'
 377     else
 378       # Default works for linux, might work on other platforms as well.
 379       SHARED_LIBRARY_FLAGS='-shared'
 380       SET_EXECUTABLE_ORIGIN='-Wl,-rpath,\$$$$ORIGIN[$]1'
 381       SET_SHARED_LIBRARY_ORIGIN="-Wl,-z,origin $SET_EXECUTABLE_ORIGIN"
 382       SET_SHARED_LIBRARY_NAME='-Wl,-soname=[$]1'
 383       SET_SHARED_LIBRARY_MAPFILE='-Wl,-version-script=[$]1'
 384     fi
 385   elif test "x$TOOLCHAIN_TYPE" = xclang; then
 386     C_FLAG_REORDER=''
 387     CXX_FLAG_REORDER=''
 388 
 389     if test "x$OPENJDK_TARGET_OS" = xmacosx; then
 390       # Linking is different on MacOSX
 391       PICFLAG=''
 392       SHARED_LIBRARY_FLAGS="-dynamiclib -compatibility_version 1.0.0 -current_version 1.0.0 $PICFLAG"
 393       SET_EXECUTABLE_ORIGIN='-Wl,-rpath,@loader_path/.'
 394       SET_SHARED_LIBRARY_ORIGIN="$SET_EXECUTABLE_ORIGIN"
 395       SET_SHARED_LIBRARY_NAME='-Wl,-install_name,@rpath/[$]1'
 396       SET_SHARED_LIBRARY_MAPFILE='-Wl,-exported_symbols_list,[$]1'
 397 
 398       if test "x$STATIC_BUILD" = xfalse; then
 399         JVM_CFLAGS="$JVM_CFLAGS -fPIC"
 400       fi
 401     else
 402       # Default works for linux, might work on other platforms as well.
 403       PICFLAG='-fPIC'
 404       SHARED_LIBRARY_FLAGS='-shared'
 405       SET_EXECUTABLE_ORIGIN='-Wl,-rpath,\$$$$ORIGIN[$]1'
 406       SET_SHARED_LIBRARY_ORIGIN="-Wl,-z,origin $SET_EXECUTABLE_ORIGIN"
 407       SET_SHARED_LIBRARY_NAME='-Wl,-soname=[$]1'
 408       SET_SHARED_LIBRARY_MAPFILE='-Wl,-version-script=[$]1'
 409     fi
 410   elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
 411     PICFLAG="-KPIC"
 412     C_FLAG_REORDER='-xF'
 413     CXX_FLAG_REORDER='-xF'
 414     SHARED_LIBRARY_FLAGS="-G"
 415     SET_EXECUTABLE_ORIGIN='-R\$$$$ORIGIN[$]1'
 416     SET_SHARED_LIBRARY_ORIGIN="$SET_EXECUTABLE_ORIGIN"
 417     SET_SHARED_LIBRARY_NAME='-h [$]1'
 418     SET_SHARED_LIBRARY_MAPFILE='-M[$]1'
 419   elif test "x$TOOLCHAIN_TYPE" = xxlc; then
 420     # '-qpic' defaults to 'qpic=small'. This means that the compiler generates only
 421     # one instruction for accessing the TOC. If the TOC grows larger than 64K, the linker
 422     # will have to patch this single instruction with a call to some out-of-order code which
 423     # does the load from the TOC. This is of course slow. But in that case we also would have
 424     # to use '-bbigtoc' for linking anyway so we could also change the PICFLAG to 'qpic=large'.
 425     # With 'qpic=large' the compiler will by default generate a two-instruction sequence which
 426     # can be patched directly by the linker and does not require a jump to out-of-order code.
 427     # Another alternative instead of using 'qpic=large -bbigtoc' may be to use '-qminimaltoc'
 428     # instead. This creates a distinct TOC for every compilation unit (and thus requires two
 429     # loads for accessing a global variable). But there are rumors that this may be seen as a
 430     # 'performance feature' because of improved code locality of the symbols used in a
 431     # compilation unit.
 432     PICFLAG="-qpic"
 433     JVM_CFLAGS="$JVM_CFLAGS $PICFLAG"
 434     C_FLAG_REORDER=''
 435     CXX_FLAG_REORDER=''
 436     SHARED_LIBRARY_FLAGS="-qmkshrobj -bM:SRE -bnoentry"
 437     SET_EXECUTABLE_ORIGIN=""
 438     SET_SHARED_LIBRARY_ORIGIN=''
 439     SET_SHARED_LIBRARY_NAME=''
 440     SET_SHARED_LIBRARY_MAPFILE=''
 441   elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
 442     PICFLAG=""
 443     C_FLAG_REORDER=''
 444     CXX_FLAG_REORDER=''
 445     SHARED_LIBRARY_FLAGS="-dll"
 446     SET_EXECUTABLE_ORIGIN=''
 447     SET_SHARED_LIBRARY_ORIGIN=''
 448     SET_SHARED_LIBRARY_NAME=''
 449     SET_SHARED_LIBRARY_MAPFILE='-def:[$]1'
 450   fi
 451 
 452   # arm specific settings 
 453   if test "x$OPENJDK_TARGET_CPU_ARCH" = "xarm"; then
 454     CXXFLAGS_JDKLIB="$CXXFLAGS_JDKLIB -fsigned-char"
 455     CFLAGS_JDKLIB="$CFLAGS_JDKLIB -fsigned-char"
 456     CXXFLAGS_JDKEXE="$CXXFLAGS_JDKEXE -fsigned-char"
 457     CFLAGS_JDKEXE="$CFLAGS_JDKEXE -fsigned-char"
 458     # '-Wl,-z,origin' isn't used on arm.
 459     SET_SHARED_LIBRARY_ORIGIN='-Wl,-rpath,\$$$$ORIGIN[$]1'
 460   fi
 461 
 462   AC_SUBST(C_FLAG_REORDER)
 463   AC_SUBST(CXX_FLAG_REORDER)
 464   AC_SUBST(SET_EXECUTABLE_ORIGIN)
 465   AC_SUBST(SET_SHARED_LIBRARY_ORIGIN)
 466   AC_SUBST(SET_SHARED_LIBRARY_NAME)
 467   AC_SUBST(SET_SHARED_LIBRARY_MAPFILE)
 468   AC_SUBST(SHARED_LIBRARY_FLAGS)
 469 
 470   # The (cross) compiler is now configured, we can now test capabilities
 471   # of the target platform.
 472 ])
 473 
 474 # Documentation on common flags used for solstudio in HIGHEST.
 475 #
 476 # WARNING: Use of OPTIMIZATION_LEVEL=HIGHEST in your Makefile needs to be
 477 #          done with care, there are some assumptions below that need to
 478 #          be understood about the use of pointers, and IEEE behavior.
 479 #
 480 # -fns: Use non-standard floating point mode (not IEEE 754)
 481 # -fsimple: Do some simplification of floating point arithmetic (not IEEE 754)
 482 # -fsingle: Use single precision floating point with 'float'
 483 # -xalias_level=basic: Assume memory references via basic pointer types do not alias
 484 #   (Source with excessing pointer casting and data access with mixed
 485 #    pointer types are not recommended)
 486 # -xbuiltin=%all: Use intrinsic or inline versions for math/std functions
 487 #   (If you expect perfect errno behavior, do not use this)
 488 # -xdepend: Loop data dependency optimizations (need -xO3 or higher)
 489 # -xrestrict: Pointer parameters to functions do not overlap
 490 #   (Similar to -xalias_level=basic usage, but less obvious sometimes.
 491 #    If you pass in multiple pointers to the same data, do not use this)
 492 # -xlibmil: Inline some library routines
 493 #   (If you expect perfect errno behavior, do not use this)
 494 # -xlibmopt: Use optimized math routines (CURRENTLY DISABLED)
 495 #   (If you expect perfect errno behavior, do not use this)
 496 #  Can cause undefined external on Solaris 8 X86 on __sincos, removing for now
 497 
 498     # FIXME: this will never happen since sparc != sparcv9, ie 32 bit, which we don't build anymore.
 499     # Bug?
 500     #if test "x$OPENJDK_TARGET_CPU" = xsparc; then
 501     #  CFLAGS_JDK="${CFLAGS_JDK} -xmemalign=4s"
 502     #  CXXFLAGS_JDK="${CXXFLAGS_JDK} -xmemalign=4s"
 503     #fi
 504 
 505 AC_DEFUN_ONCE([FLAGS_SETUP_COMPILER_FLAGS_FOR_OPTIMIZATION],
 506 [
 507 
 508   ###############################################################################
 509   #
 510   # Setup the opt flags for different compilers
 511   # and different operating systems.
 512   #
 513 
 514   # FIXME: this was indirectly the old default, but just inherited.
 515   # if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
 516   #   C_FLAG_DEPS="-MMD -MF"
 517   # fi
 518 
 519   # Generate make dependency files
 520   if test "x$TOOLCHAIN_TYPE" = xgcc; then
 521     C_FLAG_DEPS="-MMD -MF"
 522   elif test "x$TOOLCHAIN_TYPE" = xclang; then
 523     C_FLAG_DEPS="-MMD -MF"
 524   elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
 525     C_FLAG_DEPS="-xMMD -xMF"
 526   elif test "x$TOOLCHAIN_TYPE" = xxlc; then
 527     C_FLAG_DEPS="-qmakedep=gcc -MF"
 528   fi
 529   CXX_FLAG_DEPS="$C_FLAG_DEPS"
 530   AC_SUBST(C_FLAG_DEPS)
 531   AC_SUBST(CXX_FLAG_DEPS)
 532 
 533   # Debug symbols
 534   if test "x$TOOLCHAIN_TYPE" = xgcc; then
 535     if test "x$OPENJDK_TARGET_CPU_BITS" = "x64" && test "x$DEBUG_LEVEL" = "xfastdebug"; then
 536       # reduce from default "-g2" option to save space
 537       CFLAGS_DEBUG_SYMBOLS="-g1"
 538       CXXFLAGS_DEBUG_SYMBOLS="-g1"
 539     else
 540       CFLAGS_DEBUG_SYMBOLS="-g"
 541       CXXFLAGS_DEBUG_SYMBOLS="-g"
 542     fi
 543   elif test "x$TOOLCHAIN_TYPE" = xclang; then
 544     CFLAGS_DEBUG_SYMBOLS="-g"
 545     CXXFLAGS_DEBUG_SYMBOLS="-g"
 546   elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
 547     CFLAGS_DEBUG_SYMBOLS="-g -xs"
 548     # -g0 enables debug symbols without disabling inlining.
 549     CXXFLAGS_DEBUG_SYMBOLS="-g0 -xs"
 550   elif test "x$TOOLCHAIN_TYPE" = xxlc; then
 551     CFLAGS_DEBUG_SYMBOLS="-g"
 552     CXXFLAGS_DEBUG_SYMBOLS="-g"
 553   elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
 554     CFLAGS_DEBUG_SYMBOLS="-Zi"
 555     CXXFLAGS_DEBUG_SYMBOLS="-Zi"
 556   fi
 557   AC_SUBST(CFLAGS_DEBUG_SYMBOLS)
 558   AC_SUBST(CXXFLAGS_DEBUG_SYMBOLS)
 559 
 560   # Debug symbols for JVM_CFLAGS
 561   if test "x$TOOLCHAIN_TYPE" = xsolstudio; then
 562     JVM_CFLAGS_SYMBOLS="$JVM_CFLAGS_SYMBOLS -xs"
 563     if test "x$DEBUG_LEVEL" = xslowdebug; then
 564       JVM_CFLAGS_SYMBOLS="$JVM_CFLAGS_SYMBOLS -g"
 565     else
 566       # -g0 does not disable inlining, which -g does.
 567       JVM_CFLAGS_SYMBOLS="$JVM_CFLAGS_SYMBOLS -g0"
 568     fi
 569   elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
 570     JVM_CFLAGS_SYMBOLS="$JVM_CFLAGS_SYMBOLS -Z7 -d2Zi+"
 571   else
 572     JVM_CFLAGS_SYMBOLS="$JVM_CFLAGS_SYMBOLS -g"
 573   fi
 574   AC_SUBST(JVM_CFLAGS_SYMBOLS)
 575 
 576   # bounds, memory and behavior checking options
 577   if test "x$TOOLCHAIN_TYPE" = xgcc; then
 578     case $DEBUG_LEVEL in
 579     release )
 580       # no adjustment
 581       ;;
 582     fastdebug )
 583       # no adjustment
 584       ;;
 585     slowdebug )
 586       # FIXME: By adding this to C(XX)FLAGS_DEBUG_OPTIONS/JVM_CFLAGS_SYMBOLS it
 587       # get's added conditionally on whether we produce debug symbols or not.
 588       # This is most likely not really correct.
 589 
 590       # Add runtime stack smashing and undefined behavior checks.
 591       # Not all versions of gcc support -fstack-protector
 592       STACK_PROTECTOR_CFLAG="-fstack-protector-all"
 593       FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [$STACK_PROTECTOR_CFLAG -Werror], IF_FALSE: [STACK_PROTECTOR_CFLAG=""])
 594 
 595       CFLAGS_DEBUG_OPTIONS="$STACK_PROTECTOR_CFLAG --param ssp-buffer-size=1"
 596       CXXFLAGS_DEBUG_OPTIONS="$STACK_PROTECTOR_CFLAG --param ssp-buffer-size=1"
 597       if test "x$STACK_PROTECTOR_CFLAG" != x; then
 598         JVM_CFLAGS_SYMBOLS="$JVM_CFLAGS_SYMBOLS $STACK_PROTECTOR_CFLAG --param ssp-buffer-size=1"
 599       fi
 600       ;;
 601     esac
 602   fi
 603 
 604   if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
 605     if test "x$DEBUG_LEVEL" != xrelease; then
 606       if test "x$OPENJDK_TARGET_CPU" = xx86_64; then
 607         JVM_CFLAGS="$JVM_CFLAGS -homeparams"
 608       fi
 609     fi
 610   fi
 611 
 612   # Optimization levels
 613   if test "x$TOOLCHAIN_TYPE" = xsolstudio; then
 614     CC_HIGHEST="$CC_HIGHEST -fns -fsimple -fsingle -xbuiltin=%all -xdepend -xrestrict -xlibmil"
 615 
 616     if test "x$OPENJDK_TARGET_CPU_ARCH" = "xx86"; then
 617       # FIXME: seems we always set -xregs=no%frameptr; put it elsewhere more global?
 618       C_O_FLAG_HIGHEST_JVM="-xO4"
 619       C_O_FLAG_HIGHEST="-xO4 -Wu,-O4~yz $CC_HIGHEST -xalias_level=basic -xregs=no%frameptr"
 620       C_O_FLAG_HI="-xO4 -Wu,-O4~yz -xregs=no%frameptr"
 621       C_O_FLAG_NORM="-xO2 -Wu,-O2~yz -xregs=no%frameptr"
 622       C_O_FLAG_DEBUG="-xregs=no%frameptr"
 623       C_O_FLAG_DEBUG_JVM=""
 624       C_O_FLAG_NONE="-xregs=no%frameptr"
 625       CXX_O_FLAG_HIGHEST_JVM="-xO4"
 626       CXX_O_FLAG_HIGHEST="-xO4 -Qoption ube -O4~yz $CC_HIGHEST -xregs=no%frameptr"
 627       CXX_O_FLAG_HI="-xO4 -Qoption ube -O4~yz -xregs=no%frameptr"
 628       CXX_O_FLAG_NORM="-xO2 -Qoption ube -O2~yz -xregs=no%frameptr"
 629       CXX_O_FLAG_DEBUG="-xregs=no%frameptr"
 630       CXX_O_FLAG_DEBUG_JVM=""
 631       CXX_O_FLAG_NONE="-xregs=no%frameptr"
 632       if test "x$OPENJDK_TARGET_CPU_BITS" = "x32"; then
 633         C_O_FLAG_HIGHEST="$C_O_FLAG_HIGHEST -xchip=pentium"
 634         CXX_O_FLAG_HIGHEST="$CXX_O_FLAG_HIGHEST -xchip=pentium"
 635       fi
 636     elif test "x$OPENJDK_TARGET_CPU_ARCH" = "xsparc"; then
 637       C_O_FLAG_HIGHEST_JVM="-xO4"
 638       C_O_FLAG_HIGHEST="-xO4 -Wc,-Qrm-s -Wc,-Qiselect-T0 $CC_HIGHEST -xalias_level=basic -xprefetch=auto,explicit -xchip=ultra"
 639       C_O_FLAG_HI="-xO4 -Wc,-Qrm-s -Wc,-Qiselect-T0"
 640       C_O_FLAG_NORM="-xO2 -Wc,-Qrm-s -Wc,-Qiselect-T0"
 641       C_O_FLAG_DEBUG=""
 642       C_O_FLAG_DEBUG_JVM=""
 643       C_O_FLAG_NONE=""
 644       CXX_O_FLAG_HIGHEST_JVM="-xO4"
 645       CXX_O_FLAG_HIGHEST="-xO4 -Qoption cg -Qrm-s -Qoption cg -Qiselect-T0 $CC_HIGHEST -xprefetch=auto,explicit -xchip=ultra"
 646       CXX_O_FLAG_HI="-xO4 -Qoption cg -Qrm-s -Qoption cg -Qiselect-T0"
 647       CXX_O_FLAG_NORM="-xO2 -Qoption cg -Qrm-s -Qoption cg -Qiselect-T0"
 648       CXX_O_FLAG_DEBUG=""
 649       CXX_O_FLAG_DEBUG_JVM=""
 650       CXX_O_FLAG_NONE=""
 651     fi
 652   else
 653     # The remaining toolchains share opt flags between CC and CXX;
 654     # setup for C and duplicate afterwards.
 655     if test "x$TOOLCHAIN_TYPE" = xgcc; then
 656       if test "x$OPENJDK_TARGET_OS" = xmacosx; then
 657         # On MacOSX we optimize for size, something
 658         # we should do for all platforms?
 659         C_O_FLAG_HIGHEST_JVM="-Os"
 660         C_O_FLAG_HIGHEST="-Os"
 661         C_O_FLAG_HI="-Os"
 662         C_O_FLAG_NORM="-Os"
 663         C_O_FLAG_SIZE="-Os"
 664       else
 665         C_O_FLAG_HIGHEST_JVM="-O3"
 666         C_O_FLAG_HIGHEST="-O3"
 667         C_O_FLAG_HI="-O3"
 668         C_O_FLAG_NORM="-O2"
 669         C_O_FLAG_SIZE="-Os"
 670       fi
 671       C_O_FLAG_DEBUG="-O0"
 672       if test "x$OPENJDK_TARGET_OS" = xmacosx; then
 673         C_O_FLAG_DEBUG_JVM=""
 674       elif test "x$OPENJDK_TARGET_OS" = xlinux; then
 675         C_O_FLAG_DEBUG_JVM="-O0"
 676       fi
 677       C_O_FLAG_NONE="-O0"
 678     elif test "x$TOOLCHAIN_TYPE" = xclang; then
 679       if test "x$OPENJDK_TARGET_OS" = xmacosx; then
 680         # On MacOSX we optimize for size, something
 681         # we should do for all platforms?
 682         C_O_FLAG_HIGHEST_JVM="-Os"
 683         C_O_FLAG_HIGHEST="-Os"
 684         C_O_FLAG_HI="-Os"
 685         C_O_FLAG_NORM="-Os"
 686         C_O_FLAG_SIZE="-Os"
 687       else
 688         C_O_FLAG_HIGHEST_JVM="-O3"
 689         C_O_FLAG_HIGHEST="-O3"
 690         C_O_FLAG_HI="-O3"
 691         C_O_FLAG_NORM="-O2"
 692         C_O_FLAG_SIZE="-Os"
 693       fi
 694       C_O_FLAG_DEBUG="-O0"
 695       if test "x$OPENJDK_TARGET_OS" = xmacosx; then
 696         C_O_FLAG_DEBUG_JVM=""
 697       elif test "x$OPENJDK_TARGET_OS" = xlinux; then
 698         C_O_FLAG_DEBUG_JVM="-O0"
 699       fi
 700       C_O_FLAG_NONE="-O0"
 701     elif test "x$TOOLCHAIN_TYPE" = xxlc; then
 702       C_O_FLAG_HIGHEST_JVM="-O3 -qhot=level=1 -qinline -qinlglue"
 703       C_O_FLAG_HIGHEST="-O3 -qhot=level=1 -qinline -qinlglue"
 704       C_O_FLAG_HI="-O3 -qinline -qinlglue"
 705       C_O_FLAG_NORM="-O2"
 706       C_O_FLAG_DEBUG="-qnoopt"
 707       # FIXME: Value below not verified.
 708       C_O_FLAG_DEBUG_JVM=""
 709       C_O_FLAG_NONE="-qnoopt"
 710     elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
 711       C_O_FLAG_HIGHEST_JVM="-O2 -Oy-"
 712       C_O_FLAG_HIGHEST="-O2"
 713       C_O_FLAG_HI="-O1"
 714       C_O_FLAG_NORM="-O1"
 715       C_O_FLAG_DEBUG="-Od"
 716       C_O_FLAG_DEBUG_JVM=""
 717       C_O_FLAG_NONE="-Od"
 718       C_O_FLAG_SIZE="-Os"
 719     fi
 720     CXX_O_FLAG_HIGHEST_JVM="$C_O_FLAG_HIGHEST_JVM"
 721     CXX_O_FLAG_HIGHEST="$C_O_FLAG_HIGHEST"
 722     CXX_O_FLAG_HI="$C_O_FLAG_HI"
 723     CXX_O_FLAG_NORM="$C_O_FLAG_NORM"
 724     CXX_O_FLAG_DEBUG="$C_O_FLAG_DEBUG"
 725     CXX_O_FLAG_DEBUG_JVM="$C_O_FLAG_DEBUG_JVM"
 726     CXX_O_FLAG_NONE="$C_O_FLAG_NONE"
 727     CXX_O_FLAG_SIZE="$C_O_FLAG_SIZE"
 728   fi
 729 
 730   # Adjust optimization flags according to debug level.
 731   case $DEBUG_LEVEL in
 732     release )
 733       # no adjustment
 734       ;;
 735     fastdebug )
 736       # Not quite so much optimization
 737       C_O_FLAG_HI="$C_O_FLAG_NORM"
 738       CXX_O_FLAG_HI="$CXX_O_FLAG_NORM"
 739       ;;
 740     slowdebug )
 741       # Disable optimization
 742       C_O_FLAG_HIGHEST_JVM="$C_O_FLAG_DEBUG_JVM"
 743       C_O_FLAG_HIGHEST="$C_O_FLAG_DEBUG"
 744       C_O_FLAG_HI="$C_O_FLAG_DEBUG"
 745       C_O_FLAG_NORM="$C_O_FLAG_DEBUG"
 746       C_O_FLAG_SIZE="$C_O_FLAG_DEBUG"
 747       CXX_O_FLAG_HIGHEST_JVM="$CXX_O_FLAG_DEBUG_JVM"
 748       CXX_O_FLAG_HIGHEST="$CXX_O_FLAG_DEBUG"
 749       CXX_O_FLAG_HI="$CXX_O_FLAG_DEBUG"
 750       CXX_O_FLAG_NORM="$CXX_O_FLAG_DEBUG"
 751       CXX_O_FLAG_SIZE="$CXX_O_FLAG_DEBUG"
 752       ;;
 753   esac
 754 
 755   AC_SUBST(C_O_FLAG_HIGHEST_JVM)
 756   AC_SUBST(C_O_FLAG_HIGHEST)
 757   AC_SUBST(C_O_FLAG_HI)
 758   AC_SUBST(C_O_FLAG_NORM)
 759   AC_SUBST(C_O_FLAG_DEBUG)
 760   AC_SUBST(C_O_FLAG_NONE)
 761   AC_SUBST(C_O_FLAG_SIZE)
 762   AC_SUBST(CXX_O_FLAG_HIGHEST_JVM)
 763   AC_SUBST(CXX_O_FLAG_HIGHEST)
 764   AC_SUBST(CXX_O_FLAG_HI)
 765   AC_SUBST(CXX_O_FLAG_NORM)
 766   AC_SUBST(CXX_O_FLAG_DEBUG)
 767   AC_SUBST(CXX_O_FLAG_NONE)
 768   AC_SUBST(CXX_O_FLAG_SIZE)
 769 ])
 770 
 771 
 772 AC_DEFUN([FLAGS_SETUP_COMPILER_FLAGS_FOR_JDK],
 773 [
 774 
 775   FLAGS_SETUP_COMPILER_FLAGS_FOR_JDK_HELPER([TARGET])
 776   FLAGS_SETUP_COMPILER_FLAGS_FOR_JDK_HELPER([BUILD], [OPENJDK_BUILD_])
 777 
 778   # Tests are only ever compiled for TARGET
 779   # Flags for compiling test libraries
 780   CFLAGS_TESTLIB="$COMMON_CCXXFLAGS_JDK $CFLAGS_JDK $PICFLAG $CFLAGS_JDKLIB_EXTRA"
 781   CXXFLAGS_TESTLIB="$COMMON_CCXXFLAGS_JDK $CXXFLAGS_JDK $PICFLAG $CXXFLAGS_JDKLIB_EXTRA"
 782 
 783   # Flags for compiling test executables
 784   CFLAGS_TESTEXE="$COMMON_CCXXFLAGS_JDK $CFLAGS_JDK"
 785   CXXFLAGS_TESTEXE="$COMMON_CCXXFLAGS_JDK $CXXFLAGS_JDK"
 786 
 787   AC_SUBST(CFLAGS_TESTLIB)
 788   AC_SUBST(CFLAGS_TESTEXE)
 789   AC_SUBST(CXXFLAGS_TESTLIB)
 790   AC_SUBST(CXXFLAGS_TESTEXE)
 791 
 792   LDFLAGS_TESTLIB="$LDFLAGS_JDKLIB"
 793   LDFLAGS_TESTEXE="$LDFLAGS_JDKEXE $JAVA_BASE_LDFLAGS"
 794 
 795   AC_SUBST(LDFLAGS_TESTLIB)
 796   AC_SUBST(LDFLAGS_TESTEXE)
 797 
 798 ])
 799 
 800 ################################################################################
 801 # $1 - Either BUILD or TARGET to pick the correct OS/CPU variables to check
 802 #      conditionals against.
 803 # $2 - Optional prefix for each variable defined.
 804 AC_DEFUN([FLAGS_SETUP_COMPILER_FLAGS_FOR_JDK_HELPER],
 805 [
 806   # Special extras...
 807   if test "x$TOOLCHAIN_TYPE" = xsolstudio; then
 808     if test "x$OPENJDK_$1_CPU_ARCH" = "xsparc"; then
 809       $2CFLAGS_JDKLIB_EXTRA="${$2CFLAGS_JDKLIB_EXTRA} -xregs=no%appl"
 810       $2CXXFLAGS_JDKLIB_EXTRA="${$2CXXFLAGS_JDKLIB_EXTRA} -xregs=no%appl"
 811     fi
 812     $2CFLAGS_JDKLIB_EXTRA="${$2CFLAGS_JDKLIB_EXTRA} -errtags=yes -errfmt"
 813     $2CXXFLAGS_JDKLIB_EXTRA="${$2CXXFLAGS_JDKLIB_EXTRA} -errtags=yes -errfmt"
 814   elif test "x$TOOLCHAIN_TYPE" = xxlc; then
 815     $2CFLAGS_JDK="${$2CFLAGS_JDK} -qchars=signed -qfullpath -qsaveopt"
 816     $2CXXFLAGS_JDK="${$2CXXFLAGS_JDK} -qchars=signed -qfullpath -qsaveopt"
 817   elif test "x$TOOLCHAIN_TYPE" = xgcc; then
 818     $2CXXSTD_CXXFLAG="-std=gnu++98"
 819     FLAGS_CXX_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [[$]$2CXXSTD_CXXFLAG -Werror],
 820                                                  IF_FALSE: [$2CXXSTD_CXXFLAG=""])
 821     $2CXXFLAGS_JDK="${$2CXXFLAGS_JDK} ${$2CXXSTD_CXXFLAG}"
 822     $2JVM_CFLAGS="${$2JVM_CFLAGS} ${$2CXXSTD_CXXFLAG}"
 823     AC_SUBST([$2CXXSTD_CXXFLAG])
 824   fi
 825   if test "x$OPENJDK_TARGET_OS" = xsolaris; then
 826     $2CFLAGS_JDK="${$2CFLAGS_JDK} -D__solaris__"
 827     $2CXXFLAGS_JDK="${$2CXXFLAGS_JDK} -D__solaris__"
 828   fi
 829 
 830   if test "x$OPENJDK_TARGET_OS" = xsolaris; then
 831     $2CFLAGS_JDK="${$2CFLAGS_JDK} -D__solaris__"
 832     $2CXXFLAGS_JDK="${$2CXXFLAGS_JDK} -D__solaris__"
 833   fi
 834 
 835   $2CFLAGS_JDK="${$2CFLAGS_JDK} ${$2EXTRA_CFLAGS}"
 836   $2CXXFLAGS_JDK="${$2CXXFLAGS_JDK} ${$2EXTRA_CXXFLAGS}"
 837   $2LDFLAGS_JDK="${$2LDFLAGS_JDK} ${$2EXTRA_LDFLAGS}"
 838 
 839   ###############################################################################
 840   #
 841   # Now setup the CFLAGS and LDFLAGS for the JDK build.
 842   # Later we will also have CFLAGS and LDFLAGS for the hotspot subrepo build.
 843   #
 844 
 845   # Setup compiler/platform specific flags into
 846   #    $2CFLAGS_JDK    - C Compiler flags
 847   #    $2CXXFLAGS_JDK  - C++ Compiler flags
 848   #    $2COMMON_CCXXFLAGS_JDK - common to C and C++
 849   if test "x$TOOLCHAIN_TYPE" = xgcc; then
 850     $2JVM_CFLAGS="[$]$2JVM_CFLAGS -D_GNU_SOURCE"
 851     $2JVM_CFLAGS="[$]$2JVM_CFLAGS -D_REENTRANT"
 852     $2JVM_CFLAGS="[$]$2JVM_CFLAGS -fcheck-new"
 853     if test "x$OPENJDK_$1_CPU" = xx86; then
 854       # Force compatibility with i586 on 32 bit intel platforms.
 855       $2COMMON_CCXXFLAGS="${$2COMMON_CCXXFLAGS} -march=i586"
 856       $2JVM_CFLAGS="[$]$2JVM_CFLAGS -march=i586"
 857     fi
 858     $2COMMON_CCXXFLAGS_JDK="[$]$2COMMON_CCXXFLAGS [$]$2COMMON_CCXXFLAGS_JDK -Wall -Wextra -Wno-unused -Wno-unused-parameter -Wformat=2 \
 859         -pipe -D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE"
 860     case $OPENJDK_$1_CPU_ARCH in
 861       arm )
 862         # on arm we don't prevent gcc to omit frame pointer but do prevent strict aliasing
 863         $2CFLAGS_JDK="${$2CFLAGS_JDK} -fno-strict-aliasing"
 864         ;;
 865       ppc )
 866         # on ppc we don't prevent gcc to omit frame pointer but do prevent strict aliasing
 867         $2CFLAGS_JDK="${$2CFLAGS_JDK} -fno-strict-aliasing"
 868         ;;
 869       * )
 870         $2COMMON_CCXXFLAGS_JDK="[$]$2COMMON_CCXXFLAGS_JDK -fno-omit-frame-pointer"
 871         $2CFLAGS_JDK="${$2CFLAGS_JDK} -fno-strict-aliasing"
 872         ;;
 873     esac
 874     TOOLCHAIN_CHECK_COMPILER_VERSION(VERSION: 6, PREFIX: $2, IF_AT_LEAST: FLAGS_SETUP_GCC6_COMPILER_FLAGS($2))
 875   elif test "x$TOOLCHAIN_TYPE" = xclang; then
 876     $2JVM_CFLAGS="[$]$2JVM_CFLAGS -D_GNU_SOURCE"
 877 
 878     # Restrict the debug information created by Clang to avoid
 879     # too big object files and speed the build up a little bit
 880     # (see http://llvm.org/bugs/show_bug.cgi?id=7554)
 881     $2JVM_CFLAGS="[$]$2JVM_CFLAGS -flimit-debug-info"
 882     if test "x$OPENJDK_$1_OS" = xlinux; then
 883       if test "x$OPENJDK_$1_CPU" = xx86; then
 884         # Force compatibility with i586 on 32 bit intel platforms.
 885         $2COMMON_CCXXFLAGS="${$2COMMON_CCXXFLAGS} -march=i586"
 886         $2JVM_CFLAGS="[$]$2JVM_CFLAGS -march=i586"
 887       fi
 888       $2JVM_CFLAGS="[$]$2JVM_CFLAGS -Wno-sometimes-uninitialized"
 889       $2COMMON_CCXXFLAGS_JDK="[$]$2COMMON_CCXXFLAGS [$]$2COMMON_CCXXFLAGS_JDK -Wall -Wextra -Wno-unused -Wno-unused-parameter -Wformat=2 \
 890           -pipe -D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE"
 891       case $OPENJDK_$1_CPU_ARCH in
 892         ppc )
 893           # on ppc we don't prevent gcc to omit frame pointer but do prevent strict aliasing
 894           $2CFLAGS_JDK="${$2CFLAGS_JDK} -fno-strict-aliasing"
 895           ;;
 896         * )
 897           $2COMMON_CCXXFLAGS_JDK="[$]$2COMMON_CCXXFLAGS_JDK -fno-omit-frame-pointer"
 898           $2CFLAGS_JDK="${$2CFLAGS_JDK} -fno-strict-aliasing"
 899           ;;
 900       esac
 901     fi
 902   elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
 903     $2JVM_CFLAGS="[$]$2JVM_CFLAGS -DSPARC_WORKS"
 904     $2COMMON_CCXXFLAGS_JDK="[$]$2COMMON_CCXXFLAGS [$]$2COMMON_CCXXFLAGS_JDK -DTRACING -DMACRO_MEMSYS_OPS -DBREAKPTS"
 905     if test "x$OPENJDK_$1_CPU_ARCH" = xx86; then
 906       $2COMMON_CCXXFLAGS_JDK="[$]$2COMMON_CCXXFLAGS_JDK -DcpuIntel -Di586 -D$OPENJDK_$1_CPU_LEGACY_LIB"
 907     fi
 908 
 909     $2CFLAGS_JDK="[$]$2CFLAGS_JDK -xc99=%none -xCC -errshort=tags -Xa -v -mt -W0,-noglobal"
 910     $2CXXFLAGS_JDK="[$]$2CXXFLAGS_JDK -errtags=yes +w -mt -features=no%except -DCC_NOEX -norunpath -xnolib"
 911   elif test "x$TOOLCHAIN_TYPE" = xxlc; then
 912     $2JVM_CFLAGS="[$]$2JVM_CFLAGS -D_REENTRANT -D__STDC_FORMAT_MACROS"
 913     $2CFLAGS_JDK="[$]$2CFLAGS_JDK -D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE -DSTDC"
 914     $2CXXFLAGS_JDK="[$]$2CXXFLAGS_JDK -D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE -DSTDC"
 915   elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
 916     $2COMMON_CCXXFLAGS_JDK="[$]$2COMMON_CCXXFLAGS [$]$2COMMON_CCXXFLAGS_JDK \
 917         -MD -Zc:wchar_t- -W3 -wd4800 \
 918         -DWIN32_LEAN_AND_MEAN \
 919         -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE \
 920         -D_WINSOCK_DEPRECATED_NO_WARNINGS \
 921         -DWIN32 -DIAL"
 922     if test "x$OPENJDK_$1_CPU" = xx86_64; then
 923       $2COMMON_CCXXFLAGS_JDK="[$]$2COMMON_CCXXFLAGS_JDK -D_AMD64_ -Damd64"
 924     else
 925       $2COMMON_CCXXFLAGS_JDK="[$]$2COMMON_CCXXFLAGS_JDK -D_X86_ -Dx86"
 926     fi
 927     # If building with Visual Studio 2010, we can still use _STATIC_CPPLIB to
 928     # avoid bundling msvcpNNN.dll. Doesn't work with newer versions of visual
 929     # studio.
 930     if test "x$TOOLCHAIN_VERSION" = "x2010"; then
 931       STATIC_CPPLIB_FLAGS="-D_STATIC_CPPLIB -D_DISABLE_DEPRECATE_STATIC_CPPLIB"
 932       $2COMMON_CCXXFLAGS_JDK="[$]$2COMMON_CCXXFLAGS_JDK $STATIC_CPPLIB_FLAGS"
 933       $2JVM_CFLAGS="[$]$2JVM_CFLAGS $STATIC_CPPLIB_FLAGS"
 934     fi
 935   fi
 936 
 937   ###############################################################################
 938 
 939   # Adjust flags according to debug level.
 940   case $DEBUG_LEVEL in
 941     fastdebug | slowdebug )
 942       $2CFLAGS_JDK="[$]$2CFLAGS_JDK $CFLAGS_DEBUG_SYMBOLS $CFLAGS_DEBUG_OPTIONS"
 943       $2CXXFLAGS_JDK="[$]$2CXXFLAGS_JDK $CXXFLAGS_DEBUG_SYMBOLS $CXXFLAGS_DEBUG_OPTIONS"
 944       JAVAC_FLAGS="$JAVAC_FLAGS -g"
 945       ;;
 946     release )
 947       ;;
 948     * )
 949       AC_MSG_ERROR([Unrecognized \$DEBUG_LEVEL: $DEBUG_LEVEL])
 950       ;;
 951   esac
 952 
 953   # Set some common defines. These works for all compilers, but assume
 954   # -D is universally accepted.
 955 
 956   # Setup endianness
 957   if test "x$OPENJDK_$1_CPU_ENDIAN" = xlittle; then
 958     # The macro _LITTLE_ENDIAN needs to be defined the same to avoid the
 959     #   Sun C compiler warning message: warning: macro redefined: _LITTLE_ENDIAN
 960     #   (The Solaris X86 system defines this in file /usr/include/sys/isa_defs.h).
 961     #   Note: -Dmacro         is the same as    #define macro 1
 962     #         -Dmacro=        is the same as    #define macro
 963     if test "x$OPENJDK_$1_OS" = xsolaris; then
 964       $2COMMON_CCXXFLAGS_JDK="[$]$2COMMON_CCXXFLAGS_JDK -D_LITTLE_ENDIAN="
 965     else
 966       $2COMMON_CCXXFLAGS_JDK="[$]$2COMMON_CCXXFLAGS_JDK -D_LITTLE_ENDIAN"
 967     fi
 968   else
 969     # Same goes for _BIG_ENDIAN. Do we really need to set *ENDIAN on Solaris if they
 970     # are defined in the system?
 971     if test "x$OPENJDK_$1_OS" = xsolaris; then
 972       $2COMMON_CCXXFLAGS_JDK="[$]$2COMMON_CCXXFLAGS_JDK -D_BIG_ENDIAN="
 973     else
 974       $2COMMON_CCXXFLAGS_JDK="[$]$2COMMON_CCXXFLAGS_JDK -D_BIG_ENDIAN"
 975     fi
 976   fi
 977 
 978   # Setup target OS define. Use OS target name but in upper case.
 979   OPENJDK_$1_OS_UPPERCASE=`$ECHO $OPENJDK_$1_OS | $TR 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
 980   $2COMMON_CCXXFLAGS_JDK="[$]$2COMMON_CCXXFLAGS_JDK -D$OPENJDK_$1_OS_UPPERCASE"
 981 
 982   # Setup target CPU
 983   $2COMMON_CCXXFLAGS_JDK="[$]$2COMMON_CCXXFLAGS_JDK \
 984       $OPENJDK_$1_ADD_LP64 \
 985       -DARCH='\"$OPENJDK_$1_CPU_LEGACY\"' -D$OPENJDK_$1_CPU_LEGACY"
 986 
 987   # Setup debug/release defines
 988   if test "x$DEBUG_LEVEL" = xrelease; then
 989     $2COMMON_CCXXFLAGS_JDK="[$]$2COMMON_CCXXFLAGS_JDK -DNDEBUG"
 990     if test "x$OPENJDK_$1_OS" = xsolaris; then
 991       $2COMMON_CCXXFLAGS_JDK="[$]$2COMMON_CCXXFLAGS_JDK -DTRIMMED"
 992     fi
 993   else
 994     $2COMMON_CCXXFLAGS_JDK="[$]$2COMMON_CCXXFLAGS_JDK -DDEBUG"
 995   fi
 996 
 997   # Set some additional per-OS defines.
 998   if test "x$OPENJDK_$1_OS" = xlinux; then
 999     $2JVM_CFLAGS="[$]$2JVM_CFLAGS -DLINUX"
1000     $2JVM_CFLAGS="[$]$2JVM_CFLAGS -pipe -fPIC -fno-rtti -fno-exceptions \
1001         -fvisibility=hidden -fno-strict-aliasing -fno-omit-frame-pointer"
1002   elif test "x$OPENJDK_$1_OS" = xsolaris; then
1003     $2JVM_CFLAGS="[$]$2JVM_CFLAGS -DSOLARIS"
1004     $2JVM_CFLAGS="[$]$2JVM_CFLAGS -template=no%extdef -features=no%split_init \
1005         -D_Crun_inline_placement -library=%none -KPIC -mt -xwe -features=no%except"
1006   elif test "x$OPENJDK_$1_OS" = xmacosx; then
1007     $2COMMON_CCXXFLAGS_JDK="[$]$2COMMON_CCXXFLAGS_JDK -D_ALLBSD_SOURCE -D_DARWIN_UNLIMITED_SELECT"
1008     $2JVM_CFLAGS="[$]$2JVM_CFLAGS -D_ALLBSD_SOURCE"
1009     $2JVM_CFLAGS="[$]$2JVM_CFLAGS -D_DARWIN_C_SOURCE -D_XOPEN_SOURCE"
1010     $2JVM_CFLAGS="[$]$2JVM_CFLAGS -fno-rtti -fno-exceptions -fvisibility=hidden \
1011         -mno-omit-leaf-frame-pointer -mstack-alignment=16 -pipe -fno-strict-aliasing \
1012         -DMAC_OS_X_VERSION_MAX_ALLOWED=1070 -mmacosx-version-min=10.7.0 \
1013         -fno-omit-frame-pointer"
1014   elif test "x$OPENJDK_$1_OS" = xaix; then
1015     $2JVM_CFLAGS="[$]$2JVM_CFLAGS -DAIX"
1016     # We may need '-qminimaltoc' or '-qpic=large -bbigtoc' if the TOC overflows.
1017     $2JVM_CFLAGS="[$]$2JVM_CFLAGS -qtune=balanced \
1018         -qalias=noansi -qstrict -qtls=default -qlanglvl=c99vla \
1019         -qlanglvl=noredefmac -qnortti -qnoeh -qignerrno"
1020   elif test "x$OPENJDK_$1_OS" = xbsd; then
1021     $2COMMON_CCXXFLAGS_JDK="[$]$2COMMON_CCXXFLAGS_JDK -D_ALLBSD_SOURCE"
1022   elif test "x$OPENJDK_$1_OS" = xwindows; then
1023     $2JVM_CFLAGS="[$]$2JVM_CFLAGS -D_WINDOWS -DWIN32 -D_JNI_IMPLEMENTATION_"
1024     $2JVM_CFLAGS="[$]$2JVM_CFLAGS -nologo -W3 -MD -MP"
1025   fi
1026 
1027   # Set some additional per-CPU defines.
1028   if test "x$OPENJDK_$1_OS-$OPENJDK_$1_CPU" = xwindows-x86; then
1029     $2JVM_CFLAGS="[$]$2JVM_CFLAGS -arch:IA32"
1030   elif test "x$OPENJDK_$1_CPU" = xsparcv9; then
1031     $2JVM_CFLAGS="[$]$2JVM_CFLAGS -xarch=sparc"
1032   elif test "x$OPENJDK_$1_CPU" = xppc64; then
1033     if test "x$OPENJDK_$1_OS" = xlinux; then
1034       $2JVM_CFLAGS="[$]$2JVM_CFLAGS -minsert-sched-nops=regroup_exact -mno-multiple -mno-string"
1035       # fixes `relocation truncated to fit' error for gcc 4.1.
1036       $2JVM_CFLAGS="[$]$2JVM_CFLAGS -mminimal-toc"
1037       # Use ppc64 instructions, but schedule for power5
1038       $2JVM_CFLAGS="[$]$2JVM_CFLAGS -mcpu=powerpc64 -mtune=power5"
1039     elif test "x$OPENJDK_$1_OS" = xaix; then
1040       $2JVM_CFLAGS="[$]$2JVM_CFLAGS -qarch=ppc64"
1041     fi
1042   elif test "x$OPENJDK_$1_CPU" = xppc64le; then
1043     if test "x$OPENJDK_$1_OS" = xlinux; then
1044       $2JVM_CFLAGS="[$]$2JVM_CFLAGS -minsert-sched-nops=regroup_exact -mno-multiple -mno-string"
1045       # Little endian machine uses ELFv2 ABI.
1046       $2JVM_CFLAGS="[$]$2JVM_CFLAGS -DABI_ELFv2"
1047       # Use Power8, this is the first CPU to support PPC64 LE with ELFv2 ABI.
1048       $2JVM_CFLAGS="[$]$2JVM_CFLAGS -mcpu=power7 -mtune=power8"
1049     fi
1050   fi
1051 
1052   if test "x$OPENJDK_$1_CPU_ENDIAN" = xlittle; then
1053     $2JVM_CFLAGS="[$]$2JVM_CFLAGS -DVM_LITTLE_ENDIAN"
1054   fi
1055 
1056   if test "x$OPENJDK_$1_CPU_BITS" = x64; then
1057     if test "x$OPENJDK_$1_OS" != xsolaris && test "x$OPENJDK_$1_OS" != xaix; then
1058       # Solaris does not have _LP64=1 in the old build.
1059       # xlc on AIX defines _LP64=1 by default and issues a warning if we redefine it.
1060       $2JVM_CFLAGS="[$]$2JVM_CFLAGS -D_LP64=1"
1061     fi
1062   fi
1063 
1064   # Set $2JVM_CFLAGS warning handling
1065   if test "x$OPENJDK_$1_OS" = xlinux; then
1066     $2JVM_CFLAGS="[$]$2JVM_CFLAGS -Wpointer-arith -Wsign-compare -Wunused-function \
1067         -Wunused-value -Woverloaded-virtual"
1068 
1069     if test "x$TOOLCHAIN_TYPE" = xgcc; then
1070       TOOLCHAIN_CHECK_COMPILER_VERSION(VERSION: [4.8], PREFIX: $2,
1071           IF_AT_LEAST: [
1072             # These flags either do not work or give spurious warnings prior to gcc 4.8.
1073             $2JVM_CFLAGS="[$]$2JVM_CFLAGS -Wno-format-zero-length -Wtype-limits -Wuninitialized"
1074           ]
1075       )
1076     fi
1077     if ! HOTSPOT_CHECK_JVM_VARIANT(zero) && ! HOTSPOT_CHECK_JVM_VARIANT(zeroshark); then
1078       # Non-zero builds have stricter warnings
1079       $2JVM_CFLAGS="[$]$2JVM_CFLAGS -Wreturn-type -Wundef -Wformat=2"
1080     else
1081       if test "x$TOOLCHAIN_TYPE" = xclang; then
1082         # Some versions of llvm do not like -Wundef
1083         $2JVM_CFLAGS="[$]$2JVM_CFLAGS -Wno-undef"
1084       fi
1085     fi
1086   elif test "x$OPENJDK_$1_OS" = xmacosx; then
1087     $2JVM_CFLAGS="[$]$2JVM_CFLAGS -Wno-deprecated -Wpointer-arith \
1088         -Wsign-compare -Wundef -Wunused-function -Wformat=2"
1089   fi
1090 
1091   # Additional macosx handling
1092   if test "x$OPENJDK_$1_OS" = xmacosx; then
1093     # Setting these parameters makes it an error to link to macosx APIs that are
1094     # newer than the given OS version and makes the linked binaries compatible
1095     # even if built on a newer version of the OS.
1096     # The expected format is X.Y.Z
1097     MACOSX_VERSION_MIN=10.7.0
1098     AC_SUBST(MACOSX_VERSION_MIN)
1099 
1100     # The macro takes the version with no dots, ex: 1070
1101     # Let the flags variables get resolved in make for easier override on make
1102     # command line.
1103     $2COMMON_CCXXFLAGS_JDK="[$]$2COMMON_CCXXFLAGS_JDK -DMAC_OS_X_VERSION_MAX_ALLOWED=\$(subst .,,\$(MACOSX_VERSION_MIN)) -mmacosx-version-min=\$(MACOSX_VERSION_MIN)"
1104     $2LDFLAGS_JDK="[$]$2LDFLAGS_JDK -mmacosx-version-min=\$(MACOSX_VERSION_MIN)"
1105   fi
1106 
1107   # Setup some hard coded includes
1108   $2COMMON_CCXXFLAGS_JDK="[$]$2COMMON_CCXXFLAGS_JDK \
1109       -I${JDK_TOPDIR}/src/java.base/share/native/include \
1110       -I${JDK_TOPDIR}/src/java.base/$OPENJDK_$1_OS/native/include \
1111       -I${JDK_TOPDIR}/src/java.base/$OPENJDK_$1_OS_TYPE/native/include \
1112       -I${JDK_TOPDIR}/src/java.base/share/native/libjava \
1113       -I${JDK_TOPDIR}/src/java.base/$OPENJDK_$1_OS_TYPE/native/libjava"
1114 
1115   # The shared libraries are compiled using the picflag.
1116   $2CFLAGS_JDKLIB="[$]$2COMMON_CCXXFLAGS_JDK \
1117       [$]$2CFLAGS_JDK [$]$2EXTRA_CFLAGS_JDK $PICFLAG [$]$2CFLAGS_JDKLIB_EXTRA"
1118   $2CXXFLAGS_JDKLIB="[$]$2COMMON_CCXXFLAGS_JDK \
1119       [$]$2CXXFLAGS_JDK [$]$2EXTRA_CXXFLAGS_JDK $PICFLAG [$]$2CXXFLAGS_JDKLIB_EXTRA"
1120 
1121   # Executable flags
1122   $2CFLAGS_JDKEXE="[$]$2COMMON_CCXXFLAGS_JDK [$]$2CFLAGS_JDK [$]$2EXTRA_CFLAGS_JDK"
1123   $2CXXFLAGS_JDKEXE="[$]$2COMMON_CCXXFLAGS_JDK [$]$2CXXFLAGS_JDK [$]$2EXTRA_CXXFLAGS_JDK"
1124 
1125   AC_SUBST($2CFLAGS_JDKLIB)
1126   AC_SUBST($2CFLAGS_JDKEXE)
1127   AC_SUBST($2CXXFLAGS_JDKLIB)
1128   AC_SUBST($2CXXFLAGS_JDKEXE)
1129 
1130   # Setup LDFLAGS et al.
1131   #
1132 
1133   if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
1134     LDFLAGS_MICROSOFT="-nologo -opt:ref"
1135     $2LDFLAGS_JDK="[$]$2LDFLAGS_JDK $LDFLAGS_MICROSOFT -incremental:no"
1136     $2JVM_LDFLAGS="[$]$2JVM_LDFLAGS $LDFLAGS_MICROSOFT -opt:icf,8 -subsystem:windows -base:0x8000000"
1137     if test "x$OPENJDK_$1_CPU_BITS" = "x32"; then
1138       LDFLAGS_SAFESH="-safeseh"
1139       $2LDFLAGS_JDK="[$]$2LDFLAGS_JDK $LDFLAGS_SAFESH"
1140       $2JVM_LDFLAGS="[$]$2JVM_LDFLAGS $LDFLAGS_SAFESH"
1141       # NOTE: Old build added -machine. Probably not needed.
1142       $2JVM_LDFLAGS="[$]$2JVM_LDFLAGS -machine:I386"
1143     else
1144       $2JVM_LDFLAGS="[$]$2JVM_LDFLAGS -machine:AMD64"
1145     fi
1146   elif test "x$TOOLCHAIN_TYPE" = xclang; then
1147       $2JVM_LDFLAGS="[$]$2JVM_LDFLAGS -mno-omit-leaf-frame-pointer -mstack-alignment=16 -stdlib=libstdc++ -fPIC"
1148       if test "x$OPENJDK_$1_OS" = xmacosx; then
1149         # FIXME: We should really generalize SET_SHARED_LIBRARY_ORIGIN instead.
1150         $2JVM_LDFLAGS="[$]$2JVM_LDFLAGS -Wl,-rpath,@loader_path/. -Wl,-rpath,@loader_path/.."
1151     fi
1152   elif test "x$TOOLCHAIN_TYPE" = xgcc; then
1153     # If this is a --hash-style=gnu system, use --hash-style=both, why?
1154     # We have previously set HAS_GNU_HASH if this is the case
1155     if test -n "$HAS_GNU_HASH"; then
1156       $2LDFLAGS_HASH_STYLE="-Wl,--hash-style=both"
1157       $2LDFLAGS_JDK="${$2LDFLAGS_JDK} [$]$2LDFLAGS_HASH_STYLE"
1158       $2JVM_LDFLAGS="[$]$2JVM_LDFLAGS [$]$2LDFLAGS_HASH_STYLE"
1159     fi
1160       if test "x$OPENJDK_$1_OS" = xmacosx; then
1161         $2JVM_LDFLAGS="[$]$2JVM_LDFLAGS -Wl,-rpath,@loader_path/. -Wl,-rpath,@loader_path/.."
1162     fi
1163     if test "x$OPENJDK_$1_OS" = xlinux; then
1164       # And since we now know that the linker is gnu, then add -z defs, to forbid
1165       # undefined symbols in object files.
1166       LDFLAGS_NO_UNDEF_SYM="-Wl,-z,defs"
1167       $2LDFLAGS_JDK="${$2LDFLAGS_JDK} $LDFLAGS_NO_UNDEF_SYM"
1168       $2JVM_LDFLAGS="[$]$2JVM_LDFLAGS  $LDFLAGS_NO_UNDEF_SYM"
1169       LDFLAGS_NO_EXEC_STACK="-Wl,-z,noexecstack"
1170       $2JVM_LDFLAGS="[$]$2JVM_LDFLAGS $LDFLAGS_NO_EXEC_STACK"
1171       if test "x$OPENJDK_$1_CPU" = xx86; then
1172         $2JVM_LDFLAGS="[$]$2JVM_LDFLAGS -march=i586"
1173       fi
1174       case $DEBUG_LEVEL in
1175         release )
1176           # tell linker to optimize libraries.
1177           # Should this be supplied to the OSS linker as well?
1178           LDFLAGS_DEBUGLEVEL_release="-Wl,-O1"
1179           $2LDFLAGS_JDK="${$2LDFLAGS_JDK} $LDFLAGS_DEBUGLEVEL_release"
1180           $2JVM_LDFLAGS="[$]$2JVM_LDFLAGS $LDFLAGS_DEBUGLEVEL_release"
1181           if test "x$HAS_LINKER_RELRO" = "xtrue"; then
1182             $2JVM_LDFLAGS="[$]$2JVM_LDFLAGS $LINKER_RELRO_FLAG"
1183           fi
1184           ;;
1185         slowdebug )
1186           # Hotspot always let the linker optimize
1187           $2JVM_LDFLAGS="[$]$2JVM_LDFLAGS -Wl,-O1"
1188           if test "x$HAS_LINKER_NOW" = "xtrue"; then
1189             # do relocations at load
1190             $2LDFLAGS_JDK="[$]$2LDFLAGS_JDK $LINKER_NOW_FLAG"
1191             $2LDFLAGS_CXX_JDK="[$]$2LDFLAGS_CXX_JDK $LINKER_NOW_FLAG"
1192             $2JVM_LDFLAGS="[$]$2JVM_LDFLAGS $LINKER_NOW_FLAG"
1193           fi
1194           if test "x$HAS_LINKER_RELRO" = "xtrue"; then
1195             # mark relocations read only
1196             $2LDFLAGS_JDK="[$]$2LDFLAGS_JDK $LINKER_RELRO_FLAG"
1197             $2LDFLAGS_CXX_JDK="[$]$2LDFLAGS_CXX_JDK $LINKER_RELRO_FLAG"
1198             $2JVM_LDFLAGS="[$]$2JVM_LDFLAGS $LINKER_RELRO_FLAG"
1199           fi
1200           ;;
1201         fastdebug )
1202           # Hotspot always let the linker optimize
1203           $2JVM_LDFLAGS="[$]$2JVM_LDFLAGS -Wl,-O1"
1204           if test "x$HAS_LINKER_RELRO" = "xtrue"; then
1205             # mark relocations read only
1206             $2LDFLAGS_JDK="[$]$2LDFLAGS_JDK $LINKER_RELRO_FLAG"
1207             $2LDFLAGS_CXX_JDK="[$]$2LDFLAGS_CXX_JDK $LINKER_RELRO_FLAG"
1208             $2JVM_LDFLAGS="[$]$2JVM_LDFLAGS $LINKER_RELRO_FLAG"
1209           fi
1210           ;;
1211         * )
1212           AC_MSG_ERROR([Unrecognized \$DEBUG_LEVEL: $DEBUG_LEVEL])
1213           ;;
1214         esac
1215     fi
1216   elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
1217     LDFLAGS_SOLSTUDIO="-Wl,-z,defs"
1218     $2LDFLAGS_JDK="[$]$2LDFLAGS_JDK $LDFLAGS_SOLSTUDIO -ztext"
1219     LDFLAGS_CXX_SOLSTUDIO="-norunpath"
1220     $2LDFLAGS_CXX_JDK="[$]$2LDFLAGS_CXX_JDK $LDFLAGS_CXX_SOLSTUDIO -xnolib"
1221     $2JVM_LDFLAGS="[$]$2JVM_LDFLAGS $LDFLAGS_SOLSTUDIO -library=%none -mt $LDFLAGS_CXX_SOLSTUDIO -z noversion"
1222     if test "x$OPENJDK_$1_CPU_ARCH" = "xsparc"; then
1223       $2JVM_LDFLAGS="[$]$2JVM_LDFLAGS -xarch=sparc"
1224     fi
1225   elif test "x$TOOLCHAIN_TYPE" = xxlc; then
1226     LDFLAGS_XLC="-b64 -brtl -bnolibpath -bexpall -bernotok"
1227     $2LDFLAGS_JDK="${$2LDFLAGS_JDK} $LDFLAGS_XLC"
1228     $2JVM_LDFLAGS="[$]$2JVM_LDFLAGS $LDFLAGS_XLC"
1229   fi
1230 
1231   # Customize LDFLAGS for executables
1232 
1233   $2LDFLAGS_JDKEXE="${$2LDFLAGS_JDK}"
1234 
1235   if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
1236     if test "x$OPENJDK_$1_CPU_BITS" = "x64"; then
1237       LDFLAGS_STACK_SIZE=1048576
1238     else
1239       LDFLAGS_STACK_SIZE=327680
1240     fi
1241     $2LDFLAGS_JDKEXE="${$2LDFLAGS_JDKEXE} /STACK:$LDFLAGS_STACK_SIZE"
1242   elif test "x$OPENJDK_$1_OS" = xlinux; then
1243     $2LDFLAGS_JDKEXE="[$]$2LDFLAGS_JDKEXE -Wl,--allow-shlib-undefined"
1244   fi
1245 
1246   $2LDFLAGS_JDKEXE="${$2LDFLAGS_JDKEXE} ${$2EXTRA_LDFLAGS_JDK}"
1247 
1248   # Customize LDFLAGS for libs
1249   $2LDFLAGS_JDKLIB="${$2LDFLAGS_JDK}"
1250 
1251   $2LDFLAGS_JDKLIB="${$2LDFLAGS_JDKLIB} ${SHARED_LIBRARY_FLAGS}"
1252   if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
1253     $2JAVA_BASE_LDFLAGS="${$2JAVA_BASE_LDFLAGS} \
1254         -libpath:${OUTPUT_ROOT}/support/modules_libs/java.base"
1255     $2JDKLIB_LIBS=""
1256   else
1257     $2JAVA_BASE_LDFLAGS="${$2JAVA_BASE_LDFLAGS} \
1258         -L\$(SUPPORT_OUTPUTDIR)/modules_libs/java.base\$(OPENJDK_$1_CPU_LIBDIR)"
1259 
1260     if test "x$1" = "xTARGET"; then
1261     # On some platforms (mac) the linker warns about non existing -L dirs.
1262     # Add server first if available. Linking aginst client does not always produce the same results.
1263       # Only add client/minimal dir if client/minimal is being built.
1264     # Default to server for other variants.
1265       if HOTSPOT_CHECK_JVM_VARIANT(server); then
1266         $2JAVA_BASE_LDFLAGS="${$2JAVA_BASE_LDFLAGS} -L\$(SUPPORT_OUTPUTDIR)/modules_libs/java.base\$(OPENJDK_$1_CPU_LIBDIR)/server"
1267       elif HOTSPOT_CHECK_JVM_VARIANT(client); then
1268         $2JAVA_BASE_LDFLAGS="${$2JAVA_BASE_LDFLAGS} -L\$(SUPPORT_OUTPUTDIR)/modules_libs/java.base\$(OPENJDK_$1_CPU_LIBDIR)/client"
1269       elif HOTSPOT_CHECK_JVM_VARIANT(minimal); then
1270         $2JAVA_BASE_LDFLAGS="${$2JAVA_BASE_LDFLAGS} -L\$(SUPPORT_OUTPUTDIR)/modules_libs/java.base\$(OPENJDK_$1_CPU_LIBDIR)/minimal"
1271     else
1272         $2JAVA_BASE_LDFLAGS="${$2JAVA_BASE_LDFLAGS} -L\$(SUPPORT_OUTPUTDIR)/modules_libs/java.base\$(OPENJDK_$1_CPU_LIBDIR)/server"
1273     fi
1274     elif test "x$1" = "xBUILD"; then
1275       # When building a buildjdk, it's always only the server variant
1276       $2JAVA_BASE_LDFLAGS="${$2JAVA_BASE_LDFLAGS} \
1277           -L\$(SUPPORT_OUTPUTDIR)/modules_libs/java.base\$(OPENJDK_$1_CPU_LIBDIR)/server"
1278     fi
1279 
1280     $2JDKLIB_LIBS="-ljava -ljvm"
1281     if test "x$TOOLCHAIN_TYPE" = xsolstudio; then
1282       $2JDKLIB_LIBS="[$]$2JDKLIB_LIBS -lc"
1283     fi
1284 
1285   fi
1286 
1287 $2LDFLAGS_JDKLIB="${$2LDFLAGS_JDKLIB} ${$2JAVA_BASE_LDFLAGS}"
1288 
1289   # Set $2JVM_LIBS (per os)
1290   if test "x$OPENJDK_$1_OS" = xlinux; then
1291     $2JVM_LIBS="[$]$2JVM_LIBS -lm -ldl -lpthread"
1292   elif test "x$OPENJDK_$1_OS" = xsolaris; then
1293     # FIXME: This hard-coded path is not really proper.
1294     if test "x$OPENJDK_$1_CPU" = xx86_64; then
1295       $2SOLARIS_LIBM_LIBS="/usr/lib/amd64/libm.so.1"
1296     elif test "x$OPENJDK_$1_CPU" = xsparcv9; then
1297       $2SOLARIS_LIBM_LIBS="/usr/lib/sparcv9/libm.so.1"
1298     fi
1299     $2JVM_LIBS="[$]$2JVM_LIBS -lsocket -lsched -ldl $SOLARIS_LIBM_LIBS -lCrun \
1300         -lthread -ldoor -lc -ldemangle -lnsl -lkstat -lrt"
1301   elif test "x$OPENJDK_$1_OS" = xmacosx; then
1302     $2JVM_LIBS="[$]$2JVM_LIBS -lm"
1303   elif test "x$OPENJDK_$1_OS" = xaix; then
1304     $2JVM_LIBS="[$]$2JVM_LIBS -Wl,-lC_r -lm -ldl -lpthread"
1305   elif test "x$OPENJDK_$1_OS" = xbsd; then
1306     $2JVM_LIBS="[$]$2JVM_LIBS -lm"
1307   elif test "x$OPENJDK_$1_OS" = xwindows; then
1308     $2JVM_LIBS="[$]$2JVM_LIBS kernel32.lib user32.lib gdi32.lib winspool.lib \
1309         comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib \
1310         wsock32.lib winmm.lib version.lib psapi.lib"
1311     fi
1312 
1313   # Set $2JVM_ASFLAGS
1314   if test "x$OPENJDK_$1_OS" = xlinux; then
1315     if test "x$OPENJDK_$1_CPU" = xx86; then
1316       $2JVM_ASFLAGS="[$]$2JVM_ASFLAGS -march=i586"
1317     fi
1318   elif test "x$OPENJDK_$1_OS" = xmacosx; then
1319     $2JVM_ASFLAGS="[$]$2JVM_ASFLAGS -x assembler-with-cpp -mno-omit-leaf-frame-pointer -mstack-alignment=16"
1320   fi
1321 
1322   $2LDFLAGS_JDKLIB="${$2LDFLAGS_JDKLIB} ${$2EXTRA_LDFLAGS_JDK}"
1323 
1324   AC_SUBST($2LDFLAGS_JDKLIB)
1325   AC_SUBST($2LDFLAGS_JDKEXE)
1326   AC_SUBST($2JDKLIB_LIBS)
1327   AC_SUBST($2JDKEXE_LIBS)
1328   AC_SUBST($2LDFLAGS_CXX_JDK)
1329   AC_SUBST($2LDFLAGS_HASH_STYLE)
1330 
1331   AC_SUBST($2JVM_CFLAGS)
1332   AC_SUBST($2JVM_LDFLAGS)
1333   AC_SUBST($2JVM_ASFLAGS)
1334   AC_SUBST($2JVM_LIBS)
1335 
1336 ])
1337 
1338 # FLAGS_C_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [ARGUMENT], IF_TRUE: [RUN-IF-TRUE],
1339 #                                  IF_FALSE: [RUN-IF-FALSE])
1340 # ------------------------------------------------------------
1341 # Check that the C compiler supports an argument
1342 BASIC_DEFUN_NAMED([FLAGS_C_COMPILER_CHECK_ARGUMENTS],
1343     [*ARGUMENT IF_TRUE IF_FALSE], [$@],
1344 [
1345   AC_MSG_CHECKING([if the C compiler supports "ARG_ARGUMENT"])
1346   supports=yes
1347 
1348   saved_cflags="$CFLAGS"
1349   CFLAGS="$CFLAGS ARG_ARGUMENT"
1350   AC_LANG_PUSH([C])
1351   AC_COMPILE_IFELSE([AC_LANG_SOURCE([[int i;]])], [],
1352       [supports=no])
1353   AC_LANG_POP([C])
1354   CFLAGS="$saved_cflags"
1355 
1356   AC_MSG_RESULT([$supports])
1357   if test "x$supports" = "xyes" ; then
1358     :
1359     ARG_IF_TRUE
1360   else
1361     :
1362     ARG_IF_FALSE
1363   fi
1364 ])
1365 
1366 # FLAGS_CXX_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [ARGUMENT], IF_TRUE: [RUN-IF-TRUE],
1367 #                                    IF_FALSE: [RUN-IF-FALSE])
1368 # ------------------------------------------------------------
1369 # Check that the C++ compiler supports an argument
1370 BASIC_DEFUN_NAMED([FLAGS_CXX_COMPILER_CHECK_ARGUMENTS],
1371     [*ARGUMENT IF_TRUE IF_FALSE], [$@],
1372 [
1373   AC_MSG_CHECKING([if the C++ compiler supports "ARG_ARGUMENT"])
1374   supports=yes
1375 
1376   saved_cxxflags="$CXXFLAGS"
1377   CXXFLAGS="$CXXFLAG ARG_ARGUMENT"
1378   AC_LANG_PUSH([C++])
1379   AC_COMPILE_IFELSE([AC_LANG_SOURCE([[int i;]])], [],
1380       [supports=no])
1381   AC_LANG_POP([C++])
1382   CXXFLAGS="$saved_cxxflags"
1383 
1384   AC_MSG_RESULT([$supports])
1385   if test "x$supports" = "xyes" ; then
1386     :
1387     ARG_IF_TRUE
1388   else
1389     :
1390     ARG_IF_FALSE
1391   fi
1392 ])
1393 
1394 # FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [ARGUMENT], IF_TRUE: [RUN-IF-TRUE],
1395 #                                IF_FALSE: [RUN-IF-FALSE])
1396 # ------------------------------------------------------------
1397 # Check that the C and C++ compilers support an argument
1398 BASIC_DEFUN_NAMED([FLAGS_COMPILER_CHECK_ARGUMENTS],
1399     [*ARGUMENT IF_TRUE IF_FALSE], [$@],
1400 [
1401   FLAGS_C_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [ARG_ARGUMENT],
1402                                              IF_TRUE: [C_COMP_SUPPORTS="yes"],
1403                                              IF_FALSE: [C_COMP_SUPPORTS="no"])
1404   FLAGS_CXX_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [ARG_ARGUMENT],
1405                                                IF_TRUE: [CXX_COMP_SUPPORTS="yes"],
1406                                                IF_FALSE: [CXX_COMP_SUPPORTS="no"])
1407 
1408   AC_MSG_CHECKING([if both compilers support "ARG_ARGUMENT"])
1409   supports=no
1410   if test "x$C_COMP_SUPPORTS" = "xyes" -a "x$CXX_COMP_SUPPORTS" = "xyes"; then supports=yes; fi
1411   
1412   AC_MSG_RESULT([$supports])
1413   if test "x$supports" = "xyes" ; then
1414     :
1415     ARG_IF_TRUE
1416   else
1417     :
1418     ARG_IF_FALSE
1419   fi
1420 ])
1421 
1422 # FLAGS_LINKER_CHECK_ARGUMENTS(ARGUMENT: [ARGUMENT], IF_TRUE: [RUN-IF-TRUE],
1423 #                                   IF_FALSE: [RUN-IF-FALSE])
1424 # ------------------------------------------------------------
1425 # Check that the linker support an argument
1426 BASIC_DEFUN_NAMED([FLAGS_LINKER_CHECK_ARGUMENTS],
1427     [*ARGUMENT IF_TRUE IF_FALSE], [$@],
1428 [
1429   AC_MSG_CHECKING([if linker supports "ARG_ARGUMENT"])
1430   supports=yes
1431 
1432   saved_ldflags="$LDFLAGS"
1433   LDFLAGS="$LDFLAGS ARG_ARGUMENT"
1434   AC_LANG_PUSH([C])
1435   AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[]])],
1436       [], [supports=no])
1437   AC_LANG_POP([C])
1438   LDFLAGS="$saved_ldflags"
1439 
1440   AC_MSG_RESULT([$supports])
1441   if test "x$supports" = "xyes" ; then
1442     :
1443     ARG_IF_TRUE
1444   else
1445     :
1446     ARG_IF_FALSE
1447   fi
1448 ])
1449 
1450 AC_DEFUN_ONCE([FLAGS_SETUP_COMPILER_FLAGS_MISC],
1451 [
1452   # Some Zero and Shark settings.
1453   # ZERO_ARCHFLAG tells the compiler which mode to build for
1454   case "${OPENJDK_TARGET_CPU}" in
1455     s390)
1456       ZERO_ARCHFLAG="${COMPILER_TARGET_BITS_FLAG}31"
1457       ;;
1458     *)
1459       ZERO_ARCHFLAG="${COMPILER_TARGET_BITS_FLAG}${OPENJDK_TARGET_CPU_BITS}"
1460   esac
1461   FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [$ZERO_ARCHFLAG], IF_FALSE: [ZERO_ARCHFLAG=""])
1462   AC_SUBST(ZERO_ARCHFLAG)
1463 
1464   # Check that the compiler supports -mX (or -qX on AIX) flags
1465   # Set COMPILER_SUPPORTS_TARGET_BITS_FLAG to 'true' if it does
1466   FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [${COMPILER_TARGET_BITS_FLAG}${OPENJDK_TARGET_CPU_BITS}],
1467       IF_TRUE: [COMPILER_SUPPORTS_TARGET_BITS_FLAG=true],
1468       IF_FALSE: [COMPILER_SUPPORTS_TARGET_BITS_FLAG=false])
1469   AC_SUBST(COMPILER_SUPPORTS_TARGET_BITS_FLAG)
1470 
1471   AC_ARG_ENABLE([warnings-as-errors], [AS_HELP_STRING([--disable-warnings-as-errors],
1472       [do not consider native warnings to be an error @<:@enabled@:>@])])
1473 
1474   AC_MSG_CHECKING([if native warnings are errors])
1475   if test "x$enable_warnings_as_errors" = "xyes"; then
1476     AC_MSG_RESULT([yes (explicitely set)])
1477     WARNINGS_AS_ERRORS=true
1478   elif test "x$enable_warnings_as_errors" = "xno"; then
1479     AC_MSG_RESULT([no])
1480     WARNINGS_AS_ERRORS=false
1481   elif test "x$enable_warnings_as_errors" = "x"; then
1482     AC_MSG_RESULT([yes (default)])
1483     WARNINGS_AS_ERRORS=true
1484   else
1485     AC_MSG_ERROR([--enable-warnings-as-errors accepts no argument])
1486   fi
1487 
1488   if test "x$WARNINGS_AS_ERRORS" = "xfalse"; then
1489     # Set legacy hotspot variable
1490     HOTSPOT_SET_WARNINGS_AS_ERRORS="WARNINGS_ARE_ERRORS="
1491   else
1492     HOTSPOT_SET_WARNINGS_AS_ERRORS=""
1493   fi
1494 
1495   AC_SUBST(WARNINGS_AS_ERRORS)
1496   AC_SUBST(HOTSPOT_SET_WARNINGS_AS_ERRORS)
1497 
1498   case "${TOOLCHAIN_TYPE}" in
1499     microsoft)
1500       DISABLE_WARNING_PREFIX="-wd"
1501       CFLAGS_WARNINGS_ARE_ERRORS="-WX"
1502       ;;
1503     solstudio)
1504       DISABLE_WARNING_PREFIX="-erroff="
1505       CFLAGS_WARNINGS_ARE_ERRORS="-errtags -errwarn=%all"
1506       ;;
1507     gcc)
1508       # Prior to gcc 4.4, a -Wno-X where X is unknown for that version of gcc will cause an error
1509       FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [-Wno-this-is-a-warning-that-do-not-exist],
1510           IF_TRUE: [GCC_CAN_DISABLE_WARNINGS=true],
1511           IF_FALSE: [GCC_CAN_DISABLE_WARNINGS=false]
1512       )
1513       if test "x$GCC_CAN_DISABLE_WARNINGS" = "xtrue"; then
1514         DISABLE_WARNING_PREFIX="-Wno-"
1515       else
1516         DISABLE_WARNING_PREFIX=
1517       fi
1518       CFLAGS_WARNINGS_ARE_ERRORS="-Werror"
1519       # Repeate the check for the BUILD_CC and BUILD_CXX. Need to also reset
1520       # CFLAGS since any target specific flags will likely not work with the
1521       # build compiler
1522       CC_OLD="$CC"
1523       CXX_OLD="$CXX"
1524       CC="$BUILD_CC"
1525       CXX="$BUILD_CXX"
1526       CFLAGS_OLD="$CFLAGS"
1527       CFLAGS=""
1528       FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [-Wno-this-is-a-warning-that-do-not-exist],
1529           IF_TRUE: [BUILD_CC_CAN_DISABLE_WARNINGS=true],
1530           IF_FALSE: [BUILD_CC_CAN_DISABLE_WARNINGS=false]
1531       )
1532       if test "x$BUILD_CC_CAN_DISABLE_WARNINGS" = "xtrue"; then
1533         BUILD_CC_DISABLE_WARNING_PREFIX="-Wno-"
1534       else
1535         BUILD_CC_DISABLE_WARNING_PREFIX=
1536       fi
1537       CC="$CC_OLD"
1538       CXX="$CXX_OLD"
1539       CFLAGS="$CFLAGS_OLD"
1540       ;;
1541     clang)
1542       DISABLE_WARNING_PREFIX="-Wno-"
1543       CFLAGS_WARNINGS_ARE_ERRORS="-Werror"
1544       ;;
1545     xlc)
1546       DISABLE_WARNING_PREFIX="-qsuppress="
1547       CFLAGS_WARNINGS_ARE_ERRORS="-qhalt=w"
1548       ;;
1549   esac
1550   AC_SUBST(DISABLE_WARNING_PREFIX)
1551   AC_SUBST(BUILD_CC_DISABLE_WARNING_PREFIX)
1552   AC_SUBST(CFLAGS_WARNINGS_ARE_ERRORS)
1553 ])
1554 
1555 # FLAGS_SETUP_GCC6_COMPILER_FLAGS([PREFIX])
1556 # Arguments:
1557 # $1 - Optional prefix for each variable defined.
1558 AC_DEFUN([FLAGS_SETUP_GCC6_COMPILER_FLAGS],
1559 [
1560   # These flags are required for GCC 6 builds as undefined behaviour in OpenJDK code
1561   # runs afoul of the more aggressive versions of these optimisations.
1562   # Notably, value range propagation now assumes that the this pointer of C++
1563   # member functions is non-null.
1564   NO_DELETE_NULL_POINTER_CHECKS_CFLAG="-fno-delete-null-pointer-checks"
1565   dnl Argument check is disabled until FLAGS_COMPILER_CHECK_ARGUMENTS handles cross-compilation
1566   dnl FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [$NO_DELETE_NULL_POINTER_CHECKS_CFLAG -Werror],
1567   dnl                                        IF_FALSE: [NO_DELETE_NULL_POINTER_CHECKS_CFLAG=""])
1568   NO_LIFETIME_DSE_CFLAG="-fno-lifetime-dse"
1569   dnl Argument check is disabled until FLAGS_COMPILER_CHECK_ARGUMENTS handles cross-compilation
1570   dnl FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [$NO_LIFETIME_DSE_CFLAG -Werror],
1571   dnl                                        IF_FALSE: [NO_LIFETIME_DSE_CFLAG=""])
1572   AC_MSG_NOTICE([GCC >= 6 detected; adding ${NO_DELETE_NULL_POINTER_CHECKS_CFLAG} and ${NO_LIFETIME_DSE_CFLAG}])
1573   $1CFLAGS_JDK="[$]$1CFLAGS_JDK ${NO_DELETE_NULL_POINTER_CHECKS_CFLAG} ${NO_LIFETIME_DSE_CFLAG}"
1574   $1JVM_CFLAGS="[$]$1JVM_CFLAGS ${NO_DELETE_NULL_POINTER_CHECKS_CFLAG} ${NO_LIFETIME_DSE_CFLAG}"
1575 ])