common/autoconf/flags.m4

Print this page
rev 992 : 8032045: Enable compiler and linker safety switches for debug builds
Reviewed-by: duke


  99       RC_FLAGS="$RC_FLAGS -d NDEBUG"
 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     # FIXME: likely bug, should be CCXXFLAGS_JDK? or one for C or CXX.
 120     CCXXFLAGS="$CCXXFLAGS -nologo"
 121   fi
 122 ])
 123 
 124 AC_DEFUN_ONCE([FLAGS_SETUP_COMPILER_FLAGS_FOR_LIBS],
 125 [
 126   ###############################################################################
 127   #
 128   # How to compile shared libraries.
 129   #
 130 
 131   if test "x$TOOLCHAIN_TYPE" = xgcc; then
 132     PICFLAG="-fPIC"
 133     C_FLAG_REORDER=''
 134     CXX_FLAG_REORDER=''
 135 
 136     if test "x$OPENJDK_TARGET_OS" = xmacosx; then
 137       # Linking is different on MacOSX
 138       SHARED_LIBRARY_FLAGS="-dynamiclib -compatibility_version 1.0.0 -current_version 1.0.0 $PICFLAG"
 139       SET_EXECUTABLE_ORIGIN='-Xlinker -rpath -Xlinker @loader_path/.'
 140       SET_SHARED_LIBRARY_ORIGIN="$SET_EXECUTABLE_ORIGIN"


 259   #   C_FLAG_DEPS="-MMD -MF"
 260   # fi
 261 
 262   # Generate make dependency files
 263   if test "x$TOOLCHAIN_TYPE" = xgcc; then
 264     C_FLAG_DEPS="-MMD -MF"
 265   elif test "x$TOOLCHAIN_TYPE" = xclang; then
 266     C_FLAG_DEPS="-MMD -MF"
 267   elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
 268     C_FLAG_DEPS="-xMMD -xMF"
 269   elif test "x$TOOLCHAIN_TYPE" = xxlc; then
 270     C_FLAG_DEPS="-qmakedep=gcc -MF"
 271   fi
 272   CXX_FLAG_DEPS="$C_FLAG_DEPS"
 273   AC_SUBST(C_FLAG_DEPS)
 274   AC_SUBST(CXX_FLAG_DEPS)
 275 
 276   # Debug symbols
 277   if test "x$TOOLCHAIN_TYPE" = xgcc; then
 278     if test "x$OPENJDK_TARGET_CPU_BITS" = "x64" && test "x$DEBUG_LEVEL" = "xfastdebug"; then

 279       CFLAGS_DEBUG_SYMBOLS="-g1"
 280       CXXFLAGS_DEBUG_SYMBOLS="-g1"
 281     else
 282       CFLAGS_DEBUG_SYMBOLS="-g"
 283       CXXFLAGS_DEBUG_SYMBOLS="-g"
 284     fi
 285   elif test "x$TOOLCHAIN_TYPE" = xclang; then
 286     CFLAGS_DEBUG_SYMBOLS="-g"
 287     CXXFLAGS_DEBUG_SYMBOLS="-g"
 288   elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
 289     CFLAGS_DEBUG_SYMBOLS="-g -xs"

 290     CXXFLAGS_DEBUG_SYMBOLS="-g0 -xs"
 291   elif test "x$TOOLCHAIN_TYPE" = xxlc; then
 292     CFLAGS_DEBUG_SYMBOLS="-g"
 293     CXXFLAGS_DEBUG_SYMBOLS="-g"
 294   fi
 295   AC_SUBST(CFLAGS_DEBUG_SYMBOLS)
 296   AC_SUBST(CXXFLAGS_DEBUG_SYMBOLS)
 297 





















 298   # Optimization levels
 299   if test "x$TOOLCHAIN_TYPE" = xsolstudio; then
 300     CC_HIGHEST="$CC_HIGHEST -fns -fsimple -fsingle -xbuiltin=%all -xdepend -xrestrict -xlibmil"
 301 
 302     if test "x$OPENJDK_TARGET_CPU_ARCH" = "xx86"; then
 303       # FIXME: seems we always set -xregs=no%frameptr; put it elsewhere more global?
 304       C_O_FLAG_HIGHEST="-xO4 -Wu,-O4~yz $CC_HIGHEST -xalias_level=basic -xregs=no%frameptr"
 305       C_O_FLAG_HI="-xO4 -Wu,-O4~yz -xregs=no%frameptr"
 306       C_O_FLAG_NORM="-xO2 -Wu,-O2~yz -xregs=no%frameptr"

 307       C_O_FLAG_NONE="-xregs=no%frameptr"
 308       CXX_O_FLAG_HIGHEST="-xO4 -Qoption ube -O4~yz $CC_HIGHEST -xregs=no%frameptr"
 309       CXX_O_FLAG_HI="-xO4 -Qoption ube -O4~yz -xregs=no%frameptr"
 310       CXX_O_FLAG_NORM="-xO2 -Qoption ube -O2~yz -xregs=no%frameptr"

 311       CXX_O_FLAG_NONE="-xregs=no%frameptr"
 312       if test "x$OPENJDK_TARGET_CPU_BITS" = "x32"; then
 313         C_O_FLAG_HIGHEST="$C_O_FLAG_HIGHEST -xchip=pentium"
 314         CXX_O_FLAG_HIGHEST="$CXX_O_FLAG_HIGHEST -xchip=pentium"
 315       fi
 316     elif test "x$OPENJDK_TARGET_CPU_ARCH" = "xsparc"; then
 317       C_O_FLAG_HIGHEST="-xO4 -Wc,-Qrm-s -Wc,-Qiselect-T0 $CC_HIGHEST -xalias_level=basic -xprefetch=auto,explicit -xchip=ultra"
 318       C_O_FLAG_HI="-xO4 -Wc,-Qrm-s -Wc,-Qiselect-T0"
 319       C_O_FLAG_NORM="-xO2 -Wc,-Qrm-s -Wc,-Qiselect-T0"

 320       C_O_FLAG_NONE=""
 321       CXX_O_FLAG_HIGHEST="-xO4 -Qoption cg -Qrm-s -Qoption cg -Qiselect-T0 $CC_HIGHEST -xprefetch=auto,explicit -xchip=ultra"
 322       CXX_O_FLAG_HI="-xO4 -Qoption cg -Qrm-s -Qoption cg -Qiselect-T0"
 323       CXX_O_FLAG_NORM="-xO2 -Qoption cg -Qrm-s -Qoption cg -Qiselect-T0"

 324       CXX_O_FLAG_NONE=""
 325     fi
 326   else
 327     # The remaining toolchains share opt flags between CC and CXX;
 328     # setup for C and duplicate afterwards.
 329     if test "x$TOOLCHAIN_TYPE" = xgcc; then
 330       if test "x$OPENJDK_TARGET_OS" = xmacosx; then
 331         # On MacOSX we optimize for size, something
 332         # we should do for all platforms?
 333         C_O_FLAG_HIGHEST="-Os"
 334         C_O_FLAG_HI="-Os"
 335         C_O_FLAG_NORM="-Os"
 336         C_O_FLAG_NONE=""
 337       else
 338         C_O_FLAG_HIGHEST="-O3"
 339         C_O_FLAG_HI="-O3"
 340         C_O_FLAG_NORM="-O2"
 341         C_O_FLAG_NONE="-O0"
 342       fi






 343     elif test "x$TOOLCHAIN_TYPE" = xclang; then
 344       if test "x$OPENJDK_TARGET_OS" = xmacosx; then
 345         # On MacOSX we optimize for size, something
 346         # we should do for all platforms?
 347         C_O_FLAG_HIGHEST="-Os"
 348         C_O_FLAG_HI="-Os"
 349         C_O_FLAG_NORM="-Os"
 350         C_O_FLAG_NONE=""
 351       else
 352         C_O_FLAG_HIGHEST="-O3"
 353         C_O_FLAG_HI="-O3"
 354         C_O_FLAG_NORM="-O2"
 355         C_O_FLAG_NONE="-O0"
 356       fi


 357     elif test "x$TOOLCHAIN_TYPE" = xxlc; then
 358       C_O_FLAG_HIGHEST="-O3"
 359       C_O_FLAG_HI="-O3 -qstrict"
 360       C_O_FLAG_NORM="-O2"
 361       C_O_FLAG_NONE=""

 362     elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
 363       C_O_FLAG_HIGHEST="-O2"
 364       C_O_FLAG_HI="-O1"
 365       C_O_FLAG_NORM="-O1"

 366       C_O_FLAG_NONE="-Od"
 367     fi
 368     CXX_O_FLAG_HIGHEST="$C_O_FLAG_HIGHEST"
 369     CXX_O_FLAG_HI="$C_O_FLAG_HI"
 370     CXX_O_FLAG_NORM="$C_O_FLAG_NORM"

 371     CXX_O_FLAG_NONE="$C_O_FLAG_NONE"
 372   fi
 373 























 374   AC_SUBST(C_O_FLAG_HIGHEST)
 375   AC_SUBST(C_O_FLAG_HI)
 376   AC_SUBST(C_O_FLAG_NORM)

 377   AC_SUBST(C_O_FLAG_NONE)
 378   AC_SUBST(CXX_O_FLAG_HIGHEST)
 379   AC_SUBST(CXX_O_FLAG_HI)
 380   AC_SUBST(CXX_O_FLAG_NORM)

 381   AC_SUBST(CXX_O_FLAG_NONE)
 382 ])
 383 
 384 AC_DEFUN_ONCE([FLAGS_SETUP_COMPILER_FLAGS_FOR_JDK],
 385 [
 386   # Special extras...
 387   if test "x$TOOLCHAIN_TYPE" = xsolstudio; then
 388     if test "x$OPENJDK_TARGET_CPU_ARCH" = "xsparc"; then
 389       CFLAGS_JDKLIB_EXTRA="${CFLAGS_JDKLIB_EXTRA} -xregs=no%appl"
 390       CXXFLAGS_JDKLIB_EXTRA="${CXXFLAGS_JDKLIB_EXTRA} -xregs=no%appl"
 391     fi
 392   elif test "x$TOOLCHAIN_TYPE" = xxlc; then
 393     LDFLAGS_JDK="${LDFLAGS_JDK} -q64 -brtl -bnolibpath -liconv -bexpall"
 394     CFLAGS_JDK="${CFLAGS_JDK} -qchars=signed -q64 -qfullpath -qsaveopt"
 395     CXXFLAGS_JDK="${CXXFLAGS_JDK} -qchars=signed -q64 -qfullpath -qsaveopt"
 396   fi
 397 
 398   if test "x$CFLAGS" != "x${ADDED_CFLAGS}"; then
 399     AC_MSG_WARN([Ignoring CFLAGS($CFLAGS) found in environment. Use --with-extra-cflags])
 400   fi


 418 
 419   CFLAGS_JDK="${CFLAGS_JDK} $with_extra_cflags"
 420   CXXFLAGS_JDK="${CXXFLAGS_JDK} $with_extra_cxxflags"
 421   LDFLAGS_JDK="${LDFLAGS_JDK} $with_extra_ldflags"
 422 
 423   # Hotspot needs these set in their legacy form
 424   LEGACY_EXTRA_CFLAGS=$with_extra_cflags
 425   LEGACY_EXTRA_CXXFLAGS=$with_extra_cxxflags
 426   LEGACY_EXTRA_LDFLAGS=$with_extra_ldflags
 427 
 428   AC_SUBST(LEGACY_EXTRA_CFLAGS)
 429   AC_SUBST(LEGACY_EXTRA_CXXFLAGS)
 430   AC_SUBST(LEGACY_EXTRA_LDFLAGS)
 431 
 432   ###############################################################################
 433   #
 434   # Now setup the CFLAGS and LDFLAGS for the JDK build.
 435   # Later we will also have CFLAGS and LDFLAGS for the hotspot subrepo build.
 436   #
 437 
 438   # Setup compiler/platform specific flags to CFLAGS_JDK,
 439   # CXXFLAGS_JDK and CCXXFLAGS_JDK (common to C and CXX?)


 440   if test "x$TOOLCHAIN_TYPE" = xgcc; then
 441     # these options are used for both C and C++ compiles
 442     CCXXFLAGS_JDK="$CCXXFLAGS $CCXXFLAGS_JDK -Wall -Wno-parentheses -Wextra -Wno-unused -Wno-unused-parameter -Wformat=2 \
 443         -pipe -D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE"
 444     case $OPENJDK_TARGET_CPU_ARCH in
 445       arm )
 446         # on arm we don't prevent gcc to omit frame pointer but do prevent strict aliasing
 447         CFLAGS_JDK="${CFLAGS_JDK} -fno-strict-aliasing"
 448         ;;
 449       ppc )
 450         # on ppc we don't prevent gcc to omit frame pointer nor strict-aliasing
 451         ;;
 452       * )
 453         CCXXFLAGS_JDK="$CCXXFLAGS_JDK -fno-omit-frame-pointer"
 454         CFLAGS_JDK="${CFLAGS_JDK} -fno-strict-aliasing"
 455         ;;
 456     esac
 457   elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
 458     CCXXFLAGS_JDK="$CCXXFLAGS $CCXXFLAGS_JDK -DTRACING -DMACRO_MEMSYS_OPS -DBREAKPTS"
 459     if test "x$OPENJDK_TARGET_CPU_ARCH" = xx86; then
 460       CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DcpuIntel -Di586 -D$OPENJDK_TARGET_CPU_LEGACY_LIB"
 461       CFLAGS_JDK="$CFLAGS_JDK -erroff=E_BAD_PRAGMA_PACK_VALUE"
 462     fi
 463   
 464     CFLAGS_JDK="$CFLAGS_JDK -xc99=%none -xCC -errshort=tags -Xa -v -mt -W0,-noglobal"
 465     CXXFLAGS_JDK="$CXXFLAGS_JDK -errtags=yes +w -mt -features=no%except -DCC_NOEX -norunpath -xnolib"
 466   elif test "x$TOOLCHAIN_TYPE" = xxlc; then
 467     CFLAGS_JDK="$CFLAGS_JDK -D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE -DSTDC"
 468     CXXFLAGS_JDK="$CXXFLAGS_JDK -D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE -DSTDC"
 469   elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
 470     CCXXFLAGS_JDK="$CCXXFLAGS $CCXXFLAGS_JDK -Zi -MD -Zc:wchar_t- -W3 -wd4800 \
 471     -D_STATIC_CPPLIB -D_DISABLE_DEPRECATE_STATIC_CPPLIB -DWIN32_LEAN_AND_MEAN \
 472     -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE \
 473     -DWIN32 -DIAL"
 474     if test "x$OPENJDK_TARGET_CPU" = xx86_64; then
 475       CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_AMD64_ -Damd64"
 476     else
 477       CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_X86_ -Dx86"
 478     fi
 479   fi
 480 
 481   ###############################################################################
 482 
 483   # Adjust flags according to debug level.
 484   case $DEBUG_LEVEL in
 485     fastdebug )
 486       CFLAGS_JDK="$CFLAGS_JDK $CFLAGS_DEBUG_SYMBOLS"
 487       CXXFLAGS_JDK="$CXXFLAGS_JDK $CXXFLAGS_DEBUG_SYMBOLS"
 488       C_O_FLAG_HI="$C_O_FLAG_NORM"
 489       C_O_FLAG_NORM="$C_O_FLAG_NORM"
 490       CXX_O_FLAG_HI="$CXX_O_FLAG_NORM"
 491       CXX_O_FLAG_NORM="$CXX_O_FLAG_NORM"
 492       JAVAC_FLAGS="$JAVAC_FLAGS -g"
 493       ;;
 494     slowdebug )
 495       CFLAGS_JDK="$CFLAGS_JDK $CFLAGS_DEBUG_SYMBOLS"
 496       CXXFLAGS_JDK="$CXXFLAGS_JDK $CXXFLAGS_DEBUG_SYMBOLS"
 497       C_O_FLAG_HI="$C_O_FLAG_NONE"
 498       C_O_FLAG_NORM="$C_O_FLAG_NONE"
 499       CXX_O_FLAG_HI="$CXX_O_FLAG_NONE"
 500       CXX_O_FLAG_NORM="$CXX_O_FLAG_NONE"
 501       JAVAC_FLAGS="$JAVAC_FLAGS -g"
 502       ;;
 503   esac
 504 
 505   # Setup LP64
 506   CCXXFLAGS_JDK="$CCXXFLAGS_JDK $ADD_LP64"
 507 
 508   # Set some common defines. These works for all compilers, but assume
 509   # -D is universally accepted.
 510 
 511   # Setup endianness
 512   if test "x$OPENJDK_TARGET_CPU_ENDIAN" = xlittle; then
 513     # The macro _LITTLE_ENDIAN needs to be defined the same to avoid the
 514     #   Sun C compiler warning message: warning: macro redefined: _LITTLE_ENDIAN
 515     #   (The Solaris X86 system defines this in file /usr/include/sys/isa_defs.h).
 516     #   Note: -Dmacro         is the same as    #define macro 1
 517     #         -Dmacro=        is the same as    #define macro
 518     if test "x$OPENJDK_TARGET_OS" = xsolaris; then
 519       CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_LITTLE_ENDIAN="
 520     else
 521       CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_LITTLE_ENDIAN"
 522     fi
 523   else
 524     CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_BIG_ENDIAN"
 525   fi
 526   
 527   # Setup target OS define. Use OS target name but in upper case.
 528   OPENJDK_TARGET_OS_UPPERCASE=`$ECHO $OPENJDK_TARGET_OS | $TR 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
 529   CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D$OPENJDK_TARGET_OS_UPPERCASE"
 530 
 531   # Setup target CPU
 532   CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DARCH='\"$OPENJDK_TARGET_CPU_LEGACY\"' -D$OPENJDK_TARGET_CPU_LEGACY"
 533   
 534   # Setup debug/release defines
 535   if test "x$DEBUG_LEVEL" = xrelease; then
 536     CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DNDEBUG"
 537     if test "x$OPENJDK_TARGET_OS" = xsolaris; then
 538       CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DTRIMMED"
 539     fi
 540   else
 541     CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DDEBUG"
 542   fi
 543 

 544   # Setup release name
 545   CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DRELEASE='\"\$(RELEASE)\"'"
 546 
 547 
 548   # Set some additional per-OS defines.
 549   if test "x$OPENJDK_TARGET_OS" = xmacosx; then
 550     CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_ALLBSD_SOURCE -D_DARWIN_UNLIMITED_SELECT"
 551   elif test "x$OPENJDK_TARGET_OS" = xaix; then
 552     # FIXME: PPC64 should not be here.
 553     CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DPPC64"
 554   elif test "x$OPENJDK_TARGET_OS" = xbsd; then
 555     CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_ALLBSD_SOURCE"
 556   fi
 557 
 558   # Additional macosx handling
 559   if test "x$OPENJDK_TARGET_OS" = xmacosx; then
 560     if test "x$TOOLCHAIN_TYPE" = xgcc; then
 561       # FIXME: This needs to be exported in spec.gmk due to closed legacy code.
 562       # FIXME: clean this up, and/or move it elsewhere.
 563 
 564       # Setting these parameters makes it an error to link to macosx APIs that are
 565       # newer than the given OS version and makes the linked binaries compatible 
 566       # even if built on a newer version of the OS.
 567       # The expected format is X.Y.Z
 568       MACOSX_VERSION_MIN=10.7.0
 569       AC_SUBST(MACOSX_VERSION_MIN)
 570     
 571       # The macro takes the version with no dots, ex: 1070
 572       # Let the flags variables get resolved in make for easier override on make
 573       # command line.
 574       CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DMAC_OS_X_VERSION_MAX_ALLOWED=\$(subst .,,\$(MACOSX_VERSION_MIN)) -mmacosx-version-min=\$(MACOSX_VERSION_MIN)"
 575       LDFLAGS_JDK="$LDFLAGS_JDK -mmacosx-version-min=\$(MACOSX_VERSION_MIN)"
 576     fi
 577   fi
 578 
 579   # Setup some hard coded includes
 580   CCXXFLAGS_JDK="$CCXXFLAGS_JDK \
 581       -I${JDK_OUTPUTDIR}/include \
 582       -I${JDK_OUTPUTDIR}/include/$OPENJDK_TARGET_OS \
 583       -I${JDK_TOPDIR}/src/share/javavm/export \
 584       -I${JDK_TOPDIR}/src/$OPENJDK_TARGET_OS_EXPORT_DIR/javavm/export \
 585       -I${JDK_TOPDIR}/src/share/native/common \
 586       -I${JDK_TOPDIR}/src/$OPENJDK_TARGET_OS_API_DIR/native/common"
 587 
 588   # The shared libraries are compiled using the picflag.
 589   CFLAGS_JDKLIB="$CCXXFLAGS_JDK $CFLAGS_JDK $PICFLAG $CFLAGS_JDKLIB_EXTRA"
 590   CXXFLAGS_JDKLIB="$CCXXFLAGS_JDK $CXXFLAGS_JDK $PICFLAG $CXXFLAGS_JDKLIB_EXTRA "
 591 
 592   # Executable flags
 593   CFLAGS_JDKEXE="$CCXXFLAGS_JDK $CFLAGS_JDK"
 594   CXXFLAGS_JDKEXE="$CCXXFLAGS_JDK $CXXFLAGS_JDK"
 595 
 596   AC_SUBST(CFLAGS_JDKLIB)
 597   AC_SUBST(CFLAGS_JDKEXE)
 598   AC_SUBST(CXXFLAGS_JDKLIB)
 599   AC_SUBST(CXXFLAGS_JDKEXE)
 600 
 601   # Setup LDFLAGS et al.
 602   #
 603   # Now this is odd. The JDK native libraries have to link against libjvm.so
 604   # On 32-bit machines there is normally two distinct libjvm.so:s, client and server.
 605   # Which should we link to? Are we lucky enough that the binary api to the libjvm.so library
 606   # is identical for client and server? Yes. Which is picked at runtime (client or server)?
 607   # Neither, since the chosen libjvm.so has already been loaded by the launcher, all the following
 608   # libraries will link to whatever is in memory. Yuck.
 609   #
 610   # Thus we offer the compiler to find libjvm.so first in server then in client. It works. Ugh.
 611   if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
 612     LDFLAGS_JDK="$LDFLAGS_JDK -nologo -opt:ref -incremental:no"
 613     if test "x$OPENJDK_TARGET_CPU_BITS" = "x32"; then
 614       LDFLAGS_JDK="$LDFLAGS_JDK -safeseh"
 615     fi
 616     # TODO: make -debug optional "--disable-full-debug-symbols"
 617     LDFLAGS_JDK="$LDFLAGS_JDK -debug"
 618     LDFLAGS_JDKLIB="${LDFLAGS_JDK} -dll -libpath:${JDK_OUTPUTDIR}/lib"
 619     LDFLAGS_JDKLIB_SUFFIX=""
 620     if test "x$OPENJDK_TARGET_CPU_BITS" = "x64"; then
 621       LDFLAGS_STACK_SIZE=1048576
 622     else
 623       LDFLAGS_STACK_SIZE=327680
 624     fi
 625     LDFLAGS_JDKEXE="${LDFLAGS_JDK} /STACK:$LDFLAGS_STACK_SIZE"
 626   else
 627     if test "x$TOOLCHAIN_TYPE" = xgcc; then
 628       # If this is a --hash-style=gnu system, use --hash-style=both, why?
 629       # We have previously set HAS_GNU_HASH if this is the case
 630       if test -n "$HAS_GNU_HASH"; then
 631         LDFLAGS_JDK="${LDFLAGS_JDK} -Xlinker --hash-style=both "
 632       fi
 633       if test "x$OPENJDK_TARGET_OS" = xlinux; then
 634         # And since we now know that the linker is gnu, then add -z defs, to forbid
 635         # undefined symbols in object files.
 636         LDFLAGS_JDK="${LDFLAGS_JDK} -Xlinker -z -Xlinker defs"
 637         if test "x$DEBUG_LEVEL" = "xrelease"; then
 638           # When building release libraries, tell the linker optimize them.

 639           # Should this be supplied to the OSS linker as well?
 640           LDFLAGS_JDK="${LDFLAGS_JDK} -Xlinker -O1"






 641         fi






 642       fi





 643     fi
 644 
 645     if test "x$TOOLCHAIN_TYPE" = xsolstudio; then

 646       LDFLAGS_JDK="$LDFLAGS_JDK -z defs -xildoff -ztext"
 647       LDFLAGS_CXX_JDK="$LDFLAGS_CXX_JDK -norunpath -xnolib"
 648     fi
 649 
 650     LDFLAGS_JDKLIB="${LDFLAGS_JDK} $SHARED_LIBRARY_FLAGS \
 651         -L${JDK_OUTPUTDIR}/lib${OPENJDK_TARGET_CPU_LIBDIR}"
 652 
 653     # On some platforms (mac) the linker warns about non existing -L dirs.
 654     # Add server first if available. Linking aginst client does not always produce the same results.
 655     # Only add client dir if client is being built. Add minimal (note not minimal1) if only building minimal1.
 656     # Default to server for other variants.
 657     if test "x$JVM_VARIANT_SERVER" = xtrue; then
 658       LDFLAGS_JDKLIB="${LDFLAGS_JDKLIB} -L${JDK_OUTPUTDIR}/lib${OPENJDK_TARGET_CPU_LIBDIR}/server"
 659     elif test "x$JVM_VARIANT_CLIENT" = xtrue; then
 660       LDFLAGS_JDKLIB="${LDFLAGS_JDKLIB} -L${JDK_OUTPUTDIR}/lib${OPENJDK_TARGET_CPU_LIBDIR}/client"
 661     elif test "x$JVM_VARIANT_MINIMAL1" = xtrue; then
 662       LDFLAGS_JDKLIB="${LDFLAGS_JDKLIB} -L${JDK_OUTPUTDIR}/lib${OPENJDK_TARGET_CPU_LIBDIR}/minimal"
 663     else
 664       LDFLAGS_JDKLIB="${LDFLAGS_JDKLIB} -L${JDK_OUTPUTDIR}/lib${OPENJDK_TARGET_CPU_LIBDIR}/server"
 665     fi
 666 
 667     LDFLAGS_JDKLIB_SUFFIX="-ljava -ljvm"
 668     if test "x$TOOLCHAIN_TYPE" = xsolstudio; then
 669       LDFLAGS_JDKLIB_SUFFIX="$LDFLAGS_JDKLIB_SUFFIX -lc"
 670     fi
 671 
 672     LDFLAGS_JDKEXE="${LDFLAGS_JDK}"
 673     if test "x$OPENJDK_TARGET_OS" = xlinux; then
 674       LDFLAGS_JDKEXE="$LDFLAGS_JDKEXE -Xlinker --allow-shlib-undefined"
 675     fi
 676   fi
 677   AC_SUBST(LDFLAGS_JDKLIB)
 678   AC_SUBST(LDFLAGS_JDKEXE)
 679   AC_SUBST(LDFLAGS_JDKLIB_SUFFIX)
 680   AC_SUBST(LDFLAGS_JDKEXE_SUFFIX)
 681   AC_SUBST(LDFLAGS_CXX_JDK)
 682 ])
 683 
 684 
 685 # FLAGS_COMPILER_CHECK_ARGUMENTS([ARGUMENT], [RUN-IF-TRUE],
 686 #                                   [RUN-IF-FALSE])
 687 # ------------------------------------------------------------
 688 # Check that the c and c++ compilers support an argument
 689 AC_DEFUN([FLAGS_COMPILER_CHECK_ARGUMENTS],
 690 [
 691   AC_MSG_CHECKING([if compiler supports "$1"])
 692   supports=yes
 693 
 694   saved_cflags="$CFLAGS"
 695   CFLAGS="$CFLAGS $1"
 696   AC_LANG_PUSH([C])
 697   AC_COMPILE_IFELSE([AC_LANG_SOURCE([[int i;]])], [], 
 698       [supports=no])
 699   AC_LANG_POP([C])
 700   CFLAGS="$saved_cflags"
 701 
 702   saved_cxxflags="$CXXFLAGS"
 703   CXXFLAGS="$CXXFLAG $1"
 704   AC_LANG_PUSH([C++])
 705   AC_COMPILE_IFELSE([AC_LANG_SOURCE([[int i;]])], [], 
 706       [supports=no])
 707   AC_LANG_POP([C++])
 708   CXXFLAGS="$saved_cxxflags"
 709 
 710   AC_MSG_RESULT([$supports])
 711   if test "x$supports" = "xyes" ; then
 712     m4_ifval([$2], [$2], [:])
 713   else
 714     m4_ifval([$3], [$3], [:])
 715   fi
 716 ])
 717 
 718 AC_DEFUN_ONCE([FLAGS_SETUP_COMPILER_FLAGS_MISC],
 719 [
 720   # Some Zero and Shark settings.
 721   # ZERO_ARCHFLAG tells the compiler which mode to build for
 722   case "${OPENJDK_TARGET_CPU}" in
 723     s390)
 724       ZERO_ARCHFLAG="${COMPILER_TARGET_BITS_FLAG}31"
 725       ;;
 726     *)
 727       ZERO_ARCHFLAG="${COMPILER_TARGET_BITS_FLAG}${OPENJDK_TARGET_CPU_BITS}"
 728   esac
 729   FLAGS_COMPILER_CHECK_ARGUMENTS([$ZERO_ARCHFLAG], [], [ZERO_ARCHFLAG=""])
 730   AC_SUBST(ZERO_ARCHFLAG)
 731 
 732   # Check that the compiler supports -mX (or -qX on AIX) flags
 733   # Set COMPILER_SUPPORTS_TARGET_BITS_FLAG to 'true' if it does
 734   FLAGS_COMPILER_CHECK_ARGUMENTS([${COMPILER_TARGET_BITS_FLAG}${OPENJDK_TARGET_CPU_BITS}],
 735       [COMPILER_SUPPORTS_TARGET_BITS_FLAG=true],
 736       [COMPILER_SUPPORTS_TARGET_BITS_FLAG=false])
 737   AC_SUBST(COMPILER_SUPPORTS_TARGET_BITS_FLAG)
 738 ])


  99       RC_FLAGS="$RC_FLAGS -d NDEBUG"
 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_FLAGS="$COMMON_FLAGS -nologo"
 121   fi
 122 ])
 123 
 124 AC_DEFUN_ONCE([FLAGS_SETUP_COMPILER_FLAGS_FOR_LIBS],
 125 [
 126   ###############################################################################
 127   #
 128   # How to compile shared libraries.
 129   #
 130 
 131   if test "x$TOOLCHAIN_TYPE" = xgcc; then
 132     PICFLAG="-fPIC"
 133     C_FLAG_REORDER=''
 134     CXX_FLAG_REORDER=''
 135 
 136     if test "x$OPENJDK_TARGET_OS" = xmacosx; then
 137       # Linking is different on MacOSX
 138       SHARED_LIBRARY_FLAGS="-dynamiclib -compatibility_version 1.0.0 -current_version 1.0.0 $PICFLAG"
 139       SET_EXECUTABLE_ORIGIN='-Xlinker -rpath -Xlinker @loader_path/.'
 140       SET_SHARED_LIBRARY_ORIGIN="$SET_EXECUTABLE_ORIGIN"


 259   #   C_FLAG_DEPS="-MMD -MF"
 260   # fi
 261 
 262   # Generate make dependency files
 263   if test "x$TOOLCHAIN_TYPE" = xgcc; then
 264     C_FLAG_DEPS="-MMD -MF"
 265   elif test "x$TOOLCHAIN_TYPE" = xclang; then
 266     C_FLAG_DEPS="-MMD -MF"
 267   elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
 268     C_FLAG_DEPS="-xMMD -xMF"
 269   elif test "x$TOOLCHAIN_TYPE" = xxlc; then
 270     C_FLAG_DEPS="-qmakedep=gcc -MF"
 271   fi
 272   CXX_FLAG_DEPS="$C_FLAG_DEPS"
 273   AC_SUBST(C_FLAG_DEPS)
 274   AC_SUBST(CXX_FLAG_DEPS)
 275 
 276   # Debug symbols
 277   if test "x$TOOLCHAIN_TYPE" = xgcc; then
 278     if test "x$OPENJDK_TARGET_CPU_BITS" = "x64" && test "x$DEBUG_LEVEL" = "xfastdebug"; then
 279       # reduce from default "-g2" option to save space
 280       CFLAGS_DEBUG_SYMBOLS="-g1"
 281       CXXFLAGS_DEBUG_SYMBOLS="-g1"
 282     else
 283       CFLAGS_DEBUG_SYMBOLS="-g"
 284       CXXFLAGS_DEBUG_SYMBOLS="-g"
 285     fi
 286   elif test "x$TOOLCHAIN_TYPE" = xclang; then
 287     CFLAGS_DEBUG_SYMBOLS="-g"
 288     CXXFLAGS_DEBUG_SYMBOLS="-g"
 289   elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
 290     CFLAGS_DEBUG_SYMBOLS="-g -xs"
 291     # FIXME: likely a bug, this disables debug symbols rather than enables them
 292     CXXFLAGS_DEBUG_SYMBOLS="-g0 -xs"
 293   elif test "x$TOOLCHAIN_TYPE" = xxlc; then
 294     CFLAGS_DEBUG_SYMBOLS="-g"
 295     CXXFLAGS_DEBUG_SYMBOLS="-g"
 296   fi
 297   AC_SUBST(CFLAGS_DEBUG_SYMBOLS)
 298   AC_SUBST(CXXFLAGS_DEBUG_SYMBOLS)
 299 
 300   # bounds and memory checking options
 301   if test "x$TOOLCHAIN_TYPE" = xgcc; then
 302     case $DEBUG_LEVEL in
 303     release )
 304       # no adjustment
 305       ;;
 306     fastdebug )
 307       # Add compile time bounds checks.
 308       CFLAGS_DEBUG_OPTIONS="-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1"
 309       CXXFLAGS_DEBUG_OPTIONS="-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1"
 310       ;;
 311     slowdebug )
 312       # Add runtime bounds checks and symbol info.
 313       CFLAGS_DEBUG_OPTIONS="-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fstack-protector-all --param ssp-buffer-size=1"
 314       CXXFLAGS_DEBUG_OPTIONS="-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fstack-protector-all --param ssp-buffer-size=1"
 315       ;;
 316     esac
 317   fi
 318   AC_SUBST(CFLAGS_DEBUG_OPTIONS)
 319   AC_SUBST(CXXFLAGS_DEBUG_OPTIONS)
 320 
 321   # Optimization levels
 322   if test "x$TOOLCHAIN_TYPE" = xsolstudio; then
 323     CC_HIGHEST="$CC_HIGHEST -fns -fsimple -fsingle -xbuiltin=%all -xdepend -xrestrict -xlibmil"
 324 
 325     if test "x$OPENJDK_TARGET_CPU_ARCH" = "xx86"; then
 326       # FIXME: seems we always set -xregs=no%frameptr; put it elsewhere more global?
 327       C_O_FLAG_HIGHEST="-xO4 -Wu,-O4~yz $CC_HIGHEST -xalias_level=basic -xregs=no%frameptr"
 328       C_O_FLAG_HI="-xO4 -Wu,-O4~yz -xregs=no%frameptr"
 329       C_O_FLAG_NORM="-xO2 -Wu,-O2~yz -xregs=no%frameptr"
 330       C_O_FLAG_DEBUG="-xregs=no%frameptr"
 331       C_O_FLAG_NONE="-xregs=no%frameptr"
 332       CXX_O_FLAG_HIGHEST="-xO4 -Qoption ube -O4~yz $CC_HIGHEST -xregs=no%frameptr"
 333       CXX_O_FLAG_HI="-xO4 -Qoption ube -O4~yz -xregs=no%frameptr"
 334       CXX_O_FLAG_NORM="-xO2 -Qoption ube -O2~yz -xregs=no%frameptr"
 335       CXX_O_FLAG_DEBUG="-xregs=no%frameptr"
 336       CXX_O_FLAG_NONE="-xregs=no%frameptr"
 337       if test "x$OPENJDK_TARGET_CPU_BITS" = "x32"; then
 338         C_O_FLAG_HIGHEST="$C_O_FLAG_HIGHEST -xchip=pentium"
 339         CXX_O_FLAG_HIGHEST="$CXX_O_FLAG_HIGHEST -xchip=pentium"
 340       fi
 341     elif test "x$OPENJDK_TARGET_CPU_ARCH" = "xsparc"; then
 342       C_O_FLAG_HIGHEST="-xO4 -Wc,-Qrm-s -Wc,-Qiselect-T0 $CC_HIGHEST -xalias_level=basic -xprefetch=auto,explicit -xchip=ultra"
 343       C_O_FLAG_HI="-xO4 -Wc,-Qrm-s -Wc,-Qiselect-T0"
 344       C_O_FLAG_NORM="-xO2 -Wc,-Qrm-s -Wc,-Qiselect-T0"
 345       C_O_FLAG_DEBUG=""
 346       C_O_FLAG_NONE=""
 347       CXX_O_FLAG_HIGHEST="-xO4 -Qoption cg -Qrm-s -Qoption cg -Qiselect-T0 $CC_HIGHEST -xprefetch=auto,explicit -xchip=ultra"
 348       CXX_O_FLAG_HI="-xO4 -Qoption cg -Qrm-s -Qoption cg -Qiselect-T0"
 349       CXX_O_FLAG_NORM="-xO2 -Qoption cg -Qrm-s -Qoption cg -Qiselect-T0"
 350       C_O_FLAG_DEBUG=""
 351       CXX_O_FLAG_NONE=""
 352     fi
 353   else
 354     # The remaining toolchains share opt flags between CC and CXX;
 355     # setup for C and duplicate afterwards.
 356     if test "x$TOOLCHAIN_TYPE" = xgcc; then
 357       if test "x$OPENJDK_TARGET_OS" = xmacosx; then
 358         # On MacOSX we optimize for size, something
 359         # we should do for all platforms?
 360         C_O_FLAG_HIGHEST="-Os"
 361         C_O_FLAG_HI="-Os"
 362         C_O_FLAG_NORM="-Os"

 363       else
 364         C_O_FLAG_HIGHEST="-O3"
 365         C_O_FLAG_HI="-O3"
 366         C_O_FLAG_NORM="-O2"

 367       fi
 368       if test "x$HAS_CFLAG_OPTIMIZE_DEBUG" = "xtrue"; then
 369         C_O_FLAG_DEBUG="-Og"
 370       else
 371         C_O_FLAG_DEBUG="-O0"
 372       fi
 373       C_O_FLAG_NONE="-O0"
 374     elif test "x$TOOLCHAIN_TYPE" = xclang; then
 375       if test "x$OPENJDK_TARGET_OS" = xmacosx; then
 376         # On MacOSX we optimize for size, something
 377         # we should do for all platforms?
 378         C_O_FLAG_HIGHEST="-Os"
 379         C_O_FLAG_HI="-Os"
 380         C_O_FLAG_NORM="-Os"

 381       else
 382         C_O_FLAG_HIGHEST="-O3"
 383         C_O_FLAG_HI="-O3"
 384         C_O_FLAG_NORM="-O2"

 385       fi
 386       C_O_FLAG_DEBUG="-O0"
 387       C_O_FLAG_NONE="-O0"
 388     elif test "x$TOOLCHAIN_TYPE" = xxlc; then
 389       C_O_FLAG_HIGHEST="-O3"
 390       C_O_FLAG_HI="-O3 -qstrict"
 391       C_O_FLAG_NORM="-O2"
 392       C_O_FLAG_DEBUG="-qnoopt"
 393       C_O_FLAG_NONE="-qnoop"
 394     elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
 395       C_O_FLAG_HIGHEST="-O2"
 396       C_O_FLAG_HI="-O1"
 397       C_O_FLAG_NORM="-O1"
 398       C_O_FLAG_DEBUG="-Od"
 399       C_O_FLAG_NONE="-Od"
 400     fi
 401     CXX_O_FLAG_HIGHEST="$C_O_FLAG_HIGHEST"
 402     CXX_O_FLAG_HI="$C_O_FLAG_HI"
 403     CXX_O_FLAG_NORM="$C_O_FLAG_NORM"
 404     CXX_O_FLAG_DEBUG="$C_O_FLAG_DEBUG"
 405     CXX_O_FLAG_NONE="$C_O_FLAG_NONE"
 406   fi
 407 
 408   # Adjust optimization flags according to debug level.
 409   case $DEBUG_LEVEL in
 410     release )
 411       # no adjustment
 412       ;;
 413     fastdebug )
 414       # Not quite so much optimization
 415       C_O_FLAG_HIGHEST="$C_O_FLAG_NORM"
 416       C_O_FLAG_HI="$C_O_FLAG_NORM"
 417       CXX_O_FLAG_HIGHEST="$CXX_O_FLAG_NORM"
 418       CXX_O_FLAG_HI="$CXX_O_FLAG_NORM"
 419       ;;
 420     slowdebug )
 421       # Disable optimization
 422       C_O_FLAG_HIGHEST="$C_O_FLAG_DEBUG"
 423       C_O_FLAG_HI="$C_O_FLAG_DEBUG"
 424       C_O_FLAG_NORM="$C_O_FLAG_DEBUG"
 425       CXX_O_FLAG_HIGHEST="$CXX_O_FLAG_DEBUG"
 426       CXX_O_FLAG_HI="$CXX_O_FLAG_DEBUG"
 427       CXX_O_FLAG_NORM="$CXX_O_FLAG_DEBUG"
 428       ;;
 429   esac
 430 
 431   AC_SUBST(C_O_FLAG_HIGHEST)
 432   AC_SUBST(C_O_FLAG_HI)
 433   AC_SUBST(C_O_FLAG_NORM)
 434   AC_SUBST(C_O_FLAG_DEBUG)
 435   AC_SUBST(C_O_FLAG_NONE)
 436   AC_SUBST(CXX_O_FLAG_HIGHEST)
 437   AC_SUBST(CXX_O_FLAG_HI)
 438   AC_SUBST(CXX_O_FLAG_NORM)
 439   AC_SUBST(CXX_O_FLAG_DEBUG)
 440   AC_SUBST(CXX_O_FLAG_NONE)
 441 ])
 442 
 443 AC_DEFUN_ONCE([FLAGS_SETUP_COMPILER_FLAGS_FOR_JDK],
 444 [
 445   # Special extras...
 446   if test "x$TOOLCHAIN_TYPE" = xsolstudio; then
 447     if test "x$OPENJDK_TARGET_CPU_ARCH" = "xsparc"; then
 448       CFLAGS_JDKLIB_EXTRA="${CFLAGS_JDKLIB_EXTRA} -xregs=no%appl"
 449       CXXFLAGS_JDKLIB_EXTRA="${CXXFLAGS_JDKLIB_EXTRA} -xregs=no%appl"
 450     fi
 451   elif test "x$TOOLCHAIN_TYPE" = xxlc; then
 452     LDFLAGS_JDK="${LDFLAGS_JDK} -q64 -brtl -bnolibpath -liconv -bexpall"
 453     CFLAGS_JDK="${CFLAGS_JDK} -qchars=signed -q64 -qfullpath -qsaveopt"
 454     CXXFLAGS_JDK="${CXXFLAGS_JDK} -qchars=signed -q64 -qfullpath -qsaveopt"
 455   fi
 456 
 457   if test "x$CFLAGS" != "x${ADDED_CFLAGS}"; then
 458     AC_MSG_WARN([Ignoring CFLAGS($CFLAGS) found in environment. Use --with-extra-cflags])
 459   fi


 477 
 478   CFLAGS_JDK="${CFLAGS_JDK} $with_extra_cflags"
 479   CXXFLAGS_JDK="${CXXFLAGS_JDK} $with_extra_cxxflags"
 480   LDFLAGS_JDK="${LDFLAGS_JDK} $with_extra_ldflags"
 481 
 482   # Hotspot needs these set in their legacy form
 483   LEGACY_EXTRA_CFLAGS=$with_extra_cflags
 484   LEGACY_EXTRA_CXXFLAGS=$with_extra_cxxflags
 485   LEGACY_EXTRA_LDFLAGS=$with_extra_ldflags
 486 
 487   AC_SUBST(LEGACY_EXTRA_CFLAGS)
 488   AC_SUBST(LEGACY_EXTRA_CXXFLAGS)
 489   AC_SUBST(LEGACY_EXTRA_LDFLAGS)
 490 
 491   ###############################################################################
 492   #
 493   # Now setup the CFLAGS and LDFLAGS for the JDK build.
 494   # Later we will also have CFLAGS and LDFLAGS for the hotspot subrepo build.
 495   #
 496 
 497   # Setup compiler/platform specific flags into
 498   #    CFLAGS_JDK    - C Compiler flags
 499   #    CXXFLAGS_JDK  - C++ Compiler flags
 500   #    COMMON_FLAGS_JDK - common to C and C++
 501   if test "x$TOOLCHAIN_TYPE" = xgcc; then
 502     COMMON_FLAGS_JDK="$COMMON_FLAGS $COMMON_FLAGS_JDK -Wall -Wno-parentheses -Wextra -Wno-unused -Wno-unused-parameter -Wformat=2 \

 503         -pipe -D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE"
 504     case $OPENJDK_TARGET_CPU_ARCH in
 505       arm )
 506         # on arm we don't prevent gcc to omit frame pointer but do prevent strict aliasing
 507         CFLAGS_JDK="${CFLAGS_JDK} -fno-strict-aliasing"
 508         ;;
 509       ppc )
 510         # on ppc we don't prevent gcc to omit frame pointer nor strict-aliasing
 511         ;;
 512       * )
 513         COMMON_FLAGS_JDK="$COMMON_FLAGS_JDK -fno-omit-frame-pointer"
 514         CFLAGS_JDK="${CFLAGS_JDK} -fno-strict-aliasing"
 515         ;;
 516     esac
 517   elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
 518     COMMON_FLAGS_JDK="$COMMON_FLAGS $COMMON_FLAGS_JDK -DTRACING -DMACRO_MEMSYS_OPS -DBREAKPTS"
 519     if test "x$OPENJDK_TARGET_CPU_ARCH" = xx86; then
 520       COMMON_FLAGS_JDK="$COMMON_FLAGS_JDK -DcpuIntel -Di586 -D$OPENJDK_TARGET_CPU_LEGACY_LIB"
 521       CFLAGS_JDK="$CFLAGS_JDK -erroff=E_BAD_PRAGMA_PACK_VALUE"
 522     fi
 523   
 524     CFLAGS_JDK="$CFLAGS_JDK -xc99=%none -xCC -errshort=tags -Xa -v -mt -W0,-noglobal"
 525     CXXFLAGS_JDK="$CXXFLAGS_JDK -errtags=yes +w -mt -features=no%except -DCC_NOEX -norunpath -xnolib"
 526   elif test "x$TOOLCHAIN_TYPE" = xxlc; then
 527     CFLAGS_JDK="$CFLAGS_JDK -D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE -DSTDC"
 528     CXXFLAGS_JDK="$CXXFLAGS_JDK -D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE -DSTDC"
 529   elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
 530     COMMON_FLAGS_JDK="$COMMON_FLAGS $COMMON_FLAGS_JDK -Zi -MD -Zc:wchar_t- -W3 -wd4800 \
 531     -D_STATIC_CPPLIB -D_DISABLE_DEPRECATE_STATIC_CPPLIB -DWIN32_LEAN_AND_MEAN \
 532     -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE \
 533     -DWIN32 -DIAL"
 534     if test "x$OPENJDK_TARGET_CPU" = xx86_64; then
 535       COMMON_FLAGS_JDK="$COMMON_FLAGS_JDK -D_AMD64_ -Damd64"
 536     else
 537       COMMON_FLAGS_JDK="$COMMON_FLAGS_JDK -D_X86_ -Dx86"
 538     fi
 539   fi
 540 
 541   ###############################################################################
 542 
 543   # Adjust flags according to debug level.
 544   case $DEBUG_LEVEL in
 545     "fastdebug" | "slowdebug" )
 546       CFLAGS_JDK="$CFLAGS_JDK $CFLAGS_DEBUG_SYMBOLS $CFLAGS_DEBUG_OPTIONS"
 547       CXXFLAGS_JDK="$CXXFLAGS_JDK $CXXFLAGS_DEBUG_SYMBOLS $CXXFLAGS_DEBUG_OPTIONS"




 548       JAVAC_FLAGS="$JAVAC_FLAGS -g"
 549       ;;
 550     "release" )
 551       ;;
 552     * )
 553       AC_MSG_ERROR([Unrecognized \$DEBUG_LEVEL: $DEBUG_LEVEL])




 554       ;;
 555   esac
 556 
 557   # Setup LP64
 558   COMMON_FLAGS_JDK="$COMMON_FLAGS_JDK $ADD_LP64"
 559 
 560   # Set some common defines. These works for all compilers, but assume
 561   # -D is universally accepted.
 562 
 563   # Setup endianness
 564   if test "x$OPENJDK_TARGET_CPU_ENDIAN" = xlittle; then
 565     # The macro _LITTLE_ENDIAN needs to be defined the same to avoid the
 566     #   Sun C compiler warning message: warning: macro redefined: _LITTLE_ENDIAN
 567     #   (The Solaris X86 system defines this in file /usr/include/sys/isa_defs.h).
 568     #   Note: -Dmacro         is the same as    #define macro 1
 569     #         -Dmacro=        is the same as    #define macro
 570     if test "x$OPENJDK_TARGET_OS" = xsolaris; then
 571       COMMON_FLAGS_JDK="$COMMON_FLAGS_JDK -D_LITTLE_ENDIAN="
 572     else
 573       COMMON_FLAGS_JDK="$COMMON_FLAGS_JDK -D_LITTLE_ENDIAN"
 574     fi
 575   else
 576     COMMON_FLAGS_JDK="$COMMON_FLAGS_JDK -D_BIG_ENDIAN"
 577   fi
 578   
 579   # Setup target OS define. Use OS target name but in upper case.
 580   OPENJDK_TARGET_OS_UPPERCASE=`$ECHO $OPENJDK_TARGET_OS | $TR 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
 581   COMMON_FLAGS_JDK="$COMMON_FLAGS_JDK -D$OPENJDK_TARGET_OS_UPPERCASE"
 582 
 583   # Setup target CPU
 584   COMMON_FLAGS_JDK="$COMMON_FLAGS_JDK -DARCH='\"$OPENJDK_TARGET_CPU_LEGACY\"' -D$OPENJDK_TARGET_CPU_LEGACY"
 585   
 586   # Setup debug/release defines
 587   if test "x$DEBUG_LEVEL" = xrelease; then
 588     COMMON_FLAGS_JDK="$COMMON_FLAGS_JDK -DNDEBUG"
 589     if test "x$OPENJDK_TARGET_OS" = xsolaris; then
 590       COMMON_FLAGS_JDK="$COMMON_FLAGS_JDK -DTRIMMED"
 591     fi
 592   else
 593     COMMON_FLAGS_JDK="$COMMON_FLAGS_JDK -DDEBUG"
 594   fi
 595 
 596 
 597   # Setup release name
 598   COMMON_FLAGS_JDK="$COMMON_FLAGS_JDK -DRELEASE='\"\$(RELEASE)\"'"
 599 
 600 
 601   # Set some additional per-OS defines.
 602   if test "x$OPENJDK_TARGET_OS" = xmacosx; then
 603     COMMON_FLAGS_JDK="$COMMON_FLAGS_JDK -D_ALLBSD_SOURCE -D_DARWIN_UNLIMITED_SELECT"
 604   elif test "x$OPENJDK_TARGET_OS" = xaix; then
 605     # FIXME: PPC64 should not be here.
 606     COMMON_FLAGS_JDK="$COMMON_FLAGS_JDK -DPPC64"
 607   elif test "x$OPENJDK_TARGET_OS" = xbsd; then
 608     COMMON_FLAGS_JDK="$COMMON_FLAGS_JDK -D_ALLBSD_SOURCE"
 609   fi
 610 
 611   # Additional macosx handling
 612   if test "x$OPENJDK_TARGET_OS" = xmacosx; then
 613     if test "x$TOOLCHAIN_TYPE" = xgcc; then
 614       # FIXME: This needs to be exported in spec.gmk due to closed legacy code.
 615       # FIXME: clean this up, and/or move it elsewhere.
 616 
 617       # Setting these parameters makes it an error to link to macosx APIs that are
 618       # newer than the given OS version and makes the linked binaries compatible 
 619       # even if built on a newer version of the OS.
 620       # The expected format is X.Y.Z
 621       MACOSX_VERSION_MIN=10.7.0
 622       AC_SUBST(MACOSX_VERSION_MIN)
 623     
 624       # The macro takes the version with no dots, ex: 1070
 625       # Let the flags variables get resolved in make for easier override on make
 626       # command line.
 627       COMMON_FLAGS_JDK="$COMMON_FLAGS_JDK -DMAC_OS_X_VERSION_MAX_ALLOWED=\$(subst .,,\$(MACOSX_VERSION_MIN)) -mmacosx-version-min=\$(MACOSX_VERSION_MIN)"
 628       LDFLAGS_JDK="$LDFLAGS_JDK -mmacosx-version-min=\$(MACOSX_VERSION_MIN)"
 629     fi
 630   fi
 631 
 632   # Setup some hard coded includes
 633   COMMON_FLAGS_JDK="$COMMON_FLAGS_JDK \
 634       -I${JDK_OUTPUTDIR}/include \
 635       -I${JDK_OUTPUTDIR}/include/$OPENJDK_TARGET_OS \
 636       -I${JDK_TOPDIR}/src/share/javavm/export \
 637       -I${JDK_TOPDIR}/src/$OPENJDK_TARGET_OS_EXPORT_DIR/javavm/export \
 638       -I${JDK_TOPDIR}/src/share/native/common \
 639       -I${JDK_TOPDIR}/src/$OPENJDK_TARGET_OS_API_DIR/native/common"
 640 
 641   # The shared libraries are compiled using the picflag.
 642   CFLAGS_JDKLIB="$COMMON_FLAGS_JDK $CFLAGS_JDK $PICFLAG $CFLAGS_JDKLIB_EXTRA"
 643   CXXFLAGS_JDKLIB="$COMMON_FLAGS_JDK $CXXFLAGS_JDK $PICFLAG $CXXFLAGS_JDKLIB_EXTRA "
 644 
 645   # Executable flags
 646   CFLAGS_JDKEXE="$COMMON_FLAGS_JDK $CFLAGS_JDK"
 647   CXXFLAGS_JDKEXE="$COMMON_FLAGS_JDK $CXXFLAGS_JDK"
 648 
 649   AC_SUBST(CFLAGS_JDKLIB)
 650   AC_SUBST(CFLAGS_JDKEXE)
 651   AC_SUBST(CXXFLAGS_JDKLIB)
 652   AC_SUBST(CXXFLAGS_JDKEXE)
 653 
 654   # Setup LDFLAGS et al.
 655   #
 656   # Now this is odd. The JDK native libraries have to link against libjvm.so
 657   # On 32-bit machines there is normally two distinct libjvm.so:s, client and server.
 658   # Which should we link to? Are we lucky enough that the binary api to the libjvm.so library
 659   # is identical for client and server? Yes. Which is picked at runtime (client or server)?
 660   # Neither, since the chosen libjvm.so has already been loaded by the launcher, all the following
 661   # libraries will link to whatever is in memory. Yuck.
 662   #
 663   # Thus we offer the compiler to find libjvm.so first in server then in client. It works. Ugh.
 664   if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
 665     LDFLAGS_JDK="$LDFLAGS_JDK -nologo -opt:ref -incremental:no"
 666     if test "x$OPENJDK_TARGET_CPU_BITS" = "x32"; then
 667       LDFLAGS_JDK="$LDFLAGS_JDK -safeseh"
 668     fi
 669     # TODO: make -debug optional "--disable-full-debug-symbols"
 670     LDFLAGS_JDK="$LDFLAGS_JDK -debug"
 671     LDFLAGS_JDKLIB="${LDFLAGS_JDK} -dll -libpath:${JDK_OUTPUTDIR}/lib"
 672     LDFLAGS_JDKLIB_SUFFIX=""
 673     if test "x$OPENJDK_TARGET_CPU_BITS" = "x64"; then
 674       LDFLAGS_STACK_SIZE=1048576
 675     else
 676       LDFLAGS_STACK_SIZE=327680
 677     fi
 678     LDFLAGS_JDKEXE="${LDFLAGS_JDK} /STACK:$LDFLAGS_STACK_SIZE"
 679   elif test "x$TOOLCHAIN_TYPE" = xgcc; then

 680     # If this is a --hash-style=gnu system, use --hash-style=both, why?
 681     # We have previously set HAS_GNU_HASH if this is the case
 682     if test -n "$HAS_GNU_HASH"; then
 683       LDFLAGS_JDK="${LDFLAGS_JDK} -Xlinker --hash-style=both"
 684     fi
 685     if test "x$OPENJDK_TARGET_OS" = xlinux; then
 686       # And since we now know that the linker is gnu, then add -z defs, to forbid
 687       # undefined symbols in object files.
 688       LDFLAGS_JDK="${LDFLAGS_JDK} -Xlinker -z -Xlinker defs"
 689       case $DEBUG_LEVEL in
 690         release )
 691           # tell linker to optimize libraries.
 692           # Should this be supplied to the OSS linker as well?
 693           LDFLAGS_JDK="${LDFLAGS_JDK} -Xlinker -O1"
 694           ;;
 695         slowdebug )
 696           if test "x$HAS_LINKER_RELRO" = "xtrue"; then
 697             # do relocations at load
 698             LDFLAGS_JDK="$LDFLAGS_JDK -Xlinker -z -Xlinker now"
 699             LDFLAGS_CXX_JDK="$LDFLAGS_CXX_JDK -Xlinker -z -Xlinker now"
 700           fi
 701           ;& # FALLSTHROUGH
 702         fastdebug )
 703           if test "x$HAS_LINKER_RELRO" = "xtrue"; then
 704             # mark relocations read only
 705             LDFLAGS_JDK="$LDFLAGS_JDK -Xlinker -z -Xlinker relro"
 706             LDFLAGS_CXX_JDK="$LDFLAGS_CXX_JDK -Xlinker -z -Xlinker relro"
 707           fi
 708           ;;
 709         * )
 710           AC_MSG_ERROR([Unrecognized \$DEBUG_LEVEL: $DEBUG_LEVEL])
 711           ;;
 712         esac
 713     fi
 714 
 715 
 716   elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
 717     LDFLAGS_JDK="$LDFLAGS_JDK -z defs -xildoff -ztext"
 718     LDFLAGS_CXX_JDK="$LDFLAGS_CXX_JDK -norunpath -xnolib"
 719   fi
 720 
 721   LDFLAGS_JDKLIB="${LDFLAGS_JDK} $SHARED_LIBRARY_FLAGS \
 722       -L${JDK_OUTPUTDIR}/lib${OPENJDK_TARGET_CPU_LIBDIR}"
 723 
 724   # On some platforms (mac) the linker warns about non existing -L dirs.
 725   # Add server first if available. Linking aginst client does not always produce the same results.
 726   # Only add client dir if client is being built. Add minimal (note not minimal1) if only building minimal1.
 727   # Default to server for other variants.
 728   if test "x$JVM_VARIANT_SERVER" = xtrue; then
 729     LDFLAGS_JDKLIB="${LDFLAGS_JDKLIB} -L${JDK_OUTPUTDIR}/lib${OPENJDK_TARGET_CPU_LIBDIR}/server"
 730   elif test "x$JVM_VARIANT_CLIENT" = xtrue; then
 731     LDFLAGS_JDKLIB="${LDFLAGS_JDKLIB} -L${JDK_OUTPUTDIR}/lib${OPENJDK_TARGET_CPU_LIBDIR}/client"
 732   elif test "x$JVM_VARIANT_MINIMAL1" = xtrue; then
 733     LDFLAGS_JDKLIB="${LDFLAGS_JDKLIB} -L${JDK_OUTPUTDIR}/lib${OPENJDK_TARGET_CPU_LIBDIR}/minimal"
 734   else
 735     LDFLAGS_JDKLIB="${LDFLAGS_JDKLIB} -L${JDK_OUTPUTDIR}/lib${OPENJDK_TARGET_CPU_LIBDIR}/server"
 736   fi
 737 
 738   LDFLAGS_JDKLIB_SUFFIX="-ljava -ljvm"
 739   if test "x$TOOLCHAIN_TYPE" = xsolstudio; then
 740     LDFLAGS_JDKLIB_SUFFIX="$LDFLAGS_JDKLIB_SUFFIX -lc"
 741   fi
 742 
 743   LDFLAGS_JDKEXE="${LDFLAGS_JDK}"
 744   if test "x$OPENJDK_TARGET_OS" = xlinux; then
 745     LDFLAGS_JDKEXE="$LDFLAGS_JDKEXE -Xlinker --allow-shlib-undefined"
 746   fi
 747 
 748   AC_SUBST(LDFLAGS_JDKLIB)
 749   AC_SUBST(LDFLAGS_JDKEXE)
 750   AC_SUBST(LDFLAGS_JDKLIB_SUFFIX)
 751   AC_SUBST(LDFLAGS_JDKEXE_SUFFIX)
 752   AC_SUBST(LDFLAGS_CXX_JDK)
 753 ])
 754 


































 755 AC_DEFUN_ONCE([FLAGS_SETUP_COMPILER_FLAGS_MISC],
 756 [
 757   # Some Zero and Shark settings.
 758   # ZERO_ARCHFLAG tells the compiler which mode to build for
 759   case "${OPENJDK_TARGET_CPU}" in
 760     s390)
 761       ZERO_ARCHFLAG="${COMPILER_TARGET_BITS_FLAG}31"
 762       ;;
 763     *)
 764       ZERO_ARCHFLAG="${COMPILER_TARGET_BITS_FLAG}${OPENJDK_TARGET_CPU_BITS}"
 765   esac
 766   TOOLCHAIN_COMPILER_CHECK_ARGUMENTS([$ZERO_ARCHFLAG], [], [ZERO_ARCHFLAG=""])
 767   AC_SUBST(ZERO_ARCHFLAG)
 768 
 769   # Check that the compiler supports -mX (or -qX on AIX) flags
 770   # Set COMPILER_SUPPORTS_TARGET_BITS_FLAG to 'true' if it does
 771   TOOLCHAIN_COMPILER_CHECK_ARGUMENTS([${COMPILER_TARGET_BITS_FLAG}${OPENJDK_TARGET_CPU_BITS}],
 772       [COMPILER_SUPPORTS_TARGET_BITS_FLAG=true],
 773       [COMPILER_SUPPORTS_TARGET_BITS_FLAG=false])
 774   AC_SUBST(COMPILER_SUPPORTS_TARGET_BITS_FLAG)
 775 ])