1 #
   2 # Copyright (c) 2011, 2015, 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 AC_DEFUN_ONCE([FLAGS_SETUP_INIT_FLAGS],
  27 [
  28   # Option used to tell the compiler whether to create 32- or 64-bit executables
  29   if test "x$TOOLCHAIN_TYPE" = xxlc; then
  30     COMPILER_TARGET_BITS_FLAG="-q"
  31   else
  32     COMPILER_TARGET_BITS_FLAG="-m"
  33   fi
  34   AC_SUBST(COMPILER_TARGET_BITS_FLAG)
  35 
  36   # FIXME: figure out if we should select AR flags depending on OS or toolchain.
  37   if test "x$OPENJDK_TARGET_OS" = xmacosx; then
  38     ARFLAGS="-r"
  39   elif test "x$OPENJDK_TARGET_OS" = xaix; then
  40     ARFLAGS="-X64"
  41   elif test "x$OPENJDK_TARGET_OS" = xwindows; then
  42     # lib.exe is used as AR to create static libraries.
  43     ARFLAGS="-nologo -NODEFAULTLIB:MSVCRT"
  44   else
  45     ARFLAGS=""
  46   fi
  47   AC_SUBST(ARFLAGS)
  48 
  49   ## Setup strip.
  50   # FIXME: should this really be per platform, or should it be per toolchain type?
  51   # strip is not provided by clang or solstudio; so guessing platform makes most sense.
  52   # FIXME: we should really only export STRIPFLAGS from here, not POST_STRIP_CMD.
  53   if test "x$OPENJDK_TARGET_OS" = xlinux; then
  54     STRIPFLAGS="-g"
  55   elif test "x$OPENJDK_TARGET_OS" = xsolaris; then
  56     STRIPFLAGS="-x"
  57   elif test "x$OPENJDK_TARGET_OS" = xmacosx; then
  58     STRIPFLAGS="-S"
  59   elif test "x$OPENJDK_TARGET_OS" = xaix; then
  60     STRIPFLAGS="-X32_64"
  61   fi
  62 
  63   if test "x$OPENJDK_TARGET_OS" != xwindows; then
  64     POST_STRIP_CMD="$STRIP $STRIPFLAGS"
  65   fi
  66   AC_SUBST(POST_STRIP_CMD)
  67 
  68   if test "x$OPENJDK_TARGET_OS" = xsolaris; then
  69     # FIXME: break out into MCSFLAGS
  70     POST_MCS_CMD="$MCS -d -a \"JDK $FULL_VERSION\""
  71   fi
  72   AC_SUBST(POST_MCS_CMD)
  73 
  74   if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
  75     CC_OUT_OPTION=-Fo
  76     EXE_OUT_OPTION=-out:
  77     LD_OUT_OPTION=-out:
  78     AR_OUT_OPTION=-out:
  79   else
  80     # The option used to specify the target .o,.a or .so file.
  81     # When compiling, how to specify the to be created object file.
  82     CC_OUT_OPTION='-o$(SPACE)'
  83     # When linking, how to specify the to be created executable.
  84     EXE_OUT_OPTION='-o$(SPACE)'
  85     # When linking, how to specify the to be created dynamically linkable library.
  86     LD_OUT_OPTION='-o$(SPACE)'
  87     # When archiving, how to specify the to be create static archive for object files.
  88     AR_OUT_OPTION='rcs$(SPACE)'
  89   fi
  90   AC_SUBST(CC_OUT_OPTION)
  91   AC_SUBST(EXE_OUT_OPTION)
  92   AC_SUBST(LD_OUT_OPTION)
  93   AC_SUBST(AR_OUT_OPTION)
  94 
  95   # On Windows, we need to set RC flags.
  96   if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
  97     RC_FLAGS="-nologo -l0x409"
  98     if test "x$VARIANT" = xOPT; then
  99       RC_FLAGS="$RC_FLAGS -DNDEBUG"
 100     fi
 101 
 102     # The version variables used to create RC_FLAGS may be overridden
 103     # in a custom configure script, or possibly the command line.
 104     # Let those variables be expanded at make time in spec.gmk.
 105     # The \$ are escaped to the shell, and the $(...) variables
 106     # are evaluated by make.
 107     RC_FLAGS="$RC_FLAGS \
 108         -D\"JDK_BUILD_ID=\$(FULL_VERSION)\" \
 109         -D\"JDK_COMPANY=\$(COMPANY_NAME)\" \
 110         -D\"JDK_COMPONENT=\$(PRODUCT_NAME) \$(JDK_RC_PLATFORM_NAME) binary\" \
 111         -D\"JDK_VER=\$(JDK_MINOR_VERSION).\$(JDK_MICRO_VERSION).\$(if \$(JDK_UPDATE_VERSION),\$(JDK_UPDATE_VERSION),0).\$(COOKED_BUILD_NUMBER)\" \
 112         -D\"JDK_COPYRIGHT=Copyright \xA9 $COPYRIGHT_YEAR\" \
 113         -D\"JDK_NAME=\$(PRODUCT_NAME) \$(JDK_RC_PLATFORM_NAME) \$(JDK_MINOR_VERSION) \$(JDK_UPDATE_META_TAG)\" \
 114         -D\"JDK_FVER=\$(JDK_MINOR_VERSION),\$(JDK_MICRO_VERSION),\$(if \$(JDK_UPDATE_VERSION),\$(JDK_UPDATE_VERSION),0),\$(COOKED_BUILD_NUMBER)\""
 115   fi
 116   AC_SUBST(RC_FLAGS)
 117 
 118   if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
 119     # silence copyright notice and other headers.
 120     COMMON_CCXXFLAGS="$COMMON_CCXXFLAGS -nologo"
 121   fi
 122 
 123   if test "x$SYSROOT" != "x"; then
 124     if test "x$TOOLCHAIN_TYPE" = xsolstudio; then
 125       if test "x$OPENJDK_TARGET_OS" = xsolaris; then
 126         # Solaris Studio does not have a concept of sysroot. Instead we must
 127         # make sure the default include and lib dirs are appended to each
 128         # compile and link command line.
 129         SYSROOT_CFLAGS="-I$SYSROOT/usr/include"
 130         SYSROOT_LDFLAGS="-L$SYSROOT/usr/lib$OPENJDK_TARGET_CPU_ISADIR \
 131             -L$SYSROOT/lib$OPENJDK_TARGET_CPU_ISADIR \
 132             -L$SYSROOT/usr/ccs/lib$OPENJDK_TARGET_CPU_ISADIR"
 133       fi
 134     elif test "x$OPENJDK_TARGET_OS" = xmacosx; then
 135       # Apple only wants -isysroot <path>, but we also need -iframework<path>/System/Library/Frameworks
 136       SYSROOT_CFLAGS="-isysroot \"$SYSROOT\" -iframework\"$SYSROOT/System/Library/Frameworks\""
 137       SYSROOT_LDFLAGS=$SYSROOT_CFLAGS
 138     elif test "x$TOOLCHAIN_TYPE" = xgcc; then
 139       SYSROOT_CFLAGS="--sysroot=$SYSROOT"
 140       SYSROOT_LDFLAGS="--sysroot=$SYSROOT"
 141     elif test "x$TOOLCHAIN_TYPE" = xclang; then
 142       SYSROOT_CFLAGS="-isysroot \"$SYSROOT\""
 143       SYSROOT_LDFLAGS="-isysroot \"$SYSROOT\""
 144     fi
 145     # Propagate the sysroot args to hotspot
 146     LEGACY_EXTRA_CFLAGS="$LEGACY_EXTRA_CFLAGS $SYSROOT_CFLAGS"
 147     LEGACY_EXTRA_CXXFLAGS="$LEGACY_EXTRA_CXXFLAGS $SYSROOT_CFLAGS"
 148     LEGACY_EXTRA_LDFLAGS="$LEGACY_EXTRA_LDFLAGS $SYSROOT_LDFLAGS"
 149   fi
 150 
 151   # These always need to be set, or we can't find the frameworks embedded in JavaVM.framework
 152   # set this here so it doesn't have to be peppered throughout the forest
 153   if test "x$OPENJDK_TARGET_OS" = xmacosx; then
 154     SYSROOT_CFLAGS="$SYSROOT_CFLAGS -F\"$SYSROOT/System/Library/Frameworks/JavaVM.framework/Frameworks\""
 155     SYSROOT_LDFLAGS="$SYSROOT_LDFLAGS -F\"$SYSROOT/System/Library/Frameworks/JavaVM.framework/Frameworks\""
 156   fi
 157 
 158   AC_SUBST(SYSROOT_CFLAGS)
 159   AC_SUBST(SYSROOT_LDFLAGS)
 160 ])
 161 
 162 AC_DEFUN_ONCE([FLAGS_SETUP_COMPILER_FLAGS_FOR_LIBS],
 163 [
 164   ###############################################################################
 165   #
 166   # How to compile shared libraries.
 167   #
 168 
 169   if test "x$TOOLCHAIN_TYPE" = xgcc; then
 170     PICFLAG="-fPIC"
 171     C_FLAG_REORDER=''
 172     CXX_FLAG_REORDER=''
 173 
 174     if test "x$OPENJDK_TARGET_OS" = xmacosx; then
 175       # Linking is different on MacOSX
 176       SHARED_LIBRARY_FLAGS="-dynamiclib -compatibility_version 1.0.0 -current_version 1.0.0 $PICFLAG"
 177       SET_EXECUTABLE_ORIGIN='-Xlinker -rpath -Xlinker @loader_path/.'
 178       SET_SHARED_LIBRARY_ORIGIN="$SET_EXECUTABLE_ORIGIN"
 179       SET_SHARED_LIBRARY_NAME='-Xlinker -install_name -Xlinker @rpath/[$]1'
 180       SET_SHARED_LIBRARY_MAPFILE=''
 181     else
 182       # Default works for linux, might work on other platforms as well.
 183       SHARED_LIBRARY_FLAGS='-shared'
 184       SET_EXECUTABLE_ORIGIN='-Xlinker -rpath -Xlinker \$$$$ORIGIN[$]1'
 185       SET_SHARED_LIBRARY_ORIGIN="-Xlinker -z -Xlinker origin $SET_EXECUTABLE_ORIGIN"
 186       SET_SHARED_LIBRARY_NAME='-Xlinker -soname=[$]1'
 187       SET_SHARED_LIBRARY_MAPFILE='-Xlinker -version-script=[$]1'
 188     fi
 189   elif test "x$TOOLCHAIN_TYPE" = xclang; then
 190     PICFLAG=''
 191     C_FLAG_REORDER=''
 192     CXX_FLAG_REORDER=''
 193 
 194     if test "x$OPENJDK_TARGET_OS" = xmacosx; then
 195       # Linking is different on MacOSX
 196       SHARED_LIBRARY_FLAGS="-dynamiclib -compatibility_version 1.0.0 -current_version 1.0.0 $PICFLAG"
 197       SET_EXECUTABLE_ORIGIN='-Xlinker -rpath -Xlinker @loader_path/.'
 198       SET_SHARED_LIBRARY_ORIGIN="$SET_EXECUTABLE_ORIGIN"
 199       SET_SHARED_LIBRARY_NAME='-Xlinker -install_name -Xlinker @rpath/[$]1'
 200       SET_SHARED_LIBRARY_MAPFILE=''
 201     else
 202       # Default works for linux, might work on other platforms as well.
 203       SHARED_LIBRARY_FLAGS='-shared'
 204       SET_EXECUTABLE_ORIGIN='-Xlinker -rpath -Xlinker \$$$$ORIGIN[$]1'
 205       SET_SHARED_LIBRARY_ORIGIN="-Xlinker -z -Xlinker origin $SET_EXECUTABLE_ORIGIN"
 206       SET_SHARED_LIBRARY_NAME='-Xlinker -soname=[$]1'
 207       SET_SHARED_LIBRARY_MAPFILE='-Xlinker -version-script=[$]1'
 208     fi
 209   elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
 210     PICFLAG="-KPIC"
 211     C_FLAG_REORDER='-xF'
 212     CXX_FLAG_REORDER='-xF'
 213     SHARED_LIBRARY_FLAGS="-G"
 214     SET_EXECUTABLE_ORIGIN='-R\$$$$ORIGIN[$]1'
 215     SET_SHARED_LIBRARY_ORIGIN="$SET_EXECUTABLE_ORIGIN"
 216     SET_SHARED_LIBRARY_NAME=''
 217     SET_SHARED_LIBRARY_MAPFILE='-M[$]1'
 218   elif test "x$TOOLCHAIN_TYPE" = xxlc; then
 219     PICFLAG="-qpic=large"
 220     C_FLAG_REORDER=''
 221     CXX_FLAG_REORDER=''
 222     SHARED_LIBRARY_FLAGS="-qmkshrobj"
 223     SET_EXECUTABLE_ORIGIN=""
 224     SET_SHARED_LIBRARY_ORIGIN=''
 225     SET_SHARED_LIBRARY_NAME=''
 226     SET_SHARED_LIBRARY_MAPFILE=''
 227   elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
 228     PICFLAG=""
 229     C_FLAG_REORDER=''
 230     CXX_FLAG_REORDER=''
 231     SHARED_LIBRARY_FLAGS="-LD"
 232     SET_EXECUTABLE_ORIGIN=''
 233     SET_SHARED_LIBRARY_ORIGIN=''
 234     SET_SHARED_LIBRARY_NAME=''
 235     SET_SHARED_LIBRARY_MAPFILE=''
 236   fi
 237 
 238   AC_SUBST(C_FLAG_REORDER)
 239   AC_SUBST(CXX_FLAG_REORDER)
 240   AC_SUBST(SHARED_LIBRARY_FLAGS)
 241   AC_SUBST(SET_EXECUTABLE_ORIGIN)
 242   AC_SUBST(SET_SHARED_LIBRARY_ORIGIN)
 243   AC_SUBST(SET_SHARED_LIBRARY_NAME)
 244   AC_SUBST(SET_SHARED_LIBRARY_MAPFILE)
 245 
 246   if test "x$OPENJDK_TARGET_OS" = xsolaris; then
 247     CFLAGS_JDK="${CFLAGS_JDK} -D__solaris__"
 248     CXXFLAGS_JDK="${CXXFLAGS_JDK} -D__solaris__"
 249     CFLAGS_JDKLIB_EXTRA='-xstrconst'
 250   fi
 251   # The (cross) compiler is now configured, we can now test capabilities
 252   # of the target platform.
 253 ])
 254 
 255 # Documentation on common flags used for solstudio in HIGHEST.
 256 #
 257 # WARNING: Use of OPTIMIZATION_LEVEL=HIGHEST in your Makefile needs to be
 258 #          done with care, there are some assumptions below that need to
 259 #          be understood about the use of pointers, and IEEE behavior.
 260 #
 261 # -fns: Use non-standard floating point mode (not IEEE 754)
 262 # -fsimple: Do some simplification of floating point arithmetic (not IEEE 754)
 263 # -fsingle: Use single precision floating point with 'float'
 264 # -xalias_level=basic: Assume memory references via basic pointer types do not alias
 265 #   (Source with excessing pointer casting and data access with mixed
 266 #    pointer types are not recommended)
 267 # -xbuiltin=%all: Use intrinsic or inline versions for math/std functions
 268 #   (If you expect perfect errno behavior, do not use this)
 269 # -xdepend: Loop data dependency optimizations (need -xO3 or higher)
 270 # -xrestrict: Pointer parameters to functions do not overlap
 271 #   (Similar to -xalias_level=basic usage, but less obvious sometimes.
 272 #    If you pass in multiple pointers to the same data, do not use this)
 273 # -xlibmil: Inline some library routines
 274 #   (If you expect perfect errno behavior, do not use this)
 275 # -xlibmopt: Use optimized math routines (CURRENTLY DISABLED)
 276 #   (If you expect perfect errno behavior, do not use this)
 277 #  Can cause undefined external on Solaris 8 X86 on __sincos, removing for now
 278 
 279     # FIXME: this will never happen since sparc != sparcv9, ie 32 bit, which we don't build anymore.
 280     # Bug?
 281     #if test "x$OPENJDK_TARGET_CPU" = xsparc; then
 282     #  CFLAGS_JDK="${CFLAGS_JDK} -xmemalign=4s"
 283     #  CXXFLAGS_JDK="${CXXFLAGS_JDK} -xmemalign=4s"
 284     #fi
 285 
 286 AC_DEFUN_ONCE([FLAGS_SETUP_COMPILER_FLAGS_FOR_OPTIMIZATION],
 287 [
 288 
 289   ###############################################################################
 290   #
 291   # Setup the opt flags for different compilers
 292   # and different operating systems.
 293   #
 294 
 295   # FIXME: this was indirectly the old default, but just inherited.
 296   # if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
 297   #   C_FLAG_DEPS="-MMD -MF"
 298   # fi
 299 
 300   # Generate make dependency files
 301   if test "x$TOOLCHAIN_TYPE" = xgcc; then
 302     C_FLAG_DEPS="-MMD -MF"
 303   elif test "x$TOOLCHAIN_TYPE" = xclang; then
 304     C_FLAG_DEPS="-MMD -MF"
 305   elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
 306     C_FLAG_DEPS="-xMMD -xMF"
 307   elif test "x$TOOLCHAIN_TYPE" = xxlc; then
 308     C_FLAG_DEPS="-qmakedep=gcc -MF"
 309   fi
 310   CXX_FLAG_DEPS="$C_FLAG_DEPS"
 311   AC_SUBST(C_FLAG_DEPS)
 312   AC_SUBST(CXX_FLAG_DEPS)
 313 
 314   # Debug symbols
 315   if test "x$TOOLCHAIN_TYPE" = xgcc; then
 316     if test "x$OPENJDK_TARGET_CPU_BITS" = "x64" && test "x$DEBUG_LEVEL" = "xfastdebug"; then
 317       # reduce from default "-g2" option to save space
 318       CFLAGS_DEBUG_SYMBOLS="-g1"
 319       CXXFLAGS_DEBUG_SYMBOLS="-g1"
 320     else
 321       CFLAGS_DEBUG_SYMBOLS="-g"
 322       CXXFLAGS_DEBUG_SYMBOLS="-g"
 323     fi
 324   elif test "x$TOOLCHAIN_TYPE" = xclang; then
 325     CFLAGS_DEBUG_SYMBOLS="-g"
 326     CXXFLAGS_DEBUG_SYMBOLS="-g"
 327   elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
 328     CFLAGS_DEBUG_SYMBOLS="-g -xs"
 329     # FIXME: likely a bug, this disables debug symbols rather than enables them
 330     CXXFLAGS_DEBUG_SYMBOLS="-g0 -xs"
 331   elif test "x$TOOLCHAIN_TYPE" = xxlc; then
 332     CFLAGS_DEBUG_SYMBOLS="-g"
 333     CXXFLAGS_DEBUG_SYMBOLS="-g"
 334   fi
 335   AC_SUBST(CFLAGS_DEBUG_SYMBOLS)
 336   AC_SUBST(CXXFLAGS_DEBUG_SYMBOLS)
 337 
 338   # bounds, memory and behavior checking options
 339   if test "x$TOOLCHAIN_TYPE" = xgcc; then
 340     case $DEBUG_LEVEL in
 341     release )
 342       # no adjustment
 343       ;;
 344     fastdebug )
 345       # no adjustment
 346       ;;
 347     slowdebug )
 348       # Add runtime stack smashing and undefined behavior checks
 349       CFLAGS_DEBUG_OPTIONS="-fstack-protector-all --param ssp-buffer-size=1"
 350       CXXFLAGS_DEBUG_OPTIONS="-fstack-protector-all --param ssp-buffer-size=1"
 351       ;;
 352     esac
 353   fi
 354   AC_SUBST(CFLAGS_DEBUG_OPTIONS)
 355   AC_SUBST(CXXFLAGS_DEBUG_OPTIONS)
 356 
 357   # Optimization levels
 358   if test "x$TOOLCHAIN_TYPE" = xsolstudio; then
 359     CC_HIGHEST="$CC_HIGHEST -fns -fsimple -fsingle -xbuiltin=%all -xdepend -xrestrict -xlibmil"
 360 
 361     if test "x$OPENJDK_TARGET_CPU_ARCH" = "xx86"; then
 362       # FIXME: seems we always set -xregs=no%frameptr; put it elsewhere more global?
 363       C_O_FLAG_HIGHEST="-xO4 -Wu,-O4~yz $CC_HIGHEST -xalias_level=basic -xregs=no%frameptr"
 364       C_O_FLAG_HI="-xO4 -Wu,-O4~yz -xregs=no%frameptr"
 365       C_O_FLAG_NORM="-xO2 -Wu,-O2~yz -xregs=no%frameptr"
 366       C_O_FLAG_DEBUG="-xregs=no%frameptr"
 367       C_O_FLAG_NONE="-xregs=no%frameptr"
 368       CXX_O_FLAG_HIGHEST="-xO4 -Qoption ube -O4~yz $CC_HIGHEST -xregs=no%frameptr"
 369       CXX_O_FLAG_HI="-xO4 -Qoption ube -O4~yz -xregs=no%frameptr"
 370       CXX_O_FLAG_NORM="-xO2 -Qoption ube -O2~yz -xregs=no%frameptr"
 371       CXX_O_FLAG_DEBUG="-xregs=no%frameptr"
 372       CXX_O_FLAG_NONE="-xregs=no%frameptr"
 373       if test "x$OPENJDK_TARGET_CPU_BITS" = "x32"; then
 374         C_O_FLAG_HIGHEST="$C_O_FLAG_HIGHEST -xchip=pentium"
 375         CXX_O_FLAG_HIGHEST="$CXX_O_FLAG_HIGHEST -xchip=pentium"
 376       fi
 377     elif test "x$OPENJDK_TARGET_CPU_ARCH" = "xsparc"; then
 378       C_O_FLAG_HIGHEST="-xO4 -Wc,-Qrm-s -Wc,-Qiselect-T0 $CC_HIGHEST -xalias_level=basic -xprefetch=auto,explicit -xchip=ultra"
 379       C_O_FLAG_HI="-xO4 -Wc,-Qrm-s -Wc,-Qiselect-T0"
 380       C_O_FLAG_NORM="-xO2 -Wc,-Qrm-s -Wc,-Qiselect-T0"
 381       C_O_FLAG_DEBUG=""
 382       C_O_FLAG_NONE=""
 383       CXX_O_FLAG_HIGHEST="-xO4 -Qoption cg -Qrm-s -Qoption cg -Qiselect-T0 $CC_HIGHEST -xprefetch=auto,explicit -xchip=ultra"
 384       CXX_O_FLAG_HI="-xO4 -Qoption cg -Qrm-s -Qoption cg -Qiselect-T0"
 385       CXX_O_FLAG_NORM="-xO2 -Qoption cg -Qrm-s -Qoption cg -Qiselect-T0"
 386       C_O_FLAG_DEBUG=""
 387       CXX_O_FLAG_NONE=""
 388     fi
 389   else
 390     # The remaining toolchains share opt flags between CC and CXX;
 391     # setup for C and duplicate afterwards.
 392     if test "x$TOOLCHAIN_TYPE" = xgcc; then
 393       if test "x$OPENJDK_TARGET_OS" = xmacosx; then
 394         # On MacOSX we optimize for size, something
 395         # we should do for all platforms?
 396         C_O_FLAG_HIGHEST="-Os"
 397         C_O_FLAG_HI="-Os"
 398         C_O_FLAG_NORM="-Os"
 399       else
 400         C_O_FLAG_HIGHEST="-O3"
 401         C_O_FLAG_HI="-O3"
 402         C_O_FLAG_NORM="-O2"
 403       fi
 404       C_O_FLAG_DEBUG="-O0"
 405       C_O_FLAG_NONE="-O0"
 406     elif test "x$TOOLCHAIN_TYPE" = xclang; then
 407       if test "x$OPENJDK_TARGET_OS" = xmacosx; then
 408         # On MacOSX we optimize for size, something
 409         # we should do for all platforms?
 410         C_O_FLAG_HIGHEST="-Os"
 411         C_O_FLAG_HI="-Os"
 412         C_O_FLAG_NORM="-Os"
 413       else
 414         C_O_FLAG_HIGHEST="-O3"
 415         C_O_FLAG_HI="-O3"
 416         C_O_FLAG_NORM="-O2"
 417       fi
 418       C_O_FLAG_DEBUG="-O0"
 419       C_O_FLAG_NONE="-O0"
 420     elif test "x$TOOLCHAIN_TYPE" = xxlc; then
 421       C_O_FLAG_HIGHEST="-O3"
 422       C_O_FLAG_HI="-O3 -qstrict"
 423       C_O_FLAG_NORM="-O2"
 424       C_O_FLAG_DEBUG="-qnoopt"
 425       C_O_FLAG_NONE="-qnoop"
 426     elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
 427       C_O_FLAG_HIGHEST="-O2"
 428       C_O_FLAG_HI="-O1"
 429       C_O_FLAG_NORM="-O1"
 430       C_O_FLAG_DEBUG="-Od"
 431       C_O_FLAG_NONE="-Od"
 432     fi
 433     CXX_O_FLAG_HIGHEST="$C_O_FLAG_HIGHEST"
 434     CXX_O_FLAG_HI="$C_O_FLAG_HI"
 435     CXX_O_FLAG_NORM="$C_O_FLAG_NORM"
 436     CXX_O_FLAG_DEBUG="$C_O_FLAG_DEBUG"
 437     CXX_O_FLAG_NONE="$C_O_FLAG_NONE"
 438   fi
 439 
 440   # Adjust optimization flags according to debug level.
 441   case $DEBUG_LEVEL in
 442     release )
 443       # no adjustment
 444       ;;
 445     fastdebug )
 446       # Not quite so much optimization
 447       C_O_FLAG_HI="$C_O_FLAG_NORM"
 448       CXX_O_FLAG_HI="$CXX_O_FLAG_NORM"
 449       ;;
 450     slowdebug )
 451       # Disable optimization
 452       C_O_FLAG_HIGHEST="$C_O_FLAG_DEBUG"
 453       C_O_FLAG_HI="$C_O_FLAG_DEBUG"
 454       C_O_FLAG_NORM="$C_O_FLAG_DEBUG"
 455       CXX_O_FLAG_HIGHEST="$CXX_O_FLAG_DEBUG"
 456       CXX_O_FLAG_HI="$CXX_O_FLAG_DEBUG"
 457       CXX_O_FLAG_NORM="$CXX_O_FLAG_DEBUG"
 458       ;;
 459   esac
 460 
 461   AC_SUBST(C_O_FLAG_HIGHEST)
 462   AC_SUBST(C_O_FLAG_HI)
 463   AC_SUBST(C_O_FLAG_NORM)
 464   AC_SUBST(C_O_FLAG_DEBUG)
 465   AC_SUBST(C_O_FLAG_NONE)
 466   AC_SUBST(CXX_O_FLAG_HIGHEST)
 467   AC_SUBST(CXX_O_FLAG_HI)
 468   AC_SUBST(CXX_O_FLAG_NORM)
 469   AC_SUBST(CXX_O_FLAG_DEBUG)
 470   AC_SUBST(CXX_O_FLAG_NONE)
 471 ])
 472 
 473 AC_DEFUN_ONCE([FLAGS_SETUP_COMPILER_FLAGS_FOR_JDK],
 474 [
 475   # Special extras...
 476   if test "x$TOOLCHAIN_TYPE" = xsolstudio; then
 477     if test "x$OPENJDK_TARGET_CPU_ARCH" = "xsparc"; then
 478       CFLAGS_JDKLIB_EXTRA="${CFLAGS_JDKLIB_EXTRA} -xregs=no%appl"
 479       CXXFLAGS_JDKLIB_EXTRA="${CXXFLAGS_JDKLIB_EXTRA} -xregs=no%appl"
 480     fi
 481     CFLAGS_JDKLIB_EXTRA="${CFLAGS_JDKLIB_EXTRA} -errtags=yes -errfmt"
 482     CXXFLAGS_JDKLIB_EXTRA="${CXXFLAGS_JDKLIB_EXTRA} -errtags=yes -errfmt"
 483   elif test "x$TOOLCHAIN_TYPE" = xxlc; then
 484     LDFLAGS_JDK="${LDFLAGS_JDK} -q64 -brtl -bnolibpath -liconv -bexpall"
 485     CFLAGS_JDK="${CFLAGS_JDK} -qchars=signed -q64 -qfullpath -qsaveopt"
 486     CXXFLAGS_JDK="${CXXFLAGS_JDK} -qchars=signed -q64 -qfullpath -qsaveopt"
 487   fi
 488 
 489   if test "x$CFLAGS" != "x${ADDED_CFLAGS}"; then
 490     AC_MSG_WARN([Ignoring CFLAGS($CFLAGS) found in environment. Use --with-extra-cflags])
 491   fi
 492 
 493   if test "x$CXXFLAGS" != "x${ADDED_CXXFLAGS}"; then
 494     AC_MSG_WARN([Ignoring CXXFLAGS($CXXFLAGS) found in environment. Use --with-extra-cxxflags])
 495   fi
 496 
 497   if test "x$LDFLAGS" != "x${ADDED_LDFLAGS}"; then
 498     AC_MSG_WARN([Ignoring LDFLAGS($LDFLAGS) found in environment. Use --with-extra-ldflags])
 499   fi
 500 
 501   AC_ARG_WITH(extra-cflags, [AS_HELP_STRING([--with-extra-cflags],
 502       [extra flags to be used when compiling jdk c-files])])
 503 
 504   AC_ARG_WITH(extra-cxxflags, [AS_HELP_STRING([--with-extra-cxxflags],
 505       [extra flags to be used when compiling jdk c++-files])])
 506 
 507   AC_ARG_WITH(extra-ldflags, [AS_HELP_STRING([--with-extra-ldflags],
 508       [extra flags to be used when linking jdk])])
 509 
 510   CFLAGS_JDK="${CFLAGS_JDK} $with_extra_cflags"
 511   CXXFLAGS_JDK="${CXXFLAGS_JDK} $with_extra_cxxflags"
 512   LDFLAGS_JDK="${LDFLAGS_JDK} $with_extra_ldflags"
 513 
 514   # Hotspot needs these set in their legacy form
 515   LEGACY_EXTRA_CFLAGS="$LEGACY_EXTRA_CFLAGS $with_extra_cflags"
 516   LEGACY_EXTRA_CXXFLAGS="$LEGACY_EXTRA_CXXFLAGS $with_extra_cxxflags"
 517   LEGACY_EXTRA_LDFLAGS="$LEGACY_EXTRA_LDFLAGS $with_extra_ldflags"
 518 
 519   AC_SUBST(LEGACY_EXTRA_CFLAGS)
 520   AC_SUBST(LEGACY_EXTRA_CXXFLAGS)
 521   AC_SUBST(LEGACY_EXTRA_LDFLAGS)
 522 
 523   ###############################################################################
 524   #
 525   # Now setup the CFLAGS and LDFLAGS for the JDK build.
 526   # Later we will also have CFLAGS and LDFLAGS for the hotspot subrepo build.
 527   #
 528 
 529   # Setup compiler/platform specific flags into
 530   #    CFLAGS_JDK    - C Compiler flags
 531   #    CXXFLAGS_JDK  - C++ Compiler flags
 532   #    COMMON_CCXXFLAGS_JDK - common to C and C++
 533   if test "x$TOOLCHAIN_TYPE" = xgcc; then
 534     COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS $COMMON_CCXXFLAGS_JDK -Wall -Wextra -Wno-unused -Wno-unused-parameter -Wformat=2 \
 535         -pipe -D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE"
 536     case $OPENJDK_TARGET_CPU_ARCH in
 537       arm )
 538         # on arm we don't prevent gcc to omit frame pointer but do prevent strict aliasing
 539         CFLAGS_JDK="${CFLAGS_JDK} -fno-strict-aliasing"
 540         ;;
 541       ppc )
 542         # on ppc we don't prevent gcc to omit frame pointer but do prevent strict aliasing
 543         CFLAGS_JDK="${CFLAGS_JDK} -fno-strict-aliasing"
 544         ;;
 545       * )
 546         COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -fno-omit-frame-pointer"
 547         CFLAGS_JDK="${CFLAGS_JDK} -fno-strict-aliasing"
 548         ;;
 549     esac
 550   elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
 551     COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS $COMMON_CCXXFLAGS_JDK -DTRACING -DMACRO_MEMSYS_OPS -DBREAKPTS"
 552     if test "x$OPENJDK_TARGET_CPU_ARCH" = xx86; then
 553       COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DcpuIntel -Di586 -D$OPENJDK_TARGET_CPU_LEGACY_LIB"
 554     fi
 555 
 556     CFLAGS_JDK="$CFLAGS_JDK -xc99=%none -xCC -errshort=tags -Xa -v -mt -W0,-noglobal"
 557     CXXFLAGS_JDK="$CXXFLAGS_JDK -errtags=yes +w -mt -features=no%except -DCC_NOEX -norunpath -xnolib"
 558   elif test "x$TOOLCHAIN_TYPE" = xxlc; then
 559     CFLAGS_JDK="$CFLAGS_JDK -D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE -DSTDC"
 560     CXXFLAGS_JDK="$CXXFLAGS_JDK -D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE -DSTDC"
 561   elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
 562     COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS $COMMON_CCXXFLAGS_JDK \
 563         -Zi -MD -Zc:wchar_t- -W3 -wd4800 \
 564         -DWIN32_LEAN_AND_MEAN \
 565         -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE \
 566         -DWIN32 -DIAL"
 567     if test "x$OPENJDK_TARGET_CPU" = xx86_64; then
 568       COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D_AMD64_ -Damd64"
 569     else
 570       COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D_X86_ -Dx86"
 571     fi
 572     # If building with Visual Studio 2010, we can still use _STATIC_CPPLIB to
 573     # avoid bundling msvcpNNN.dll. Doesn't work with newer versions of visual
 574     # studio.
 575     if test "x$TOOLCHAIN_VERSION" = "x2010"; then
 576       COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK \
 577           -D_STATIC_CPPLIB -D_DISABLE_DEPRECATE_STATIC_CPPLIB"
 578     fi
 579   fi
 580 
 581   ###############################################################################
 582 
 583   # Adjust flags according to debug level.
 584   case $DEBUG_LEVEL in
 585     fastdebug | slowdebug )
 586       CFLAGS_JDK="$CFLAGS_JDK $CFLAGS_DEBUG_SYMBOLS $CFLAGS_DEBUG_OPTIONS"
 587       CXXFLAGS_JDK="$CXXFLAGS_JDK $CXXFLAGS_DEBUG_SYMBOLS $CXXFLAGS_DEBUG_OPTIONS"
 588       JAVAC_FLAGS="$JAVAC_FLAGS -g"
 589       ;;
 590     release )
 591       ;;
 592     * )
 593       AC_MSG_ERROR([Unrecognized \$DEBUG_LEVEL: $DEBUG_LEVEL])
 594       ;;
 595   esac
 596 
 597   # Setup LP64
 598   COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK $ADD_LP64"
 599 
 600   # Set some common defines. These works for all compilers, but assume
 601   # -D is universally accepted.
 602 
 603   # Setup endianness
 604   if test "x$OPENJDK_TARGET_CPU_ENDIAN" = xlittle; then
 605     # The macro _LITTLE_ENDIAN needs to be defined the same to avoid the
 606     #   Sun C compiler warning message: warning: macro redefined: _LITTLE_ENDIAN
 607     #   (The Solaris X86 system defines this in file /usr/include/sys/isa_defs.h).
 608     #   Note: -Dmacro         is the same as    #define macro 1
 609     #         -Dmacro=        is the same as    #define macro
 610     if test "x$OPENJDK_TARGET_OS" = xsolaris; then
 611       COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D_LITTLE_ENDIAN="
 612     else
 613       COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D_LITTLE_ENDIAN"
 614     fi
 615   else
 616     # Same goes for _BIG_ENDIAN. Do we really need to set *ENDIAN on Solaris if they
 617     # are defined in the system?
 618     if test "x$OPENJDK_TARGET_OS" = xsolaris; then
 619       COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D_BIG_ENDIAN="
 620     else
 621       COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D_BIG_ENDIAN"
 622     fi
 623   fi
 624 
 625   # Setup target OS define. Use OS target name but in upper case.
 626   OPENJDK_TARGET_OS_UPPERCASE=`$ECHO $OPENJDK_TARGET_OS | $TR 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
 627   COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D$OPENJDK_TARGET_OS_UPPERCASE"
 628 
 629   # Setup target CPU
 630   COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DARCH='\"$OPENJDK_TARGET_CPU_LEGACY\"' -D$OPENJDK_TARGET_CPU_LEGACY"
 631 
 632   # Setup debug/release defines
 633   if test "x$DEBUG_LEVEL" = xrelease; then
 634     COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DNDEBUG"
 635     if test "x$OPENJDK_TARGET_OS" = xsolaris; then
 636       COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DTRIMMED"
 637     fi
 638   else
 639     COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DDEBUG"
 640   fi
 641 
 642   # Setup release name
 643   COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DRELEASE='\"\$(RELEASE)\"'"
 644 
 645 
 646   # Set some additional per-OS defines.
 647   if test "x$OPENJDK_TARGET_OS" = xmacosx; then
 648     COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D_ALLBSD_SOURCE -D_DARWIN_UNLIMITED_SELECT"
 649   elif test "x$OPENJDK_TARGET_OS" = xaix; then
 650     # FIXME: PPC64 should not be here.
 651     COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DPPC64"
 652   elif test "x$OPENJDK_TARGET_OS" = xbsd; then
 653     COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D_ALLBSD_SOURCE"
 654   fi
 655 
 656   # Additional macosx handling
 657   if test "x$OPENJDK_TARGET_OS" = xmacosx; then
 658     # Setting these parameters makes it an error to link to macosx APIs that are
 659     # newer than the given OS version and makes the linked binaries compatible
 660     # even if built on a newer version of the OS.
 661     # The expected format is X.Y.Z
 662     MACOSX_VERSION_MIN=10.7.0
 663     AC_SUBST(MACOSX_VERSION_MIN)
 664 
 665     # The macro takes the version with no dots, ex: 1070
 666     # Let the flags variables get resolved in make for easier override on make
 667     # command line.
 668     COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DMAC_OS_X_VERSION_MAX_ALLOWED=\$(subst .,,\$(MACOSX_VERSION_MIN)) -mmacosx-version-min=\$(MACOSX_VERSION_MIN)"
 669     LDFLAGS_JDK="$LDFLAGS_JDK -mmacosx-version-min=\$(MACOSX_VERSION_MIN)"
 670   fi
 671 
 672   # Setup some hard coded includes
 673   COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK \
 674       -I${JDK_TOPDIR}/src/java.base/share/native/include \
 675       -I${JDK_TOPDIR}/src/java.base/$OPENJDK_TARGET_OS/native/include \
 676       -I${JDK_TOPDIR}/src/java.base/$OPENJDK_TARGET_OS_TYPE/native/include"
 677 
 678   # The shared libraries are compiled using the picflag.
 679   CFLAGS_JDKLIB="$COMMON_CCXXFLAGS_JDK $CFLAGS_JDK $PICFLAG $CFLAGS_JDKLIB_EXTRA"
 680   CXXFLAGS_JDKLIB="$COMMON_CCXXFLAGS_JDK $CXXFLAGS_JDK $PICFLAG $CXXFLAGS_JDKLIB_EXTRA "
 681 
 682   # Executable flags
 683   CFLAGS_JDKEXE="$COMMON_CCXXFLAGS_JDK $CFLAGS_JDK"
 684   CXXFLAGS_JDKEXE="$COMMON_CCXXFLAGS_JDK $CXXFLAGS_JDK"
 685 
 686   AC_SUBST(CFLAGS_JDKLIB)
 687   AC_SUBST(CFLAGS_JDKEXE)
 688   AC_SUBST(CXXFLAGS_JDKLIB)
 689   AC_SUBST(CXXFLAGS_JDKEXE)
 690 
 691   # Setup LDFLAGS et al.
 692   #
 693 
 694   # Now this is odd. The JDK native libraries have to link against libjvm.so
 695   # On 32-bit machines there is normally two distinct libjvm.so:s, client and server.
 696   # Which should we link to? Are we lucky enough that the binary api to the libjvm.so library
 697   # is identical for client and server? Yes. Which is picked at runtime (client or server)?
 698   # Neither, since the chosen libjvm.so has already been loaded by the launcher, all the following
 699   # libraries will link to whatever is in memory. Yuck.
 700   #
 701   # Thus we offer the compiler to find libjvm.so first in server then in client. It works. Ugh.
 702   if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
 703     LDFLAGS_JDK="$LDFLAGS_JDK -nologo -opt:ref -incremental:no"
 704     if test "x$OPENJDK_TARGET_CPU_BITS" = "x32"; then
 705       LDFLAGS_JDK="$LDFLAGS_JDK -safeseh"
 706     fi
 707     # TODO: make -debug optional "--disable-full-debug-symbols"
 708     LDFLAGS_JDK="$LDFLAGS_JDK -debug"
 709   elif test "x$TOOLCHAIN_TYPE" = xgcc; then
 710     # If this is a --hash-style=gnu system, use --hash-style=both, why?
 711     # We have previously set HAS_GNU_HASH if this is the case
 712     if test -n "$HAS_GNU_HASH"; then
 713       LDFLAGS_JDK="${LDFLAGS_JDK} -Xlinker --hash-style=both"
 714     fi
 715     if test "x$OPENJDK_TARGET_OS" = xlinux; then
 716       # And since we now know that the linker is gnu, then add -z defs, to forbid
 717       # undefined symbols in object files.
 718       LDFLAGS_JDK="${LDFLAGS_JDK} -Xlinker -z -Xlinker defs"
 719       case $DEBUG_LEVEL in
 720         release )
 721           # tell linker to optimize libraries.
 722           # Should this be supplied to the OSS linker as well?
 723           LDFLAGS_JDK="${LDFLAGS_JDK} -Xlinker -O1"
 724           ;;
 725         slowdebug )
 726           if test "x$HAS_LINKER_NOW" = "xtrue"; then
 727             # do relocations at load
 728             LDFLAGS_JDK="$LDFLAGS_JDK $LINKER_NOW_FLAG"
 729             LDFLAGS_CXX_JDK="$LDFLAGS_CXX_JDK $LINKER_NOW_FLAG"
 730           fi
 731           if test "x$HAS_LINKER_RELRO" = "xtrue"; then
 732             # mark relocations read only
 733             LDFLAGS_JDK="$LDFLAGS_JDK $LINKER_RELRO_FLAG"
 734             LDFLAGS_CXX_JDK="$LDFLAGS_CXX_JDK $LINKER_RELRO_FLAG"
 735           fi
 736           ;;
 737         fastdebug )
 738           if test "x$HAS_LINKER_RELRO" = "xtrue"; then
 739             # mark relocations read only
 740             LDFLAGS_JDK="$LDFLAGS_JDK $LINKER_RELRO_FLAG"
 741             LDFLAGS_CXX_JDK="$LDFLAGS_CXX_JDK $LINKER_RELRO_FLAG"
 742           fi
 743           ;;
 744         * )
 745           AC_MSG_ERROR([Unrecognized \$DEBUG_LEVEL: $DEBUG_LEVEL])
 746           ;;
 747         esac
 748     fi
 749   elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
 750     LDFLAGS_JDK="$LDFLAGS_JDK -z defs -xildoff -ztext"
 751     LDFLAGS_CXX_JDK="$LDFLAGS_CXX_JDK -norunpath -xnolib"
 752   fi
 753 
 754   # Customize LDFLAGS for executables
 755 
 756   LDFLAGS_JDKEXE="${LDFLAGS_JDK}"
 757 
 758   if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
 759     if test "x$OPENJDK_TARGET_CPU_BITS" = "x64"; then
 760       LDFLAGS_STACK_SIZE=1048576
 761     else
 762       LDFLAGS_STACK_SIZE=327680
 763     fi
 764     LDFLAGS_JDKEXE="${LDFLAGS_JDKEXE} /STACK:$LDFLAGS_STACK_SIZE"
 765   elif test "x$OPENJDK_TARGET_OS" = xlinux; then
 766     LDFLAGS_JDKEXE="$LDFLAGS_JDKEXE -Xlinker --allow-shlib-undefined"
 767   fi
 768 
 769   # Customize LDFLAGS for libs
 770   LDFLAGS_JDKLIB="${LDFLAGS_JDK}"
 771 
 772   if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
 773     LDFLAGS_JDKLIB="${LDFLAGS_JDKLIB} -dll -libpath:${OUTPUT_ROOT}/support/modules_libs/java.base"
 774     LDFLAGS_JDKLIB_SUFFIX=""
 775   else
 776     LDFLAGS_JDKLIB="${LDFLAGS_JDKLIB}  ${SHARED_LIBRARY_FLAGS} \
 777         -L${OUTPUT_ROOT}/support/modules_libs/java.base${OPENJDK_TARGET_CPU_LIBDIR}"
 778 
 779     # On some platforms (mac) the linker warns about non existing -L dirs.
 780     # Add server first if available. Linking aginst client does not always produce the same results.
 781     # Only add client dir if client is being built. Add minimal (note not minimal1) if only building minimal1.
 782     # Default to server for other variants.
 783     if test "x$JVM_VARIANT_SERVER" = xtrue; then
 784       LDFLAGS_JDKLIB="${LDFLAGS_JDKLIB} -L${OUTPUT_ROOT}/support/modules_libs/java.base${OPENJDK_TARGET_CPU_LIBDIR}/server"
 785     elif test "x$JVM_VARIANT_CLIENT" = xtrue; then
 786       LDFLAGS_JDKLIB="${LDFLAGS_JDKLIB} -L${OUTPUT_ROOT}/support/modules_libs/java.base${OPENJDK_TARGET_CPU_LIBDIR}/client"
 787     elif test "x$JVM_VARIANT_MINIMAL1" = xtrue; then
 788       LDFLAGS_JDKLIB="${LDFLAGS_JDKLIB} -L${OUTPUT_ROOT}/support/modules_libs/java.base${OPENJDK_TARGET_CPU_LIBDIR}/minimal"
 789     else
 790       LDFLAGS_JDKLIB="${LDFLAGS_JDKLIB} -L${OUTPUT_ROOT}/support/modules_libs/java.base${OPENJDK_TARGET_CPU_LIBDIR}/server"
 791     fi
 792 
 793     LDFLAGS_JDKLIB_SUFFIX="-ljava -ljvm"
 794     if test "x$TOOLCHAIN_TYPE" = xsolstudio; then
 795       LDFLAGS_JDKLIB_SUFFIX="$LDFLAGS_JDKLIB_SUFFIX -lc"
 796     fi
 797   fi
 798 
 799   AC_SUBST(LDFLAGS_JDKLIB)
 800   AC_SUBST(LDFLAGS_JDKEXE)
 801   AC_SUBST(LDFLAGS_JDKLIB_SUFFIX)
 802   AC_SUBST(LDFLAGS_JDKEXE_SUFFIX)
 803   AC_SUBST(LDFLAGS_CXX_JDK)
 804 ])
 805 
 806 # FLAGS_COMPILER_CHECK_ARGUMENTS([ARGUMENT], [RUN-IF-TRUE],
 807 #                                   [RUN-IF-FALSE])
 808 # ------------------------------------------------------------
 809 # Check that the c and c++ compilers support an argument
 810 AC_DEFUN([FLAGS_COMPILER_CHECK_ARGUMENTS],
 811 [
 812   AC_MSG_CHECKING([if compiler supports "$1"])
 813   supports=yes
 814 
 815   saved_cflags="$CFLAGS"
 816   CFLAGS="$CFLAGS $1"
 817   AC_LANG_PUSH([C])
 818   AC_COMPILE_IFELSE([AC_LANG_SOURCE([[int i;]])], [],
 819       [supports=no])
 820   AC_LANG_POP([C])
 821   CFLAGS="$saved_cflags"
 822 
 823   saved_cxxflags="$CXXFLAGS"
 824   CXXFLAGS="$CXXFLAG $1"
 825   AC_LANG_PUSH([C++])
 826   AC_COMPILE_IFELSE([AC_LANG_SOURCE([[int i;]])], [],
 827       [supports=no])
 828   AC_LANG_POP([C++])
 829   CXXFLAGS="$saved_cxxflags"
 830 
 831   AC_MSG_RESULT([$supports])
 832   if test "x$supports" = "xyes" ; then
 833     m4_ifval([$2], [$2], [:])
 834   else
 835     m4_ifval([$3], [$3], [:])
 836   fi
 837 ])
 838 
 839 # FLAGS_LINKER_CHECK_ARGUMENTS([ARGUMENT], [RUN-IF-TRUE],
 840 #                                    [RUN-IF-FALSE])
 841 # ------------------------------------------------------------
 842 # Check that the linker support an argument
 843 AC_DEFUN([FLAGS_LINKER_CHECK_ARGUMENTS],
 844 [
 845   AC_MSG_CHECKING([if linker supports "$1"])
 846   supports=yes
 847 
 848   saved_ldflags="$LDFLAGS"
 849   LDFLAGS="$LDFLAGS $1"
 850   AC_LANG_PUSH([C])
 851   AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[]])],
 852       [], [supports=no])
 853   AC_LANG_POP([C])
 854   LDFLAGS="$saved_ldflags"
 855 
 856   AC_MSG_RESULT([$supports])
 857   if test "x$supports" = "xyes" ; then
 858     m4_ifval([$2], [$2], [:])
 859   else
 860     m4_ifval([$3], [$3], [:])
 861   fi
 862 ])
 863 
 864 AC_DEFUN_ONCE([FLAGS_SETUP_COMPILER_FLAGS_MISC],
 865 [
 866   # Some Zero and Shark settings.
 867   # ZERO_ARCHFLAG tells the compiler which mode to build for
 868   case "${OPENJDK_TARGET_CPU}" in
 869     s390)
 870       ZERO_ARCHFLAG="${COMPILER_TARGET_BITS_FLAG}31"
 871       ;;
 872     *)
 873       ZERO_ARCHFLAG="${COMPILER_TARGET_BITS_FLAG}${OPENJDK_TARGET_CPU_BITS}"
 874   esac
 875   FLAGS_COMPILER_CHECK_ARGUMENTS([$ZERO_ARCHFLAG], [], [ZERO_ARCHFLAG=""])
 876   AC_SUBST(ZERO_ARCHFLAG)
 877 
 878   # Check that the compiler supports -mX (or -qX on AIX) flags
 879   # Set COMPILER_SUPPORTS_TARGET_BITS_FLAG to 'true' if it does
 880   FLAGS_COMPILER_CHECK_ARGUMENTS([${COMPILER_TARGET_BITS_FLAG}${OPENJDK_TARGET_CPU_BITS}],
 881       [COMPILER_SUPPORTS_TARGET_BITS_FLAG=true],
 882       [COMPILER_SUPPORTS_TARGET_BITS_FLAG=false])
 883   AC_SUBST(COMPILER_SUPPORTS_TARGET_BITS_FLAG)
 884 
 885   case "${TOOLCHAIN_TYPE}" in
 886     microsoft)
 887       DISABLE_WARNING_PREFIX="-wd"
 888       CFLAGS_WARNINGS_ARE_ERRORS="-WX"
 889       ;;
 890     solstudio)
 891       DISABLE_WARNING_PREFIX="-erroff="
 892       CFLAGS_WARNINGS_ARE_ERRORS="-errtags -errwarn=%all"
 893       ;;
 894     gcc)
 895       # Prior to gcc 4.4, a -Wno-X where X is unknown for that version of gcc will cause an error
 896       AC_MSG_CHECKING([if gcc can disable warnings])
 897       GCC_CAN_DISABLE_WARNINGS=`$ECHO $CC_VERSION_NUMBER | $GREP -e  '^4\.[[4-9]]' -e '^[[5-9]]'`
 898       if test "x$GCC_CAN_DISABLE_WARNINGS" != "x"; then
 899         DISABLE_WARNING_PREFIX="-Wno-"
 900         AC_MSG_RESULT([yes])
 901       else
 902         DISABLE_WARNING_PREFIX=
 903         AC_MSG_RESULT([no])
 904       fi
 905       CFLAGS_WARNINGS_ARE_ERRORS="-Werror"
 906       ;;
 907     clang)
 908       DISABLE_WARNING_PREFIX="-Wno-"
 909       CFLAGS_WARNINGS_ARE_ERRORS="-Werror"
 910       ;;
 911   esac
 912   AC_SUBST(DISABLE_WARNING_PREFIX)
 913   AC_SUBST(CFLAGS_WARNINGS_ARE_ERRORS)
 914 ])