common/autoconf/flags.m4

Mon, 19 Nov 2018 14:52:55 -0800

author
kevinw
date
Mon, 19 Nov 2018 14:52:55 -0800
changeset 2373
2c9ec0970599
parent 2298
d7057bcda329
child 2375
10c71c9fba23
permissions
-rw-r--r--

8199552: Update to build scripts
Reviewed-by: jwilhelm

     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
    23 # questions.
    24 #
    26 AC_DEFUN_ONCE([FLAGS_SETUP_INIT_FLAGS],
    27 [
    28   # Option used to tell the compiler whether to create 32- or 64-bit executables
    29   if test "x$TOOLCHAIN_TYPE" = xxlc; then
    30     COMPILER_TARGET_BITS_FLAG="-q"
    31   else
    32     COMPILER_TARGET_BITS_FLAG="-m"
    33   fi
    34   AC_SUBST(COMPILER_TARGET_BITS_FLAG)
    36   # FIXME: figure out if we should select AR flags depending on OS or toolchain.
    37   if test "x$OPENJDK_TARGET_OS" = xmacosx; then
    38     ARFLAGS="-r"
    39   elif test "x$OPENJDK_TARGET_OS" = xaix; then
    40     ARFLAGS="-X64"
    41   elif test "x$OPENJDK_TARGET_OS" = xwindows; then
    42     # lib.exe is used as AR to create static libraries.
    43     ARFLAGS="-nologo -NODEFAULTLIB:MSVCRT"
    44   else
    45     ARFLAGS=""
    46   fi
    47   AC_SUBST(ARFLAGS)
    49   ## Setup strip.
    50   # FIXME: should this really be per platform, or should it be per toolchain type?
    51   # strip is not provided by clang or solstudio; so guessing platform makes most sense.
    52   # FIXME: we should really only export STRIPFLAGS from here, not POST_STRIP_CMD.
    53   if test "x$OPENJDK_TARGET_OS" = xlinux; then
    54     STRIPFLAGS="-g"
    55   elif test "x$OPENJDK_TARGET_OS" = xsolaris; then
    56     STRIPFLAGS="-x"
    57   elif test "x$OPENJDK_TARGET_OS" = xmacosx; then
    58     STRIPFLAGS="-S"
    59   elif test "x$OPENJDK_TARGET_OS" = xaix; then
    60     STRIPFLAGS="-X32_64"
    61   fi
    63   if test "x$OPENJDK_TARGET_OS" != xwindows; then
    64     POST_STRIP_CMD="$STRIP $STRIPFLAGS"
    65   fi
    66   AC_SUBST(POST_STRIP_CMD)
    68   if test "x$OPENJDK_TARGET_OS" = xsolaris; then
    69     # FIXME: break out into MCSFLAGS
    70     POST_MCS_CMD="$MCS -d -a \"JDK $FULL_VERSION\""
    71   fi
    72   AC_SUBST(POST_MCS_CMD)
    74   if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
    75     CC_OUT_OPTION=-Fo
    76     EXE_OUT_OPTION=-out:
    77     LD_OUT_OPTION=-out:
    78     AR_OUT_OPTION=-out:
    79   else
    80     # The option used to specify the target .o,.a or .so file.
    81     # When compiling, how to specify the to be created object file.
    82     CC_OUT_OPTION='-o$(SPACE)'
    83     # When linking, how to specify the to be created executable.
    84     EXE_OUT_OPTION='-o$(SPACE)'
    85     # When linking, how to specify the to be created dynamically linkable library.
    86     LD_OUT_OPTION='-o$(SPACE)'
    87     # When archiving, how to specify the to be create static archive for object files.
    88     AR_OUT_OPTION='rcs$(SPACE)'
    89   fi
    90   AC_SUBST(CC_OUT_OPTION)
    91   AC_SUBST(EXE_OUT_OPTION)
    92   AC_SUBST(LD_OUT_OPTION)
    93   AC_SUBST(AR_OUT_OPTION)
    95   # On Windows, we need to set RC flags.
    96   if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
    97     RC_FLAGS="-nologo -l 0x409 -r"
    98     if test "x$VARIANT" = xOPT; then
    99       RC_FLAGS="$RC_FLAGS -d NDEBUG"
   100     fi
   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).\$(COOKED_JDK_UPDATE_VERSION).\$(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)
   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
   123   if test "x$SYSROOT" != "x"; then
   124     if test "x$TOOLCHAIN_TYPE" = xsolstudio; then
   125       if test "x$OPENJDK_TARGET_OS" = xsolaris; then
   126         # Solaris Studio does not have a concept of sysroot. Instead we must
   127         # make sure the default include and lib dirs are appended to each 
   128         # compile and link command line.
   129         SYSROOT_CFLAGS="-I$SYSROOT/usr/include"
   130         SYSROOT_LDFLAGS="-L$SYSROOT/usr/lib$OPENJDK_TARGET_CPU_ISADIR \
   131             -L$SYSROOT/lib$OPENJDK_TARGET_CPU_ISADIR \
   132             -L$SYSROOT/usr/ccs/lib$OPENJDK_TARGET_CPU_ISADIR"
   133       fi
   134     elif test "x$TOOLCHAIN_TYPE" = xgcc; then
   135       SYSROOT_CFLAGS="--sysroot=\"$SYSROOT\""
   136       SYSROOT_LDFLAGS="--sysroot=\"$SYSROOT\""
   137     elif test "x$TOOLCHAIN_TYPE" = xclang; then
   138       SYSROOT_CFLAGS="-isysroot \"$SYSROOT\""
   139       SYSROOT_LDFLAGS="-isysroot \"$SYSROOT\""
   140     fi
   141     # Propagate the sysroot args to hotspot
   142     LEGACY_EXTRA_CFLAGS="$LEGACY_EXTRA_CFLAGS $SYSROOT_CFLAGS"
   143     LEGACY_EXTRA_CXXFLAGS="$LEGACY_EXTRA_CXXFLAGS $SYSROOT_CFLAGS"
   144     LEGACY_EXTRA_LDFLAGS="$LEGACY_EXTRA_LDFLAGS $SYSROOT_LDFLAGS"
   145   fi
   146   AC_SUBST(SYSROOT_CFLAGS)
   147   AC_SUBST(SYSROOT_LDFLAGS)
   148 ])
   150 AC_DEFUN_ONCE([FLAGS_SETUP_COMPILER_FLAGS_FOR_LIBS],
   151 [
   152   ###############################################################################
   153   #
   154   # How to compile shared libraries.
   155   #
   157   if test "x$TOOLCHAIN_TYPE" = xgcc; then
   158     PICFLAG="-fPIC"
   159     C_FLAG_REORDER=''
   160     CXX_FLAG_REORDER=''
   162     if test "x$OPENJDK_TARGET_OS" = xmacosx; then
   163       # Linking is different on MacOSX
   164       SHARED_LIBRARY_FLAGS="-dynamiclib -compatibility_version 1.0.0 -current_version 1.0.0 $PICFLAG"
   165       SET_EXECUTABLE_ORIGIN='-Xlinker -rpath -Xlinker @loader_path/.'
   166       SET_SHARED_LIBRARY_ORIGIN="$SET_EXECUTABLE_ORIGIN"
   167       SET_SHARED_LIBRARY_NAME='-Xlinker -install_name -Xlinker @rpath/[$]1'
   168       SET_SHARED_LIBRARY_MAPFILE=''
   169     else
   170       # Default works for linux, might work on other platforms as well.
   171       SHARED_LIBRARY_FLAGS='-shared'
   172       SET_EXECUTABLE_ORIGIN='-Xlinker -rpath -Xlinker \$$$$ORIGIN[$]1'
   173       SET_SHARED_LIBRARY_ORIGIN="-Xlinker -z -Xlinker origin $SET_EXECUTABLE_ORIGIN"
   174       SET_SHARED_LIBRARY_NAME='-Xlinker -soname=[$]1'
   175       SET_SHARED_LIBRARY_MAPFILE='-Xlinker -version-script=[$]1'
   176     fi
   177   elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
   178     PICFLAG="-KPIC"
   179     C_FLAG_REORDER='-xF'
   180     CXX_FLAG_REORDER='-xF'
   181     SHARED_LIBRARY_FLAGS="-G"
   182     SET_EXECUTABLE_ORIGIN='-R\$$$$ORIGIN[$]1'
   183     SET_SHARED_LIBRARY_ORIGIN="$SET_EXECUTABLE_ORIGIN"
   184     SET_SHARED_LIBRARY_NAME=''
   185     SET_SHARED_LIBRARY_MAPFILE='-M[$]1'
   186   elif test "x$TOOLCHAIN_TYPE" = xxlc; then
   187     PICFLAG="-qpic=large"
   188     C_FLAG_REORDER=''
   189     CXX_FLAG_REORDER=''
   190     SHARED_LIBRARY_FLAGS="-qmkshrobj"
   191     SET_EXECUTABLE_ORIGIN=""
   192     SET_SHARED_LIBRARY_ORIGIN=''
   193     SET_SHARED_LIBRARY_NAME=''
   194     SET_SHARED_LIBRARY_MAPFILE=''
   195   elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
   196     PICFLAG=""
   197     C_FLAG_REORDER=''
   198     CXX_FLAG_REORDER=''
   199     SHARED_LIBRARY_FLAGS="-LD"
   200     SET_EXECUTABLE_ORIGIN=''
   201     SET_SHARED_LIBRARY_ORIGIN=''
   202     SET_SHARED_LIBRARY_NAME=''
   203     SET_SHARED_LIBRARY_MAPFILE=''
   204   fi
   206   AC_SUBST(C_FLAG_REORDER)
   207   AC_SUBST(CXX_FLAG_REORDER)
   208   AC_SUBST(SHARED_LIBRARY_FLAGS)
   209   AC_SUBST(SET_EXECUTABLE_ORIGIN)
   210   AC_SUBST(SET_SHARED_LIBRARY_ORIGIN)
   211   AC_SUBST(SET_SHARED_LIBRARY_NAME)
   212   AC_SUBST(SET_SHARED_LIBRARY_MAPFILE)
   214   if test "x$OPENJDK_TARGET_OS" = xsolaris; then
   215     CFLAGS_JDK="${CFLAGS_JDK} -D__solaris__"
   216     CXXFLAGS_JDK="${CXXFLAGS_JDK} -D__solaris__"
   217     CFLAGS_JDKLIB_EXTRA='-xstrconst'
   218   fi
   219   # The (cross) compiler is now configured, we can now test capabilities
   220   # of the target platform.
   221 ])
   223 # Documentation on common flags used for solstudio in HIGHEST.
   224 #
   225 # WARNING: Use of OPTIMIZATION_LEVEL=HIGHEST in your Makefile needs to be
   226 #          done with care, there are some assumptions below that need to
   227 #          be understood about the use of pointers, and IEEE behavior.
   228 #
   229 # -fns: Use non-standard floating point mode (not IEEE 754)
   230 # -fsimple: Do some simplification of floating point arithmetic (not IEEE 754)
   231 # -fsingle: Use single precision floating point with 'float'
   232 # -xalias_level=basic: Assume memory references via basic pointer types do not alias
   233 #   (Source with excessing pointer casting and data access with mixed
   234 #    pointer types are not recommended)
   235 # -xbuiltin=%all: Use intrinsic or inline versions for math/std functions
   236 #   (If you expect perfect errno behavior, do not use this)
   237 # -xdepend: Loop data dependency optimizations (need -xO3 or higher)
   238 # -xrestrict: Pointer parameters to functions do not overlap
   239 #   (Similar to -xalias_level=basic usage, but less obvious sometimes.
   240 #    If you pass in multiple pointers to the same data, do not use this)
   241 # -xlibmil: Inline some library routines
   242 #   (If you expect perfect errno behavior, do not use this)
   243 # -xlibmopt: Use optimized math routines (CURRENTLY DISABLED)
   244 #   (If you expect perfect errno behavior, do not use this)
   245 #  Can cause undefined external on Solaris 8 X86 on __sincos, removing for now
   247     # FIXME: this will never happen since sparc != sparcv9, ie 32 bit, which we don't build anymore.
   248     # Bug?
   249     #if test "x$OPENJDK_TARGET_CPU" = xsparc; then
   250     #  CFLAGS_JDK="${CFLAGS_JDK} -xmemalign=4s"
   251     #  CXXFLAGS_JDK="${CXXFLAGS_JDK} -xmemalign=4s"
   252     #fi
   254 AC_DEFUN_ONCE([FLAGS_SETUP_COMPILER_FLAGS_FOR_OPTIMIZATION],
   255 [
   257   ###############################################################################
   258   #
   259   # Setup the opt flags for different compilers
   260   # and different operating systems.
   261   #
   263   # FIXME: this was indirectly the old default, but just inherited.
   264   # if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
   265   #   C_FLAG_DEPS="-MMD -MF"
   266   # fi
   268   # Generate make dependency files
   269   if test "x$TOOLCHAIN_TYPE" = xgcc; then
   270     C_FLAG_DEPS="-MMD -MF"
   271   elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
   272     C_FLAG_DEPS="-xMMD -xMF"
   273   elif test "x$TOOLCHAIN_TYPE" = xxlc; then
   274     C_FLAG_DEPS="-qmakedep=gcc -MF"
   275   fi
   276   CXX_FLAG_DEPS="$C_FLAG_DEPS"
   277   AC_SUBST(C_FLAG_DEPS)
   278   AC_SUBST(CXX_FLAG_DEPS)
   280   # Debug symbols
   281   if test "x$TOOLCHAIN_TYPE" = xgcc; then
   282     if test "x$OPENJDK_TARGET_CPU_BITS" = "x64" && test "x$DEBUG_LEVEL" = "xfastdebug"; then
   283       CFLAGS_DEBUG_SYMBOLS="-g1"
   284       CXXFLAGS_DEBUG_SYMBOLS="-g1"
   285     else
   286       CFLAGS_DEBUG_SYMBOLS="-g"
   287       CXXFLAGS_DEBUG_SYMBOLS="-g"
   288     fi
   289   elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
   290     CFLAGS_DEBUG_SYMBOLS="-g -xs"
   291     CXXFLAGS_DEBUG_SYMBOLS="-g0 -xs"
   292   elif test "x$TOOLCHAIN_TYPE" = xxlc; then
   293     CFLAGS_DEBUG_SYMBOLS="-g"
   294     CXXFLAGS_DEBUG_SYMBOLS="-g"
   295   fi
   296   AC_SUBST(CFLAGS_DEBUG_SYMBOLS)
   297   AC_SUBST(CXXFLAGS_DEBUG_SYMBOLS)
   299   # Optimization levels
   300   if test "x$TOOLCHAIN_TYPE" = xsolstudio; then
   301     CC_HIGHEST="$CC_HIGHEST -fns -fsimple -fsingle -xalias_level=basic -xbuiltin=%all -xdepend -xrestrict -xlibmil"
   303     if test "x$OPENJDK_TARGET_CPU_ARCH" = "xx86"; then
   304       # FIXME: seems we always set -xregs=no%frameptr; put it elsewhere more global?
   305       C_O_FLAG_HIGHEST="-xO4 -Wu,-O4~yz $CC_HIGHEST -xregs=no%frameptr"
   306       C_O_FLAG_HI="-xO4 -Wu,-O4~yz -xregs=no%frameptr"
   307       C_O_FLAG_NORM="-xO2 -Wu,-O2~yz -xregs=no%frameptr"
   308       C_O_FLAG_NONE="-xregs=no%frameptr"
   309       CXX_O_FLAG_HIGHEST="-xO4 -Qoption ube -O4~yz $CC_HIGHEST -xregs=no%frameptr"
   310       CXX_O_FLAG_HI="-xO4 -Qoption ube -O4~yz -xregs=no%frameptr"
   311       CXX_O_FLAG_NORM="-xO2 -Qoption ube -O2~yz -xregs=no%frameptr"
   312       CXX_O_FLAG_NONE="-xregs=no%frameptr"
   313       if test "x$OPENJDK_TARGET_CPU_BITS" = "x32"; then
   314         C_O_FLAG_HIGHEST="$C_O_FLAG_HIGHEST -xchip=pentium"
   315         CXX_O_FLAG_HIGHEST="$CXX_O_FLAG_HIGHEST -xchip=pentium"
   316       fi
   317     elif test "x$OPENJDK_TARGET_CPU_ARCH" = "xsparc"; then
   318       C_O_FLAG_HIGHEST="-xO4 -Wc,-Qrm-s -Wc,-Qiselect-T0 $CC_HIGHEST -xprefetch=auto,explicit -xchip=ultra"
   319       C_O_FLAG_HI="-xO4 -Wc,-Qrm-s -Wc,-Qiselect-T0"
   320       C_O_FLAG_NORM="-xO2 -Wc,-Qrm-s -Wc,-Qiselect-T0"
   321       C_O_FLAG_NONE=""
   322       CXX_O_FLAG_HIGHEST="-xO4 -Qoption cg -Qrm-s -Qoption cg -Qiselect-T0 $CC_HIGHEST -xprefetch=auto,explicit -xchip=ultra"
   323       CXX_O_FLAG_HI="-xO4 -Qoption cg -Qrm-s -Qoption cg -Qiselect-T0"
   324       CXX_O_FLAG_NORM="-xO2 -Qoption cg -Qrm-s -Qoption cg -Qiselect-T0"
   325       CXX_O_FLAG_NONE=""
   326     fi
   327   else
   328     # The remaining toolchains share opt flags between CC and CXX;
   329     # setup for C and duplicate afterwards.
   330     if test "x$TOOLCHAIN_TYPE" = xgcc; then
   331       if test "x$OPENJDK_TARGET_OS" = xmacosx; then
   332         # On MacOSX we optimize for size, something
   333         # we should do for all platforms?
   334         C_O_FLAG_HIGHEST="-Os"
   335         C_O_FLAG_HI="-Os"
   336         C_O_FLAG_NORM="-Os"
   337         C_O_FLAG_NONE=""
   338       else
   339         C_O_FLAG_HIGHEST="-O3"
   340         C_O_FLAG_HI="-O3"
   341         C_O_FLAG_NORM="-O2"
   342         C_O_FLAG_NONE="-O0"
   343       fi
   344     elif test "x$TOOLCHAIN_TYPE" = xxlc; then
   345       C_O_FLAG_HIGHEST="-O3"
   346       C_O_FLAG_HI="-O3 -qstrict"
   347       C_O_FLAG_NORM="-O2"
   348       C_O_FLAG_NONE=""
   349     elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
   350       C_O_FLAG_HIGHEST="-O2"
   351       C_O_FLAG_HI="-O1"
   352       C_O_FLAG_NORM="-O1"
   353       C_O_FLAG_NONE="-Od"
   354     fi
   355     CXX_O_FLAG_HIGHEST="$C_O_FLAG_HIGHEST"
   356     CXX_O_FLAG_HI="$C_O_FLAG_HI"
   357     CXX_O_FLAG_NORM="$C_O_FLAG_NORM"
   358     CXX_O_FLAG_NONE="$C_O_FLAG_NONE"
   359   fi
   361   AC_SUBST(C_O_FLAG_HIGHEST)
   362   AC_SUBST(C_O_FLAG_HI)
   363   AC_SUBST(C_O_FLAG_NORM)
   364   AC_SUBST(C_O_FLAG_NONE)
   365   AC_SUBST(CXX_O_FLAG_HIGHEST)
   366   AC_SUBST(CXX_O_FLAG_HI)
   367   AC_SUBST(CXX_O_FLAG_NORM)
   368   AC_SUBST(CXX_O_FLAG_NONE)
   369 ])
   371 AC_DEFUN_ONCE([FLAGS_SETUP_COMPILER_FLAGS_FOR_JDK],
   372 [
   373   # Special extras...
   374   if test "x$TOOLCHAIN_TYPE" = xsolstudio; then
   375     if test "x$OPENJDK_TARGET_CPU_ARCH" = "xsparc"; then
   376       CFLAGS_JDKLIB_EXTRA="${CFLAGS_JDKLIB_EXTRA} -xregs=no%appl"
   377       CXXFLAGS_JDKLIB_EXTRA="${CXXFLAGS_JDKLIB_EXTRA} -xregs=no%appl"
   378     fi
   379   elif test "x$TOOLCHAIN_TYPE" = xxlc; then
   380     LDFLAGS_JDK="${LDFLAGS_JDK} -q64 -brtl -bnolibpath -liconv -bexpall"
   381     CFLAGS_JDK="${CFLAGS_JDK} -qchars=signed -q64 -qfullpath -qsaveopt"
   382     CXXFLAGS_JDK="${CXXFLAGS_JDK} -qchars=signed -q64 -qfullpath -qsaveopt"
   383   elif test "x$TOOLCHAIN_TYPE" = xgcc; then
   384     case $OPENJDK_TARGET_CPU_ARCH in
   385     x86 )
   386       LEGACY_EXTRA_CFLAGS="$LEGACY_EXTRA_CFLAGS -fstack-protector"
   387       LEGACY_EXTRA_CXXFLAGS="$LEGACY_EXTRA_CXXFLAGS -fstack-protector"
   388       ;;
   389     x86_64 )
   390       LEGACY_EXTRA_CFLAGS="$LEGACY_EXTRA_CFLAGS -fstack-protector"
   391       LEGACY_EXTRA_CXXFLAGS="$LEGACY_EXTRA_CXXFLAGS -fstack-protector"
   392       ;;
   393     esac
   394     if test "x$OPENJDK_TARGET_OS" != xmacosx; then
   395       LDFLAGS_JDK="$LDFLAGS_JDK -Wl,-z,relro"
   396       LEGACY_EXTRA_LDFLAGS="$LEGACY_EXTRA_LDFLAGS -Wl,-z,relro"
   397     fi
   398     $2CXXSTD_CXXFLAG="-std=gnu++98"
   399     FLAGS_CXX_COMPILER_CHECK_ARGUMENTS([[$]$2CXXSTD_CXXFLAG -Werror],
   400                                        [], [$2CXXSTD_CXXFLAG=""])
   401     $2CXXFLAGS_JDK="${$2CXXFLAGS_JDK} ${$2CXXSTD_CXXFLAG}"
   402     $2JVM_CFLAGS="${$2JVM_CFLAGS} ${$2CXXSTD_CXXFLAG}"
   403     AC_SUBST($2CXXSTD_CXXFLAG)
   404   fi
   406   if test "x$CFLAGS" != "x${ADDED_CFLAGS}"; then
   407     AC_MSG_WARN([Ignoring CFLAGS($CFLAGS) found in environment. Use --with-extra-cflags])
   408   fi
   410   if test "x$CXXFLAGS" != "x${ADDED_CXXFLAGS}"; then
   411     AC_MSG_WARN([Ignoring CXXFLAGS($CXXFLAGS) found in environment. Use --with-extra-cxxflags])
   412   fi
   414   if test "x$LDFLAGS" != "x${ADDED_LDFLAGS}"; then
   415     AC_MSG_WARN([Ignoring LDFLAGS($LDFLAGS) found in environment. Use --with-extra-ldflags])
   416   fi
   418   AC_ARG_WITH(extra-cflags, [AS_HELP_STRING([--with-extra-cflags],
   419       [extra flags to be used when compiling jdk c-files])])
   421   AC_ARG_WITH(extra-cxxflags, [AS_HELP_STRING([--with-extra-cxxflags],
   422       [extra flags to be used when compiling jdk c++-files])])
   424   AC_ARG_WITH(extra-ldflags, [AS_HELP_STRING([--with-extra-ldflags],
   425       [extra flags to be used when linking jdk])])
   427   CFLAGS_JDK="${CFLAGS_JDK} $with_extra_cflags"
   428   CXXFLAGS_JDK="${CXXFLAGS_JDK} $with_extra_cxxflags"
   429   LDFLAGS_JDK="${LDFLAGS_JDK} $with_extra_ldflags"
   431   # Hotspot needs these set in their legacy form
   432   LEGACY_EXTRA_CFLAGS="$LEGACY_EXTRA_CFLAGS $with_extra_cflags"
   433   LEGACY_EXTRA_CXXFLAGS="$LEGACY_EXTRA_CXXFLAGS $with_extra_cxxflags"
   434   LEGACY_EXTRA_LDFLAGS="$LEGACY_EXTRA_LDFLAGS $with_extra_ldflags"
   436   AC_SUBST(LEGACY_EXTRA_CFLAGS)
   437   AC_SUBST(LEGACY_EXTRA_CXXFLAGS)
   438   AC_SUBST(LEGACY_EXTRA_LDFLAGS)
   440   ###############################################################################
   441   #
   442   # Now setup the CFLAGS and LDFLAGS for the JDK build.
   443   # Later we will also have CFLAGS and LDFLAGS for the hotspot subrepo build.
   444   #
   446   # Setup compiler/platform specific flags to CFLAGS_JDK,
   447   # CXXFLAGS_JDK and CCXXFLAGS_JDK (common to C and CXX?)
   448   if test "x$TOOLCHAIN_TYPE" = xgcc; then
   449     # these options are used for both C and C++ compiles
   450     CCXXFLAGS_JDK="$CCXXFLAGS $CCXXFLAGS_JDK -Wall -Wno-parentheses -Wextra -Wno-unused -Wno-unused-parameter -Wformat=2 \
   451         -pipe -D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE"
   452     case $OPENJDK_TARGET_CPU_ARCH in
   453       arm )
   454         # on arm we don't prevent gcc to omit frame pointer but do prevent strict aliasing
   455         CFLAGS_JDK="${CFLAGS_JDK} -fno-strict-aliasing"
   456         ;;
   457       ppc )
   458         # on ppc we don't prevent gcc to omit frame pointer nor strict-aliasing
   459         ;;
   460       x86 )
   461         CCXXFLAGS_JDK="$CCXXFLAGS_JDK -fno-omit-frame-pointer -fstack-protector"
   462         CFLAGS_JDK="${CFLAGS_JDK} -fno-strict-aliasing -fstack-protector"
   463         ;;
   464       * )
   465         CCXXFLAGS_JDK="$CCXXFLAGS_JDK -fno-omit-frame-pointer"
   466         CFLAGS_JDK="${CFLAGS_JDK} -fno-strict-aliasing"
   467         ;;
   468     esac
   469     TOOLCHAIN_CHECK_COMPILER_VERSION(6, FLAGS_SETUP_GCC6_COMPILER_FLAGS)
   470   elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
   471     CCXXFLAGS_JDK="$CCXXFLAGS $CCXXFLAGS_JDK -DTRACING -DMACRO_MEMSYS_OPS -DBREAKPTS"
   472     if test "x$OPENJDK_TARGET_CPU_ARCH" = xx86; then
   473       CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DcpuIntel -Di586 -D$OPENJDK_TARGET_CPU_LEGACY_LIB"
   474       CFLAGS_JDK="$CFLAGS_JDK -erroff=E_BAD_PRAGMA_PACK_VALUE"
   475     fi
   477     CFLAGS_JDK="$CFLAGS_JDK -xc99=%none -xCC -errshort=tags -Xa -v -mt -W0,-noglobal"
   478     CXXFLAGS_JDK="$CXXFLAGS_JDK -errtags=yes +w -mt -features=no%except -DCC_NOEX -norunpath -xnolib"
   479   elif test "x$TOOLCHAIN_TYPE" = xxlc; then
   480     CFLAGS_JDK="$CFLAGS_JDK -D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE -DSTDC"
   481     CXXFLAGS_JDK="$CXXFLAGS_JDK -D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE -DSTDC"
   482   elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
   483     CCXXFLAGS_JDK="$CCXXFLAGS $CCXXFLAGS_JDK \
   484         -Zi -MD -Zc:wchar_t- -W3 -wd4800 \
   485         -DWIN32_LEAN_AND_MEAN \
   486         -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE \
   487         -DWIN32 -DIAL"
   488     if test "x$OPENJDK_TARGET_CPU" = xx86_64; then
   489       CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_AMD64_ -Damd64"
   490     else
   491       CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_X86_ -Dx86"
   492     fi
   493     # If building with Visual Studio 2010, we can still use _STATIC_CPPLIB to
   494     # avoid bundling msvcpNNN.dll. Doesn't work with newer versions of visual
   495     # studio.
   496     if test "x$TOOLCHAIN_VERSION" = "x2010"; then
   497       CCXXFLAGS_JDK="$CCXXFLAGS_JDK \
   498           -D_STATIC_CPPLIB -D_DISABLE_DEPRECATE_STATIC_CPPLIB"
   499     fi
   500   fi
   502   ###############################################################################
   504   # Adjust flags according to debug level.
   505   case $DEBUG_LEVEL in
   506     fastdebug )
   507       CFLAGS_JDK="$CFLAGS_JDK $CFLAGS_DEBUG_SYMBOLS"
   508       CXXFLAGS_JDK="$CXXFLAGS_JDK $CXXFLAGS_DEBUG_SYMBOLS"
   509       C_O_FLAG_HI="$C_O_FLAG_NORM"
   510       C_O_FLAG_NORM="$C_O_FLAG_NORM"
   511       CXX_O_FLAG_HI="$CXX_O_FLAG_NORM"
   512       CXX_O_FLAG_NORM="$CXX_O_FLAG_NORM"
   513       JAVAC_FLAGS="$JAVAC_FLAGS -g"
   514       ;;
   515     slowdebug )
   516       CFLAGS_JDK="$CFLAGS_JDK $CFLAGS_DEBUG_SYMBOLS"
   517       CXXFLAGS_JDK="$CXXFLAGS_JDK $CXXFLAGS_DEBUG_SYMBOLS"
   518       C_O_FLAG_HI="$C_O_FLAG_NONE"
   519       C_O_FLAG_NORM="$C_O_FLAG_NONE"
   520       CXX_O_FLAG_HI="$CXX_O_FLAG_NONE"
   521       CXX_O_FLAG_NORM="$CXX_O_FLAG_NONE"
   522       JAVAC_FLAGS="$JAVAC_FLAGS -g"
   523       ;;
   524   esac
   526   # Setup LP64
   527   CCXXFLAGS_JDK="$CCXXFLAGS_JDK $ADD_LP64"
   529   # Set some common defines. These works for all compilers, but assume
   530   # -D is universally accepted.
   532   # Setup endianness
   533   if test "x$OPENJDK_TARGET_CPU_ENDIAN" = xlittle; then
   534     # The macro _LITTLE_ENDIAN needs to be defined the same to avoid the
   535     #   Sun C compiler warning message: warning: macro redefined: _LITTLE_ENDIAN
   536     #   (The Solaris X86 system defines this in file /usr/include/sys/isa_defs.h).
   537     #   Note: -Dmacro         is the same as    #define macro 1
   538     #         -Dmacro=        is the same as    #define macro
   539     if test "x$OPENJDK_TARGET_OS" = xsolaris; then
   540       CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_LITTLE_ENDIAN="
   541     else
   542       CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_LITTLE_ENDIAN"
   543     fi
   544   else
   545     # Same goes for _BIG_ENDIAN. Do we really need to set *ENDIAN on Solaris if they
   546     # are defined in the system?
   547     if test "x$OPENJDK_TARGET_OS" = xsolaris; then
   548       CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_BIG_ENDIAN="
   549     else
   550       CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_BIG_ENDIAN"
   551     fi
   552   fi
   554   # Setup target OS define. Use OS target name but in upper case.
   555   OPENJDK_TARGET_OS_UPPERCASE=`$ECHO $OPENJDK_TARGET_OS | $TR 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
   556   CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D$OPENJDK_TARGET_OS_UPPERCASE"
   558   # Setup target CPU
   559   CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DARCH='\"$OPENJDK_TARGET_CPU_LEGACY\"' -D$OPENJDK_TARGET_CPU_LEGACY"
   561   # Setup debug/release defines
   562   if test "x$DEBUG_LEVEL" = xrelease; then
   563     CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DNDEBUG"
   564     if test "x$OPENJDK_TARGET_OS" = xsolaris; then
   565       CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DTRIMMED"
   566     fi
   567   else
   568     CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DDEBUG"
   569   fi
   571   # Setup release name
   572   CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DRELEASE='\"\$(RELEASE)\"'"
   575   # Set some additional per-OS defines.
   576   if test "x$OPENJDK_TARGET_OS" = xmacosx; then
   577     CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_ALLBSD_SOURCE -D_DARWIN_UNLIMITED_SELECT"
   578   elif test "x$OPENJDK_TARGET_OS" = xaix; then
   579     # FIXME: PPC64 should not be here.
   580     CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DPPC64"
   581   elif test "x$OPENJDK_TARGET_OS" = xbsd; then
   582     CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_ALLBSD_SOURCE"
   583   fi
   585   # Additional macosx handling
   586   if test "x$OPENJDK_TARGET_OS" = xmacosx; then
   587     if test "x$TOOLCHAIN_TYPE" = xgcc; then
   588       # FIXME: This needs to be exported in spec.gmk due to closed legacy code.
   589       # FIXME: clean this up, and/or move it elsewhere.
   591       # Setting these parameters makes it an error to link to macosx APIs that are
   592       # newer than the given OS version and makes the linked binaries compatible 
   593       # even if built on a newer version of the OS.
   594       # The expected format is X.Y.Z
   595       MACOSX_VERSION_MIN=10.7.0
   596       AC_SUBST(MACOSX_VERSION_MIN)
   598       # The macro takes the version with no dots, ex: 1070
   599       # Let the flags variables get resolved in make for easier override on make
   600       # command line.
   601       CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DMAC_OS_X_VERSION_MAX_ALLOWED=\$(subst .,,\$(MACOSX_VERSION_MIN)) -mmacosx-version-min=\$(MACOSX_VERSION_MIN)"
   602       LDFLAGS_JDK="$LDFLAGS_JDK -mmacosx-version-min=\$(MACOSX_VERSION_MIN)"
   603     fi
   604   fi
   606   # Setup some hard coded includes
   607   CCXXFLAGS_JDK="$CCXXFLAGS_JDK \
   608       -I${JDK_OUTPUTDIR}/include \
   609       -I${JDK_OUTPUTDIR}/include/$OPENJDK_TARGET_OS \
   610       -I${JDK_TOPDIR}/src/share/javavm/export \
   611       -I${JDK_TOPDIR}/src/$OPENJDK_TARGET_OS_EXPORT_DIR/javavm/export \
   612       -I${JDK_TOPDIR}/src/share/native/common \
   613       -I${JDK_TOPDIR}/src/$OPENJDK_TARGET_OS_API_DIR/native/common"
   615   # The shared libraries are compiled using the picflag.
   616   CFLAGS_JDKLIB="$CCXXFLAGS_JDK $CFLAGS_JDK $PICFLAG $CFLAGS_JDKLIB_EXTRA"
   617   CXXFLAGS_JDKLIB="$CCXXFLAGS_JDK $CXXFLAGS_JDK $PICFLAG $CXXFLAGS_JDKLIB_EXTRA "
   619   # Executable flags
   620   CFLAGS_JDKEXE="$CCXXFLAGS_JDK $CFLAGS_JDK"
   621   CXXFLAGS_JDKEXE="$CCXXFLAGS_JDK $CXXFLAGS_JDK"
   623   AC_SUBST(CFLAGS_JDKLIB)
   624   AC_SUBST(CFLAGS_JDKEXE)
   625   AC_SUBST(CXXFLAGS_JDKLIB)
   626   AC_SUBST(CXXFLAGS_JDKEXE)
   628   # Setup LDFLAGS et al.
   629   #
   630   # Now this is odd. The JDK native libraries have to link against libjvm.so
   631   # On 32-bit machines there is normally two distinct libjvm.so:s, client and server.
   632   # Which should we link to? Are we lucky enough that the binary api to the libjvm.so library
   633   # is identical for client and server? Yes. Which is picked at runtime (client or server)?
   634   # Neither, since the chosen libjvm.so has already been loaded by the launcher, all the following
   635   # libraries will link to whatever is in memory. Yuck.
   636   #
   637   # Thus we offer the compiler to find libjvm.so first in server then in client. It works. Ugh.
   638   if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
   639     LDFLAGS_JDK="$LDFLAGS_JDK -nologo -opt:ref -incremental:no"
   640     if test "x$OPENJDK_TARGET_CPU_BITS" = "x32"; then
   641       LDFLAGS_JDK="$LDFLAGS_JDK -safeseh"
   642     fi
   643     # TODO: make -debug optional "--disable-full-debug-symbols"
   644     LDFLAGS_JDK="$LDFLAGS_JDK -debug"
   645     LDFLAGS_JDKLIB="${LDFLAGS_JDK} -dll -libpath:${JDK_OUTPUTDIR}/lib"
   646     LDFLAGS_JDKLIB_SUFFIX=""
   647     if test "x$OPENJDK_TARGET_CPU_BITS" = "x64"; then
   648       LDFLAGS_STACK_SIZE=1048576
   649     else
   650       LDFLAGS_STACK_SIZE=327680
   651     fi
   652     LDFLAGS_JDKEXE="${LDFLAGS_JDK} /STACK:$LDFLAGS_STACK_SIZE"
   653   else
   654     if test "x$TOOLCHAIN_TYPE" = xgcc; then
   655       # If this is a --hash-style=gnu system, use --hash-style=both, why?
   656       # We have previously set HAS_GNU_HASH if this is the case
   657       if test -n "$HAS_GNU_HASH"; then
   658         LDFLAGS_JDK="${LDFLAGS_JDK} -Xlinker --hash-style=both "
   659       fi
   660       if test "x$OPENJDK_TARGET_OS" = xlinux; then
   661         # And since we now know that the linker is gnu, then add:
   662         #   -z defs, to forbid undefined symbols in object files
   663         #   -z noexecstack, to mark stack regions as non-executable
   664         LDFLAGS_JDK="${LDFLAGS_JDK} -Xlinker -z -Xlinker defs -Xlinker -z -Xlinker noexecstack"
   665         if test "x$DEBUG_LEVEL" = "xrelease"; then
   666           # When building release libraries, tell the linker optimize them.
   667           # Should this be supplied to the OSS linker as well?
   668           LDFLAGS_JDK="${LDFLAGS_JDK} -Xlinker -O1"
   669         fi
   670       fi
   671     fi
   673     if test "x$TOOLCHAIN_TYPE" = xsolstudio; then
   674       LDFLAGS_JDK="$LDFLAGS_JDK -z defs -xildoff -ztext"
   675       LDFLAGS_CXX_JDK="$LDFLAGS_CXX_JDK -norunpath -xnolib"
   676     fi
   678     LDFLAGS_JDKLIB="${LDFLAGS_JDK} $SHARED_LIBRARY_FLAGS \
   679         -L${JDK_OUTPUTDIR}/lib${OPENJDK_TARGET_CPU_LIBDIR}"
   681     # On some platforms (mac) the linker warns about non existing -L dirs.
   682     # Add server first if available. Linking aginst client does not always produce the same results.
   683     # Only add client dir if client is being built. Add minimal (note not minimal1) if only building minimal1.
   684     # Default to server for other variants.
   685     if test "x$JVM_VARIANT_SERVER" = xtrue; then
   686       LDFLAGS_JDKLIB="${LDFLAGS_JDKLIB} -L${JDK_OUTPUTDIR}/lib${OPENJDK_TARGET_CPU_LIBDIR}/server"
   687     elif test "x$JVM_VARIANT_CLIENT" = xtrue; then
   688       LDFLAGS_JDKLIB="${LDFLAGS_JDKLIB} -L${JDK_OUTPUTDIR}/lib${OPENJDK_TARGET_CPU_LIBDIR}/client"
   689     elif test "x$JVM_VARIANT_MINIMAL1" = xtrue; then
   690       LDFLAGS_JDKLIB="${LDFLAGS_JDKLIB} -L${JDK_OUTPUTDIR}/lib${OPENJDK_TARGET_CPU_LIBDIR}/minimal"
   691     else
   692       LDFLAGS_JDKLIB="${LDFLAGS_JDKLIB} -L${JDK_OUTPUTDIR}/lib${OPENJDK_TARGET_CPU_LIBDIR}/server"
   693     fi
   695     LDFLAGS_JDKLIB_SUFFIX="-ljava -ljvm"
   696     if test "x$TOOLCHAIN_TYPE" = xsolstudio; then
   697       LDFLAGS_JDKLIB_SUFFIX="$LDFLAGS_JDKLIB_SUFFIX -lc"
   698     fi
   700     LDFLAGS_JDKEXE="${LDFLAGS_JDK}"
   701     if test "x$OPENJDK_TARGET_OS" = xlinux; then
   702       LDFLAGS_JDKEXE="$LDFLAGS_JDKEXE -Xlinker --allow-shlib-undefined"
   703     fi
   704   fi
   705   AC_SUBST(LDFLAGS_JDKLIB)
   706   AC_SUBST(LDFLAGS_JDKEXE)
   707   AC_SUBST(LDFLAGS_JDKLIB_SUFFIX)
   708   AC_SUBST(LDFLAGS_JDKEXE_SUFFIX)
   709   AC_SUBST(LDFLAGS_CXX_JDK)
   710 ])
   713 # FLAGS_C_COMPILER_CHECK_ARGUMENTS([ARGUMENT], [RUN-IF-TRUE],
   714 #                                  [RUN-IF-FALSE])
   715 # ------------------------------------------------------------
   716 # Check that the C compiler supports an argument
   717 AC_DEFUN([FLAGS_C_COMPILER_CHECK_ARGUMENTS],
   718 [
   719   AC_MSG_CHECKING([if the C compiler supports "$1"])
   720   supports=yes
   722   saved_cflags="$CFLAGS"
   723   CFLAGS="$CFLAGS $1"
   724   AC_LANG_PUSH([C])
   725   AC_COMPILE_IFELSE([AC_LANG_SOURCE([[int i;]])], [], 
   726       [supports=no])
   727   AC_LANG_POP([C])
   728   CFLAGS="$saved_cflags"
   730   AC_MSG_RESULT([$supports])
   731   if test "x$supports" = "xyes" ; then
   732     m4_ifval([$2], [$2], [:])
   733   else
   734     m4_ifval([$3], [$3], [:])
   735   fi
   736 ])
   738 # FLAGS_CXX_COMPILER_CHECK_ARGUMENTS([ARGUMENT], [RUN-IF-TRUE],
   739 #                                    [RUN-IF-FALSE])
   740 # ------------------------------------------------------------
   741 # Check that the C++ compiler supports an argument
   742 AC_DEFUN([FLAGS_CXX_COMPILER_CHECK_ARGUMENTS],
   743 [
   744   AC_MSG_CHECKING([if the C++ compiler supports "$1"])
   745   supports=yes
   747   saved_cxxflags="$CXXFLAGS"
   748   CXXFLAGS="$CXXFLAG $1"
   749   AC_LANG_PUSH([C++])
   750   AC_COMPILE_IFELSE([AC_LANG_SOURCE([[int i;]])], [], 
   751       [supports=no])
   752   AC_LANG_POP([C++])
   753   CXXFLAGS="$saved_cxxflags"
   755   AC_MSG_RESULT([$supports])
   756   if test "x$supports" = "xyes" ; then
   757     m4_ifval([$2], [$2], [:])
   758   else
   759     m4_ifval([$3], [$3], [:])
   760   fi
   761 ])
   763 # FLAGS_COMPILER_CHECK_ARGUMENTS([ARGUMENT], [RUN-IF-TRUE],
   764 #                                [RUN-IF-FALSE])
   765 # ------------------------------------------------------------
   766 # Check that the C and C++ compilers support an argument
   767 AC_DEFUN([FLAGS_COMPILER_CHECK_ARGUMENTS],
   768 [
   769   FLAGS_C_COMPILER_CHECK_ARGUMENTS([$1],
   770                        [C_COMP_SUPPORTS="yes"],
   771                        [C_COMP_SUPPORTS="no"])
   772   FLAGS_CXX_COMPILER_CHECK_ARGUMENTS([$1],
   773                      [CXX_COMP_SUPPORTS="yes"],
   774                      [CXX_COMP_SUPPORTS="no"])
   776   AC_MSG_CHECKING([if both compilers support "$1"])
   777   supports=no
   778   if test "x$C_COMP_SUPPORTS" = "xyes" -a "x$CXX_COMP_SUPPORTS" = "xyes"; then supports=yes; fi
   780   AC_MSG_RESULT([$supports])
   781   if test "x$supports" = "xyes" ; then
   782     m4_ifval([$2], [$2], [:])
   783   else
   784     m4_ifval([$3], [$3], [:])
   785   fi
   786 ])
   788 AC_DEFUN_ONCE([FLAGS_SETUP_COMPILER_FLAGS_MISC],
   789 [
   790   # Some Zero and Shark settings.
   791   # ZERO_ARCHFLAG tells the compiler which mode to build for
   792   case "${OPENJDK_TARGET_CPU}" in
   793     s390)
   794       ZERO_ARCHFLAG="${COMPILER_TARGET_BITS_FLAG}31"
   795       ;;
   796     *)
   797       ZERO_ARCHFLAG="${COMPILER_TARGET_BITS_FLAG}${OPENJDK_TARGET_CPU_BITS}"
   798   esac
   799   FLAGS_COMPILER_CHECK_ARGUMENTS([$ZERO_ARCHFLAG], [], [ZERO_ARCHFLAG=""])
   800   AC_SUBST(ZERO_ARCHFLAG)
   802   # Check that the compiler supports -mX (or -qX on AIX) flags
   803   # Set COMPILER_SUPPORTS_TARGET_BITS_FLAG to 'true' if it does
   804   FLAGS_COMPILER_CHECK_ARGUMENTS([${COMPILER_TARGET_BITS_FLAG}${OPENJDK_TARGET_CPU_BITS}],
   805       [COMPILER_SUPPORTS_TARGET_BITS_FLAG=true],
   806       [COMPILER_SUPPORTS_TARGET_BITS_FLAG=false])
   807   AC_SUBST(COMPILER_SUPPORTS_TARGET_BITS_FLAG)
   808 ])
   810 AC_DEFUN_ONCE([FLAGS_SETUP_GCC6_COMPILER_FLAGS],
   811 [
   812   # These flags are required for GCC 6 builds as undefined behaviour in OpenJDK code
   813   # runs afoul of the more aggressive versions of these optimisations.
   814   # Notably, value range propagation now assumes that the this pointer of C++
   815   # member functions is non-null.
   816   NO_DELETE_NULL_POINTER_CHECKS_CFLAG="-fno-delete-null-pointer-checks"
   817   FLAGS_COMPILER_CHECK_ARGUMENTS([$NO_DELETE_NULL_POINTER_CHECKS_CFLAG -Werror],
   818                                      [], [NO_DELETE_NULL_POINTER_CHECKS_CFLAG=""])
   819   AC_SUBST([NO_DELETE_NULL_POINTER_CHECKS_CFLAG])
   820   NO_LIFETIME_DSE_CFLAG="-fno-lifetime-dse"
   821   FLAGS_COMPILER_CHECK_ARGUMENTS([$NO_LIFETIME_DSE_CFLAG -Werror],
   822                                      [], [NO_LIFETIME_DSE_CFLAG=""])
   823   CFLAGS_JDK="${CFLAGS_JDK} ${NO_DELETE_NULL_POINTER_CHECKS_CFLAG} ${NO_LIFETIME_DSE_CFLAG}"
   824   AC_SUBST([NO_LIFETIME_DSE_CFLAG])
   825 ])

mercurial