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