make/autoconf/flags.m4
branchihse-cflags-rewrite-branch
changeset 56178 7e63ac6274dd
parent 56177 2fbe3b84ee3d
child 56179 dc0add3a3212
equal deleted inserted replaced
56177:2fbe3b84ee3d 56178:7e63ac6274dd
   394   FLAGS_SETUP_ASFLAGS
   394   FLAGS_SETUP_ASFLAGS
   395   FLAGS_SETUP_ASFLAGS_CPU_DEP([TARGET])
   395   FLAGS_SETUP_ASFLAGS_CPU_DEP([TARGET])
   396   FLAGS_SETUP_ASFLAGS_CPU_DEP([BUILD], [OPENJDK_BUILD_])
   396   FLAGS_SETUP_ASFLAGS_CPU_DEP([BUILD], [OPENJDK_BUILD_])
   397 ])
   397 ])
   398 
   398 
   399 AC_DEFUN([FLAGS_SETUP_CFLAGS],
       
   400 [
       
   401   # FIXME: How to handle this?
       
   402   if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
       
   403     # silence copyright notice and other headers.
       
   404     COMMON_CCXXFLAGS="$COMMON_CCXXFLAGS -nologo"
       
   405 
       
   406     if test "x$DEBUG_LEVEL" != xrelease; then
       
   407       if test "x$OPENJDK_TARGET_CPU" = xx86_64; then
       
   408         JVM_CFLAGS="$JVM_CFLAGS -homeparams"
       
   409       fi
       
   410     fi
       
   411   fi
       
   412 
       
   413   ### CFLAGS
       
   414 
       
   415   FLAGS_SETUP_CFLAGS_HELPER
       
   416 
       
   417   FLAGS_OS=$OPENJDK_TARGET_OS
       
   418   FLAGS_OS_TYPE=$OPENJDK_TARGET_OS_TYPE
       
   419   FLAGS_CPU=$OPENJDK_TARGET_CPU
       
   420   FLAGS_CPU_ARCH=$OPENJDK_TARGET_CPU_ARCH
       
   421   FLAGS_CPU_BITS=$OPENJDK_TARGET_CPU_BITS
       
   422   FLAGS_CPU_ENDIAN=$OPENJDK_TARGET_CPU_ENDIAN
       
   423   FLAGS_CPU_LEGACY=$OPENJDK_TARGET_CPU_LEGACY
       
   424   FLAGS_CPU_LEGACY_LIB=$OPENJDK_TARGET_CPU_LEGACY_LIB
       
   425 
       
   426   FLAGS_SETUP_CFLAGS_CPU_DEP([TARGET])
       
   427 
       
   428   FLAGS_OS=$OPENJDK_BUILD_OS
       
   429   FLAGS_OS_TYPE=$OPENJDK_BUILD_OS_TYPE
       
   430   FLAGS_CPU=$OPENJDK_BUILD_CPU
       
   431   FLAGS_CPU_ARCH=$OPENJDK_BUILD_CPU_ARCH
       
   432   FLAGS_CPU_BITS=$OPENJDK_BUILD_CPU_BITS
       
   433   FLAGS_CPU_ENDIAN=$OPENJDK_BUILD_CPU_ENDIAN
       
   434   FLAGS_CPU_LEGACY=$OPENJDK_BUILD_CPU_LEGACY
       
   435   FLAGS_CPU_LEGACY_LIB=$OPENJDK_BUILD_CPU_LEGACY_LIB
       
   436 
       
   437   FLAGS_SETUP_CFLAGS_CPU_DEP([BUILD], [OPENJDK_BUILD_])
       
   438 
       
   439   # Tests are only ever compiled for TARGET
       
   440   CFLAGS_TESTLIB="$CFLAGS_JDKLIB"
       
   441   CXXFLAGS_TESTLIB="$CXXFLAGS_JDKLIB"
       
   442   CFLAGS_TESTEXE="$CFLAGS_JDKEXE"
       
   443   CXXFLAGS_TESTEXE="$CXXFLAGS_JDKEXE"
       
   444 
       
   445   AC_SUBST(CFLAGS_TESTLIB)
       
   446   AC_SUBST(CFLAGS_TESTEXE)
       
   447   AC_SUBST(CXXFLAGS_TESTLIB)
       
   448   AC_SUBST(CXXFLAGS_TESTEXE)
       
   449 ])
       
   450 
       
   451 ################################################################################
       
   452 # platform independent
       
   453 AC_DEFUN([FLAGS_SETUP_CFLAGS_HELPER],
       
   454 [
       
   455   #### OS DEFINES, these should be independent on toolchain
       
   456   if test "x$OPENJDK_TARGET_OS" = xlinux; then
       
   457     CFLAGS_OS_DEF_JVM="-DLINUX"
       
   458     CFLAGS_OS_DEF_JDK="-D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE"
       
   459   elif test "x$OPENJDK_TARGET_OS" = xsolaris; then
       
   460     CFLAGS_OS_DEF_JVM="-DSOLARIS"
       
   461     CFLAGS_OS_DEF_JDK="-D__solaris__"
       
   462   elif test "x$OPENJDK_TARGET_OS" = xmacosx; then
       
   463     CFLAGS_OS_DEF_JVM="-D_ALLBSD_SOURCE -D_DARWIN_C_SOURCE -D_XOPEN_SOURCE"
       
   464     CFLAGS_OS_DEF_JDK="-D_ALLBSD_SOURCE -D_DARWIN_UNLIMITED_SELECT"
       
   465   elif test "x$OPENJDK_TARGET_OS" = xaix; then
       
   466     CFLAGS_OS_DEF_JVM="-DAIX"
       
   467   elif test "x$OPENJDK_TARGET_OS" = xbsd; then
       
   468     CFLAGS_OS_DEF_JDK="-D_ALLBSD_SOURCE"
       
   469   elif test "x$OPENJDK_TARGET_OS" = xwindows; then
       
   470     CFLAGS_OS_DEF_JVM="-D_WINDOWS -DWIN32 -D_JNI_IMPLEMENTATION_"
       
   471   fi
       
   472 
       
   473   # Setup target OS define. Use OS target name but in upper case.
       
   474   OPENJDK_TARGET_OS_UPPERCASE=`$ECHO $OPENJDK_TARGET_OS | $TR 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
       
   475   CFLAGS_OS_DEF_JDK="$CFLAGS_OS_DEF_JDK -D$OPENJDK_TARGET_OS_UPPERCASE"
       
   476 
       
   477   #### GLOBAL DEFINES
       
   478   # Set some common defines. These works for all compilers, but assume
       
   479   # -D is universally accepted.
       
   480 
       
   481   # Always enable optional macros for VM.
       
   482   ALWAYS_CFLAGS_JVM="-D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS"
       
   483 
       
   484   # Setup some hard coded includes
       
   485   ALWAYS_CFLAGS_JDK=" \
       
   486       -I\$(SUPPORT_OUTPUTDIR)/modules_include/java.base \
       
   487       -I\$(SUPPORT_OUTPUTDIR)/modules_include/java.base/\$(OPENJDK_TARGET_OS_INCLUDE_SUBDIR) \
       
   488       -I${TOPDIR}/src/java.base/share/native/libjava \
       
   489       -I${TOPDIR}/src/java.base/$OPENJDK_TARGET_OS_TYPE/native/libjava \
       
   490       -I${TOPDIR}/src/hotspot/share/include \
       
   491       -I${TOPDIR}/src/hotspot/os/${HOTSPOT_TARGET_OS_TYPE}/include"
       
   492 
       
   493   ###############################################################################
       
   494 
       
   495   # Adjust flags according to debug level.
       
   496   # Setup debug/release defines
       
   497   if test "x$DEBUG_LEVEL" = xrelease; then
       
   498     DEBUG_CFLAGS_JDK="-DNDEBUG"
       
   499     if test "x$OPENJDK_TARGET_OS" = xsolaris; then
       
   500       DEBUG_CFLAGS_JDK="$DEBUG_CFLAGS_JDK -DTRIMMED"
       
   501     fi
       
   502   else
       
   503     DEBUG_CFLAGS_JDK="-DDEBUG"
       
   504 
       
   505     if test "x$TOOLCHAIN_TYPE" = xxlc; then
       
   506       # We need '-qminimaltoc' or '-qpic=large -bbigtoc' if the TOC overflows.
       
   507       # Hotspot now overflows its 64K TOC (currently only for debug),
       
   508       # so for debug we build with '-qpic=large -bbigtoc'.
       
   509       DEBUG_CFLAGS_JVM="-qpic=large"
       
   510     fi
       
   511   fi
       
   512 
       
   513   if test "x$DEBUG_LEVEL" != xrelease; then
       
   514     DEBUG_SYMBOLS_CFLAGS_JDK="$CFLAGS_DEBUG_SYMBOLS $CFLAGS_DEBUG_OPTIONS"
       
   515   fi
       
   516 
       
   517   #### TOOLCHAIN DEFINES
       
   518 
       
   519   if test "x$TOOLCHAIN_TYPE" = xgcc; then
       
   520     ALWAYS_DEFINES_JVM="-D_GNU_SOURCE -D_REENTRANT"
       
   521   elif test "x$TOOLCHAIN_TYPE" = xclang; then
       
   522     ALWAYS_DEFINES_JVM="-D_GNU_SOURCE"
       
   523   elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
       
   524     ALWAYS_DEFINES_JVM="-DSPARC_WORKS -D_Crun_inline_placement"
       
   525     ALWAYS_DEFINES_JDK="-DTRACING -DMACRO_MEMSYS_OPS -DBREAKPTS"
       
   526     ALWAYS_DEFINES_JDK_CXXONLY="-DCC_NOEX"
       
   527   elif test "x$TOOLCHAIN_TYPE" = xxlc; then
       
   528     ALWAYS_DEFINES_JVM="-D_REENTRANT"
       
   529     ALWAYS_DEFINES_JDK="-D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE -DSTDC"
       
   530   elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
       
   531     ALWAYS_DEFINES_JDK="-DWIN32_LEAN_AND_MEAN -D_CRT_SECURE_NO_DEPRECATE \
       
   532         -D_CRT_NONSTDC_NO_DEPRECATE -DWIN32 -DIAL"
       
   533   fi
       
   534 
       
   535   ###############################################################################
       
   536   #
       
   537   #
       
   538   # CFLAGS BASIC
       
   539   if test "x$TOOLCHAIN_TYPE" = xgcc || test "x$TOOLCHAIN_TYPE" = xclang; then
       
   540     # COMMON to gcc and clang
       
   541     TOOLCHAIN_CFLAGS_JVM="-pipe -fno-rtti -fno-exceptions \
       
   542         -fvisibility=hidden -fno-strict-aliasing -fno-omit-frame-pointer"
       
   543   fi
       
   544 
       
   545   if test "x$TOOLCHAIN_TYPE" = xgcc; then
       
   546     TOOLCHAIN_CFLAGS_JVM="$TOOLCHAIN_CFLAGS_JVM -fcheck-new"
       
   547     TOOLCHAIN_CFLAGS_JDK="-pipe"
       
   548     TOOLCHAIN_CFLAGS_JDK_CONLY="-fno-strict-aliasing" # technically NOT for CXX (but since this gives *worse* performance, use no-strict-aliasing everywhere!)
       
   549 
       
   550     CXXSTD_CXXFLAG="-std=gnu++98"
       
   551     FLAGS_CXX_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [$CXXSTD_CXXFLAG -Werror],
       
   552     						 IF_FALSE: [CXXSTD_CXXFLAG=""])
       
   553     TOOLCHAIN_CFLAGS_JDK_CXXONLY="$CXXSTD_CXXFLAG"
       
   554     TOOLCHAIN_CFLAGS_JVM="$TOOLCHAIN_CFLAGS_JVM $CXXSTD_CXXFLAG"
       
   555     ADLC_CXXFLAG="$CXXSTD_CXXFLAG"
       
   556 
       
   557 
       
   558   elif test "x$TOOLCHAIN_TYPE" = xclang; then
       
   559     # Restrict the debug information created by Clang to avoid
       
   560     # too big object files and speed the build up a little bit
       
   561     # (see http://llvm.org/bugs/show_bug.cgi?id=7554)
       
   562     TOOLCHAIN_CFLAGS_JVM="$TOOLCHAIN_CFLAGS_JVM -flimit-debug-info"
       
   563 
       
   564     if test "x$OPENJDK_TARGET_OS" = xlinux; then
       
   565       TOOLCHAIN_CFLAGS_JDK="-pipe"
       
   566       TOOLCHAIN_CFLAGS_JDK_CONLY="-fno-strict-aliasing" # technically NOT for CXX
       
   567     fi
       
   568   elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
       
   569     TOOLCHAIN_CFLAGS_JDK="-mt"
       
   570     TOOLCHAIN_CFLAGS_JDK_CONLY="-xc99=%none -xCC -Xa -v -W0,-noglobal" # C only
       
   571     TOOLCHAIN_CFLAGS_JDK_CXXONLY="-features=no%except -norunpath -xnolib" # CXX only
       
   572     TOOLCHAIN_CFLAGS_JVM="-template=no%extdef -features=no%split_init \
       
   573         -library=stlport4 -mt -features=no%except"
       
   574   elif test "x$TOOLCHAIN_TYPE" = xxlc; then
       
   575     TOOLCHAIN_CFLAGS_JDK="-qchars=signed -qfullpath -qsaveopt"  # add on both CFLAGS
       
   576     TOOLCHAIN_CFLAGS_JVM="-qtune=balanced \
       
   577         -qalias=noansi -qstrict -qtls=default -qlanglvl=c99vla \
       
   578         -qlanglvl=noredefmac -qnortti -qnoeh -qignerrno"
       
   579   elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
       
   580     TOOLCHAIN_CFLAGS_JVM="-nologo -MD -MP"
       
   581     TOOLCHAIN_CFLAGS_JDK="-MD -Zc:wchar_t-"
       
   582   fi
       
   583 
       
   584   # CFLAGS WARNINGS STUFF
       
   585   # Set JVM_CFLAGS warning handling
       
   586   if test "x$TOOLCHAIN_TYPE" = xgcc || test "x$TOOLCHAIN_TYPE" = xclang; then
       
   587     # COMMON to gcc and clang
       
   588     WARNING_CFLAGS_JVM="-Wpointer-arith -Wsign-compare -Wunused-function"
       
   589     if ! HOTSPOT_CHECK_JVM_VARIANT(zero); then
       
   590       # Non-zero builds have stricter warnings
       
   591       WARNING_CFLAGS_JVM="$WARNING_CFLAGS_JVM -Wundef -Wformat=2"
       
   592     fi
       
   593 
       
   594   fi
       
   595   if test "x$TOOLCHAIN_TYPE" = xgcc; then
       
   596     WARNING_CFLAGS_JDK="-Wall -Wextra -Wno-unused -Wno-unused-parameter -Wformat=2"
       
   597     WARNING_CFLAGS_JVM="$WARNING_CFLAGS_JVM -Wunused-value -Woverloaded-virtual"
       
   598 
       
   599     if ! HOTSPOT_CHECK_JVM_VARIANT(zero); then
       
   600       # Non-zero builds have stricter warnings
       
   601       WARNING_CFLAGS_JVM="$WARNING_CFLAGS_JVM -Wreturn-type"
       
   602     fi
       
   603   elif test "x$TOOLCHAIN_TYPE" = xclang; then
       
   604     WARNING_CFLAGS_JVM="$WARNING_CFLAGS_JVM -Wno-deprecated"
       
   605     if test "x$OPENJDK_TARGET_OS" = xlinux; then
       
   606       WARNING_CFLAGS_JVM="$WARNING_CFLAGS_JVM -Wno-sometimes-uninitialized"
       
   607       WARNING_CFLAGS_JDK="-Wall -Wextra -Wno-unused -Wno-unused-parameter -Wformat=2"
       
   608     fi
       
   609   elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
       
   610     WARNING_CFLAGS_JDK_CONLY="-errshort=tags"
       
   611     WARNING_CFLAGS_JDK_CXXONLY="+w"
       
   612     WARNING_CFLAGS_JDK="-errtags=yes -errfmt"
       
   613   elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
       
   614     WARNING_CFLAGS="-W3"
       
   615     WARNING_CFLAGS_JDK="-wd4800"
       
   616   fi
       
   617 
       
   618   # Set some additional per-OS defines.
       
   619 
       
   620   # Additional macosx handling
       
   621   if test "x$OPENJDK_TARGET_OS" = xmacosx; then
       
   622     OS_CFLAGS="-DMAC_OS_X_VERSION_MIN_REQUIRED=$MACOSX_VERSION_MIN_NODOTS \
       
   623         -mmacosx-version-min=$MACOSX_VERSION_MIN"
       
   624 
       
   625     if test -n "$MACOSX_VERSION_MAX"; then
       
   626         OS_CFLAGS="$OS_CFLAGS \
       
   627             -DMAC_OS_X_VERSION_MAX_ALLOWED=$MACOSX_VERSION_MAX_NODOTS"
       
   628     fi
       
   629   fi
       
   630 
       
   631   # Where does this really belong??
       
   632   if test "x$TOOLCHAIN_TYPE" = xgcc || test "x$TOOLCHAIN_TYPE" = xclang; then
       
   633     PICFLAG="-fPIC"
       
   634   elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
       
   635     PICFLAG="-KPIC"
       
   636   elif test "x$TOOLCHAIN_TYPE" = xxlc; then
       
   637     # '-qpic' defaults to 'qpic=small'. This means that the compiler generates only
       
   638     # one instruction for accessing the TOC. If the TOC grows larger than 64K, the linker
       
   639     # will have to patch this single instruction with a call to some out-of-order code which
       
   640     # does the load from the TOC. This is of course slow. But in that case we also would have
       
   641     # to use '-bbigtoc' for linking anyway so we could also change the PICFLAG to 'qpic=large'.
       
   642     # With 'qpic=large' the compiler will by default generate a two-instruction sequence which
       
   643     # can be patched directly by the linker and does not require a jump to out-of-order code.
       
   644     # Another alternative instead of using 'qpic=large -bbigtoc' may be to use '-qminimaltoc'
       
   645     # instead. This creates a distinct TOC for every compilation unit (and thus requires two
       
   646     # loads for accessing a global variable). But there are rumors that this may be seen as a
       
   647     # 'performance feature' because of improved code locality of the symbols used in a
       
   648     # compilation unit.
       
   649     PICFLAG="-qpic"
       
   650   elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
       
   651     PICFLAG=""
       
   652   fi
       
   653 
       
   654   JVM_PICFLAG="$PICFLAG"
       
   655   JDK_PICFLAG="$PICFLAG"
       
   656 
       
   657   if test "x$OPENJDK_TARGET_OS" = xmacosx; then
       
   658     # Linking is different on MacOSX
       
   659     JDK_PICFLAG=''
       
   660     if test "x$STATIC_BUILD" = xtrue; then
       
   661       JVM_PICFLAG=""
       
   662     fi
       
   663   fi
       
   664 
       
   665   if test "x$OPENJDK_TARGET_OS" = xmacosx; then
       
   666     OS_CFLAGS_JVM="$OS_CFLAGS_JVM -mno-omit-leaf-frame-pointer -mstack-alignment=16"
       
   667   fi
       
   668 
       
   669   # Optional POSIX functionality needed by the JVM
       
   670   #
       
   671   # Check if clock_gettime is available and in which library. This indicates
       
   672   # availability of CLOCK_MONOTONIC for hotspot. But we don't need to link, so
       
   673   # don't let it update LIBS.
       
   674   save_LIBS="$LIBS"
       
   675   AC_SEARCH_LIBS(clock_gettime, rt, [HAS_CLOCK_GETTIME=true], [])
       
   676   if test "x$LIBS" = "x-lrt "; then
       
   677     CLOCK_GETTIME_IN_LIBRT=true
       
   678   fi
       
   679   LIBS="$save_LIBS"
       
   680 
       
   681   if test "x$HAS_CLOCK_GETTIME" = "xtrue"; then
       
   682     OS_CFLAGS_JVM="$OS_CFLAGS_JVM -DSUPPORTS_CLOCK_MONOTONIC"
       
   683     if test "x$CLOCK_GETTIME_IN_LIBRT" = "xtrue"; then
       
   684       OS_CFLAGS_JVM="$OS_CFLAGS_JVM -DNEEDS_LIBRT"
       
   685     fi
       
   686   fi
       
   687 
       
   688   # EXPORT
       
   689   AC_SUBST(ADLC_CXXFLAG)
       
   690 ])
       
   691 
       
   692 ################################################################################
       
   693 # $1 - Either BUILD or TARGET to pick the correct OS/CPU variables to check
       
   694 #      conditionals against.
       
   695 # $2 - Optional prefix for each variable defined.
       
   696 AC_DEFUN([FLAGS_SETUP_CFLAGS_CPU_DEP],
       
   697 [
       
   698   #### CPU DEFINES, these should be independent on toolchain
       
   699 
       
   700   # Setup target CPU
       
   701   # Setup endianness
       
   702   # The macros _LITTLE/BIG_ENDIAN needs to be defined with = to avoid
       
   703   # sunstudio warning message: warning: macro redefined: _LITTLE_ENDIAN
       
   704   if test "x$FLAGS_CPU_ENDIAN" = xlittle; then
       
   705     $1_DEFINES_CPU_JVM="-DVM_LITTLE_ENDIAN"
       
   706     $1_DEFINES_CPU_JDK="-D_LITTLE_ENDIAN="
       
   707   else
       
   708     $1_DEFINES_CPU_JDK="-D_BIG_ENDIAN="
       
   709   fi
       
   710 
       
   711   # setup CPU bit size
       
   712   $1_DEFINES_CPU_JDK="${$1_DEFINES_CPU_JDK} -DARCH='\"$FLAGS_CPU_LEGACY\"' \
       
   713       -D$FLAGS_CPU_LEGACY"
       
   714 
       
   715   if test "x$FLAGS_CPU_BITS" = x64; then
       
   716     # -D_LP64=1 is only set on linux and mac. Setting on windows causes diff in
       
   717     # unpack200.exe.
       
   718     if test "x$FLAGS_OS" = xlinux || test "x$FLAGS_OS" = xmacosx; then
       
   719       $1_DEFINES_CPU_JDK="${$1_DEFINES_CPU_JDK} -D_LP64=1"
       
   720     fi
       
   721     if test "x$FLAGS_OS" != xsolaris && test "x$FLAGS_OS" != xaix; then
       
   722       # Solaris does not have _LP64=1 in the old build.
       
   723       # xlc on AIX defines _LP64=1 by default and issues a warning if we redefine it.
       
   724       $1_DEFINES_CPU_JVM="${$1_DEFINES_CPU_JVM} -D_LP64=1"
       
   725     fi
       
   726   fi
       
   727 
       
   728   # toolchain dependend, per-cpu
       
   729   if test "x$TOOLCHAIN_TYPE" = xsolstudio; then
       
   730     if test "x$FLAGS_CPU_ARCH" = xx86; then
       
   731       $1_DEFINES_CPU_JDK="${$1_DEFINES_CPU_JDK} -DcpuIntel -Di586 -D$FLAGS_CPU_LEGACY_LIB"
       
   732     fi
       
   733   elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
       
   734     if test "x$FLAGS_CPU" = xx86_64; then
       
   735       $1_DEFINES_CPU_JDK="${$1_DEFINES_CPU_JDK} -D_AMD64_ -Damd64"
       
   736     else
       
   737       $1_DEFINES_CPU_JDK="${$1_DEFINES_CPU_JDK} -D_X86_ -Dx86"
       
   738     fi
       
   739   fi
       
   740 
       
   741   # CFLAGS PER CPU
       
   742   if test "x$TOOLCHAIN_TYPE" = xgcc || test "x$TOOLCHAIN_TYPE" = xclang; then
       
   743     # COMMON to gcc and clang
       
   744     if test "x$FLAGS_CPU" = xx86; then
       
   745       # Force compatibility with i586 on 32 bit intel platforms.
       
   746       $1_CFLAGS_CPU="-march=i586"
       
   747     fi
       
   748   fi
       
   749 
       
   750   if test "x$TOOLCHAIN_TYPE" = xgcc; then
       
   751     if test "x$FLAGS_CPU" = xarm; then
       
   752       # -Wno-psabi to get rid of annoying "note: the mangling of 'va_list' has changed in GCC 4.4"
       
   753       $1_CFLAGS_CPU="-fsigned-char -Wno-psabi $ARM_ARCH_TYPE_FLAGS $ARM_FLOAT_TYPE_FLAGS -DJDK_ARCH_ABI_PROP_NAME='\"\$(JDK_ARCH_ABI_PROP_NAME)\"'"
       
   754       $1_CFLAGS_CPU_JVM="-DARM"
       
   755     elif test "x$FLAGS_CPU" = xaarch64; then
       
   756       if test "x$HOTSPOT_TARGET_CPU_PORT" = xarm64; then
       
   757         $1_CFLAGS_CPU_JVM="-fsigned-char -DARM"
       
   758       fi
       
   759     elif test "x$FLAGS_CPU_ARCH" = xppc; then
       
   760       $1_CFLAGS_CPU_JVM="-minsert-sched-nops=regroup_exact -mno-multiple -mno-string"
       
   761       if test "x$FLAGS_CPU" = xppc64; then
       
   762         # -mminimal-toc fixes `relocation truncated to fit' error for gcc 4.1.
       
   763         # Use ppc64 instructions, but schedule for power5
       
   764         $1_CFLAGS_CPU_JVM="${$1_CFLAGS_CPU_JVM} -mminimal-toc -mcpu=powerpc64 -mtune=power5"
       
   765       elif test "x$FLAGS_CPU" = xppc64le; then
       
   766         # Little endian machine uses ELFv2 ABI.
       
   767         # Use Power8, this is the first CPU to support PPC64 LE with ELFv2 ABI.
       
   768         $1_CFLAGS_CPU_JVM="${$1_CFLAGS_CPU_JVM} -DABI_ELFv2 -mcpu=power8 -mtune=power8"
       
   769       fi
       
   770     elif test "x$FLAGS_CPU" = xs390x; then
       
   771       $1_CFLAGS_CPU="-mbackchain -march=z10"
       
   772     fi
       
   773 
       
   774     if test "x$FLAGS_CPU_ARCH" != xarm &&  test "x$FLAGS_CPU_ARCH" != xppc; then
       
   775       # for all archs except arm and ppc, prevent gcc to omit frame pointer
       
   776       $1_CFLAGS_CPU_JDK="${$1_CFLAGS_CPU_JDK} -fno-omit-frame-pointer"
       
   777     fi
       
   778 
       
   779   elif test "x$TOOLCHAIN_TYPE" = xclang; then
       
   780     if test "x$FLAGS_OS" = xlinux; then
       
   781       # ppc test not really needed for clang
       
   782       if test "x$FLAGS_CPU_ARCH" != xarm &&  test "x$FLAGS_CPU_ARCH" != xppc; then
       
   783         # for all archs except arm and ppc, prevent gcc to omit frame pointer
       
   784         $1_CFLAGS_CPU_JDK="${$1_CFLAGS_CPU_JDK} -fno-omit-frame-pointer"
       
   785       fi
       
   786     fi
       
   787 
       
   788   elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
       
   789     if test "x$FLAGS_CPU" = xx86_64; then
       
   790       # NOTE: -xregs=no%frameptr is supposed to be default on x64
       
   791       $1_CFLAGS_CPU_JDK="-xregs=no%frameptr"
       
   792     elif test "x$FLAGS_CPU" = xsparcv9; then
       
   793       $1_CFLAGS_CPU_JVM="-xarch=sparc"
       
   794       $1_CFLAGS_CPU_JDK_LIBONLY="-xregs=no%appl"
       
   795     fi
       
   796 
       
   797   elif test "x$TOOLCHAIN_TYPE" = xxlc; then
       
   798     if test "x$FLAGS_CPU" = xppc64; then
       
   799       $1_CFLAGS_CPU_JVM="-qarch=ppc64"
       
   800     fi
       
   801 
       
   802   elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
       
   803     if test "x$FLAGS_CPU" = xx86; then
       
   804       $1_CFLAGS_CPU_JVM="-arch:IA32"
       
   805     fi
       
   806   fi
       
   807 
       
   808   if test "x$TOOLCHAIN_TYPE" = xgcc; then
       
   809     TOOLCHAIN_CHECK_COMPILER_VERSION(VERSION: 6, PREFIX: $2, IF_AT_LEAST: FLAGS_SETUP_GCC6_COMPILER_FLAGS($1))
       
   810     $1_TOOLCHAIN_CFLAGS="${$1_GCC6_CFLAGS}"
       
   811 
       
   812     TOOLCHAIN_CHECK_COMPILER_VERSION(VERSION: [4.8], PREFIX: $2,
       
   813         IF_AT_LEAST: [
       
   814           # These flags either do not work or give spurious warnings prior to gcc 4.8.
       
   815           $1_WARNING_CFLAGS_JVM="-Wno-format-zero-length -Wtype-limits -Wuninitialized"
       
   816         ]
       
   817     )
       
   818   fi
       
   819 
       
   820   # EXPORT to API
       
   821   CFLAGS_JVM_COMMON="$ALWAYS_CFLAGS_JVM $ALWAYS_DEFINES_JVM $TOOLCHAIN_CFLAGS_JVM \
       
   822       $OS_CFLAGS $OS_CFLAGS_JVM $CFLAGS_OS_DEF_JVM $DEBUG_CFLAGS_JVM \
       
   823       $WARNING_CFLAGS $WARNING_CFLAGS_JVM $JVM_PICFLAG"
       
   824 
       
   825   CFLAGS_JDK_COMMON="$ALWAYS_CFLAGS_JDK $ALWAYS_DEFINES_JDK $TOOLCHAIN_CFLAGS_JDK \
       
   826       $OS_CFLAGS $CFLAGS_OS_DEF_JDK $DEBUG_CFLAGS_JDK $DEBUG_SYMBOLS_CFLAGS_JDK \
       
   827       $WARNING_CFLAGS $WARNING_CFLAGS_JDK"
       
   828 
       
   829   # Use ${$2EXTRA_CFLAGS} to block EXTRA_CFLAGS to be added to build flags.
       
   830   # (Currently we don't have any OPENJDK_BUILD_EXTRA_CFLAGS, but that might
       
   831   # change in the future.)
       
   832 
       
   833   CFLAGS_JDK_COMMON_CONLY="$TOOLCHAIN_CFLAGS_JDK_CONLY $WARNING_CFLAGS_JDK_CONLY ${$2EXTRA_CFLAGS}"
       
   834   CFLAGS_JDK_COMMON_CXXONLY="$ALWAYS_DEFINES_JDK_CXXONLY $TOOLCHAIN_CFLAGS_JDK_CXXONLY \
       
   835       $WARNING_CFLAGS_JDK_CXXONLY ${$2EXTRA_CXXFLAGS}"
       
   836 
       
   837   $1_CFLAGS_JVM="${$1_DEFINES_CPU_JVM} ${$1_CFLAGS_CPU} ${$1_CFLAGS_CPU_JVM} ${$1_TOOLCHAIN_CFLAGS} ${$1_WARNING_CFLAGS_JVM}"
       
   838   $1_CFLAGS_JDK="${$1_DEFINES_CPU_JDK} ${$1_CFLAGS_CPU} ${$1_CFLAGS_CPU_JDK} ${$1_TOOLCHAIN_CFLAGS}"
       
   839 
       
   840   $2JVM_CFLAGS="$CFLAGS_JVM_COMMON ${$1_CFLAGS_JVM} ${$2EXTRA_CXXFLAGS}"
       
   841 
       
   842   $2CFLAGS_JDKEXE="$CFLAGS_JDK_COMMON $CFLAGS_JDK_COMMON_CONLY ${$1_CFLAGS_JDK}"
       
   843   $2CXXFLAGS_JDKEXE="$CFLAGS_JDK_COMMON $CFLAGS_JDK_COMMON_CXXONLY ${$1_CFLAGS_JDK}"
       
   844   $2CFLAGS_JDKLIB="${$2CFLAGS_JDKEXE} $JDK_PICFLAG ${$1_CFLAGS_CPU_JDK_LIBONLY}"
       
   845   $2CXXFLAGS_JDKLIB="${$2CXXFLAGS_JDKEXE} $JDK_PICFLAG ${$1_CFLAGS_CPU_JDK_LIBONLY}"
       
   846 
       
   847   AC_SUBST($2JVM_CFLAGS)
       
   848   AC_SUBST($2CFLAGS_JDKLIB)
       
   849   AC_SUBST($2CFLAGS_JDKEXE)
       
   850   AC_SUBST($2CXXFLAGS_JDKLIB)
       
   851   AC_SUBST($2CXXFLAGS_JDKEXE)
       
   852 ])
       
   853 
       
   854 # FLAGS_C_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [ARGUMENT], IF_TRUE: [RUN-IF-TRUE],
   399 # FLAGS_C_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [ARGUMENT], IF_TRUE: [RUN-IF-TRUE],
   855 #                                  IF_FALSE: [RUN-IF-FALSE])
   400 #                                  IF_FALSE: [RUN-IF-FALSE])
   856 # ------------------------------------------------------------
   401 # ------------------------------------------------------------
   857 # Check that the C compiler supports an argument
   402 # Check that the C compiler supports an argument
   858 BASIC_DEFUN_NAMED([FLAGS_C_COMPILER_CHECK_ARGUMENTS],
   403 BASIC_DEFUN_NAMED([FLAGS_C_COMPILER_CHECK_ARGUMENTS],
   960   else
   505   else
   961     :
   506     :
   962     ARG_IF_FALSE
   507     ARG_IF_FALSE
   963   fi
   508   fi
   964 ])
   509 ])
   965 
       
   966 # FLAGS_SETUP_GCC6_COMPILER_FLAGS([PREFIX])
       
   967 # Arguments:
       
   968 # $1 - Prefix for each variable defined.
       
   969 AC_DEFUN([FLAGS_SETUP_GCC6_COMPILER_FLAGS],
       
   970 [
       
   971   # These flags are required for GCC 6 builds as undefined behaviour in OpenJDK code
       
   972   # runs afoul of the more aggressive versions of these optimisations.
       
   973   # Notably, value range propagation now assumes that the this pointer of C++
       
   974   # member functions is non-null.
       
   975   NO_DELETE_NULL_POINTER_CHECKS_CFLAG="-fno-delete-null-pointer-checks"
       
   976   dnl Argument check is disabled until FLAGS_COMPILER_CHECK_ARGUMENTS handles cross-compilation
       
   977   dnl FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [$NO_DELETE_NULL_POINTER_CHECKS_CFLAG -Werror],
       
   978   dnl					     IF_FALSE: [NO_DELETE_NULL_POINTER_CHECKS_CFLAG=""])
       
   979   NO_LIFETIME_DSE_CFLAG="-fno-lifetime-dse"
       
   980   dnl Argument check is disabled until FLAGS_COMPILER_CHECK_ARGUMENTS handles cross-compilation
       
   981   dnl FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [$NO_LIFETIME_DSE_CFLAG -Werror],
       
   982   dnl					     IF_FALSE: [NO_LIFETIME_DSE_CFLAG=""])
       
   983   AC_MSG_NOTICE([GCC >= 6 detected; adding ${NO_DELETE_NULL_POINTER_CHECKS_CFLAG} and ${NO_LIFETIME_DSE_CFLAG}])
       
   984   $1_GCC6_CFLAGS="${NO_DELETE_NULL_POINTER_CHECKS_CFLAG} ${NO_LIFETIME_DSE_CFLAG}"
       
   985 ])
       
   986 
       
   987 
       
   988 # Documentation on common flags used for solstudio in HIGHEST.
       
   989 #
       
   990 # WARNING: Use of OPTIMIZATION_LEVEL=HIGHEST in your Makefile needs to be
       
   991 #          done with care, there are some assumptions below that need to
       
   992 #          be understood about the use of pointers, and IEEE behavior.
       
   993 #
       
   994 # -fns: Use non-standard floating point mode (not IEEE 754)
       
   995 # -fsimple: Do some simplification of floating point arithmetic (not IEEE 754)
       
   996 # -fsingle: Use single precision floating point with 'float'
       
   997 # -xalias_level=basic: Assume memory references via basic pointer types do not alias
       
   998 #   (Source with excessing pointer casting and data access with mixed
       
   999 #    pointer types are not recommended)
       
  1000 # -xbuiltin=%all: Use intrinsic or inline versions for math/std functions
       
  1001 #   (If you expect perfect errno behavior, do not use this)
       
  1002 # -xdepend: Loop data dependency optimizations (need -xO3 or higher)
       
  1003 # -xrestrict: Pointer parameters to functions do not overlap
       
  1004 #   (Similar to -xalias_level=basic usage, but less obvious sometimes.
       
  1005 #    If you pass in multiple pointers to the same data, do not use this)
       
  1006 # -xlibmil: Inline some library routines
       
  1007 #   (If you expect perfect errno behavior, do not use this)
       
  1008 # -xlibmopt: Use optimized math routines (CURRENTLY DISABLED)
       
  1009 #   (If you expect perfect errno behavior, do not use this)
       
  1010 #  Can cause undefined external on Solaris 8 X86 on __sincos, removing for now