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 # Reset the global CFLAGS/LDFLAGS variables and initialize them with the
  27 # corresponding configure arguments instead
  28 AC_DEFUN_ONCE([FLAGS_SETUP_USER_SUPPLIED_FLAGS],
  29 [
  30   if test "x$CFLAGS" != "x${ADDED_CFLAGS}"; then
  31     AC_MSG_WARN([Ignoring CFLAGS($CFLAGS) found in environment. Use --with-extra-cflags])
  32   fi
  33 
  34   if test "x$CXXFLAGS" != "x${ADDED_CXXFLAGS}"; then
  35     AC_MSG_WARN([Ignoring CXXFLAGS($CXXFLAGS) found in environment. Use --with-extra-cxxflags])
  36   fi
  37 
  38   if test "x$LDFLAGS" != "x${ADDED_LDFLAGS}"; then
  39     AC_MSG_WARN([Ignoring LDFLAGS($LDFLAGS) found in environment. Use --with-extra-ldflags])
  40   fi
  41 
  42   AC_ARG_WITH(extra-cflags, [AS_HELP_STRING([--with-extra-cflags],
  43       [extra flags to be used when compiling jdk c-files])])
  44 
  45   AC_ARG_WITH(extra-cxxflags, [AS_HELP_STRING([--with-extra-cxxflags],
  46       [extra flags to be used when compiling jdk c++-files])])
  47 
  48   AC_ARG_WITH(extra-ldflags, [AS_HELP_STRING([--with-extra-ldflags],
  49       [extra flags to be used when linking jdk])])
  50 
  51   EXTRA_CFLAGS="$with_extra_cflags"
  52   EXTRA_CXXFLAGS="$with_extra_cxxflags"
  53   EXTRA_LDFLAGS="$with_extra_ldflags"
  54 
  55   # Hotspot needs these set in their legacy form
  56   LEGACY_EXTRA_CFLAGS="$LEGACY_EXTRA_CFLAGS $EXTRA_CFLAGS"
  57   LEGACY_EXTRA_CXXFLAGS="$LEGACY_EXTRA_CXXFLAGS $EXTRA_CXXFLAGS"
  58   LEGACY_EXTRA_LDFLAGS="$LEGACY_EXTRA_LDFLAGS $EXTRA_LDFLAGS"
  59 
  60   AC_SUBST(LEGACY_EXTRA_CFLAGS)
  61   AC_SUBST(LEGACY_EXTRA_CXXFLAGS)
  62   AC_SUBST(LEGACY_EXTRA_LDFLAGS)
  63 
  64   # The global CFLAGS and LDLAGS variables are used by configure tests and
  65   # should include the extra parameters
  66   CFLAGS="$EXTRA_CFLAGS"
  67   CXXFLAGS="$EXTRA_CXXFLAGS"
  68   LDFLAGS="$EXTRA_LDFLAGS"
  69   CPPFLAGS=""
  70 ])
  71 
  72 # Setup the sysroot flags and add them to global CFLAGS and LDFLAGS so
  73 # that configure can use them while detecting compilers.
  74 # TOOLCHAIN_TYPE is available here.
  75 # Param 1 - Optional prefix to all variables. (e.g BUILD_)
  76 AC_DEFUN([FLAGS_SETUP_SYSROOT_FLAGS],
  77 [
  78   if test "x[$]$1SYSROOT" != "x"; then
  79     if test "x$TOOLCHAIN_TYPE" = xsolstudio; then
  80       if test "x$OPENJDK_TARGET_OS" = xsolaris; then
  81         # Solaris Studio does not have a concept of sysroot. Instead we must
  82         # make sure the default include and lib dirs are appended to each
  83         # compile and link command line.
  84         $1SYSROOT_CFLAGS="-I[$]$1SYSROOT/usr/include"
  85         $1SYSROOT_LDFLAGS="-L[$]$1SYSROOT/usr/lib$OPENJDK_TARGET_CPU_ISADIR \
  86             -L[$]$1SYSROOT/lib$OPENJDK_TARGET_CPU_ISADIR \
  87             -L[$]$1SYSROOT/usr/ccs/lib$OPENJDK_TARGET_CPU_ISADIR"
  88       fi
  89     elif test "x$TOOLCHAIN_TYPE" = xgcc; then
  90       $1SYSROOT_CFLAGS="--sysroot=[$]$1SYSROOT"
  91       $1SYSROOT_LDFLAGS="--sysroot=[$]$1SYSROOT"
  92     elif test "x$TOOLCHAIN_TYPE" = xclang; then
  93       $1SYSROOT_CFLAGS="-isysroot [$]$1SYSROOT"
  94       $1SYSROOT_LDFLAGS="-isysroot [$]$1SYSROOT"
  95     fi
  96     # Propagate the sysroot args to hotspot
  97     $1LEGACY_EXTRA_CFLAGS="[$]$1LEGACY_EXTRA_CFLAGS [$]$1SYSROOT_CFLAGS"
  98     $1LEGACY_EXTRA_CXXFLAGS="[$]$1LEGACY_EXTRA_CXXFLAGS [$]$1SYSROOT_CFLAGS"
  99     $1LEGACY_EXTRA_LDFLAGS="[$]$1LEGACY_EXTRA_LDFLAGS [$]$1SYSROOT_LDFLAGS"
 100     # The global CFLAGS and LDFLAGS variables need these for configure to function
 101     $1CFLAGS="[$]$1CFLAGS [$]$1SYSROOT_CFLAGS"
 102     $1CPPFLAGS="[$]$1CPPFLAGS [$]$1SYSROOT_CFLAGS"
 103     $1CXXFLAGS="[$]$1CXXFLAGS [$]$1SYSROOT_CFLAGS"
 104     $1LDFLAGS="[$]$1LDFLAGS [$]$1SYSROOT_LDFLAGS"
 105   fi
 106 
 107   if test "x$OPENJDK_TARGET_OS" = xmacosx; then
 108     # We also need -iframework<path>/System/Library/Frameworks
 109     $1SYSROOT_CFLAGS="[$]$1SYSROOT_CFLAGS -iframework [$]$1SYSROOT/System/Library/Frameworks"
 110     $1SYSROOT_LDFLAGS="[$]$1SYSROOT_LDFLAGS -iframework [$]$1SYSROOT/System/Library/Frameworks"
 111     # These always need to be set, or we can't find the frameworks embedded in JavaVM.framework
 112     # set this here so it doesn't have to be peppered throughout the forest
 113     $1SYSROOT_CFLAGS="[$]$1SYSROOT_CFLAGS -F [$]$1SYSROOT/System/Library/Frameworks/JavaVM.framework/Frameworks"
 114     $1SYSROOT_LDFLAGS="[$]$1SYSROOT_LDFLAGS -F [$]$1SYSROOT/System/Library/Frameworks/JavaVM.framework/Frameworks"
 115   fi
 116 
 117   AC_SUBST($1SYSROOT_CFLAGS)
 118   AC_SUBST($1SYSROOT_LDFLAGS)
 119 ])
 120 
 121 AC_DEFUN_ONCE([FLAGS_SETUP_INIT_FLAGS],
 122 [
 123   # COMPILER_TARGET_BITS_FLAG  : option for selecting 32- or 64-bit output
 124   # COMPILER_COMMAND_FILE_FLAG : option for passing a command file to the compiler
 125   if test "x$TOOLCHAIN_TYPE" = xxlc; then
 126     COMPILER_TARGET_BITS_FLAG="-q"
 127     COMPILER_COMMAND_FILE_FLAG="-f"
 128   else
 129     COMPILER_TARGET_BITS_FLAG="-m"
 130     COMPILER_COMMAND_FILE_FLAG="@"
 131 
 132     # The solstudio linker does not support @-files.
 133     if test "x$TOOLCHAIN_TYPE" = xsolstudio; then
 134       COMPILER_COMMAND_FILE_FLAG=
 135     fi
 136 
 137     # Check if @file is supported by gcc
 138     if test "x$TOOLCHAIN_TYPE" = xgcc; then
 139       AC_MSG_CHECKING([if @file is supported by gcc])
 140       # Extra emtpy "" to prevent ECHO from interpreting '--version' as argument
 141       $ECHO "" "--version" > command.file
 142       if $CXX @command.file 2>&AS_MESSAGE_LOG_FD >&AS_MESSAGE_LOG_FD; then
 143         AC_MSG_RESULT(yes)
 144         COMPILER_COMMAND_FILE_FLAG="@"
 145       else
 146         AC_MSG_RESULT(no)
 147         COMPILER_COMMAND_FILE_FLAG=
 148       fi
 149       rm -rf command.file
 150     fi
 151   fi
 152   AC_SUBST(COMPILER_TARGET_BITS_FLAG)
 153   AC_SUBST(COMPILER_COMMAND_FILE_FLAG)
 154 
 155   # FIXME: figure out if we should select AR flags depending on OS or toolchain.
 156   if test "x$OPENJDK_TARGET_OS" = xmacosx; then
 157     ARFLAGS="-r"
 158   elif test "x$OPENJDK_TARGET_OS" = xaix; then
 159     ARFLAGS="-X64"
 160   elif test "x$OPENJDK_TARGET_OS" = xwindows; then
 161     # lib.exe is used as AR to create static libraries.
 162     ARFLAGS="-nologo -NODEFAULTLIB:MSVCRT"
 163   else
 164     ARFLAGS=""
 165   fi
 166   AC_SUBST(ARFLAGS)
 167 
 168   ## Setup strip.
 169   # FIXME: should this really be per platform, or should it be per toolchain type?
 170   # strip is not provided by clang or solstudio; so guessing platform makes most sense.
 171   # FIXME: we should really only export STRIPFLAGS from here, not POST_STRIP_CMD.
 172   if test "x$OPENJDK_TARGET_OS" = xlinux; then
 173     STRIPFLAGS="-g"
 174   elif test "x$OPENJDK_TARGET_OS" = xsolaris; then
 175     STRIPFLAGS="-x"
 176   elif test "x$OPENJDK_TARGET_OS" = xmacosx; then
 177     STRIPFLAGS="-S"
 178   elif test "x$OPENJDK_TARGET_OS" = xaix; then
 179     STRIPFLAGS="-X32_64"
 180   fi
 181 
 182   AC_SUBST(STRIPFLAGS)
 183 
 184   if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
 185     CC_OUT_OPTION=-Fo
 186     EXE_OUT_OPTION=-out:
 187     LD_OUT_OPTION=-out:
 188     AR_OUT_OPTION=-out:
 189   else
 190     # The option used to specify the target .o,.a or .so file.
 191     # When compiling, how to specify the to be created object file.
 192     CC_OUT_OPTION='-o$(SPACE)'
 193     # When linking, how to specify the to be created executable.
 194     EXE_OUT_OPTION='-o$(SPACE)'
 195     # When linking, how to specify the to be created dynamically linkable library.
 196     LD_OUT_OPTION='-o$(SPACE)'
 197     # When archiving, how to specify the to be create static archive for object files.
 198     AR_OUT_OPTION='rcs$(SPACE)'
 199   fi
 200   AC_SUBST(CC_OUT_OPTION)
 201   AC_SUBST(EXE_OUT_OPTION)
 202   AC_SUBST(LD_OUT_OPTION)
 203   AC_SUBST(AR_OUT_OPTION)
 204 
 205   # On Windows, we need to set RC flags.
 206   if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
 207     RC_FLAGS="-nologo -l0x409"
 208     if test "x$VARIANT" = xOPT; then
 209       RC_FLAGS="$RC_FLAGS -DNDEBUG"
 210     fi
 211 
 212     # The version variables used to create RC_FLAGS may be overridden
 213     # in a custom configure script, or possibly the command line.
 214     # Let those variables be expanded at make time in spec.gmk.
 215     # The \$ are escaped to the shell, and the $(...) variables
 216     # are evaluated by make.
 217     RC_FLAGS="$RC_FLAGS \
 218         -D\"JDK_VERSION_STRING=\$(VERSION_STRING)\" \
 219         -D\"JDK_COMPANY=\$(COMPANY_NAME)\" \
 220         -D\"JDK_COMPONENT=\$(PRODUCT_NAME) \$(JDK_RC_PLATFORM_NAME) binary\" \
 221         -D\"JDK_VER=\$(VERSION_NUMBER)\" \
 222         -D\"JDK_COPYRIGHT=Copyright \xA9 $COPYRIGHT_YEAR\" \
 223         -D\"JDK_NAME=\$(PRODUCT_NAME) \$(JDK_RC_PLATFORM_NAME) \$(VERSION_MAJOR)\" \
 224         -D\"JDK_FVER=\$(subst .,\$(COMMA),\$(VERSION_NUMBER_FOUR_POSITIONS))\""
 225   fi
 226   AC_SUBST(RC_FLAGS)
 227 
 228   if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
 229     # silence copyright notice and other headers.
 230     COMMON_CCXXFLAGS="$COMMON_CCXXFLAGS -nologo"
 231   fi
 232 ])
 233 
 234 AC_DEFUN_ONCE([FLAGS_SETUP_COMPILER_FLAGS_FOR_LIBS],
 235 [
 236   ###############################################################################
 237   #
 238   # How to compile shared libraries.
 239   #
 240 
 241   if test "x$TOOLCHAIN_TYPE" = xgcc; then
 242     PICFLAG="-fPIC"
 243     C_FLAG_REORDER=''
 244     CXX_FLAG_REORDER=''
 245 
 246     if test "x$OPENJDK_TARGET_OS" = xmacosx; then
 247       # Linking is different on MacOSX
 248       if test "x$STATIC_BUILD" = xtrue; then
 249         SHARED_LIBRARY_FLAGS ='-undefined dynamic_lookup'
 250       else
 251         SHARED_LIBRARY_FLAGS="-dynamiclib -compatibility_version 1.0.0 -current_version 1.0.0 $PICFLAG"
 252       fi
 253       SET_EXECUTABLE_ORIGIN='-Wl,-rpath,@loader_path/.'
 254       SET_SHARED_LIBRARY_ORIGIN="$SET_EXECUTABLE_ORIGIN"
 255       SET_SHARED_LIBRARY_NAME='-Wl,-install_name,@rpath/[$]1'
 256       SET_SHARED_LIBRARY_MAPFILE=''
 257     else
 258       # Default works for linux, might work on other platforms as well.
 259       SHARED_LIBRARY_FLAGS='-shared'
 260       SET_EXECUTABLE_ORIGIN='-Wl,-rpath,\$$$$ORIGIN[$]1'
 261       SET_SHARED_LIBRARY_ORIGIN="-Wl,-z,origin $SET_EXECUTABLE_ORIGIN"





 262       SET_SHARED_LIBRARY_NAME='-Wl,-soname=[$]1'
 263       SET_SHARED_LIBRARY_MAPFILE='-Wl,-version-script=[$]1'
 264     fi
 265   elif test "x$TOOLCHAIN_TYPE" = xclang; then
 266     C_FLAG_REORDER=''
 267     CXX_FLAG_REORDER=''
 268 
 269     if test "x$OPENJDK_TARGET_OS" = xmacosx; then
 270       # Linking is different on MacOSX
 271       PICFLAG=''
 272       SHARED_LIBRARY_FLAGS="-dynamiclib -compatibility_version 1.0.0 -current_version 1.0.0 $PICFLAG"
 273       SET_EXECUTABLE_ORIGIN='-Wl,-rpath,@loader_path/.'
 274       SET_SHARED_LIBRARY_ORIGIN="$SET_EXECUTABLE_ORIGIN"
 275       SET_SHARED_LIBRARY_NAME='-Wl,-install_name,@rpath/[$]1'
 276       SET_SHARED_LIBRARY_MAPFILE=''
 277     else
 278       # Default works for linux, might work on other platforms as well.
 279       PICFLAG='-fPIC'
 280       SHARED_LIBRARY_FLAGS='-shared'
 281       SET_EXECUTABLE_ORIGIN='-Wl,-rpath,\$$$$ORIGIN[$]1'
 282       SET_SHARED_LIBRARY_ORIGIN="-Wl,-z,origin $SET_EXECUTABLE_ORIGIN"





 283       SET_SHARED_LIBRARY_NAME='-Wl,-soname=[$]1'
 284       SET_SHARED_LIBRARY_MAPFILE='-Wl,-version-script=[$]1'
 285     fi
 286   elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
 287     PICFLAG="-KPIC"
 288     C_FLAG_REORDER='-xF'
 289     CXX_FLAG_REORDER='-xF'
 290     SHARED_LIBRARY_FLAGS="-G"
 291     SET_EXECUTABLE_ORIGIN='-R\$$$$ORIGIN[$]1'
 292     SET_SHARED_LIBRARY_ORIGIN="$SET_EXECUTABLE_ORIGIN"
 293     SET_SHARED_LIBRARY_NAME='-h [$]1'
 294     SET_SHARED_LIBRARY_MAPFILE='-M[$]1'
 295   elif test "x$TOOLCHAIN_TYPE" = xxlc; then
 296     PICFLAG="-qpic=large"
 297     C_FLAG_REORDER=''
 298     CXX_FLAG_REORDER=''
 299     SHARED_LIBRARY_FLAGS="-qmkshrobj"
 300     SET_EXECUTABLE_ORIGIN=""
 301     SET_SHARED_LIBRARY_ORIGIN=''
 302     SET_SHARED_LIBRARY_NAME=''
 303     SET_SHARED_LIBRARY_MAPFILE=''
 304   elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
 305     PICFLAG=""
 306     C_FLAG_REORDER=''
 307     CXX_FLAG_REORDER=''
 308     SHARED_LIBRARY_FLAGS="-dll"
 309     SET_EXECUTABLE_ORIGIN=''
 310     SET_SHARED_LIBRARY_ORIGIN=''
 311     SET_SHARED_LIBRARY_NAME=''
 312     SET_SHARED_LIBRARY_MAPFILE=''
 313   fi
 314 
 315   AC_SUBST(C_FLAG_REORDER)
 316   AC_SUBST(CXX_FLAG_REORDER)
 317   AC_SUBST(SET_EXECUTABLE_ORIGIN)
 318   AC_SUBST(SET_SHARED_LIBRARY_ORIGIN)
 319   AC_SUBST(SET_SHARED_LIBRARY_NAME)
 320   AC_SUBST(SET_SHARED_LIBRARY_MAPFILE)
 321   AC_SUBST(SHARED_LIBRARY_FLAGS)
 322 
 323   if test "x$OPENJDK_TARGET_OS" = xsolaris; then
 324     CFLAGS_JDK="${CFLAGS_JDK} -D__solaris__"
 325     CXXFLAGS_JDK="${CXXFLAGS_JDK} -D__solaris__"
 326     CFLAGS_JDKLIB_EXTRA='-xstrconst'
 327   fi
 328   # The (cross) compiler is now configured, we can now test capabilities
 329   # of the target platform.
 330 ])
 331 
 332 # Documentation on common flags used for solstudio in HIGHEST.
 333 #
 334 # WARNING: Use of OPTIMIZATION_LEVEL=HIGHEST in your Makefile needs to be
 335 #          done with care, there are some assumptions below that need to
 336 #          be understood about the use of pointers, and IEEE behavior.
 337 #
 338 # -fns: Use non-standard floating point mode (not IEEE 754)
 339 # -fsimple: Do some simplification of floating point arithmetic (not IEEE 754)
 340 # -fsingle: Use single precision floating point with 'float'
 341 # -xalias_level=basic: Assume memory references via basic pointer types do not alias
 342 #   (Source with excessing pointer casting and data access with mixed
 343 #    pointer types are not recommended)
 344 # -xbuiltin=%all: Use intrinsic or inline versions for math/std functions
 345 #   (If you expect perfect errno behavior, do not use this)
 346 # -xdepend: Loop data dependency optimizations (need -xO3 or higher)
 347 # -xrestrict: Pointer parameters to functions do not overlap
 348 #   (Similar to -xalias_level=basic usage, but less obvious sometimes.
 349 #    If you pass in multiple pointers to the same data, do not use this)
 350 # -xlibmil: Inline some library routines
 351 #   (If you expect perfect errno behavior, do not use this)
 352 # -xlibmopt: Use optimized math routines (CURRENTLY DISABLED)
 353 #   (If you expect perfect errno behavior, do not use this)
 354 #  Can cause undefined external on Solaris 8 X86 on __sincos, removing for now
 355 
 356     # FIXME: this will never happen since sparc != sparcv9, ie 32 bit, which we don't build anymore.
 357     # Bug?
 358     #if test "x$OPENJDK_TARGET_CPU" = xsparc; then
 359     #  CFLAGS_JDK="${CFLAGS_JDK} -xmemalign=4s"
 360     #  CXXFLAGS_JDK="${CXXFLAGS_JDK} -xmemalign=4s"
 361     #fi
 362 
 363 AC_DEFUN_ONCE([FLAGS_SETUP_COMPILER_FLAGS_FOR_OPTIMIZATION],
 364 [
 365 
 366   ###############################################################################
 367   #
 368   # Setup the opt flags for different compilers
 369   # and different operating systems.
 370   #
 371 
 372   # FIXME: this was indirectly the old default, but just inherited.
 373   # if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
 374   #   C_FLAG_DEPS="-MMD -MF"
 375   # fi
 376 
 377   # Generate make dependency files
 378   if test "x$TOOLCHAIN_TYPE" = xgcc; then
 379     C_FLAG_DEPS="-MMD -MF"
 380   elif test "x$TOOLCHAIN_TYPE" = xclang; then
 381     C_FLAG_DEPS="-MMD -MF"
 382   elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
 383     C_FLAG_DEPS="-xMMD -xMF"
 384   elif test "x$TOOLCHAIN_TYPE" = xxlc; then
 385     C_FLAG_DEPS="-qmakedep=gcc -MF"
 386   fi
 387   CXX_FLAG_DEPS="$C_FLAG_DEPS"
 388   AC_SUBST(C_FLAG_DEPS)
 389   AC_SUBST(CXX_FLAG_DEPS)
 390 
 391   # Debug symbols
 392   if test "x$TOOLCHAIN_TYPE" = xgcc; then
 393     if test "x$OPENJDK_TARGET_CPU_BITS" = "x64" && test "x$DEBUG_LEVEL" = "xfastdebug"; then
 394       # reduce from default "-g2" option to save space
 395       CFLAGS_DEBUG_SYMBOLS="-g1"
 396       CXXFLAGS_DEBUG_SYMBOLS="-g1"
 397     else
 398       CFLAGS_DEBUG_SYMBOLS="-g"
 399       CXXFLAGS_DEBUG_SYMBOLS="-g"
 400     fi
 401   elif test "x$TOOLCHAIN_TYPE" = xclang; then
 402     CFLAGS_DEBUG_SYMBOLS="-g"
 403     CXXFLAGS_DEBUG_SYMBOLS="-g"
 404   elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
 405     CFLAGS_DEBUG_SYMBOLS="-g -xs"
 406     # -g0 enables debug symbols without disabling inlining.
 407     CXXFLAGS_DEBUG_SYMBOLS="-g0 -xs"
 408   elif test "x$TOOLCHAIN_TYPE" = xxlc; then
 409     CFLAGS_DEBUG_SYMBOLS="-g"
 410     CXXFLAGS_DEBUG_SYMBOLS="-g"
 411   fi
 412   AC_SUBST(CFLAGS_DEBUG_SYMBOLS)
 413   AC_SUBST(CXXFLAGS_DEBUG_SYMBOLS)
 414 
 415   # bounds, memory and behavior checking options
 416   if test "x$TOOLCHAIN_TYPE" = xgcc; then
 417     case $DEBUG_LEVEL in
 418     release )
 419       # no adjustment
 420       ;;
 421     fastdebug )
 422       # no adjustment
 423       ;;
 424     slowdebug )
 425       # Add runtime stack smashing and undefined behavior checks.
 426       # Not all versions of gcc support -fstack-protector
 427       STACK_PROTECTOR_CFLAG="-fstack-protector-all"
 428       FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [$STACK_PROTECTOR_CFLAG], IF_FALSE: [STACK_PROTECTOR_CFLAG=""])
 429 
 430       CFLAGS_DEBUG_OPTIONS="$STACK_PROTECTOR_CFLAG --param ssp-buffer-size=1"
 431       CXXFLAGS_DEBUG_OPTIONS="$STACK_PROTECTOR_CFLAG --param ssp-buffer-size=1"
 432       ;;
 433     esac
 434   fi
 435 
 436   # Optimization levels
 437   if test "x$TOOLCHAIN_TYPE" = xsolstudio; then
 438     CC_HIGHEST="$CC_HIGHEST -fns -fsimple -fsingle -xbuiltin=%all -xdepend -xrestrict -xlibmil"
 439 
 440     if test "x$OPENJDK_TARGET_CPU_ARCH" = "xx86"; then
 441       # FIXME: seems we always set -xregs=no%frameptr; put it elsewhere more global?
 442       C_O_FLAG_HIGHEST="-xO4 -Wu,-O4~yz $CC_HIGHEST -xalias_level=basic -xregs=no%frameptr"
 443       C_O_FLAG_HI="-xO4 -Wu,-O4~yz -xregs=no%frameptr"
 444       C_O_FLAG_NORM="-xO2 -Wu,-O2~yz -xregs=no%frameptr"
 445       C_O_FLAG_DEBUG="-xregs=no%frameptr"
 446       C_O_FLAG_NONE="-xregs=no%frameptr"
 447       CXX_O_FLAG_HIGHEST="-xO4 -Qoption ube -O4~yz $CC_HIGHEST -xregs=no%frameptr"
 448       CXX_O_FLAG_HI="-xO4 -Qoption ube -O4~yz -xregs=no%frameptr"
 449       CXX_O_FLAG_NORM="-xO2 -Qoption ube -O2~yz -xregs=no%frameptr"
 450       CXX_O_FLAG_DEBUG="-xregs=no%frameptr"
 451       CXX_O_FLAG_NONE="-xregs=no%frameptr"
 452       if test "x$OPENJDK_TARGET_CPU_BITS" = "x32"; then
 453         C_O_FLAG_HIGHEST="$C_O_FLAG_HIGHEST -xchip=pentium"
 454         CXX_O_FLAG_HIGHEST="$CXX_O_FLAG_HIGHEST -xchip=pentium"
 455       fi
 456     elif test "x$OPENJDK_TARGET_CPU_ARCH" = "xsparc"; then
 457       C_O_FLAG_HIGHEST="-xO4 -Wc,-Qrm-s -Wc,-Qiselect-T0 $CC_HIGHEST -xalias_level=basic -xprefetch=auto,explicit -xchip=ultra"
 458       C_O_FLAG_HI="-xO4 -Wc,-Qrm-s -Wc,-Qiselect-T0"
 459       C_O_FLAG_NORM="-xO2 -Wc,-Qrm-s -Wc,-Qiselect-T0"
 460       C_O_FLAG_DEBUG=""
 461       C_O_FLAG_NONE=""
 462       CXX_O_FLAG_HIGHEST="-xO4 -Qoption cg -Qrm-s -Qoption cg -Qiselect-T0 $CC_HIGHEST -xprefetch=auto,explicit -xchip=ultra"
 463       CXX_O_FLAG_HI="-xO4 -Qoption cg -Qrm-s -Qoption cg -Qiselect-T0"
 464       CXX_O_FLAG_NORM="-xO2 -Qoption cg -Qrm-s -Qoption cg -Qiselect-T0"
 465       C_O_FLAG_DEBUG=""
 466       CXX_O_FLAG_NONE=""
 467     fi
 468   else
 469     # The remaining toolchains share opt flags between CC and CXX;
 470     # setup for C and duplicate afterwards.
 471     if test "x$TOOLCHAIN_TYPE" = xgcc; then
 472       if test "x$OPENJDK_TARGET_OS" = xmacosx; then
 473         # On MacOSX we optimize for size, something
 474         # we should do for all platforms?
 475         C_O_FLAG_HIGHEST="-Os"
 476         C_O_FLAG_HI="-Os"
 477         C_O_FLAG_NORM="-Os"
 478       else
 479         C_O_FLAG_HIGHEST="-O3"
 480         C_O_FLAG_HI="-O3"
 481         C_O_FLAG_NORM="-O2"
 482       fi
 483       C_O_FLAG_DEBUG="-O0"
 484       C_O_FLAG_NONE="-O0"
 485     elif test "x$TOOLCHAIN_TYPE" = xclang; then
 486       if test "x$OPENJDK_TARGET_OS" = xmacosx; then
 487         # On MacOSX we optimize for size, something
 488         # we should do for all platforms?
 489         C_O_FLAG_HIGHEST="-Os"
 490         C_O_FLAG_HI="-Os"
 491         C_O_FLAG_NORM="-Os"
 492       else
 493         C_O_FLAG_HIGHEST="-O3"
 494         C_O_FLAG_HI="-O3"
 495         C_O_FLAG_NORM="-O2"
 496       fi
 497       C_O_FLAG_DEBUG="-O0"
 498       C_O_FLAG_NONE="-O0"
 499     elif test "x$TOOLCHAIN_TYPE" = xxlc; then
 500       C_O_FLAG_HIGHEST="-O3"
 501       C_O_FLAG_HI="-O3 -qstrict"
 502       C_O_FLAG_NORM="-O2"
 503       C_O_FLAG_DEBUG="-qnoopt"
 504       C_O_FLAG_NONE="-qnoopt"
 505     elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
 506       C_O_FLAG_HIGHEST="-O2"
 507       C_O_FLAG_HI="-O1"
 508       C_O_FLAG_NORM="-O1"
 509       C_O_FLAG_DEBUG="-Od"
 510       C_O_FLAG_NONE="-Od"
 511     fi
 512     CXX_O_FLAG_HIGHEST="$C_O_FLAG_HIGHEST"
 513     CXX_O_FLAG_HI="$C_O_FLAG_HI"
 514     CXX_O_FLAG_NORM="$C_O_FLAG_NORM"
 515     CXX_O_FLAG_DEBUG="$C_O_FLAG_DEBUG"
 516     CXX_O_FLAG_NONE="$C_O_FLAG_NONE"
 517   fi
 518 
 519   # Adjust optimization flags according to debug level.
 520   case $DEBUG_LEVEL in
 521     release )
 522       # no adjustment
 523       ;;
 524     fastdebug )
 525       # Not quite so much optimization
 526       C_O_FLAG_HI="$C_O_FLAG_NORM"
 527       CXX_O_FLAG_HI="$CXX_O_FLAG_NORM"
 528       ;;
 529     slowdebug )
 530       # Disable optimization
 531       C_O_FLAG_HIGHEST="$C_O_FLAG_DEBUG"
 532       C_O_FLAG_HI="$C_O_FLAG_DEBUG"
 533       C_O_FLAG_NORM="$C_O_FLAG_DEBUG"
 534       CXX_O_FLAG_HIGHEST="$CXX_O_FLAG_DEBUG"
 535       CXX_O_FLAG_HI="$CXX_O_FLAG_DEBUG"
 536       CXX_O_FLAG_NORM="$CXX_O_FLAG_DEBUG"
 537       ;;
 538   esac
 539 
 540   AC_SUBST(C_O_FLAG_HIGHEST)
 541   AC_SUBST(C_O_FLAG_HI)
 542   AC_SUBST(C_O_FLAG_NORM)
 543   AC_SUBST(C_O_FLAG_DEBUG)
 544   AC_SUBST(C_O_FLAG_NONE)
 545   AC_SUBST(CXX_O_FLAG_HIGHEST)
 546   AC_SUBST(CXX_O_FLAG_HI)
 547   AC_SUBST(CXX_O_FLAG_NORM)
 548   AC_SUBST(CXX_O_FLAG_DEBUG)
 549   AC_SUBST(CXX_O_FLAG_NONE)
 550 ])
 551 
 552 AC_DEFUN_ONCE([FLAGS_SETUP_COMPILER_FLAGS_FOR_JDK],
 553 [
 554   # Special extras...
 555   if test "x$TOOLCHAIN_TYPE" = xsolstudio; then
 556     if test "x$OPENJDK_TARGET_CPU_ARCH" = "xsparc"; then
 557       CFLAGS_JDKLIB_EXTRA="${CFLAGS_JDKLIB_EXTRA} -xregs=no%appl"
 558       CXXFLAGS_JDKLIB_EXTRA="${CXXFLAGS_JDKLIB_EXTRA} -xregs=no%appl"
 559     fi
 560     CFLAGS_JDKLIB_EXTRA="${CFLAGS_JDKLIB_EXTRA} -errtags=yes -errfmt"
 561     CXXFLAGS_JDKLIB_EXTRA="${CXXFLAGS_JDKLIB_EXTRA} -errtags=yes -errfmt"
 562   elif test "x$TOOLCHAIN_TYPE" = xxlc; then
 563     CFLAGS_JDK="${CFLAGS_JDK} -qchars=signed -qfullpath -qsaveopt"
 564     CXXFLAGS_JDK="${CXXFLAGS_JDK} -qchars=signed -qfullpath -qsaveopt"
 565   fi
 566 
 567   CFLAGS_JDK="${CFLAGS_JDK} $EXTRA_CFLAGS"
 568   CXXFLAGS_JDK="${CXXFLAGS_JDK} $EXTRA_CXXFLAGS"
 569   LDFLAGS_JDK="${LDFLAGS_JDK} $EXTRA_LDFLAGS"
 570 
 571   ###############################################################################
 572   #
 573   # Now setup the CFLAGS and LDFLAGS for the JDK build.
 574   # Later we will also have CFLAGS and LDFLAGS for the hotspot subrepo build.
 575   #
 576 
 577   # Setup compiler/platform specific flags into
 578   #    CFLAGS_JDK    - C Compiler flags
 579   #    CXXFLAGS_JDK  - C++ Compiler flags
 580   #    COMMON_CCXXFLAGS_JDK - common to C and C++
 581   if test "x$TOOLCHAIN_TYPE" = xgcc; then
 582     if test "x$OPENJDK_TARGET_CPU" = xx86; then
 583       # Force compatibility with i586 on 32 bit intel platforms.
 584       COMMON_CCXXFLAGS="${COMMON_CCXXFLAGS} -march=i586"
 585     fi
 586     COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS $COMMON_CCXXFLAGS_JDK -Wall -Wextra -Wno-unused -Wno-unused-parameter -Wformat=2 \
 587         -pipe -D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE"
 588     case $OPENJDK_TARGET_CPU_ARCH in
 589       arm )
 590         # on arm we don't prevent gcc to omit frame pointer but do prevent strict aliasing
 591         CFLAGS_JDK="${CFLAGS_JDK} -fno-strict-aliasing"
 592         ;;
 593       ppc )
 594         # on ppc we don't prevent gcc to omit frame pointer but do prevent strict aliasing
 595         CFLAGS_JDK="${CFLAGS_JDK} -fno-strict-aliasing"
 596         ;;
 597       * )
 598         COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -fno-omit-frame-pointer"
 599         CFLAGS_JDK="${CFLAGS_JDK} -fno-strict-aliasing"
 600         ;;
 601     esac
 602   elif test "x$TOOLCHAIN_TYPE" = xclang; then
 603     if test "x$OPENJDK_TARGET_OS" = xlinux; then
 604             if test "x$OPENJDK_TARGET_CPU" = xx86; then
 605               # Force compatibility with i586 on 32 bit intel platforms.
 606               COMMON_CCXXFLAGS="${COMMON_CCXXFLAGS} -march=i586"
 607             fi
 608             COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS $COMMON_CCXXFLAGS_JDK -Wall -Wextra -Wno-unused -Wno-unused-parameter -Wformat=2 \
 609                 -pipe -D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE"
 610             case $OPENJDK_TARGET_CPU_ARCH in
 611               ppc )
 612                 # on ppc we don't prevent gcc to omit frame pointer but do prevent strict aliasing
 613                 CFLAGS_JDK="${CFLAGS_JDK} -fno-strict-aliasing"
 614                 ;;
 615               * )
 616                 COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -fno-omit-frame-pointer"
 617                 CFLAGS_JDK="${CFLAGS_JDK} -fno-strict-aliasing"
 618                 ;;
 619             esac
 620     fi
 621   elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
 622     COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS $COMMON_CCXXFLAGS_JDK -DTRACING -DMACRO_MEMSYS_OPS -DBREAKPTS"
 623     if test "x$OPENJDK_TARGET_CPU_ARCH" = xx86; then
 624       COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DcpuIntel -Di586 -D$OPENJDK_TARGET_CPU_LEGACY_LIB"
 625     fi
 626 
 627     CFLAGS_JDK="$CFLAGS_JDK -xc99=%none -xCC -errshort=tags -Xa -v -mt -W0,-noglobal"
 628     CXXFLAGS_JDK="$CXXFLAGS_JDK -errtags=yes +w -mt -features=no%except -DCC_NOEX -norunpath -xnolib"
 629   elif test "x$TOOLCHAIN_TYPE" = xxlc; then
 630     CFLAGS_JDK="$CFLAGS_JDK -D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE -DSTDC"
 631     CXXFLAGS_JDK="$CXXFLAGS_JDK -D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE -DSTDC"
 632   elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
 633     COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS $COMMON_CCXXFLAGS_JDK \
 634         -Zi -MD -Zc:wchar_t- -W3 -wd4800 \
 635         -DWIN32_LEAN_AND_MEAN \
 636         -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE \
 637         -D_WINSOCK_DEPRECATED_NO_WARNINGS \
 638         -DWIN32 -DIAL"
 639     if test "x$OPENJDK_TARGET_CPU" = xx86_64; then
 640       COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D_AMD64_ -Damd64"
 641     else
 642       COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D_X86_ -Dx86"
 643     fi
 644     # If building with Visual Studio 2010, we can still use _STATIC_CPPLIB to
 645     # avoid bundling msvcpNNN.dll. Doesn't work with newer versions of visual
 646     # studio.
 647     if test "x$TOOLCHAIN_VERSION" = "x2010"; then
 648       COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK \
 649           -D_STATIC_CPPLIB -D_DISABLE_DEPRECATE_STATIC_CPPLIB"
 650     fi
 651   fi
 652 
 653   ###############################################################################
 654 
 655   # Adjust flags according to debug level.
 656   case $DEBUG_LEVEL in
 657     fastdebug | slowdebug )
 658       CFLAGS_JDK="$CFLAGS_JDK $CFLAGS_DEBUG_SYMBOLS $CFLAGS_DEBUG_OPTIONS"
 659       CXXFLAGS_JDK="$CXXFLAGS_JDK $CXXFLAGS_DEBUG_SYMBOLS $CXXFLAGS_DEBUG_OPTIONS"
 660       JAVAC_FLAGS="$JAVAC_FLAGS -g"
 661       ;;
 662     release )
 663       ;;
 664     * )
 665       AC_MSG_ERROR([Unrecognized \$DEBUG_LEVEL: $DEBUG_LEVEL])
 666       ;;
 667   esac
 668 
 669   # Setup LP64
 670   COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK $ADD_LP64"
 671 
 672   # Set some common defines. These works for all compilers, but assume
 673   # -D is universally accepted.
 674 
 675   # Setup endianness
 676   if test "x$OPENJDK_TARGET_CPU_ENDIAN" = xlittle; then
 677     # The macro _LITTLE_ENDIAN needs to be defined the same to avoid the
 678     #   Sun C compiler warning message: warning: macro redefined: _LITTLE_ENDIAN
 679     #   (The Solaris X86 system defines this in file /usr/include/sys/isa_defs.h).
 680     #   Note: -Dmacro         is the same as    #define macro 1
 681     #         -Dmacro=        is the same as    #define macro
 682     if test "x$OPENJDK_TARGET_OS" = xsolaris; then
 683       COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D_LITTLE_ENDIAN="
 684     else
 685       COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D_LITTLE_ENDIAN"
 686     fi
 687   else
 688     # Same goes for _BIG_ENDIAN. Do we really need to set *ENDIAN on Solaris if they
 689     # are defined in the system?
 690     if test "x$OPENJDK_TARGET_OS" = xsolaris; then
 691       COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D_BIG_ENDIAN="
 692     else
 693       COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D_BIG_ENDIAN"
 694     fi
 695   fi
 696 
 697   # Setup target OS define. Use OS target name but in upper case.
 698   OPENJDK_TARGET_OS_UPPERCASE=`$ECHO $OPENJDK_TARGET_OS | $TR 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
 699   COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D$OPENJDK_TARGET_OS_UPPERCASE"
 700 
 701   # Setup target CPU
 702   COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DARCH='\"$OPENJDK_TARGET_CPU_LEGACY\"' -D$OPENJDK_TARGET_CPU_LEGACY"
 703 
 704   # Setup debug/release defines
 705   if test "x$DEBUG_LEVEL" = xrelease; then
 706     COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DNDEBUG"
 707     if test "x$OPENJDK_TARGET_OS" = xsolaris; then
 708       COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DTRIMMED"
 709     fi
 710   else
 711     COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DDEBUG"
 712   fi
 713 
 714   # Set some additional per-OS defines.
 715   if test "x$OPENJDK_TARGET_OS" = xmacosx; then
 716     COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D_ALLBSD_SOURCE -D_DARWIN_UNLIMITED_SELECT"
 717   elif test "x$OPENJDK_TARGET_OS" = xaix; then
 718     # FIXME: PPC64 should not be here.
 719     COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DPPC64"
 720   elif test "x$OPENJDK_TARGET_OS" = xbsd; then
 721     COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D_ALLBSD_SOURCE"
 722   fi
 723 
 724   # Additional macosx handling
 725   if test "x$OPENJDK_TARGET_OS" = xmacosx; then
 726     # Setting these parameters makes it an error to link to macosx APIs that are
 727     # newer than the given OS version and makes the linked binaries compatible
 728     # even if built on a newer version of the OS.
 729     # The expected format is X.Y.Z
 730     MACOSX_VERSION_MIN=10.7.0
 731     AC_SUBST(MACOSX_VERSION_MIN)
 732 
 733     # The macro takes the version with no dots, ex: 1070
 734     # Let the flags variables get resolved in make for easier override on make
 735     # command line.
 736     COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DMAC_OS_X_VERSION_MAX_ALLOWED=\$(subst .,,\$(MACOSX_VERSION_MIN)) -mmacosx-version-min=\$(MACOSX_VERSION_MIN)"
 737     LDFLAGS_JDK="$LDFLAGS_JDK -mmacosx-version-min=\$(MACOSX_VERSION_MIN)"
 738   fi
 739 
 740   # Setup some hard coded includes
 741   COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK \
 742       -I${JDK_TOPDIR}/src/java.base/share/native/include \
 743       -I${JDK_TOPDIR}/src/java.base/$OPENJDK_TARGET_OS/native/include \
 744       -I${JDK_TOPDIR}/src/java.base/$OPENJDK_TARGET_OS_TYPE/native/include \
 745       -I${JDK_TOPDIR}/src/java.base/share/native/libjava \
 746       -I${JDK_TOPDIR}/src/java.base/$OPENJDK_TARGET_OS_TYPE/native/libjava"
 747 
 748   # The shared libraries are compiled using the picflag.
 749   CFLAGS_JDKLIB="$COMMON_CCXXFLAGS_JDK $CFLAGS_JDK $PICFLAG $CFLAGS_JDKLIB_EXTRA"
 750   CXXFLAGS_JDKLIB="$COMMON_CCXXFLAGS_JDK $CXXFLAGS_JDK $PICFLAG $CXXFLAGS_JDKLIB_EXTRA"
 751 
 752   # Executable flags
 753   CFLAGS_JDKEXE="$COMMON_CCXXFLAGS_JDK $CFLAGS_JDK"
 754   CXXFLAGS_JDKEXE="$COMMON_CCXXFLAGS_JDK $CXXFLAGS_JDK"
 755 
 756   AC_SUBST(CFLAGS_JDKLIB)
 757   AC_SUBST(CFLAGS_JDKEXE)
 758   AC_SUBST(CXXFLAGS_JDKLIB)
 759   AC_SUBST(CXXFLAGS_JDKEXE)
 760 
 761   # Flags for compiling test libraries
 762   CFLAGS_TESTLIB="$COMMON_CCXXFLAGS_JDK $CFLAGS_JDK $PICFLAG $CFLAGS_JDKLIB_EXTRA"
 763   CXXFLAGS_TESTLIB="$COMMON_CCXXFLAGS_JDK $CXXFLAGS_JDK $PICFLAG $CXXFLAGS_JDKLIB_EXTRA"
 764 
 765   # Flags for compiling test executables
 766   CFLAGS_TESTEXE="$COMMON_CCXXFLAGS_JDK $CFLAGS_JDK"
 767   CXXFLAGS_TESTEXE="$COMMON_CCXXFLAGS_JDK $CXXFLAGS_JDK"
 768 
 769   AC_SUBST(CFLAGS_TESTLIB)
 770   AC_SUBST(CFLAGS_TESTEXE)
 771   AC_SUBST(CXXFLAGS_TESTLIB)
 772   AC_SUBST(CXXFLAGS_TESTEXE)
 773 
 774   # Setup LDFLAGS et al.
 775   #
 776 
 777   # Now this is odd. The JDK native libraries have to link against libjvm.so
 778   # On 32-bit machines there is normally two distinct libjvm.so:s, client and server.
 779   # Which should we link to? Are we lucky enough that the binary api to the libjvm.so library
 780   # is identical for client and server? Yes. Which is picked at runtime (client or server)?
 781   # Neither, since the chosen libjvm.so has already been loaded by the launcher, all the following
 782   # libraries will link to whatever is in memory. Yuck.
 783   #
 784   # Thus we offer the compiler to find libjvm.so first in server then in client. It works. Ugh.
 785   if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
 786     LDFLAGS_JDK="$LDFLAGS_JDK -nologo -opt:ref -incremental:no"
 787     if test "x$OPENJDK_TARGET_CPU_BITS" = "x32"; then
 788       LDFLAGS_JDK="$LDFLAGS_JDK -safeseh"
 789     fi
 790     # TODO: make -debug optional "--disable-full-debug-symbols"
 791     LDFLAGS_JDK="$LDFLAGS_JDK -debug"
 792   elif test "x$TOOLCHAIN_TYPE" = xgcc; then
 793     # If this is a --hash-style=gnu system, use --hash-style=both, why?
 794     # We have previously set HAS_GNU_HASH if this is the case
 795     if test -n "$HAS_GNU_HASH"; then
 796       LDFLAGS_JDK="${LDFLAGS_JDK} -Wl,--hash-style=both"
 797     fi
 798     if test "x$OPENJDK_TARGET_OS" = xlinux; then
 799       # And since we now know that the linker is gnu, then add -z defs, to forbid
 800       # undefined symbols in object files.
 801       LDFLAGS_JDK="${LDFLAGS_JDK} -Wl,-z,defs"
 802       case $DEBUG_LEVEL in
 803         release )
 804           # tell linker to optimize libraries.
 805           # Should this be supplied to the OSS linker as well?
 806           LDFLAGS_JDK="${LDFLAGS_JDK} -Wl,-O1"
 807           ;;
 808         slowdebug )
 809           if test "x$HAS_LINKER_NOW" = "xtrue"; then
 810             # do relocations at load
 811             LDFLAGS_JDK="$LDFLAGS_JDK $LINKER_NOW_FLAG"
 812             LDFLAGS_CXX_JDK="$LDFLAGS_CXX_JDK $LINKER_NOW_FLAG"
 813           fi
 814           if test "x$HAS_LINKER_RELRO" = "xtrue"; then
 815             # mark relocations read only
 816             LDFLAGS_JDK="$LDFLAGS_JDK $LINKER_RELRO_FLAG"
 817             LDFLAGS_CXX_JDK="$LDFLAGS_CXX_JDK $LINKER_RELRO_FLAG"
 818           fi
 819           ;;
 820         fastdebug )
 821           if test "x$HAS_LINKER_RELRO" = "xtrue"; then
 822             # mark relocations read only
 823             LDFLAGS_JDK="$LDFLAGS_JDK $LINKER_RELRO_FLAG"
 824             LDFLAGS_CXX_JDK="$LDFLAGS_CXX_JDK $LINKER_RELRO_FLAG"
 825           fi
 826           ;;
 827         * )
 828           AC_MSG_ERROR([Unrecognized \$DEBUG_LEVEL: $DEBUG_LEVEL])
 829           ;;
 830         esac
 831     fi
 832   elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
 833     LDFLAGS_JDK="$LDFLAGS_JDK -Wl,-z,defs -xildoff -ztext"
 834     LDFLAGS_CXX_JDK="$LDFLAGS_CXX_JDK -norunpath -xnolib"
 835   elif test "x$TOOLCHAIN_TYPE" = xxlc; then
 836     LDFLAGS_JDK="${LDFLAGS_JDK} -brtl -bnolibpath -bexpall -bernotok"
 837   fi
 838 
 839   # Customize LDFLAGS for executables
 840 
 841   LDFLAGS_JDKEXE="${LDFLAGS_JDK}"
 842 
 843   if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
 844     if test "x$OPENJDK_TARGET_CPU_BITS" = "x64"; then
 845       LDFLAGS_STACK_SIZE=1048576
 846     else
 847       LDFLAGS_STACK_SIZE=327680
 848     fi
 849     LDFLAGS_JDKEXE="${LDFLAGS_JDKEXE} /STACK:$LDFLAGS_STACK_SIZE"
 850   elif test "x$OPENJDK_TARGET_OS" = xlinux; then
 851     LDFLAGS_JDKEXE="$LDFLAGS_JDKEXE -Wl,--allow-shlib-undefined"
 852   fi
 853 
 854   # Customize LDFLAGS for libs
 855   LDFLAGS_JDKLIB="${LDFLAGS_JDK}"
 856 
 857   LDFLAGS_JDKLIB="${LDFLAGS_JDKLIB} ${SHARED_LIBRARY_FLAGS}"
 858   if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
 859     LDFLAGS_JDKLIB="${LDFLAGS_JDKLIB} \
 860         -libpath:${OUTPUT_ROOT}/support/modules_libs/java.base"
 861     JDKLIB_LIBS=""
 862   else
 863     LDFLAGS_JDKLIB="${LDFLAGS_JDKLIB} \
 864         -L${OUTPUT_ROOT}/support/modules_libs/java.base${OPENJDK_TARGET_CPU_LIBDIR}"
 865 
 866     # On some platforms (mac) the linker warns about non existing -L dirs.
 867     # Add server first if available. Linking aginst client does not always produce the same results.
 868     # Only add client dir if client is being built. Add minimal (note not minimal1) if only building minimal1.
 869     # Default to server for other variants.
 870     if test "x$JVM_VARIANT_SERVER" = xtrue; then
 871       LDFLAGS_JDKLIB="${LDFLAGS_JDKLIB} -L${OUTPUT_ROOT}/support/modules_libs/java.base${OPENJDK_TARGET_CPU_LIBDIR}/server"
 872     elif test "x$JVM_VARIANT_CLIENT" = xtrue; then
 873       LDFLAGS_JDKLIB="${LDFLAGS_JDKLIB} -L${OUTPUT_ROOT}/support/modules_libs/java.base${OPENJDK_TARGET_CPU_LIBDIR}/client"
 874     elif test "x$JVM_VARIANT_MINIMAL1" = xtrue; then
 875       LDFLAGS_JDKLIB="${LDFLAGS_JDKLIB} -L${OUTPUT_ROOT}/support/modules_libs/java.base${OPENJDK_TARGET_CPU_LIBDIR}/minimal"
 876     else
 877       LDFLAGS_JDKLIB="${LDFLAGS_JDKLIB} -L${OUTPUT_ROOT}/support/modules_libs/java.base${OPENJDK_TARGET_CPU_LIBDIR}/server"
 878     fi
 879 
 880     JDKLIB_LIBS="-ljava -ljvm"
 881     if test "x$TOOLCHAIN_TYPE" = xsolstudio; then
 882       JDKLIB_LIBS="$JDKLIB_LIBS -lc"
 883     fi
 884   fi
 885 
 886   AC_SUBST(LDFLAGS_JDKLIB)
 887   AC_SUBST(LDFLAGS_JDKEXE)
 888   AC_SUBST(JDKLIB_LIBS)
 889   AC_SUBST(JDKEXE_LIBS)
 890   AC_SUBST(LDFLAGS_CXX_JDK)
 891 
 892   LDFLAGS_TESTLIB="$LDFLAGS_JDKLIB"
 893   LDFLAGS_TESTEXE="$LDFLAGS_JDKEXE"
 894 
 895   AC_SUBST(LDFLAGS_TESTLIB)
 896   AC_SUBST(LDFLAGS_TESTEXE)
 897 ])
 898 
 899 # FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [ARGUMENT], IF_TRUE: [RUN-IF-TRUE],
 900 #                                   IF_FALSE: [RUN-IF-FALSE])
 901 # ------------------------------------------------------------
 902 # Check that the c and c++ compilers support an argument
 903 BASIC_DEFUN_NAMED([FLAGS_COMPILER_CHECK_ARGUMENTS],
 904     [*ARGUMENT IF_TRUE IF_FALSE], [$@],
 905 [
 906   AC_MSG_CHECKING([if compiler supports "ARG_ARGUMENT"])
 907   supports=yes
 908 
 909   saved_cflags="$CFLAGS"
 910   CFLAGS="$CFLAGS ARG_ARGUMENT"
 911   AC_LANG_PUSH([C])
 912   AC_COMPILE_IFELSE([AC_LANG_SOURCE([[int i;]])], [],
 913       [supports=no])
 914   AC_LANG_POP([C])
 915   CFLAGS="$saved_cflags"
 916 
 917   saved_cxxflags="$CXXFLAGS"
 918   CXXFLAGS="$CXXFLAG ARG_ARGUMENT"
 919   AC_LANG_PUSH([C++])
 920   AC_COMPILE_IFELSE([AC_LANG_SOURCE([[int i;]])], [],
 921       [supports=no])
 922   AC_LANG_POP([C++])
 923   CXXFLAGS="$saved_cxxflags"
 924 
 925   AC_MSG_RESULT([$supports])
 926   if test "x$supports" = "xyes" ; then
 927     :
 928     ARG_IF_TRUE
 929   else
 930     :
 931     ARG_IF_FALSE
 932   fi
 933 ])
 934 
 935 # FLAGS_LINKER_CHECK_ARGUMENTS(ARGUMENT: [ARGUMENT], IF_TRUE: [RUN-IF-TRUE],
 936 #                                   IF_FALSE: [RUN-IF-FALSE])
 937 # ------------------------------------------------------------
 938 # Check that the linker support an argument
 939 BASIC_DEFUN_NAMED([FLAGS_LINKER_CHECK_ARGUMENTS],
 940     [*ARGUMENT IF_TRUE IF_FALSE], [$@],
 941 [
 942   AC_MSG_CHECKING([if linker supports "ARG_ARGUMENT"])
 943   supports=yes
 944 
 945   saved_ldflags="$LDFLAGS"
 946   LDFLAGS="$LDFLAGS ARG_ARGUMENT"
 947   AC_LANG_PUSH([C])
 948   AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[]])],
 949       [], [supports=no])
 950   AC_LANG_POP([C])
 951   LDFLAGS="$saved_ldflags"
 952 
 953   AC_MSG_RESULT([$supports])
 954   if test "x$supports" = "xyes" ; then
 955     :
 956     ARG_IF_TRUE
 957   else
 958     :
 959     ARG_IF_FALSE
 960   fi
 961 ])
 962 
 963 AC_DEFUN_ONCE([FLAGS_SETUP_COMPILER_FLAGS_MISC],
 964 [
 965   # Some Zero and Shark settings.
 966   # ZERO_ARCHFLAG tells the compiler which mode to build for
 967   case "${OPENJDK_TARGET_CPU}" in
 968     s390)
 969       ZERO_ARCHFLAG="${COMPILER_TARGET_BITS_FLAG}31"
 970       ;;
 971     *)
 972       ZERO_ARCHFLAG="${COMPILER_TARGET_BITS_FLAG}${OPENJDK_TARGET_CPU_BITS}"
 973   esac
 974   FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [$ZERO_ARCHFLAG], IF_FALSE: [ZERO_ARCHFLAG=""])
 975   AC_SUBST(ZERO_ARCHFLAG)
 976 
 977   # Check that the compiler supports -mX (or -qX on AIX) flags
 978   # Set COMPILER_SUPPORTS_TARGET_BITS_FLAG to 'true' if it does
 979   FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [${COMPILER_TARGET_BITS_FLAG}${OPENJDK_TARGET_CPU_BITS}],
 980       IF_TRUE: [COMPILER_SUPPORTS_TARGET_BITS_FLAG=true],
 981       IF_FALSE: [COMPILER_SUPPORTS_TARGET_BITS_FLAG=false])
 982   AC_SUBST(COMPILER_SUPPORTS_TARGET_BITS_FLAG)
 983 
 984   AC_ARG_ENABLE([warnings-as-errors], [AS_HELP_STRING([--disable-warnings-as-errors],
 985       [do not consider native warnings to be an error @<:@enabled@:>@])])
 986 
 987   AC_MSG_CHECKING([if native warnings are errors])
 988   if test "x$enable_warnings_as_errors" = "xyes"; then
 989     AC_MSG_RESULT([yes (explicitely set)])
 990     WARNINGS_AS_ERRORS=true
 991   elif test "x$enable_warnings_as_errors" = "xno"; then
 992     AC_MSG_RESULT([no])
 993     WARNINGS_AS_ERRORS=false
 994   elif test "x$enable_warnings_as_errors" = "x"; then
 995     AC_MSG_RESULT([yes (default)])
 996     WARNINGS_AS_ERRORS=true
 997   else
 998     AC_MSG_ERROR([--enable-warnings-as-errors accepts no argument])
 999   fi
1000 
1001   if test "x$WARNINGS_AS_ERRORS" = "xfalse"; then
1002     # Set legacy hotspot variable
1003     HOTSPOT_SET_WARNINGS_AS_ERRORS="WARNINGS_ARE_ERRORS="
1004   else
1005     HOTSPOT_SET_WARNINGS_AS_ERRORS=""
1006   fi
1007 
1008   AC_SUBST(WARNINGS_AS_ERRORS)
1009   AC_SUBST(HOTSPOT_SET_WARNINGS_AS_ERRORS)
1010 
1011   case "${TOOLCHAIN_TYPE}" in
1012     microsoft)
1013       DISABLE_WARNING_PREFIX="-wd"
1014       CFLAGS_WARNINGS_ARE_ERRORS="-WX"
1015       ;;
1016     solstudio)
1017       DISABLE_WARNING_PREFIX="-erroff="
1018       CFLAGS_WARNINGS_ARE_ERRORS="-errtags -errwarn=%all"
1019       ;;
1020     gcc)
1021       # Prior to gcc 4.4, a -Wno-X where X is unknown for that version of gcc will cause an error
1022       FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [-Wno-this-is-a-warning-that-do-not-exist],
1023           IF_TRUE: [GCC_CAN_DISABLE_WARNINGS=true],
1024           IF_FALSE: [GCC_CAN_DISABLE_WARNINGS=false]
1025       )
1026       if test "x$GCC_CAN_DISABLE_WARNINGS" = "xtrue"; then
1027         DISABLE_WARNING_PREFIX="-Wno-"
1028       else
1029         DISABLE_WARNING_PREFIX=
1030       fi
1031       CFLAGS_WARNINGS_ARE_ERRORS="-Werror"
1032       # Repeate the check for the BUILD_CC
1033       CC_OLD="$CC"
1034       CC="$BUILD_CC"
1035       FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [-Wno-this-is-a-warning-that-do-not-exist],
1036           IF_TRUE: [BUILD_CC_CAN_DISABLE_WARNINGS=true],
1037           IF_FALSE: [BUILD_CC_CAN_DISABLE_WARNINGS=false]
1038       )
1039       if test "x$BUILD_CC_CAN_DISABLE_WARNINGS" = "xtrue"; then
1040         BUILD_CC_DISABLE_WARNING_PREFIX="-Wno-"
1041       else
1042         BUILD_CC_DISABLE_WARNING_PREFIX=
1043       fi
1044       CC="$CC_OLD"
1045       ;;
1046     clang)
1047       DISABLE_WARNING_PREFIX="-Wno-"
1048       CFLAGS_WARNINGS_ARE_ERRORS="-Werror"
1049       ;;
1050   esac
1051   AC_SUBST(DISABLE_WARNING_PREFIX)
1052   AC_SUBST(CFLAGS_WARNINGS_ARE_ERRORS)
1053 ])
--- EOF ---