< prev index next >

make/autoconf/flags-cflags.m4

Print this page


   1 #
   2 # Copyright (c) 2011, 2019, 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


 104   AC_SUBST(SHARED_LIBRARY_FLAGS)
 105 ])
 106 
 107 AC_DEFUN([FLAGS_SETUP_DEBUG_SYMBOLS],
 108 [
 109   # By default don't set any specific assembler debug
 110   # info flags for toolchains unless we know they work.
 111   # See JDK-8207057.
 112   ASFLAGS_DEBUG_SYMBOLS=""
 113   # Debug symbols
 114   if test "x$TOOLCHAIN_TYPE" = xgcc; then
 115     CFLAGS_DEBUG_SYMBOLS="-g"
 116     ASFLAGS_DEBUG_SYMBOLS="-g"
 117   elif test "x$TOOLCHAIN_TYPE" = xclang; then
 118     CFLAGS_DEBUG_SYMBOLS="-g"
 119     ASFLAGS_DEBUG_SYMBOLS="-g"
 120   elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
 121     # -g0 enables debug symbols without disabling inlining.
 122     CFLAGS_DEBUG_SYMBOLS="-g0 -xs"
 123   elif test "x$TOOLCHAIN_TYPE" = xxlc; then
 124     if test "x$XLC_USES_CLANG" = xtrue; then
 125       CFLAGS_DEBUG_SYMBOLS="-g1"
 126     else
 127       CFLAGS_DEBUG_SYMBOLS="-g"
 128     fi
 129   elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
 130     CFLAGS_DEBUG_SYMBOLS="-Z7 -d2Zi+"
 131   fi
 132 
 133   AC_SUBST(CFLAGS_DEBUG_SYMBOLS)
 134   AC_SUBST(ASFLAGS_DEBUG_SYMBOLS)
 135 ])
 136 
 137 AC_DEFUN([FLAGS_SETUP_WARNINGS],
 138 [
 139   AC_ARG_ENABLE([warnings-as-errors], [AS_HELP_STRING([--disable-warnings-as-errors],
 140       [do not consider native warnings to be an error @<:@enabled@:>@])])
 141 
 142   # Set default value.
 143   if test "x$TOOLCHAIN_TYPE" = xxlc; then
 144     WARNINGS_AS_ERRORS=false
 145   else
 146     WARNINGS_AS_ERRORS=true
 147   fi
 148 


 170       DISABLED_WARNINGS="4800"
 171       ;;
 172 
 173     solstudio)
 174       DISABLE_WARNING_PREFIX="-erroff="
 175       CFLAGS_WARNINGS_ARE_ERRORS="-errwarn=%all"
 176 
 177       WARNINGS_ENABLE_ALL_CFLAGS="-v"
 178       WARNINGS_ENABLE_ALL_CXXFLAGS="+w"
 179 
 180       DISABLED_WARNINGS_C=""
 181       DISABLED_WARNINGS_CXX=""
 182       ;;
 183 
 184     gcc)
 185       DISABLE_WARNING_PREFIX="-Wno-"
 186       CFLAGS_WARNINGS_ARE_ERRORS="-Werror"
 187 
 188       # Additional warnings that are not activated by -Wall and -Wextra
 189       WARNINGS_ENABLE_ADDITIONAL="-Wpointer-arith -Wsign-compare \
 190           -Wunused-function -Wundef -Wunused-value -Wreturn-type \
 191           -Wtrampolines"
 192       WARNINGS_ENABLE_ADDITIONAL_CXX="-Woverloaded-virtual -Wreorder"
 193       WARNINGS_ENABLE_ALL_CFLAGS="-Wall -Wextra -Wformat=2 $WARNINGS_ENABLE_ADDITIONAL"
 194       WARNINGS_ENABLE_ALL_CXXFLAGS="$WARNINGS_ENABLE_ALL_CFLAGS $WARNINGS_ENABLE_ADDITIONAL_CXX"
 195 
 196       DISABLED_WARNINGS="unused-parameter unused"
 197 
 198       # Repeate the check for the BUILD_CC and BUILD_CXX. Need to also reset
 199       # CFLAGS since any target specific flags will likely not work with the
 200       # build compiler
 201       CC_OLD="$CC"
 202       CXX_OLD="$CXX"
 203       CC="$BUILD_CC"
 204       CXX="$BUILD_CXX"
 205       CFLAGS_OLD="$CFLAGS"
 206       CFLAGS=""
 207       BUILD_CC_DISABLE_WARNING_PREFIX="-Wno-"
 208       CC="$CC_OLD"
 209       CXX="$CXX_OLD"
 210       CFLAGS="$CFLAGS_OLD"
 211       ;;
 212 
 213     clang)
 214       DISABLE_WARNING_PREFIX="-Wno-"
 215       CFLAGS_WARNINGS_ARE_ERRORS="-Werror"
 216 
 217       # Additional warnings that are not activated by -Wall and -Wextra
 218       WARNINGS_ENABLE_ADDITIONAL="-Wpointer-arith -Wsign-compare -Wreorder \
 219           -Wunused-function -Wundef -Wunused-value -Woverloaded-virtual"
 220       WARNINGS_ENABLE_ALL="-Wall -Wextra -Wformat=2 $WARNINGS_ENABLE_ADDITIONAL"
 221 
 222       DISABLED_WARNINGS="unknown-warning-option unused-parameter unused"
 223 
 224       if test "x$OPENJDK_TARGET_OS" = xmacosx; then
 225         # missing-method-return-type triggers in JavaNativeFoundation framework
 226         DISABLED_WARNINGS="$DISABLED_WARNINGS missing-method-return-type"
 227       fi
 228 
 229       ;;
 230 
 231     xlc)
 232       DISABLE_WARNING_PREFIX="-qsuppress="
 233       CFLAGS_WARNINGS_ARE_ERRORS="-qhalt=w"
 234 
 235       # Possibly a better subset than "all" is "lan:trx:ret:zea:cmp:ret"
 236       WARNINGS_ENABLE_ALL="-qinfo=all -qformat=all"
 237       DISABLED_WARNINGS=""
 238       ;;
 239   esac
 240   AC_SUBST(DISABLE_WARNING_PREFIX)
 241   AC_SUBST(BUILD_CC_DISABLE_WARNING_PREFIX)
 242   AC_SUBST(CFLAGS_WARNINGS_ARE_ERRORS)


 283     C_O_FLAG_NONE=""
 284     if test "x$OPENJDK_TARGET_CPU_ARCH" = "xx86"; then
 285       C_O_FLAG_HIGHEST="-xO4 -Wu,-O4~yz $CC_HIGHEST"
 286       C_O_FLAG_HI="-xO4 -Wu,-O4~yz"
 287       C_O_FLAG_NORM="-xO2 -Wu,-O2~yz"
 288     elif test "x$OPENJDK_TARGET_CPU_ARCH" = "xsparc"; then
 289       C_O_FLAG_HIGHEST="-xO4 -Wc,-Qrm-s -Wc,-Qiselect-T0 \
 290           -xprefetch=auto,explicit $CC_HIGHEST"
 291       C_O_FLAG_HI="-xO4 -Wc,-Qrm-s -Wc,-Qiselect-T0"
 292       C_O_FLAG_NORM="-xO2 -Wc,-Qrm-s -Wc,-Qiselect-T0"
 293     fi
 294   elif test "x$TOOLCHAIN_TYPE" = xgcc; then
 295     C_O_FLAG_HIGHEST_JVM="-O3"
 296     C_O_FLAG_HIGHEST="-O3"
 297     C_O_FLAG_HI="-O3"
 298     C_O_FLAG_NORM="-O2"
 299     C_O_FLAG_SIZE="-Os"
 300     C_O_FLAG_DEBUG="-O0"
 301     C_O_FLAG_DEBUG_JVM="-O0"
 302     C_O_FLAG_NONE="-O0"
 303     # -D_FORTIFY_SOURCE=2 hardening option needs optimization (at least -O1) enabled
 304     # set for lower O-levels -U_FORTIFY_SOURCE to overwrite previous settings
 305     if test "x$OPENJDK_TARGET_OS" = xlinux -a "x$DEBUG_LEVEL" = "xfastdebug"; then
 306       ENABLE_FORTIFY_CFLAGS="-D_FORTIFY_SOURCE=2"
 307       DISABLE_FORTIFY_CFLAGS="-U_FORTIFY_SOURCE"
 308       C_O_FLAG_HIGHEST_JVM="${C_O_FLAG_HIGHEST_JVM} ${ENABLE_FORTIFY_CFLAGS}"
 309       C_O_FLAG_HIGHEST="${C_O_FLAG_HIGHEST} ${ENABLE_FORTIFY_CFLAGS}"
 310       C_O_FLAG_HI="${C_O_FLAG_HI} ${ENABLE_FORTIFY_CFLAGS}"
 311       C_O_FLAG_NORM="${C_O_FLAG_NORM} ${ENABLE_FORTIFY_CFLAGS}"
 312       C_O_FLAG_SIZE="${C_O_FLAG_SIZE} ${DISABLE_FORTIFY_CFLAGS}"
 313       C_O_FLAG_DEBUG="${C_O_FLAG_DEBUG} ${DISABLE_FORTIFY_CFLAGS}"
 314       C_O_FLAG_DEBUG_JVM="${C_O_FLAG_DEBUG_JVM} ${DISABLE_FORTIFY_CFLAGS}"
 315       C_O_FLAG_NONE="${C_O_FLAG_NONE} ${DISABLE_FORTIFY_CFLAGS}"
 316     fi
 317   elif test "x$TOOLCHAIN_TYPE" = xclang; then
 318     if test "x$OPENJDK_TARGET_OS" = xmacosx; then
 319       # On MacOSX we optimize for size, something
 320       # we should do for all platforms?
 321       C_O_FLAG_HIGHEST_JVM="-Os"
 322       C_O_FLAG_HIGHEST="-Os"
 323       C_O_FLAG_HI="-Os"
 324       C_O_FLAG_NORM="-Os"
 325       C_O_FLAG_DEBUG_JVM=""
 326     else
 327       C_O_FLAG_HIGHEST_JVM="-O3"
 328       C_O_FLAG_HIGHEST="-O3"
 329       C_O_FLAG_HI="-O3"
 330       C_O_FLAG_NORM="-O2"
 331       C_O_FLAG_DEBUG_JVM="-O0"
 332     fi
 333     C_O_FLAG_SIZE="-Os"
 334     C_O_FLAG_DEBUG="-O0"
 335     C_O_FLAG_NONE="-O0"
 336   elif test "x$TOOLCHAIN_TYPE" = xxlc; then


 416   FLAGS_OS=$OPENJDK_TARGET_OS
 417   FLAGS_OS_TYPE=$OPENJDK_TARGET_OS_TYPE
 418   FLAGS_CPU=$OPENJDK_TARGET_CPU
 419   FLAGS_CPU_ARCH=$OPENJDK_TARGET_CPU_ARCH
 420   FLAGS_CPU_BITS=$OPENJDK_TARGET_CPU_BITS
 421   FLAGS_CPU_ENDIAN=$OPENJDK_TARGET_CPU_ENDIAN
 422   FLAGS_CPU_LEGACY=$OPENJDK_TARGET_CPU_LEGACY
 423   FLAGS_CPU_LEGACY_LIB=$OPENJDK_TARGET_CPU_LEGACY_LIB
 424 
 425   FLAGS_SETUP_CFLAGS_CPU_DEP([TARGET])
 426 
 427   FLAGS_OS=$OPENJDK_BUILD_OS
 428   FLAGS_OS_TYPE=$OPENJDK_BUILD_OS_TYPE
 429   FLAGS_CPU=$OPENJDK_BUILD_CPU
 430   FLAGS_CPU_ARCH=$OPENJDK_BUILD_CPU_ARCH
 431   FLAGS_CPU_BITS=$OPENJDK_BUILD_CPU_BITS
 432   FLAGS_CPU_ENDIAN=$OPENJDK_BUILD_CPU_ENDIAN
 433   FLAGS_CPU_LEGACY=$OPENJDK_BUILD_CPU_LEGACY
 434   FLAGS_CPU_LEGACY_LIB=$OPENJDK_BUILD_CPU_LEGACY_LIB
 435 
 436   FLAGS_SETUP_CFLAGS_CPU_DEP([BUILD], [OPENJDK_BUILD_], [BUILD_])














 437 ])
 438 
 439 ################################################################################
 440 # platform independent
 441 AC_DEFUN([FLAGS_SETUP_CFLAGS_HELPER],
 442 [
 443   #### OS DEFINES, these should be independent on toolchain
 444   if test "x$OPENJDK_TARGET_OS" = xlinux; then
 445     CFLAGS_OS_DEF_JVM="-DLINUX"
 446     CFLAGS_OS_DEF_JDK="-D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE"
 447   elif test "x$OPENJDK_TARGET_OS" = xsolaris; then
 448     CFLAGS_OS_DEF_JVM="-DSOLARIS"
 449     CFLAGS_OS_DEF_JDK="-D__solaris__"
 450   elif test "x$OPENJDK_TARGET_OS" = xmacosx; then
 451     CFLAGS_OS_DEF_JVM="-D_ALLBSD_SOURCE -D_DARWIN_C_SOURCE -D_XOPEN_SOURCE"
 452     CFLAGS_OS_DEF_JDK="-D_ALLBSD_SOURCE -D_DARWIN_UNLIMITED_SELECT"
 453   elif test "x$OPENJDK_TARGET_OS" = xaix; then
 454     CFLAGS_OS_DEF_JVM="-DAIX"
 455   elif test "x$OPENJDK_TARGET_OS" = xbsd; then
 456     CFLAGS_OS_DEF_JDK="-D_ALLBSD_SOURCE"


 514   elif test "x$TOOLCHAIN_TYPE" = xxlc; then
 515     ALWAYS_DEFINES_JVM="-D_REENTRANT"
 516     ALWAYS_DEFINES_JDK="-D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE -DSTDC"
 517   elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
 518     ALWAYS_DEFINES_JDK="-DWIN32_LEAN_AND_MEAN -D_CRT_SECURE_NO_DEPRECATE \
 519         -D_CRT_NONSTDC_NO_DEPRECATE -DWIN32 -DIAL"
 520     ALWAYS_DEFINES_JVM="-DNOMINMAX -DWIN32_LEAN_AND_MEAN"
 521   fi
 522 
 523   ###############################################################################
 524   #
 525   #
 526   # CFLAGS BASIC
 527   if test "x$TOOLCHAIN_TYPE" = xgcc || test "x$TOOLCHAIN_TYPE" = xclang; then
 528     # COMMON to gcc and clang
 529     TOOLCHAIN_CFLAGS_JVM="-pipe -fno-rtti -fno-exceptions \
 530         -fvisibility=hidden -fno-strict-aliasing -fno-omit-frame-pointer"
 531   fi
 532 
 533   if test "x$TOOLCHAIN_TYPE" = xgcc; then
 534     TOOLCHAIN_CFLAGS_JVM="$TOOLCHAIN_CFLAGS_JVM -fcheck-new -fstack-protector"
 535     TOOLCHAIN_CFLAGS_JDK="-pipe -fstack-protector"
 536     # technically NOT for CXX (but since this gives *worse* performance, use
 537     # no-strict-aliasing everywhere!)
 538     TOOLCHAIN_CFLAGS_JDK_CONLY="-fno-strict-aliasing"






 539 
 540   elif test "x$TOOLCHAIN_TYPE" = xclang; then
 541     # Restrict the debug information created by Clang to avoid
 542     # too big object files and speed the build up a little bit
 543     # (see http://llvm.org/bugs/show_bug.cgi?id=7554)
 544     TOOLCHAIN_CFLAGS_JVM="$TOOLCHAIN_CFLAGS_JVM -flimit-debug-info"
 545 
 546     # In principle the stack alignment below is cpu- and ABI-dependent and
 547     # should agree with values of StackAlignmentInBytes in various
 548     # src/hotspot/cpu/*/globalDefinitions_*.hpp files, but this value currently
 549     # works for all platforms.
 550     TOOLCHAIN_CFLAGS_JVM="$TOOLCHAIN_CFLAGS_JVM -mno-omit-leaf-frame-pointer -mstack-alignment=16"
 551 
 552     if test "x$OPENJDK_TARGET_OS" = xlinux; then
 553       if test "x$DEBUG_LEVEL" = xrelease; then
 554         # Clang does not inline as much as GCC does for functions with "inline" keyword by default.
 555         # This causes noticeable slowdown in pause time for G1, and possibly in other areas.
 556         # Increasing the inline hint threshold avoids the slowdown for Clang-built JVM.
 557         TOOLCHAIN_CFLAGS_JVM="$TOOLCHAIN_CFLAGS_JVM -mllvm -inlinehint-threshold=100000"
 558       fi
 559       TOOLCHAIN_CFLAGS_JDK="-pipe"
 560       TOOLCHAIN_CFLAGS_JDK_CONLY="-fno-strict-aliasing" # technically NOT for CXX
 561     fi
 562   elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
 563     TOOLCHAIN_FLAGS="-errtags -errfmt"
 564     TOOLCHAIN_CFLAGS="-errshort=tags"
 565 
 566     TOOLCHAIN_CFLAGS_JDK="-mt $TOOLCHAIN_FLAGS"
 567     TOOLCHAIN_CFLAGS_JDK_CONLY="-W0,-noglobal $TOOLCHAIN_CFLAGS" # C only
 568     TOOLCHAIN_CFLAGS_JDK_CXXONLY="-features=no%except -norunpath -xnolib" # CXX only
 569     TOOLCHAIN_CFLAGS_JVM="-template=no%extdef -features=no%split_init \
 570         -library=stlport4 -mt -features=no%except $TOOLCHAIN_FLAGS"
 571     if test "x$DEBUG_LEVEL" = xslowdebug; then
 572       # Previously -g was used instead of -g0 for slowdebug; this is equivalent
 573       # to setting +d.
 574       TOOLCHAIN_CFLAGS_JVM="$TOOLCHAIN_CFLAGS_JVM +d"
 575     fi
 576 
 577   elif test "x$TOOLCHAIN_TYPE" = xxlc; then
 578     # Suggested additions: -qsrcmsg to get improved error reporting
 579     TOOLCHAIN_CFLAGS_JDK="-qchars=signed -qfullpath -qsaveopt -qstackprotect"  # add on both CFLAGS
 580     TOOLCHAIN_CFLAGS_JVM="-qtune=balanced \
 581         -qalias=noansi -qstrict -qtls=default -qlanglvl=c99vla \
 582         -qlanglvl=noredefmac -qnortti -qnoeh -qignerrno -qstackprotect"
 583   elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
 584     TOOLCHAIN_CFLAGS_JVM="-nologo -MD -MP"
 585     TOOLCHAIN_CFLAGS_JDK="-nologo -MD -Zc:wchar_t-"
 586   fi
 587 
 588   # CFLAGS C language level for JDK sources (hotspot only uses C++)
 589   # Ideally we would have a common level across all toolchains so that all sources
 590   # are sure to conform to the same standard. Unfortunately neither our sources nor
 591   # our toolchains are in a condition to support that. But what we loosely aim for is
 592   # C99 level.
 593   if test "x$TOOLCHAIN_TYPE" = xgcc || test "x$TOOLCHAIN_TYPE" = xclang || test "x$TOOLCHAIN_TYPE" = xxlc; then
 594     # This raises the language level for older 4.8 gcc, while lowering it for later
 595     # versions. clang and xlclang support the same flag.
 596     LANGSTD_CFLAGS="-std=c99"
 597   elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
 598     # We can't turn on -std=c99 without breaking compilation of the splashscreen/png
 599     # utilities. But we can enable c99 as below (previously achieved by using -Xa).
 600     # It is the no_lib that makes the difference.
 601     LANGSTD_CFLAGS="-xc99=all,no_lib"
 602   elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
 603     # MSVC doesn't support C99/C11 explicitly, unless you compile as C++:
 604     # LANGSTD_CFLAGS="/TP"
 605     # but that requires numerous changes to the sources files. So we are limited
 606     # to C89/C90 plus whatever extensions Visual Studio has decided to implement.
 607     # This is the lowest bar for shared code.
 608     LANGSTD_CFLAGS=""
 609   fi
 610   TOOLCHAIN_CFLAGS_JDK_CONLY="$LANGSTD_CFLAGS $TOOLCHAIN_CFLAGS_JDK_CONLY"
 611 
 612   # CFLAGS WARNINGS STUFF
 613   # Set JVM_CFLAGS warning handling
 614   if test "x$TOOLCHAIN_TYPE" = xgcc; then
 615     WARNING_CFLAGS_JDK_CONLY="$WARNINGS_ENABLE_ALL_CFLAGS"
 616     WARNING_CFLAGS_JDK_CXXONLY="$WARNINGS_ENABLE_ALL_CXXFLAGS"
 617     WARNING_CFLAGS_JVM="$WARNINGS_ENABLE_ALL_CXXFLAGS"
 618 
 619   elif test "x$TOOLCHAIN_TYPE" = xclang; then
 620     WARNING_CFLAGS="$WARNINGS_ENABLE_ALL"
 621 
 622   elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
 623     WARNING_CFLAGS_JDK_CONLY="$WARNINGS_ENABLE_ALL_CFLAGS"
 624     WARNING_CFLAGS_JDK_CXXONLY="$WARNINGS_ENABLE_ALL_CXXFLAGS"
 625     WARNING_CFLAGS_JVM="$WARNINGS_ENABLE_ALL_CXXFLAGS"
 626 
 627   elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
 628     WARNING_CFLAGS="$WARNINGS_ENABLE_ALL"
 629 
 630   elif test "x$TOOLCHAIN_TYPE" = xxlc; then
 631     WARNING_CFLAGS=""  # currently left empty


 681   fi
 682 
 683   # Optional POSIX functionality needed by the JVM
 684   #
 685   # Check if clock_gettime is available and in which library. This indicates
 686   # availability of CLOCK_MONOTONIC for hotspot. But we don't need to link, so
 687   # don't let it update LIBS.
 688   save_LIBS="$LIBS"
 689   AC_SEARCH_LIBS(clock_gettime, rt, [HAS_CLOCK_GETTIME=true], [])
 690   if test "x$LIBS" = "x-lrt "; then
 691     CLOCK_GETTIME_IN_LIBRT=true
 692   fi
 693   LIBS="$save_LIBS"
 694 
 695   if test "x$HAS_CLOCK_GETTIME" = "xtrue"; then
 696     OS_CFLAGS_JVM="$OS_CFLAGS_JVM -DSUPPORTS_CLOCK_MONOTONIC"
 697     if test "x$CLOCK_GETTIME_IN_LIBRT" = "xtrue"; then
 698       OS_CFLAGS_JVM="$OS_CFLAGS_JVM -DNEEDS_LIBRT"
 699     fi
 700   fi



 701 ])
 702 
 703 ################################################################################
 704 # $1 - Either BUILD or TARGET to pick the correct OS/CPU variables to check
 705 #      conditionals against.
 706 # $2 - Optional prefix for each variable defined.
 707 # $3 - Optional prefix for compiler variables (either BUILD_ or nothing).
 708 AC_DEFUN([FLAGS_SETUP_CFLAGS_CPU_DEP],
 709 [
 710   #### CPU DEFINES, these should (in theory) be independent on toolchain
 711 
 712   # Setup target CPU
 713   # Setup endianness
 714   if test "x$FLAGS_CPU_ENDIAN" = xlittle; then
 715     $1_DEFINES_CPU_JVM="-DVM_LITTLE_ENDIAN"
 716   fi
 717   if test "x$TOOLCHAIN_TYPE" = xsolstudio; then
 718     # The macro _LITTLE_ENDIAN needs to be defined the same to avoid the
 719     #   Sun C compiler warning message: warning: macro redefined: _LITTLE_ENDIAN
 720     if test "x$FLAGS_CPU_ENDIAN" = xlittle; then
 721       $1_DEFINES_CPU_JDK="-D_LITTLE_ENDIAN="
 722     else
 723       $1_DEFINES_CPU_JDK="-D_BIG_ENDIAN="
 724     fi
 725   else
 726     if test "x$FLAGS_CPU_ENDIAN" = xlittle; then
 727       $1_DEFINES_CPU_JDK="-D_LITTLE_ENDIAN"


 777     elif test "x$FLAGS_CPU_ARCH" = xppc; then
 778       $1_CFLAGS_CPU_JVM="-minsert-sched-nops=regroup_exact -mno-multiple -mno-string"
 779       if test "x$FLAGS_CPU" = xppc64; then
 780         # -mminimal-toc fixes `relocation truncated to fit' error for gcc 4.1.
 781         # Use ppc64 instructions, but schedule for power5
 782         $1_CFLAGS_CPU_JVM="${$1_CFLAGS_CPU_JVM} -mminimal-toc -mcpu=powerpc64 -mtune=power5"
 783       elif test "x$FLAGS_CPU" = xppc64le; then
 784         # Little endian machine uses ELFv2 ABI.
 785         # Use Power8, this is the first CPU to support PPC64 LE with ELFv2 ABI.
 786         $1_CFLAGS_CPU_JVM="${$1_CFLAGS_CPU_JVM} -DABI_ELFv2 -mcpu=power8 -mtune=power8"
 787       fi
 788     elif test "x$FLAGS_CPU" = xs390x; then
 789       $1_CFLAGS_CPU="-mbackchain -march=z10"
 790     fi
 791 
 792     if test "x$FLAGS_CPU_ARCH" != xarm &&  test "x$FLAGS_CPU_ARCH" != xppc; then
 793       # for all archs except arm and ppc, prevent gcc to omit frame pointer
 794       $1_CFLAGS_CPU_JDK="${$1_CFLAGS_CPU_JDK} -fno-omit-frame-pointer"
 795     fi
 796 
 797     $1_CXXSTD_CXXFLAG="-std=gnu++98"
 798     FLAGS_CXX_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [${$1_CXXSTD_CXXFLAG} -Werror],
 799         PREFIX: $3, IF_FALSE: [$1_CXXSTD_CXXFLAG=""])
 800     $1_TOOLCHAIN_CFLAGS_JDK_CXXONLY="${$1_CXXSTD_CXXFLAG}"
 801     $1_TOOLCHAIN_CFLAGS_JVM="${$1_TOOLCHAIN_CFLAGS_JVM} ${$1_CXXSTD_CXXFLAG}"
 802     $2ADLC_CXXFLAG="${$1_CXXSTD_CXXFLAG}"
 803 
 804   elif test "x$TOOLCHAIN_TYPE" = xclang; then
 805     if test "x$FLAGS_OS" = xlinux; then
 806       # ppc test not really needed for clang
 807       if test "x$FLAGS_CPU_ARCH" != xarm &&  test "x$FLAGS_CPU_ARCH" != xppc; then
 808         # for all archs except arm and ppc, prevent gcc to omit frame pointer
 809         $1_CFLAGS_CPU_JDK="${$1_CFLAGS_CPU_JDK} -fno-omit-frame-pointer"
 810       fi
 811     fi
 812 
 813   elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
 814     if test "x$FLAGS_CPU" = xx86_64; then
 815       # NOTE: -xregs=no%frameptr is supposed to be default on x64
 816       $1_CFLAGS_CPU_JDK="-xregs=no%frameptr"
 817     elif test "x$FLAGS_CPU" = xsparcv9; then
 818       $1_CFLAGS_CPU_JVM="-xarch=sparc"
 819       $1_CFLAGS_CPU_JDK_LIBONLY="-xregs=no%appl"
 820     fi
 821 
 822   elif test "x$TOOLCHAIN_TYPE" = xxlc; then
 823     if test "x$FLAGS_CPU" = xppc64; then
 824       $1_CFLAGS_CPU_JVM="-qarch=ppc64"
 825     fi
 826 
 827   elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
 828     if test "x$FLAGS_CPU" = xx86; then
 829       $1_CFLAGS_CPU_JVM="-arch:IA32"
 830     elif test "x$OPENJDK_TARGET_CPU" = xx86_64; then
 831       if test "x$DEBUG_LEVEL" != xrelease; then
 832         # NOTE: This is probably redundant; -homeparams is default on
 833         # non-release builds.
 834         $1_CFLAGS_CPU_JVM="-homeparams"
 835       fi
 836     fi
 837   fi
 838 
 839   if test "x$TOOLCHAIN_TYPE" = xgcc; then
 840     FLAGS_SETUP_GCC6_COMPILER_FLAGS($1, $3)
 841     $1_TOOLCHAIN_CFLAGS="${$1_GCC6_CFLAGS}"
 842 
 843     $1_WARNING_CFLAGS_JVM="-Wno-format-zero-length -Wtype-limits -Wuninitialized"
 844   fi
 845 
 846   if test "x$TOOLCHAIN_TYPE" = xgcc || test "x$TOOLCHAIN_TYPE" = xclang; then
 847     # Check if compiler supports -fmacro-prefix-map. If so, use that to make
 848     # the __FILE__ macro resolve to paths relative to the workspace root.
 849     workspace_root_trailing_slash="${WORKSPACE_ROOT%/}/"
 850     FILE_MACRO_CFLAGS="-fmacro-prefix-map=${workspace_root_trailing_slash}="
 851     FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [${FILE_MACRO_CFLAGS}],
 852         PREFIX: $3,
 853         IF_FALSE: [
 854             FILE_MACRO_CFLAGS=
 855         ]
 856     )
 857   fi
 858 
 859   # EXPORT to API
 860   CFLAGS_JVM_COMMON="$ALWAYS_CFLAGS_JVM $ALWAYS_DEFINES_JVM \
 861       $TOOLCHAIN_CFLAGS_JVM ${$1_TOOLCHAIN_CFLAGS_JVM} \
 862       $OS_CFLAGS $OS_CFLAGS_JVM $CFLAGS_OS_DEF_JVM $DEBUG_CFLAGS_JVM \
 863       $WARNING_CFLAGS $WARNING_CFLAGS_JVM $JVM_PICFLAG $FILE_MACRO_CFLAGS"
 864 
 865   CFLAGS_JDK_COMMON="$ALWAYS_CFLAGS_JDK $ALWAYS_DEFINES_JDK $TOOLCHAIN_CFLAGS_JDK \
 866       $OS_CFLAGS $CFLAGS_OS_DEF_JDK $DEBUG_CFLAGS_JDK $DEBUG_OPTIONS_FLAGS_JDK \
 867       $WARNING_CFLAGS $WARNING_CFLAGS_JDK $DEBUG_SYMBOLS_CFLAGS_JDK \
 868       $FILE_MACRO_CFLAGS"
 869 
 870   # Use ${$2EXTRA_CFLAGS} to block EXTRA_CFLAGS to be added to build flags.
 871   # (Currently we don't have any OPENJDK_BUILD_EXTRA_CFLAGS, but that might
 872   # change in the future.)
 873 
 874   CFLAGS_JDK_COMMON_CONLY="$TOOLCHAIN_CFLAGS_JDK_CONLY  \
 875       $WARNING_CFLAGS_JDK_CONLY ${$2EXTRA_CFLAGS}"
 876   CFLAGS_JDK_COMMON_CXXONLY="$ALWAYS_DEFINES_JDK_CXXONLY \
 877       $TOOLCHAIN_CFLAGS_JDK_CXXONLY \
 878       ${$1_TOOLCHAIN_CFLAGS_JDK_CXXONLY} \
 879       $WARNING_CFLAGS_JDK_CXXONLY ${$2EXTRA_CXXFLAGS}"
 880 
 881   $1_CFLAGS_JVM="${$1_DEFINES_CPU_JVM} ${$1_CFLAGS_CPU} ${$1_CFLAGS_CPU_JVM} ${$1_TOOLCHAIN_CFLAGS} ${$1_WARNING_CFLAGS_JVM}"
 882   $1_CFLAGS_JDK="${$1_DEFINES_CPU_JDK} ${$1_CFLAGS_CPU} ${$1_CFLAGS_CPU_JDK} ${$1_TOOLCHAIN_CFLAGS}"
 883 
 884   $2JVM_CFLAGS="$CFLAGS_JVM_COMMON ${$1_CFLAGS_JVM} ${$2EXTRA_CXXFLAGS}"
 885 
 886   $2CFLAGS_JDKEXE="$CFLAGS_JDK_COMMON $CFLAGS_JDK_COMMON_CONLY ${$1_CFLAGS_JDK}"
 887   $2CXXFLAGS_JDKEXE="$CFLAGS_JDK_COMMON $CFLAGS_JDK_COMMON_CXXONLY ${$1_CFLAGS_JDK}"
 888   $2CFLAGS_JDKLIB="${$2CFLAGS_JDKEXE} $JDK_PICFLAG ${$1_CFLAGS_CPU_JDK_LIBONLY}"
 889   $2CXXFLAGS_JDKLIB="${$2CXXFLAGS_JDKEXE} $JDK_PICFLAG ${$1_CFLAGS_CPU_JDK_LIBONLY}"
 890 
 891   AC_SUBST($2JVM_CFLAGS)
 892   AC_SUBST($2CFLAGS_JDKLIB)
 893   AC_SUBST($2CFLAGS_JDKEXE)
 894   AC_SUBST($2CXXFLAGS_JDKLIB)
 895   AC_SUBST($2CXXFLAGS_JDKEXE)
 896   AC_SUBST($2ADLC_CXXFLAG)
 897 
 898   COMPILER_FP_CONTRACT_OFF_FLAG="-ffp-contract=off"
 899   # Check that the compiler supports -ffp-contract=off flag
 900   # Set FDLIBM_CFLAGS to -ffp-contract=off if it does. Empty
 901   # otherwise.
 902   # These flags are required for GCC-based builds of
 903   # fdlibm with optimization without losing precision.
 904   # Notably, -ffp-contract=off needs to be added for GCC >= 4.6.
 905   if test "x$TOOLCHAIN_TYPE" = xgcc || test "x$TOOLCHAIN_TYPE" = xclang; then
 906     FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [${COMPILER_FP_CONTRACT_OFF_FLAG}],
 907         PREFIX: $3,
 908         IF_TRUE: [$2FDLIBM_CFLAGS=${COMPILER_FP_CONTRACT_OFF_FLAG}],
 909         IF_FALSE: [$2FDLIBM_CFLAGS=""])
 910   fi
 911   AC_SUBST($2FDLIBM_CFLAGS)
 912 ])
 913 
 914 # FLAGS_SETUP_GCC6_COMPILER_FLAGS([PREFIX])
 915 # Arguments:
 916 # $1 - Prefix for each variable defined.
 917 # $2 - Prefix for compiler variables (either BUILD_ or nothing).
 918 AC_DEFUN([FLAGS_SETUP_GCC6_COMPILER_FLAGS],
 919 [
 920   # These flags are required for GCC 6 builds as undefined behaviour in OpenJDK code
 921   # runs afoul of the more aggressive versions of these optimisations.
 922   # Notably, value range propagation now assumes that the this pointer of C++
 923   # member functions is non-null.
 924   NO_DELETE_NULL_POINTER_CHECKS_CFLAG="-fno-delete-null-pointer-checks"
 925   FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [$NO_DELETE_NULL_POINTER_CHECKS_CFLAG -Werror],
 926       PREFIX: $2, IF_FALSE: [NO_DELETE_NULL_POINTER_CHECKS_CFLAG=""])

 927   NO_LIFETIME_DSE_CFLAG="-fno-lifetime-dse"
 928   FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [$NO_LIFETIME_DSE_CFLAG -Werror],
 929       PREFIX: $2, IF_FALSE: [NO_LIFETIME_DSE_CFLAG=""])


 930   $1_GCC6_CFLAGS="${NO_DELETE_NULL_POINTER_CHECKS_CFLAG} ${NO_LIFETIME_DSE_CFLAG}"
 931 ])
 932 
 933 # Documentation on common flags used for solstudio in HIGHEST.
 934 #
 935 # WARNING: Use of OPTIMIZATION_LEVEL=HIGHEST in your Makefile needs to be
 936 #          done with care, there are some assumptions below that need to
 937 #          be understood about the use of pointers, and IEEE behavior.
 938 #
 939 # -fns: Use non-standard floating point mode (not IEEE 754)
 940 # -fsimple: Do some simplification of floating point arithmetic (not IEEE 754)
 941 # -fsingle: Use single precision floating point with 'float'
 942 # -xalias_level=basic: Assume memory references via basic pointer types do not alias
 943 #   (Source with excessing pointer casting and data access with mixed
 944 #    pointer types are not recommended)
 945 # -xbuiltin=%all: Use intrinsic or inline versions for math/std functions
 946 #   (If you expect perfect errno behavior, do not use this)
 947 # -xdepend: Loop data dependency optimizations (need -xO3 or higher)
 948 # -xrestrict: Pointer parameters to functions do not overlap
 949 #   (Similar to -xalias_level=basic usage, but less obvious sometimes.
   1 #
   2 # Copyright (c) 2011, 2018, 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


 104   AC_SUBST(SHARED_LIBRARY_FLAGS)
 105 ])
 106 
 107 AC_DEFUN([FLAGS_SETUP_DEBUG_SYMBOLS],
 108 [
 109   # By default don't set any specific assembler debug
 110   # info flags for toolchains unless we know they work.
 111   # See JDK-8207057.
 112   ASFLAGS_DEBUG_SYMBOLS=""
 113   # Debug symbols
 114   if test "x$TOOLCHAIN_TYPE" = xgcc; then
 115     CFLAGS_DEBUG_SYMBOLS="-g"
 116     ASFLAGS_DEBUG_SYMBOLS="-g"
 117   elif test "x$TOOLCHAIN_TYPE" = xclang; then
 118     CFLAGS_DEBUG_SYMBOLS="-g"
 119     ASFLAGS_DEBUG_SYMBOLS="-g"
 120   elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
 121     # -g0 enables debug symbols without disabling inlining.
 122     CFLAGS_DEBUG_SYMBOLS="-g0 -xs"
 123   elif test "x$TOOLCHAIN_TYPE" = xxlc; then
 124     CFLAGS_DEBUG_SYMBOLS="-g"




 125   elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
 126     CFLAGS_DEBUG_SYMBOLS="-Z7 -d2Zi+"
 127   fi
 128 
 129   AC_SUBST(CFLAGS_DEBUG_SYMBOLS)
 130   AC_SUBST(ASFLAGS_DEBUG_SYMBOLS)
 131 ])
 132 
 133 AC_DEFUN([FLAGS_SETUP_WARNINGS],
 134 [
 135   AC_ARG_ENABLE([warnings-as-errors], [AS_HELP_STRING([--disable-warnings-as-errors],
 136       [do not consider native warnings to be an error @<:@enabled@:>@])])
 137 
 138   # Set default value.
 139   if test "x$TOOLCHAIN_TYPE" = xxlc; then
 140     WARNINGS_AS_ERRORS=false
 141   else
 142     WARNINGS_AS_ERRORS=true
 143   fi
 144 


 166       DISABLED_WARNINGS="4800"
 167       ;;
 168 
 169     solstudio)
 170       DISABLE_WARNING_PREFIX="-erroff="
 171       CFLAGS_WARNINGS_ARE_ERRORS="-errwarn=%all"
 172 
 173       WARNINGS_ENABLE_ALL_CFLAGS="-v"
 174       WARNINGS_ENABLE_ALL_CXXFLAGS="+w"
 175 
 176       DISABLED_WARNINGS_C=""
 177       DISABLED_WARNINGS_CXX=""
 178       ;;
 179 
 180     gcc)
 181       DISABLE_WARNING_PREFIX="-Wno-"
 182       CFLAGS_WARNINGS_ARE_ERRORS="-Werror"
 183 
 184       # Additional warnings that are not activated by -Wall and -Wextra
 185       WARNINGS_ENABLE_ADDITIONAL="-Wpointer-arith -Wsign-compare \
 186           -Wunused-function -Wundef -Wunused-value -Wreturn-type"

 187       WARNINGS_ENABLE_ADDITIONAL_CXX="-Woverloaded-virtual -Wreorder"
 188       WARNINGS_ENABLE_ALL_CFLAGS="-Wall -Wextra -Wformat=2 $WARNINGS_ENABLE_ADDITIONAL"
 189       WARNINGS_ENABLE_ALL_CXXFLAGS="$WARNINGS_ENABLE_ALL_CFLAGS $WARNINGS_ENABLE_ADDITIONAL_CXX"
 190 
 191       DISABLED_WARNINGS="unused-parameter unused"
 192 
 193       # Repeate the check for the BUILD_CC and BUILD_CXX. Need to also reset
 194       # CFLAGS since any target specific flags will likely not work with the
 195       # build compiler
 196       CC_OLD="$CC"
 197       CXX_OLD="$CXX"
 198       CC="$BUILD_CC"
 199       CXX="$BUILD_CXX"
 200       CFLAGS_OLD="$CFLAGS"
 201       CFLAGS=""
 202       BUILD_CC_DISABLE_WARNING_PREFIX="-Wno-"
 203       CC="$CC_OLD"
 204       CXX="$CXX_OLD"
 205       CFLAGS="$CFLAGS_OLD"
 206       ;;
 207 
 208     clang)
 209       DISABLE_WARNING_PREFIX="-Wno-"
 210       CFLAGS_WARNINGS_ARE_ERRORS="-Werror"
 211 
 212       # Additional warnings that are not activated by -Wall and -Wextra
 213       WARNINGS_ENABLE_ADDITIONAL="-Wpointer-arith -Wsign-compare -Wreorder \
 214           -Wunused-function -Wundef -Wunused-value -Woverloaded-virtual"
 215       WARNINGS_ENABLE_ALL="-Wall -Wextra -Wformat=2 $WARNINGS_ENABLE_ADDITIONAL"
 216 
 217       DISABLED_WARNINGS="unused-parameter unused"
 218 
 219       if test "x$OPENJDK_TARGET_OS" = xmacosx; then
 220         # missing-method-return-type triggers in JavaNativeFoundation framework
 221         DISABLED_WARNINGS="$DISABLED_WARNINGS missing-method-return-type"
 222       fi
 223 
 224       ;;
 225 
 226     xlc)
 227       DISABLE_WARNING_PREFIX="-qsuppress="
 228       CFLAGS_WARNINGS_ARE_ERRORS="-qhalt=w"
 229 
 230       # Possibly a better subset than "all" is "lan:trx:ret:zea:cmp:ret"
 231       WARNINGS_ENABLE_ALL="-qinfo=all -qformat=all"
 232       DISABLED_WARNINGS=""
 233       ;;
 234   esac
 235   AC_SUBST(DISABLE_WARNING_PREFIX)
 236   AC_SUBST(BUILD_CC_DISABLE_WARNING_PREFIX)
 237   AC_SUBST(CFLAGS_WARNINGS_ARE_ERRORS)


 278     C_O_FLAG_NONE=""
 279     if test "x$OPENJDK_TARGET_CPU_ARCH" = "xx86"; then
 280       C_O_FLAG_HIGHEST="-xO4 -Wu,-O4~yz $CC_HIGHEST"
 281       C_O_FLAG_HI="-xO4 -Wu,-O4~yz"
 282       C_O_FLAG_NORM="-xO2 -Wu,-O2~yz"
 283     elif test "x$OPENJDK_TARGET_CPU_ARCH" = "xsparc"; then
 284       C_O_FLAG_HIGHEST="-xO4 -Wc,-Qrm-s -Wc,-Qiselect-T0 \
 285           -xprefetch=auto,explicit $CC_HIGHEST"
 286       C_O_FLAG_HI="-xO4 -Wc,-Qrm-s -Wc,-Qiselect-T0"
 287       C_O_FLAG_NORM="-xO2 -Wc,-Qrm-s -Wc,-Qiselect-T0"
 288     fi
 289   elif test "x$TOOLCHAIN_TYPE" = xgcc; then
 290     C_O_FLAG_HIGHEST_JVM="-O3"
 291     C_O_FLAG_HIGHEST="-O3"
 292     C_O_FLAG_HI="-O3"
 293     C_O_FLAG_NORM="-O2"
 294     C_O_FLAG_SIZE="-Os"
 295     C_O_FLAG_DEBUG="-O0"
 296     C_O_FLAG_DEBUG_JVM="-O0"
 297     C_O_FLAG_NONE="-O0"














 298   elif test "x$TOOLCHAIN_TYPE" = xclang; then
 299     if test "x$OPENJDK_TARGET_OS" = xmacosx; then
 300       # On MacOSX we optimize for size, something
 301       # we should do for all platforms?
 302       C_O_FLAG_HIGHEST_JVM="-Os"
 303       C_O_FLAG_HIGHEST="-Os"
 304       C_O_FLAG_HI="-Os"
 305       C_O_FLAG_NORM="-Os"
 306       C_O_FLAG_DEBUG_JVM=""
 307     else
 308       C_O_FLAG_HIGHEST_JVM="-O3"
 309       C_O_FLAG_HIGHEST="-O3"
 310       C_O_FLAG_HI="-O3"
 311       C_O_FLAG_NORM="-O2"
 312       C_O_FLAG_DEBUG_JVM="-O0"
 313     fi
 314     C_O_FLAG_SIZE="-Os"
 315     C_O_FLAG_DEBUG="-O0"
 316     C_O_FLAG_NONE="-O0"
 317   elif test "x$TOOLCHAIN_TYPE" = xxlc; then


 397   FLAGS_OS=$OPENJDK_TARGET_OS
 398   FLAGS_OS_TYPE=$OPENJDK_TARGET_OS_TYPE
 399   FLAGS_CPU=$OPENJDK_TARGET_CPU
 400   FLAGS_CPU_ARCH=$OPENJDK_TARGET_CPU_ARCH
 401   FLAGS_CPU_BITS=$OPENJDK_TARGET_CPU_BITS
 402   FLAGS_CPU_ENDIAN=$OPENJDK_TARGET_CPU_ENDIAN
 403   FLAGS_CPU_LEGACY=$OPENJDK_TARGET_CPU_LEGACY
 404   FLAGS_CPU_LEGACY_LIB=$OPENJDK_TARGET_CPU_LEGACY_LIB
 405 
 406   FLAGS_SETUP_CFLAGS_CPU_DEP([TARGET])
 407 
 408   FLAGS_OS=$OPENJDK_BUILD_OS
 409   FLAGS_OS_TYPE=$OPENJDK_BUILD_OS_TYPE
 410   FLAGS_CPU=$OPENJDK_BUILD_CPU
 411   FLAGS_CPU_ARCH=$OPENJDK_BUILD_CPU_ARCH
 412   FLAGS_CPU_BITS=$OPENJDK_BUILD_CPU_BITS
 413   FLAGS_CPU_ENDIAN=$OPENJDK_BUILD_CPU_ENDIAN
 414   FLAGS_CPU_LEGACY=$OPENJDK_BUILD_CPU_LEGACY
 415   FLAGS_CPU_LEGACY_LIB=$OPENJDK_BUILD_CPU_LEGACY_LIB
 416 
 417   FLAGS_SETUP_CFLAGS_CPU_DEP([BUILD], [OPENJDK_BUILD_])
 418 
 419   COMPILER_FP_CONTRACT_OFF_FLAG="-ffp-contract=off"
 420   # Check that the compiler supports -ffp-contract=off flag
 421   # Set FDLIBM_CFLAGS to -ffp-contract=off if it does. Empty
 422   # otherwise.
 423   # These flags are required for GCC-based builds of
 424   # fdlibm with optimization without losing precision.
 425   # Notably, -ffp-contract=off needs to be added for GCC >= 4.6.
 426   if test "x$TOOLCHAIN_TYPE" = xgcc || test "x$TOOLCHAIN_TYPE" = xclang; then
 427     FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [${COMPILER_FP_CONTRACT_OFF_FLAG}],
 428         IF_TRUE: [FDLIBM_CFLAGS=${COMPILER_FP_CONTRACT_OFF_FLAG}],
 429         IF_FALSE: [FDLIBM_CFLAGS=""])
 430   fi
 431   AC_SUBST(FDLIBM_CFLAGS)
 432 ])
 433 
 434 ################################################################################
 435 # platform independent
 436 AC_DEFUN([FLAGS_SETUP_CFLAGS_HELPER],
 437 [
 438   #### OS DEFINES, these should be independent on toolchain
 439   if test "x$OPENJDK_TARGET_OS" = xlinux; then
 440     CFLAGS_OS_DEF_JVM="-DLINUX"
 441     CFLAGS_OS_DEF_JDK="-D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE"
 442   elif test "x$OPENJDK_TARGET_OS" = xsolaris; then
 443     CFLAGS_OS_DEF_JVM="-DSOLARIS"
 444     CFLAGS_OS_DEF_JDK="-D__solaris__"
 445   elif test "x$OPENJDK_TARGET_OS" = xmacosx; then
 446     CFLAGS_OS_DEF_JVM="-D_ALLBSD_SOURCE -D_DARWIN_C_SOURCE -D_XOPEN_SOURCE"
 447     CFLAGS_OS_DEF_JDK="-D_ALLBSD_SOURCE -D_DARWIN_UNLIMITED_SELECT"
 448   elif test "x$OPENJDK_TARGET_OS" = xaix; then
 449     CFLAGS_OS_DEF_JVM="-DAIX"
 450   elif test "x$OPENJDK_TARGET_OS" = xbsd; then
 451     CFLAGS_OS_DEF_JDK="-D_ALLBSD_SOURCE"


 509   elif test "x$TOOLCHAIN_TYPE" = xxlc; then
 510     ALWAYS_DEFINES_JVM="-D_REENTRANT"
 511     ALWAYS_DEFINES_JDK="-D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE -DSTDC"
 512   elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
 513     ALWAYS_DEFINES_JDK="-DWIN32_LEAN_AND_MEAN -D_CRT_SECURE_NO_DEPRECATE \
 514         -D_CRT_NONSTDC_NO_DEPRECATE -DWIN32 -DIAL"
 515     ALWAYS_DEFINES_JVM="-DNOMINMAX -DWIN32_LEAN_AND_MEAN"
 516   fi
 517 
 518   ###############################################################################
 519   #
 520   #
 521   # CFLAGS BASIC
 522   if test "x$TOOLCHAIN_TYPE" = xgcc || test "x$TOOLCHAIN_TYPE" = xclang; then
 523     # COMMON to gcc and clang
 524     TOOLCHAIN_CFLAGS_JVM="-pipe -fno-rtti -fno-exceptions \
 525         -fvisibility=hidden -fno-strict-aliasing -fno-omit-frame-pointer"
 526   fi
 527 
 528   if test "x$TOOLCHAIN_TYPE" = xgcc; then
 529     TOOLCHAIN_CFLAGS_JVM="$TOOLCHAIN_CFLAGS_JVM -fcheck-new"
 530     TOOLCHAIN_CFLAGS_JDK="-pipe"
 531     TOOLCHAIN_CFLAGS_JDK_CONLY="-fno-strict-aliasing" # technically NOT for CXX (but since this gives *worse* performance, use no-strict-aliasing everywhere!)
 532 
 533     CXXSTD_CXXFLAG="-std=gnu++98"
 534     FLAGS_CXX_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [$CXXSTD_CXXFLAG -Werror],
 535                                                  IF_FALSE: [CXXSTD_CXXFLAG=""])
 536     TOOLCHAIN_CFLAGS_JDK_CXXONLY="$CXXSTD_CXXFLAG"
 537     TOOLCHAIN_CFLAGS_JVM="$TOOLCHAIN_CFLAGS_JVM $CXXSTD_CXXFLAG"
 538     ADLC_CXXFLAG="$CXXSTD_CXXFLAG"
 539 
 540 
 541   elif test "x$TOOLCHAIN_TYPE" = xclang; then
 542     # Restrict the debug information created by Clang to avoid
 543     # too big object files and speed the build up a little bit
 544     # (see http://llvm.org/bugs/show_bug.cgi?id=7554)
 545     TOOLCHAIN_CFLAGS_JVM="$TOOLCHAIN_CFLAGS_JVM -flimit-debug-info"
 546 
 547     # In principle the stack alignment below is cpu- and ABI-dependent and
 548     # should agree with values of StackAlignmentInBytes in various
 549     # src/hotspot/cpu/*/globalDefinitions_*.hpp files, but this value currently
 550     # works for all platforms.
 551     TOOLCHAIN_CFLAGS_JVM="$TOOLCHAIN_CFLAGS_JVM -mno-omit-leaf-frame-pointer -mstack-alignment=16"
 552 
 553     if test "x$OPENJDK_TARGET_OS" = xlinux; then






 554       TOOLCHAIN_CFLAGS_JDK="-pipe"
 555       TOOLCHAIN_CFLAGS_JDK_CONLY="-fno-strict-aliasing" # technically NOT for CXX
 556     fi
 557   elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
 558     TOOLCHAIN_FLAGS="-errtags -errfmt"
 559     TOOLCHAIN_CFLAGS="-errshort=tags"
 560 
 561     TOOLCHAIN_CFLAGS_JDK="-mt $TOOLCHAIN_FLAGS"
 562     TOOLCHAIN_CFLAGS_JDK_CONLY="-xc99=%none -xCC -Xa -W0,-noglobal $TOOLCHAIN_CFLAGS" # C only
 563     TOOLCHAIN_CFLAGS_JDK_CXXONLY="-features=no%except -norunpath -xnolib" # CXX only
 564     TOOLCHAIN_CFLAGS_JVM="-template=no%extdef -features=no%split_init \
 565         -library=stlport4 -mt -features=no%except $TOOLCHAIN_FLAGS"
 566     if test "x$DEBUG_LEVEL" = xslowdebug; then
 567       # Previously -g was used instead of -g0 for slowdebug; this is equivalent
 568       # to setting +d.
 569       TOOLCHAIN_CFLAGS_JVM="$TOOLCHAIN_CFLAGS_JVM +d"
 570     fi
 571 
 572   elif test "x$TOOLCHAIN_TYPE" = xxlc; then
 573     # Suggested additions: -qsrcmsg to get improved error reporting
 574     TOOLCHAIN_CFLAGS_JDK="-qchars=signed -qfullpath -qsaveopt"  # add on both CFLAGS
 575     TOOLCHAIN_CFLAGS_JVM="-qtune=balanced \
 576         -qalias=noansi -qstrict -qtls=default -qlanglvl=c99vla \
 577         -qlanglvl=noredefmac -qnortti -qnoeh -qignerrno"
 578   elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
 579     TOOLCHAIN_CFLAGS_JVM="-nologo -MD -MP"
 580     TOOLCHAIN_CFLAGS_JDK="-nologo -MD -Zc:wchar_t-"
 581   fi
 582 
























 583   # CFLAGS WARNINGS STUFF
 584   # Set JVM_CFLAGS warning handling
 585   if test "x$TOOLCHAIN_TYPE" = xgcc; then
 586     WARNING_CFLAGS_JDK_CONLY="$WARNINGS_ENABLE_ALL_CFLAGS"
 587     WARNING_CFLAGS_JDK_CXXONLY="$WARNINGS_ENABLE_ALL_CXXFLAGS"
 588     WARNING_CFLAGS_JVM="$WARNINGS_ENABLE_ALL_CXXFLAGS"
 589 
 590   elif test "x$TOOLCHAIN_TYPE" = xclang; then
 591     WARNING_CFLAGS="$WARNINGS_ENABLE_ALL"
 592 
 593   elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
 594     WARNING_CFLAGS_JDK_CONLY="$WARNINGS_ENABLE_ALL_CFLAGS"
 595     WARNING_CFLAGS_JDK_CXXONLY="$WARNINGS_ENABLE_ALL_CXXFLAGS"
 596     WARNING_CFLAGS_JVM="$WARNINGS_ENABLE_ALL_CXXFLAGS"
 597 
 598   elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
 599     WARNING_CFLAGS="$WARNINGS_ENABLE_ALL"
 600 
 601   elif test "x$TOOLCHAIN_TYPE" = xxlc; then
 602     WARNING_CFLAGS=""  # currently left empty


 652   fi
 653 
 654   # Optional POSIX functionality needed by the JVM
 655   #
 656   # Check if clock_gettime is available and in which library. This indicates
 657   # availability of CLOCK_MONOTONIC for hotspot. But we don't need to link, so
 658   # don't let it update LIBS.
 659   save_LIBS="$LIBS"
 660   AC_SEARCH_LIBS(clock_gettime, rt, [HAS_CLOCK_GETTIME=true], [])
 661   if test "x$LIBS" = "x-lrt "; then
 662     CLOCK_GETTIME_IN_LIBRT=true
 663   fi
 664   LIBS="$save_LIBS"
 665 
 666   if test "x$HAS_CLOCK_GETTIME" = "xtrue"; then
 667     OS_CFLAGS_JVM="$OS_CFLAGS_JVM -DSUPPORTS_CLOCK_MONOTONIC"
 668     if test "x$CLOCK_GETTIME_IN_LIBRT" = "xtrue"; then
 669       OS_CFLAGS_JVM="$OS_CFLAGS_JVM -DNEEDS_LIBRT"
 670     fi
 671   fi
 672 
 673   # EXPORT
 674   AC_SUBST(ADLC_CXXFLAG)
 675 ])
 676 
 677 ################################################################################
 678 # $1 - Either BUILD or TARGET to pick the correct OS/CPU variables to check
 679 #      conditionals against.
 680 # $2 - Optional prefix for each variable defined.

 681 AC_DEFUN([FLAGS_SETUP_CFLAGS_CPU_DEP],
 682 [
 683   #### CPU DEFINES, these should (in theory) be independent on toolchain
 684 
 685   # Setup target CPU
 686   # Setup endianness
 687   if test "x$FLAGS_CPU_ENDIAN" = xlittle; then
 688     $1_DEFINES_CPU_JVM="-DVM_LITTLE_ENDIAN"
 689   fi
 690   if test "x$TOOLCHAIN_TYPE" = xsolstudio; then
 691     # The macro _LITTLE_ENDIAN needs to be defined the same to avoid the
 692     #   Sun C compiler warning message: warning: macro redefined: _LITTLE_ENDIAN
 693     if test "x$FLAGS_CPU_ENDIAN" = xlittle; then
 694       $1_DEFINES_CPU_JDK="-D_LITTLE_ENDIAN="
 695     else
 696       $1_DEFINES_CPU_JDK="-D_BIG_ENDIAN="
 697     fi
 698   else
 699     if test "x$FLAGS_CPU_ENDIAN" = xlittle; then
 700       $1_DEFINES_CPU_JDK="-D_LITTLE_ENDIAN"


 750     elif test "x$FLAGS_CPU_ARCH" = xppc; then
 751       $1_CFLAGS_CPU_JVM="-minsert-sched-nops=regroup_exact -mno-multiple -mno-string"
 752       if test "x$FLAGS_CPU" = xppc64; then
 753         # -mminimal-toc fixes `relocation truncated to fit' error for gcc 4.1.
 754         # Use ppc64 instructions, but schedule for power5
 755         $1_CFLAGS_CPU_JVM="${$1_CFLAGS_CPU_JVM} -mminimal-toc -mcpu=powerpc64 -mtune=power5"
 756       elif test "x$FLAGS_CPU" = xppc64le; then
 757         # Little endian machine uses ELFv2 ABI.
 758         # Use Power8, this is the first CPU to support PPC64 LE with ELFv2 ABI.
 759         $1_CFLAGS_CPU_JVM="${$1_CFLAGS_CPU_JVM} -DABI_ELFv2 -mcpu=power8 -mtune=power8"
 760       fi
 761     elif test "x$FLAGS_CPU" = xs390x; then
 762       $1_CFLAGS_CPU="-mbackchain -march=z10"
 763     fi
 764 
 765     if test "x$FLAGS_CPU_ARCH" != xarm &&  test "x$FLAGS_CPU_ARCH" != xppc; then
 766       # for all archs except arm and ppc, prevent gcc to omit frame pointer
 767       $1_CFLAGS_CPU_JDK="${$1_CFLAGS_CPU_JDK} -fno-omit-frame-pointer"
 768     fi
 769 







 770   elif test "x$TOOLCHAIN_TYPE" = xclang; then
 771     if test "x$FLAGS_OS" = xlinux; then
 772       # ppc test not really needed for clang
 773       if test "x$FLAGS_CPU_ARCH" != xarm &&  test "x$FLAGS_CPU_ARCH" != xppc; then
 774         # for all archs except arm and ppc, prevent gcc to omit frame pointer
 775         $1_CFLAGS_CPU_JDK="${$1_CFLAGS_CPU_JDK} -fno-omit-frame-pointer"
 776       fi
 777     fi
 778 
 779   elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
 780     if test "x$FLAGS_CPU" = xx86_64; then
 781       # NOTE: -xregs=no%frameptr is supposed to be default on x64
 782       $1_CFLAGS_CPU_JDK="-xregs=no%frameptr"
 783     elif test "x$FLAGS_CPU" = xsparcv9; then
 784       $1_CFLAGS_CPU_JVM="-xarch=sparc"
 785       $1_CFLAGS_CPU_JDK_LIBONLY="-xregs=no%appl"
 786     fi
 787 
 788   elif test "x$TOOLCHAIN_TYPE" = xxlc; then
 789     if test "x$FLAGS_CPU" = xppc64; then
 790       $1_CFLAGS_CPU_JVM="-qarch=ppc64"
 791     fi
 792 
 793   elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
 794     if test "x$FLAGS_CPU" = xx86; then
 795       $1_CFLAGS_CPU_JVM="-arch:IA32"
 796     elif test "x$OPENJDK_TARGET_CPU" = xx86_64; then
 797       if test "x$DEBUG_LEVEL" != xrelease; then
 798         # NOTE: This is probably redundant; -homeparams is default on
 799         # non-release builds.
 800         $1_CFLAGS_CPU_JVM="-homeparams"
 801       fi
 802     fi
 803   fi
 804 
 805   if test "x$TOOLCHAIN_TYPE" = xgcc; then
 806     TOOLCHAIN_CHECK_COMPILER_VERSION(VERSION: 6, PREFIX: $2, IF_AT_LEAST: FLAGS_SETUP_GCC6_COMPILER_FLAGS($1))
 807     $1_TOOLCHAIN_CFLAGS="${$1_GCC6_CFLAGS}"
 808 
 809     $1_WARNING_CFLAGS_JVM="-Wno-format-zero-length -Wtype-limits -Wuninitialized"
 810   fi
 811 













 812   # EXPORT to API
 813   CFLAGS_JVM_COMMON="$ALWAYS_CFLAGS_JVM $ALWAYS_DEFINES_JVM $TOOLCHAIN_CFLAGS_JVM \

 814       $OS_CFLAGS $OS_CFLAGS_JVM $CFLAGS_OS_DEF_JVM $DEBUG_CFLAGS_JVM \
 815       $WARNING_CFLAGS $WARNING_CFLAGS_JVM $JVM_PICFLAG"
 816 
 817   CFLAGS_JDK_COMMON="$ALWAYS_CFLAGS_JDK $ALWAYS_DEFINES_JDK $TOOLCHAIN_CFLAGS_JDK \
 818       $OS_CFLAGS $CFLAGS_OS_DEF_JDK $DEBUG_CFLAGS_JDK $DEBUG_OPTIONS_FLAGS_JDK \
 819       $WARNING_CFLAGS $WARNING_CFLAGS_JDK $DEBUG_SYMBOLS_CFLAGS_JDK"

 820 
 821   # Use ${$2EXTRA_CFLAGS} to block EXTRA_CFLAGS to be added to build flags.
 822   # (Currently we don't have any OPENJDK_BUILD_EXTRA_CFLAGS, but that might
 823   # change in the future.)
 824 
 825   CFLAGS_JDK_COMMON_CONLY="$TOOLCHAIN_CFLAGS_JDK_CONLY  \
 826       $WARNING_CFLAGS_JDK_CONLY ${$2EXTRA_CFLAGS}"
 827   CFLAGS_JDK_COMMON_CXXONLY="$ALWAYS_DEFINES_JDK_CXXONLY $TOOLCHAIN_CFLAGS_JDK_CXXONLY \


 828       $WARNING_CFLAGS_JDK_CXXONLY ${$2EXTRA_CXXFLAGS}"
 829 
 830   $1_CFLAGS_JVM="${$1_DEFINES_CPU_JVM} ${$1_CFLAGS_CPU} ${$1_CFLAGS_CPU_JVM} ${$1_TOOLCHAIN_CFLAGS} ${$1_WARNING_CFLAGS_JVM}"
 831   $1_CFLAGS_JDK="${$1_DEFINES_CPU_JDK} ${$1_CFLAGS_CPU} ${$1_CFLAGS_CPU_JDK} ${$1_TOOLCHAIN_CFLAGS}"
 832 
 833   $2JVM_CFLAGS="$CFLAGS_JVM_COMMON ${$1_CFLAGS_JVM} ${$2EXTRA_CXXFLAGS}"
 834 
 835   $2CFLAGS_JDKEXE="$CFLAGS_JDK_COMMON $CFLAGS_JDK_COMMON_CONLY ${$1_CFLAGS_JDK}"
 836   $2CXXFLAGS_JDKEXE="$CFLAGS_JDK_COMMON $CFLAGS_JDK_COMMON_CXXONLY ${$1_CFLAGS_JDK}"
 837   $2CFLAGS_JDKLIB="${$2CFLAGS_JDKEXE} $JDK_PICFLAG ${$1_CFLAGS_CPU_JDK_LIBONLY}"
 838   $2CXXFLAGS_JDKLIB="${$2CXXFLAGS_JDKEXE} $JDK_PICFLAG ${$1_CFLAGS_CPU_JDK_LIBONLY}"
 839 
 840   AC_SUBST($2JVM_CFLAGS)
 841   AC_SUBST($2CFLAGS_JDKLIB)
 842   AC_SUBST($2CFLAGS_JDKEXE)
 843   AC_SUBST($2CXXFLAGS_JDKLIB)
 844   AC_SUBST($2CXXFLAGS_JDKEXE)
















 845 ])
 846 
 847 # FLAGS_SETUP_GCC6_COMPILER_FLAGS([PREFIX])
 848 # Arguments:
 849 # $1 - Prefix for each variable defined.

 850 AC_DEFUN([FLAGS_SETUP_GCC6_COMPILER_FLAGS],
 851 [
 852   # These flags are required for GCC 6 builds as undefined behaviour in OpenJDK code
 853   # runs afoul of the more aggressive versions of these optimisations.
 854   # Notably, value range propagation now assumes that the this pointer of C++
 855   # member functions is non-null.
 856   NO_DELETE_NULL_POINTER_CHECKS_CFLAG="-fno-delete-null-pointer-checks"
 857   dnl Argument check is disabled until FLAGS_COMPILER_CHECK_ARGUMENTS handles cross-compilation
 858   dnl FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [$NO_DELETE_NULL_POINTER_CHECKS_CFLAG -Werror],
 859   dnl                                        IF_FALSE: [NO_DELETE_NULL_POINTER_CHECKS_CFLAG=""])
 860   NO_LIFETIME_DSE_CFLAG="-fno-lifetime-dse"
 861   dnl Argument check is disabled until FLAGS_COMPILER_CHECK_ARGUMENTS handles cross-compilation
 862   dnl FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [$NO_LIFETIME_DSE_CFLAG -Werror],
 863   dnl                                        IF_FALSE: [NO_LIFETIME_DSE_CFLAG=""])
 864   AC_MSG_NOTICE([GCC >= 6 detected; adding ${NO_DELETE_NULL_POINTER_CHECKS_CFLAG} and ${NO_LIFETIME_DSE_CFLAG}])
 865   $1_GCC6_CFLAGS="${NO_DELETE_NULL_POINTER_CHECKS_CFLAG} ${NO_LIFETIME_DSE_CFLAG}"
 866 ])
 867 
 868 # Documentation on common flags used for solstudio in HIGHEST.
 869 #
 870 # WARNING: Use of OPTIMIZATION_LEVEL=HIGHEST in your Makefile needs to be
 871 #          done with care, there are some assumptions below that need to
 872 #          be understood about the use of pointers, and IEEE behavior.
 873 #
 874 # -fns: Use non-standard floating point mode (not IEEE 754)
 875 # -fsimple: Do some simplification of floating point arithmetic (not IEEE 754)
 876 # -fsingle: Use single precision floating point with 'float'
 877 # -xalias_level=basic: Assume memory references via basic pointer types do not alias
 878 #   (Source with excessing pointer casting and data access with mixed
 879 #    pointer types are not recommended)
 880 # -xbuiltin=%all: Use intrinsic or inline versions for math/std functions
 881 #   (If you expect perfect errno behavior, do not use this)
 882 # -xdepend: Loop data dependency optimizations (need -xO3 or higher)
 883 # -xrestrict: Pointer parameters to functions do not overlap
 884 #   (Similar to -xalias_level=basic usage, but less obvious sometimes.
< prev index next >