common/autoconf/flags.m4

changeset 2206
7ba4e17574e0
child 2215
7a73b8b4ac8a
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/common/autoconf/flags.m4	Thu Apr 05 07:59:52 2018 -0700
     1.3 @@ -0,0 +1,767 @@
     1.4 +#
     1.5 +# Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
     1.6 +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 +#
     1.8 +# This code is free software; you can redistribute it and/or modify it
     1.9 +# under the terms of the GNU General Public License version 2 only, as
    1.10 +# published by the Free Software Foundation.  Oracle designates this
    1.11 +# particular file as subject to the "Classpath" exception as provided
    1.12 +# by Oracle in the LICENSE file that accompanied this code.
    1.13 +#
    1.14 +# This code is distributed in the hope that it will be useful, but WITHOUT
    1.15 +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.16 +# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.17 +# version 2 for more details (a copy is included in the LICENSE file that
    1.18 +# accompanied this code).
    1.19 +#
    1.20 +# You should have received a copy of the GNU General Public License version
    1.21 +# 2 along with this work; if not, write to the Free Software Foundation,
    1.22 +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.23 +#
    1.24 +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    1.25 +# or visit www.oracle.com if you need additional information or have any
    1.26 +# questions.
    1.27 +#
    1.28 +
    1.29 +AC_DEFUN_ONCE([FLAGS_SETUP_INIT_FLAGS],
    1.30 +[
    1.31 +  # Option used to tell the compiler whether to create 32- or 64-bit executables
    1.32 +  if test "x$TOOLCHAIN_TYPE" = xxlc; then
    1.33 +    COMPILER_TARGET_BITS_FLAG="-q"
    1.34 +  else
    1.35 +    COMPILER_TARGET_BITS_FLAG="-m"
    1.36 +  fi
    1.37 +  AC_SUBST(COMPILER_TARGET_BITS_FLAG)
    1.38 +
    1.39 +  # FIXME: figure out if we should select AR flags depending on OS or toolchain.
    1.40 +  if test "x$OPENJDK_TARGET_OS" = xmacosx; then
    1.41 +    ARFLAGS="-r"
    1.42 +  elif test "x$OPENJDK_TARGET_OS" = xaix; then
    1.43 +    ARFLAGS="-X64"
    1.44 +  elif test "x$OPENJDK_TARGET_OS" = xwindows; then
    1.45 +    # lib.exe is used as AR to create static libraries.
    1.46 +    ARFLAGS="-nologo -NODEFAULTLIB:MSVCRT"
    1.47 +  else
    1.48 +    ARFLAGS=""
    1.49 +  fi
    1.50 +  AC_SUBST(ARFLAGS)
    1.51 +
    1.52 +  ## Setup strip.
    1.53 +  # FIXME: should this really be per platform, or should it be per toolchain type?
    1.54 +  # strip is not provided by clang or solstudio; so guessing platform makes most sense.
    1.55 +  # FIXME: we should really only export STRIPFLAGS from here, not POST_STRIP_CMD.
    1.56 +  if test "x$OPENJDK_TARGET_OS" = xlinux; then
    1.57 +    STRIPFLAGS="-g"
    1.58 +  elif test "x$OPENJDK_TARGET_OS" = xsolaris; then
    1.59 +    STRIPFLAGS="-x"
    1.60 +  elif test "x$OPENJDK_TARGET_OS" = xmacosx; then
    1.61 +    STRIPFLAGS="-S"
    1.62 +  elif test "x$OPENJDK_TARGET_OS" = xaix; then
    1.63 +    STRIPFLAGS="-X32_64"
    1.64 +  fi
    1.65 +
    1.66 +  if test "x$OPENJDK_TARGET_OS" != xwindows; then
    1.67 +    POST_STRIP_CMD="$STRIP $STRIPFLAGS"
    1.68 +  fi
    1.69 +  AC_SUBST(POST_STRIP_CMD)
    1.70 +
    1.71 +  if test "x$OPENJDK_TARGET_OS" = xsolaris; then
    1.72 +    # FIXME: break out into MCSFLAGS
    1.73 +    POST_MCS_CMD="$MCS -d -a \"JDK $FULL_VERSION\""
    1.74 +  fi
    1.75 +  AC_SUBST(POST_MCS_CMD)
    1.76 +
    1.77 +  if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
    1.78 +    CC_OUT_OPTION=-Fo
    1.79 +    EXE_OUT_OPTION=-out:
    1.80 +    LD_OUT_OPTION=-out:
    1.81 +    AR_OUT_OPTION=-out:
    1.82 +  else
    1.83 +    # The option used to specify the target .o,.a or .so file.
    1.84 +    # When compiling, how to specify the to be created object file.
    1.85 +    CC_OUT_OPTION='-o$(SPACE)'
    1.86 +    # When linking, how to specify the to be created executable.
    1.87 +    EXE_OUT_OPTION='-o$(SPACE)'
    1.88 +    # When linking, how to specify the to be created dynamically linkable library.
    1.89 +    LD_OUT_OPTION='-o$(SPACE)'
    1.90 +    # When archiving, how to specify the to be create static archive for object files.
    1.91 +    AR_OUT_OPTION='rcs$(SPACE)'
    1.92 +  fi
    1.93 +  AC_SUBST(CC_OUT_OPTION)
    1.94 +  AC_SUBST(EXE_OUT_OPTION)
    1.95 +  AC_SUBST(LD_OUT_OPTION)
    1.96 +  AC_SUBST(AR_OUT_OPTION)
    1.97 +
    1.98 +  # On Windows, we need to set RC flags.
    1.99 +  if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
   1.100 +    RC_FLAGS="-nologo -l 0x409 -r"
   1.101 +    if test "x$VARIANT" = xOPT; then
   1.102 +      RC_FLAGS="$RC_FLAGS -d NDEBUG"
   1.103 +    fi
   1.104 +
   1.105 +    # The version variables used to create RC_FLAGS may be overridden
   1.106 +    # in a custom configure script, or possibly the command line.
   1.107 +    # Let those variables be expanded at make time in spec.gmk.
   1.108 +    # The \$ are escaped to the shell, and the $(...) variables
   1.109 +    # are evaluated by make.
   1.110 +    RC_FLAGS="$RC_FLAGS \
   1.111 +        -d \"JDK_BUILD_ID=\$(FULL_VERSION)\" \
   1.112 +        -d \"JDK_COMPANY=\$(COMPANY_NAME)\" \
   1.113 +        -d \"JDK_COMPONENT=\$(PRODUCT_NAME) \$(JDK_RC_PLATFORM_NAME) binary\" \
   1.114 +        -d \"JDK_VER=\$(JDK_MINOR_VERSION).\$(JDK_MICRO_VERSION).\$(if \$(JDK_UPDATE_VERSION),\$(JDK_UPDATE_VERSION),0).\$(COOKED_BUILD_NUMBER)\" \
   1.115 +        -d \"JDK_COPYRIGHT=Copyright \xA9 $COPYRIGHT_YEAR\" \
   1.116 +        -d \"JDK_NAME=\$(PRODUCT_NAME) \$(JDK_RC_PLATFORM_NAME) \$(JDK_MINOR_VERSION) \$(JDK_UPDATE_META_TAG)\" \
   1.117 +        -d \"JDK_FVER=\$(JDK_MINOR_VERSION),\$(JDK_MICRO_VERSION),\$(if \$(JDK_UPDATE_VERSION),\$(JDK_UPDATE_VERSION),0),\$(COOKED_BUILD_NUMBER)\""
   1.118 +  fi
   1.119 +  AC_SUBST(RC_FLAGS)
   1.120 +
   1.121 +  if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
   1.122 +    # FIXME: likely bug, should be CCXXFLAGS_JDK? or one for C or CXX.
   1.123 +    CCXXFLAGS="$CCXXFLAGS -nologo"
   1.124 +  fi
   1.125 +])
   1.126 +
   1.127 +AC_DEFUN_ONCE([FLAGS_SETUP_COMPILER_FLAGS_FOR_LIBS],
   1.128 +[
   1.129 +  ###############################################################################
   1.130 +  #
   1.131 +  # How to compile shared libraries.
   1.132 +  #
   1.133 +
   1.134 +  if test "x$TOOLCHAIN_TYPE" = xgcc; then
   1.135 +    PICFLAG="-fPIC"
   1.136 +    C_FLAG_REORDER=''
   1.137 +    CXX_FLAG_REORDER=''
   1.138 +
   1.139 +    if test "x$OPENJDK_TARGET_OS" = xmacosx; then
   1.140 +      # Linking is different on MacOSX
   1.141 +      SHARED_LIBRARY_FLAGS="-dynamiclib -compatibility_version 1.0.0 -current_version 1.0.0 $PICFLAG"
   1.142 +      SET_EXECUTABLE_ORIGIN='-Xlinker -rpath -Xlinker @loader_path/.'
   1.143 +      SET_SHARED_LIBRARY_ORIGIN="$SET_EXECUTABLE_ORIGIN"
   1.144 +      SET_SHARED_LIBRARY_NAME='-Xlinker -install_name -Xlinker @rpath/[$]1'
   1.145 +      SET_SHARED_LIBRARY_MAPFILE=''
   1.146 +    else
   1.147 +      # Default works for linux, might work on other platforms as well.
   1.148 +      SHARED_LIBRARY_FLAGS='-shared'
   1.149 +      SET_EXECUTABLE_ORIGIN='-Xlinker -rpath -Xlinker \$$$$ORIGIN[$]1'
   1.150 +      SET_SHARED_LIBRARY_ORIGIN="-Xlinker -z -Xlinker origin $SET_EXECUTABLE_ORIGIN"
   1.151 +      SET_SHARED_LIBRARY_NAME='-Xlinker -soname=[$]1'
   1.152 +      SET_SHARED_LIBRARY_MAPFILE='-Xlinker -version-script=[$]1'
   1.153 +    fi
   1.154 +  elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
   1.155 +    PICFLAG="-KPIC"
   1.156 +    C_FLAG_REORDER='-xF'
   1.157 +    CXX_FLAG_REORDER='-xF'
   1.158 +    SHARED_LIBRARY_FLAGS="-G"
   1.159 +    SET_EXECUTABLE_ORIGIN='-R\$$$$ORIGIN[$]1'
   1.160 +    SET_SHARED_LIBRARY_ORIGIN="$SET_EXECUTABLE_ORIGIN"
   1.161 +    SET_SHARED_LIBRARY_NAME=''
   1.162 +    SET_SHARED_LIBRARY_MAPFILE='-M[$]1'
   1.163 +  elif test "x$TOOLCHAIN_TYPE" = xxlc; then
   1.164 +    PICFLAG="-qpic=large"
   1.165 +    C_FLAG_REORDER=''
   1.166 +    CXX_FLAG_REORDER=''
   1.167 +    SHARED_LIBRARY_FLAGS="-qmkshrobj"
   1.168 +    SET_EXECUTABLE_ORIGIN=""
   1.169 +    SET_SHARED_LIBRARY_ORIGIN=''
   1.170 +    SET_SHARED_LIBRARY_NAME=''
   1.171 +    SET_SHARED_LIBRARY_MAPFILE=''
   1.172 +  elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
   1.173 +    PICFLAG=""
   1.174 +    C_FLAG_REORDER=''
   1.175 +    CXX_FLAG_REORDER=''
   1.176 +    SHARED_LIBRARY_FLAGS="-LD"
   1.177 +    SET_EXECUTABLE_ORIGIN=''
   1.178 +    SET_SHARED_LIBRARY_ORIGIN=''
   1.179 +    SET_SHARED_LIBRARY_NAME=''
   1.180 +    SET_SHARED_LIBRARY_MAPFILE=''
   1.181 +  fi
   1.182 +
   1.183 +  AC_SUBST(C_FLAG_REORDER)
   1.184 +  AC_SUBST(CXX_FLAG_REORDER)
   1.185 +  AC_SUBST(SHARED_LIBRARY_FLAGS)
   1.186 +  AC_SUBST(SET_EXECUTABLE_ORIGIN)
   1.187 +  AC_SUBST(SET_SHARED_LIBRARY_ORIGIN)
   1.188 +  AC_SUBST(SET_SHARED_LIBRARY_NAME)
   1.189 +  AC_SUBST(SET_SHARED_LIBRARY_MAPFILE)
   1.190 +
   1.191 +  if test "x$OPENJDK_TARGET_OS" = xsolaris; then
   1.192 +    CFLAGS_JDK="${CFLAGS_JDK} -D__solaris__"
   1.193 +    CXXFLAGS_JDK="${CXXFLAGS_JDK} -D__solaris__"
   1.194 +    CFLAGS_JDKLIB_EXTRA='-xstrconst'
   1.195 +  fi
   1.196 +  # The (cross) compiler is now configured, we can now test capabilities
   1.197 +  # of the target platform.
   1.198 +])
   1.199 +
   1.200 +# Documentation on common flags used for solstudio in HIGHEST.
   1.201 +#
   1.202 +# WARNING: Use of OPTIMIZATION_LEVEL=HIGHEST in your Makefile needs to be
   1.203 +#          done with care, there are some assumptions below that need to
   1.204 +#          be understood about the use of pointers, and IEEE behavior.
   1.205 +#
   1.206 +# -fns: Use non-standard floating point mode (not IEEE 754)
   1.207 +# -fsimple: Do some simplification of floating point arithmetic (not IEEE 754)
   1.208 +# -fsingle: Use single precision floating point with 'float'
   1.209 +# -xalias_level=basic: Assume memory references via basic pointer types do not alias
   1.210 +#   (Source with excessing pointer casting and data access with mixed
   1.211 +#    pointer types are not recommended)
   1.212 +# -xbuiltin=%all: Use intrinsic or inline versions for math/std functions
   1.213 +#   (If you expect perfect errno behavior, do not use this)
   1.214 +# -xdepend: Loop data dependency optimizations (need -xO3 or higher)
   1.215 +# -xrestrict: Pointer parameters to functions do not overlap
   1.216 +#   (Similar to -xalias_level=basic usage, but less obvious sometimes.
   1.217 +#    If you pass in multiple pointers to the same data, do not use this)
   1.218 +# -xlibmil: Inline some library routines
   1.219 +#   (If you expect perfect errno behavior, do not use this)
   1.220 +# -xlibmopt: Use optimized math routines (CURRENTLY DISABLED)
   1.221 +#   (If you expect perfect errno behavior, do not use this)
   1.222 +#  Can cause undefined external on Solaris 8 X86 on __sincos, removing for now
   1.223 +
   1.224 +    # FIXME: this will never happen since sparc != sparcv9, ie 32 bit, which we don't build anymore.
   1.225 +    # Bug?
   1.226 +    #if test "x$OPENJDK_TARGET_CPU" = xsparc; then
   1.227 +    #  CFLAGS_JDK="${CFLAGS_JDK} -xmemalign=4s"
   1.228 +    #  CXXFLAGS_JDK="${CXXFLAGS_JDK} -xmemalign=4s"
   1.229 +    #fi
   1.230 +
   1.231 +AC_DEFUN_ONCE([FLAGS_SETUP_COMPILER_FLAGS_FOR_OPTIMIZATION],
   1.232 +[
   1.233 +
   1.234 +  ###############################################################################
   1.235 +  #
   1.236 +  # Setup the opt flags for different compilers
   1.237 +  # and different operating systems.
   1.238 +  #
   1.239 +
   1.240 +  # FIXME: this was indirectly the old default, but just inherited.
   1.241 +  # if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
   1.242 +  #   C_FLAG_DEPS="-MMD -MF"
   1.243 +  # fi
   1.244 +
   1.245 +  # Generate make dependency files
   1.246 +  if test "x$TOOLCHAIN_TYPE" = xgcc; then
   1.247 +    C_FLAG_DEPS="-MMD -MF"
   1.248 +  elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
   1.249 +    C_FLAG_DEPS="-xMMD -xMF"
   1.250 +  elif test "x$TOOLCHAIN_TYPE" = xxlc; then
   1.251 +    C_FLAG_DEPS="-qmakedep=gcc -MF"
   1.252 +  fi
   1.253 +  CXX_FLAG_DEPS="$C_FLAG_DEPS"
   1.254 +  AC_SUBST(C_FLAG_DEPS)
   1.255 +  AC_SUBST(CXX_FLAG_DEPS)
   1.256 +
   1.257 +  # Debug symbols
   1.258 +  if test "x$TOOLCHAIN_TYPE" = xgcc; then
   1.259 +    if test "x$OPENJDK_TARGET_CPU_BITS" = "x64" && test "x$DEBUG_LEVEL" = "xfastdebug"; then
   1.260 +      CFLAGS_DEBUG_SYMBOLS="-g1"
   1.261 +      CXXFLAGS_DEBUG_SYMBOLS="-g1"
   1.262 +    else
   1.263 +      CFLAGS_DEBUG_SYMBOLS="-g"
   1.264 +      CXXFLAGS_DEBUG_SYMBOLS="-g"
   1.265 +    fi
   1.266 +  elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
   1.267 +    CFLAGS_DEBUG_SYMBOLS="-g -xs"
   1.268 +    CXXFLAGS_DEBUG_SYMBOLS="-g0 -xs"
   1.269 +  elif test "x$TOOLCHAIN_TYPE" = xxlc; then
   1.270 +    CFLAGS_DEBUG_SYMBOLS="-g"
   1.271 +    CXXFLAGS_DEBUG_SYMBOLS="-g"
   1.272 +  fi
   1.273 +  AC_SUBST(CFLAGS_DEBUG_SYMBOLS)
   1.274 +  AC_SUBST(CXXFLAGS_DEBUG_SYMBOLS)
   1.275 +
   1.276 +  # Optimization levels
   1.277 +  if test "x$TOOLCHAIN_TYPE" = xsolstudio; then
   1.278 +    CC_HIGHEST="$CC_HIGHEST -fns -fsimple -fsingle -xalias_level=basic -xbuiltin=%all -xdepend -xrestrict -xlibmil"
   1.279 +
   1.280 +    if test "x$OPENJDK_TARGET_CPU_ARCH" = "xx86"; then
   1.281 +      # FIXME: seems we always set -xregs=no%frameptr; put it elsewhere more global?
   1.282 +      C_O_FLAG_HIGHEST="-xO4 -Wu,-O4~yz $CC_HIGHEST -xregs=no%frameptr"
   1.283 +      C_O_FLAG_HI="-xO4 -Wu,-O4~yz -xregs=no%frameptr"
   1.284 +      C_O_FLAG_NORM="-xO2 -Wu,-O2~yz -xregs=no%frameptr"
   1.285 +      C_O_FLAG_NONE="-xregs=no%frameptr"
   1.286 +      CXX_O_FLAG_HIGHEST="-xO4 -Qoption ube -O4~yz $CC_HIGHEST -xregs=no%frameptr"
   1.287 +      CXX_O_FLAG_HI="-xO4 -Qoption ube -O4~yz -xregs=no%frameptr"
   1.288 +      CXX_O_FLAG_NORM="-xO2 -Qoption ube -O2~yz -xregs=no%frameptr"
   1.289 +      CXX_O_FLAG_NONE="-xregs=no%frameptr"
   1.290 +      if test "x$OPENJDK_TARGET_CPU_BITS" = "x32"; then
   1.291 +        C_O_FLAG_HIGHEST="$C_O_FLAG_HIGHEST -xchip=pentium"
   1.292 +        CXX_O_FLAG_HIGHEST="$CXX_O_FLAG_HIGHEST -xchip=pentium"
   1.293 +      fi
   1.294 +    elif test "x$OPENJDK_TARGET_CPU_ARCH" = "xsparc"; then
   1.295 +      C_O_FLAG_HIGHEST="-xO4 -Wc,-Qrm-s -Wc,-Qiselect-T0 $CC_HIGHEST -xprefetch=auto,explicit -xchip=ultra"
   1.296 +      C_O_FLAG_HI="-xO4 -Wc,-Qrm-s -Wc,-Qiselect-T0"
   1.297 +      C_O_FLAG_NORM="-xO2 -Wc,-Qrm-s -Wc,-Qiselect-T0"
   1.298 +      C_O_FLAG_NONE=""
   1.299 +      CXX_O_FLAG_HIGHEST="-xO4 -Qoption cg -Qrm-s -Qoption cg -Qiselect-T0 $CC_HIGHEST -xprefetch=auto,explicit -xchip=ultra"
   1.300 +      CXX_O_FLAG_HI="-xO4 -Qoption cg -Qrm-s -Qoption cg -Qiselect-T0"
   1.301 +      CXX_O_FLAG_NORM="-xO2 -Qoption cg -Qrm-s -Qoption cg -Qiselect-T0"
   1.302 +      CXX_O_FLAG_NONE=""
   1.303 +    fi
   1.304 +  else
   1.305 +    # The remaining toolchains share opt flags between CC and CXX;
   1.306 +    # setup for C and duplicate afterwards.
   1.307 +    if test "x$TOOLCHAIN_TYPE" = xgcc; then
   1.308 +      if test "x$OPENJDK_TARGET_OS" = xmacosx; then
   1.309 +        # On MacOSX we optimize for size, something
   1.310 +        # we should do for all platforms?
   1.311 +        C_O_FLAG_HIGHEST="-Os"
   1.312 +        C_O_FLAG_HI="-Os"
   1.313 +        C_O_FLAG_NORM="-Os"
   1.314 +        C_O_FLAG_NONE=""
   1.315 +      else
   1.316 +        C_O_FLAG_HIGHEST="-O3"
   1.317 +        C_O_FLAG_HI="-O3"
   1.318 +        C_O_FLAG_NORM="-O2"
   1.319 +        C_O_FLAG_NONE="-O0"
   1.320 +      fi
   1.321 +    elif test "x$TOOLCHAIN_TYPE" = xxlc; then
   1.322 +      C_O_FLAG_HIGHEST="-O3"
   1.323 +      C_O_FLAG_HI="-O3 -qstrict"
   1.324 +      C_O_FLAG_NORM="-O2"
   1.325 +      C_O_FLAG_NONE=""
   1.326 +    elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
   1.327 +      C_O_FLAG_HIGHEST="-O2"
   1.328 +      C_O_FLAG_HI="-O1"
   1.329 +      C_O_FLAG_NORM="-O1"
   1.330 +      C_O_FLAG_NONE="-Od"
   1.331 +    fi
   1.332 +    CXX_O_FLAG_HIGHEST="$C_O_FLAG_HIGHEST"
   1.333 +    CXX_O_FLAG_HI="$C_O_FLAG_HI"
   1.334 +    CXX_O_FLAG_NORM="$C_O_FLAG_NORM"
   1.335 +    CXX_O_FLAG_NONE="$C_O_FLAG_NONE"
   1.336 +  fi
   1.337 +
   1.338 +  AC_SUBST(C_O_FLAG_HIGHEST)
   1.339 +  AC_SUBST(C_O_FLAG_HI)
   1.340 +  AC_SUBST(C_O_FLAG_NORM)
   1.341 +  AC_SUBST(C_O_FLAG_NONE)
   1.342 +  AC_SUBST(CXX_O_FLAG_HIGHEST)
   1.343 +  AC_SUBST(CXX_O_FLAG_HI)
   1.344 +  AC_SUBST(CXX_O_FLAG_NORM)
   1.345 +  AC_SUBST(CXX_O_FLAG_NONE)
   1.346 +])
   1.347 +
   1.348 +AC_DEFUN_ONCE([FLAGS_SETUP_COMPILER_FLAGS_FOR_JDK],
   1.349 +[
   1.350 +  # Special extras...
   1.351 +  if test "x$TOOLCHAIN_TYPE" = xsolstudio; then
   1.352 +    if test "x$OPENJDK_TARGET_CPU_ARCH" = "xsparc"; then
   1.353 +      CFLAGS_JDKLIB_EXTRA="${CFLAGS_JDKLIB_EXTRA} -xregs=no%appl"
   1.354 +      CXXFLAGS_JDKLIB_EXTRA="${CXXFLAGS_JDKLIB_EXTRA} -xregs=no%appl"
   1.355 +    fi
   1.356 +  elif test "x$TOOLCHAIN_TYPE" = xxlc; then
   1.357 +    LDFLAGS_JDK="${LDFLAGS_JDK} -q64 -brtl -bnolibpath -liconv -bexpall"
   1.358 +    CFLAGS_JDK="${CFLAGS_JDK} -qchars=signed -q64 -qfullpath -qsaveopt"
   1.359 +    CXXFLAGS_JDK="${CXXFLAGS_JDK} -qchars=signed -q64 -qfullpath -qsaveopt"
   1.360 +  elif test "x$TOOLCHAIN_TYPE" = xgcc; then
   1.361 +    $2CXXSTD_CXXFLAG="-std=gnu++98"
   1.362 +    FLAGS_CXX_COMPILER_CHECK_ARGUMENTS([[$]$2CXXSTD_CXXFLAG -Werror],
   1.363 +                                       [], [$2CXXSTD_CXXFLAG=""])
   1.364 +    $2CXXFLAGS_JDK="${$2CXXFLAGS_JDK} ${$2CXXSTD_CXXFLAG}"
   1.365 +    $2JVM_CFLAGS="${$2JVM_CFLAGS} ${$2CXXSTD_CXXFLAG}"
   1.366 +    AC_SUBST($2CXXSTD_CXXFLAG)
   1.367 +  fi
   1.368 +
   1.369 +  if test "x$CFLAGS" != "x${ADDED_CFLAGS}"; then
   1.370 +    AC_MSG_WARN([Ignoring CFLAGS($CFLAGS) found in environment. Use --with-extra-cflags])
   1.371 +  fi
   1.372 +
   1.373 +  if test "x$CXXFLAGS" != "x${ADDED_CXXFLAGS}"; then
   1.374 +    AC_MSG_WARN([Ignoring CXXFLAGS($CXXFLAGS) found in environment. Use --with-extra-cxxflags])
   1.375 +  fi
   1.376 +
   1.377 +  if test "x$LDFLAGS" != "x${ADDED_LDFLAGS}"; then
   1.378 +    AC_MSG_WARN([Ignoring LDFLAGS($LDFLAGS) found in environment. Use --with-extra-ldflags])
   1.379 +  fi
   1.380 +
   1.381 +  AC_ARG_WITH(extra-cflags, [AS_HELP_STRING([--with-extra-cflags],
   1.382 +      [extra flags to be used when compiling jdk c-files])])
   1.383 +
   1.384 +  AC_ARG_WITH(extra-cxxflags, [AS_HELP_STRING([--with-extra-cxxflags],
   1.385 +      [extra flags to be used when compiling jdk c++-files])])
   1.386 +
   1.387 +  AC_ARG_WITH(extra-ldflags, [AS_HELP_STRING([--with-extra-ldflags],
   1.388 +      [extra flags to be used when linking jdk])])
   1.389 +
   1.390 +  CFLAGS_JDK="${CFLAGS_JDK} $with_extra_cflags"
   1.391 +  CXXFLAGS_JDK="${CXXFLAGS_JDK} $with_extra_cxxflags"
   1.392 +  LDFLAGS_JDK="${LDFLAGS_JDK} $with_extra_ldflags"
   1.393 +
   1.394 +  # Hotspot needs these set in their legacy form
   1.395 +  LEGACY_EXTRA_CFLAGS=$with_extra_cflags
   1.396 +  LEGACY_EXTRA_CXXFLAGS=$with_extra_cxxflags
   1.397 +  LEGACY_EXTRA_LDFLAGS=$with_extra_ldflags
   1.398 +
   1.399 +  AC_SUBST(LEGACY_EXTRA_CFLAGS)
   1.400 +  AC_SUBST(LEGACY_EXTRA_CXXFLAGS)
   1.401 +  AC_SUBST(LEGACY_EXTRA_LDFLAGS)
   1.402 +
   1.403 +  ###############################################################################
   1.404 +  #
   1.405 +  # Now setup the CFLAGS and LDFLAGS for the JDK build.
   1.406 +  # Later we will also have CFLAGS and LDFLAGS for the hotspot subrepo build.
   1.407 +  #
   1.408 +
   1.409 +  # Setup compiler/platform specific flags to CFLAGS_JDK,
   1.410 +  # CXXFLAGS_JDK and CCXXFLAGS_JDK (common to C and CXX?)
   1.411 +  if test "x$TOOLCHAIN_TYPE" = xgcc; then
   1.412 +    # these options are used for both C and C++ compiles
   1.413 +    CCXXFLAGS_JDK="$CCXXFLAGS $CCXXFLAGS_JDK -Wall -Wno-parentheses -Wextra -Wno-unused -Wno-unused-parameter -Wformat=2 \
   1.414 +        -pipe -D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE"
   1.415 +    case $OPENJDK_TARGET_CPU_ARCH in
   1.416 +      arm )
   1.417 +        # on arm we don't prevent gcc to omit frame pointer but do prevent strict aliasing
   1.418 +        CFLAGS_JDK="${CFLAGS_JDK} -fno-strict-aliasing"
   1.419 +        ;;
   1.420 +      ppc )
   1.421 +        # on ppc we don't prevent gcc to omit frame pointer nor strict-aliasing
   1.422 +        ;;
   1.423 +      * )
   1.424 +        CCXXFLAGS_JDK="$CCXXFLAGS_JDK -fno-omit-frame-pointer"
   1.425 +        CFLAGS_JDK="${CFLAGS_JDK} -fno-strict-aliasing"
   1.426 +        ;;
   1.427 +    esac
   1.428 +    TOOLCHAIN_CHECK_COMPILER_VERSION(6, FLAGS_SETUP_GCC6_COMPILER_FLAGS)
   1.429 +  elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
   1.430 +    CCXXFLAGS_JDK="$CCXXFLAGS $CCXXFLAGS_JDK -DTRACING -DMACRO_MEMSYS_OPS -DBREAKPTS"
   1.431 +    if test "x$OPENJDK_TARGET_CPU_ARCH" = xx86; then
   1.432 +      CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DcpuIntel -Di586 -D$OPENJDK_TARGET_CPU_LEGACY_LIB"
   1.433 +      CFLAGS_JDK="$CFLAGS_JDK -erroff=E_BAD_PRAGMA_PACK_VALUE"
   1.434 +    fi
   1.435 +  
   1.436 +    CFLAGS_JDK="$CFLAGS_JDK -xc99=%none -xCC -errshort=tags -Xa -v -mt -W0,-noglobal"
   1.437 +    CXXFLAGS_JDK="$CXXFLAGS_JDK -errtags=yes +w -mt -features=no%except -DCC_NOEX -norunpath -xnolib"
   1.438 +  elif test "x$TOOLCHAIN_TYPE" = xxlc; then
   1.439 +    CFLAGS_JDK="$CFLAGS_JDK -D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE -DSTDC"
   1.440 +    CXXFLAGS_JDK="$CXXFLAGS_JDK -D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE -DSTDC"
   1.441 +  elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
   1.442 +    CCXXFLAGS_JDK="$CCXXFLAGS $CCXXFLAGS_JDK -Zi -MD -Zc:wchar_t- -W3 -wd4800 \
   1.443 +    -D_STATIC_CPPLIB -D_DISABLE_DEPRECATE_STATIC_CPPLIB -DWIN32_LEAN_AND_MEAN \
   1.444 +    -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE \
   1.445 +    -DWIN32 -DIAL"
   1.446 +    if test "x$OPENJDK_TARGET_CPU" = xx86_64; then
   1.447 +      CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_AMD64_ -Damd64"
   1.448 +    else
   1.449 +      CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_X86_ -Dx86"
   1.450 +    fi
   1.451 +  fi
   1.452 +
   1.453 +  ###############################################################################
   1.454 +
   1.455 +  # Adjust flags according to debug level.
   1.456 +  case $DEBUG_LEVEL in
   1.457 +    fastdebug )
   1.458 +      CFLAGS_JDK="$CFLAGS_JDK $CFLAGS_DEBUG_SYMBOLS"
   1.459 +      CXXFLAGS_JDK="$CXXFLAGS_JDK $CXXFLAGS_DEBUG_SYMBOLS"
   1.460 +      C_O_FLAG_HI="$C_O_FLAG_NORM"
   1.461 +      C_O_FLAG_NORM="$C_O_FLAG_NORM"
   1.462 +      CXX_O_FLAG_HI="$CXX_O_FLAG_NORM"
   1.463 +      CXX_O_FLAG_NORM="$CXX_O_FLAG_NORM"
   1.464 +      JAVAC_FLAGS="$JAVAC_FLAGS -g"
   1.465 +      ;;
   1.466 +    slowdebug )
   1.467 +      CFLAGS_JDK="$CFLAGS_JDK $CFLAGS_DEBUG_SYMBOLS"
   1.468 +      CXXFLAGS_JDK="$CXXFLAGS_JDK $CXXFLAGS_DEBUG_SYMBOLS"
   1.469 +      C_O_FLAG_HI="$C_O_FLAG_NONE"
   1.470 +      C_O_FLAG_NORM="$C_O_FLAG_NONE"
   1.471 +      CXX_O_FLAG_HI="$CXX_O_FLAG_NONE"
   1.472 +      CXX_O_FLAG_NORM="$CXX_O_FLAG_NONE"
   1.473 +      JAVAC_FLAGS="$JAVAC_FLAGS -g"
   1.474 +      ;;
   1.475 +  esac
   1.476 +
   1.477 +  # Setup LP64
   1.478 +  CCXXFLAGS_JDK="$CCXXFLAGS_JDK $ADD_LP64"
   1.479 +
   1.480 +  # Set some common defines. These works for all compilers, but assume
   1.481 +  # -D is universally accepted.
   1.482 +
   1.483 +  # Setup endianness
   1.484 +  if test "x$OPENJDK_TARGET_CPU_ENDIAN" = xlittle; then
   1.485 +    # The macro _LITTLE_ENDIAN needs to be defined the same to avoid the
   1.486 +    #   Sun C compiler warning message: warning: macro redefined: _LITTLE_ENDIAN
   1.487 +    #   (The Solaris X86 system defines this in file /usr/include/sys/isa_defs.h).
   1.488 +    #   Note: -Dmacro         is the same as    #define macro 1
   1.489 +    #         -Dmacro=        is the same as    #define macro
   1.490 +    if test "x$OPENJDK_TARGET_OS" = xsolaris; then
   1.491 +      CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_LITTLE_ENDIAN="
   1.492 +    else
   1.493 +      CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_LITTLE_ENDIAN"
   1.494 +    fi
   1.495 +  else
   1.496 +    CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_BIG_ENDIAN"
   1.497 +  fi
   1.498 +  
   1.499 +  # Setup target OS define. Use OS target name but in upper case.
   1.500 +  OPENJDK_TARGET_OS_UPPERCASE=`$ECHO $OPENJDK_TARGET_OS | $TR 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
   1.501 +  CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D$OPENJDK_TARGET_OS_UPPERCASE"
   1.502 +
   1.503 +  # Setup target CPU
   1.504 +  CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DARCH='\"$OPENJDK_TARGET_CPU_LEGACY\"' -D$OPENJDK_TARGET_CPU_LEGACY"
   1.505 +  
   1.506 +  # Setup debug/release defines
   1.507 +  if test "x$DEBUG_LEVEL" = xrelease; then
   1.508 +    CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DNDEBUG"
   1.509 +    if test "x$OPENJDK_TARGET_OS" = xsolaris; then
   1.510 +      CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DTRIMMED"
   1.511 +    fi
   1.512 +  else
   1.513 +    CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DDEBUG"
   1.514 +  fi
   1.515 +
   1.516 +  # Setup release name
   1.517 +  CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DRELEASE='\"\$(RELEASE)\"'"
   1.518 +
   1.519 +
   1.520 +  # Set some additional per-OS defines.
   1.521 +  if test "x$OPENJDK_TARGET_OS" = xmacosx; then
   1.522 +    CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_ALLBSD_SOURCE -D_DARWIN_UNLIMITED_SELECT"
   1.523 +  elif test "x$OPENJDK_TARGET_OS" = xaix; then
   1.524 +    # FIXME: PPC64 should not be here.
   1.525 +    CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DPPC64"
   1.526 +  elif test "x$OPENJDK_TARGET_OS" = xbsd; then
   1.527 +    CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_ALLBSD_SOURCE"
   1.528 +  fi
   1.529 +
   1.530 +  # Additional macosx handling
   1.531 +  if test "x$OPENJDK_TARGET_OS" = xmacosx; then
   1.532 +    if test "x$TOOLCHAIN_TYPE" = xgcc; then
   1.533 +      # FIXME: This needs to be exported in spec.gmk due to closed legacy code.
   1.534 +      # FIXME: clean this up, and/or move it elsewhere.
   1.535 +
   1.536 +      # Setting these parameters makes it an error to link to macosx APIs that are
   1.537 +      # newer than the given OS version and makes the linked binaries compatible 
   1.538 +      # even if built on a newer version of the OS.
   1.539 +      # The expected format is X.Y.Z
   1.540 +      MACOSX_VERSION_MIN=10.7.0
   1.541 +      AC_SUBST(MACOSX_VERSION_MIN)
   1.542 +    
   1.543 +      # The macro takes the version with no dots, ex: 1070
   1.544 +      # Let the flags variables get resolved in make for easier override on make
   1.545 +      # command line.
   1.546 +      CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DMAC_OS_X_VERSION_MAX_ALLOWED=\$(subst .,,\$(MACOSX_VERSION_MIN)) -mmacosx-version-min=\$(MACOSX_VERSION_MIN)"
   1.547 +      LDFLAGS_JDK="$LDFLAGS_JDK -mmacosx-version-min=\$(MACOSX_VERSION_MIN)"
   1.548 +    fi
   1.549 +  fi
   1.550 +
   1.551 +  # Setup some hard coded includes
   1.552 +  CCXXFLAGS_JDK="$CCXXFLAGS_JDK \
   1.553 +      -I${JDK_OUTPUTDIR}/include \
   1.554 +      -I${JDK_OUTPUTDIR}/include/$OPENJDK_TARGET_OS \
   1.555 +      -I${JDK_TOPDIR}/src/share/javavm/export \
   1.556 +      -I${JDK_TOPDIR}/src/$OPENJDK_TARGET_OS_EXPORT_DIR/javavm/export \
   1.557 +      -I${JDK_TOPDIR}/src/share/native/common \
   1.558 +      -I${JDK_TOPDIR}/src/$OPENJDK_TARGET_OS_API_DIR/native/common"
   1.559 +
   1.560 +  # The shared libraries are compiled using the picflag.
   1.561 +  CFLAGS_JDKLIB="$CCXXFLAGS_JDK $CFLAGS_JDK $PICFLAG $CFLAGS_JDKLIB_EXTRA"
   1.562 +  CXXFLAGS_JDKLIB="$CCXXFLAGS_JDK $CXXFLAGS_JDK $PICFLAG $CXXFLAGS_JDKLIB_EXTRA "
   1.563 +
   1.564 +  # Executable flags
   1.565 +  CFLAGS_JDKEXE="$CCXXFLAGS_JDK $CFLAGS_JDK"
   1.566 +  CXXFLAGS_JDKEXE="$CCXXFLAGS_JDK $CXXFLAGS_JDK"
   1.567 +
   1.568 +  AC_SUBST(CFLAGS_JDKLIB)
   1.569 +  AC_SUBST(CFLAGS_JDKEXE)
   1.570 +  AC_SUBST(CXXFLAGS_JDKLIB)
   1.571 +  AC_SUBST(CXXFLAGS_JDKEXE)
   1.572 +
   1.573 +  # Setup LDFLAGS et al.
   1.574 +  #
   1.575 +  # Now this is odd. The JDK native libraries have to link against libjvm.so
   1.576 +  # On 32-bit machines there is normally two distinct libjvm.so:s, client and server.
   1.577 +  # Which should we link to? Are we lucky enough that the binary api to the libjvm.so library
   1.578 +  # is identical for client and server? Yes. Which is picked at runtime (client or server)?
   1.579 +  # Neither, since the chosen libjvm.so has already been loaded by the launcher, all the following
   1.580 +  # libraries will link to whatever is in memory. Yuck.
   1.581 +  #
   1.582 +  # Thus we offer the compiler to find libjvm.so first in server then in client. It works. Ugh.
   1.583 +  if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
   1.584 +    LDFLAGS_JDK="$LDFLAGS_JDK -nologo -opt:ref -incremental:no"
   1.585 +    if test "x$OPENJDK_TARGET_CPU_BITS" = "x32"; then
   1.586 +      LDFLAGS_JDK="$LDFLAGS_JDK -safeseh"
   1.587 +    fi
   1.588 +    # TODO: make -debug optional "--disable-full-debug-symbols"
   1.589 +    LDFLAGS_JDK="$LDFLAGS_JDK -debug"
   1.590 +    LDFLAGS_JDKLIB="${LDFLAGS_JDK} -dll -libpath:${JDK_OUTPUTDIR}/lib"
   1.591 +    LDFLAGS_JDKLIB_SUFFIX=""
   1.592 +    if test "x$OPENJDK_TARGET_CPU_BITS" = "x64"; then
   1.593 +      LDFLAGS_STACK_SIZE=1048576
   1.594 +    else
   1.595 +      LDFLAGS_STACK_SIZE=327680
   1.596 +    fi
   1.597 +    LDFLAGS_JDKEXE="${LDFLAGS_JDK} /STACK:$LDFLAGS_STACK_SIZE"
   1.598 +  else
   1.599 +    if test "x$TOOLCHAIN_TYPE" = xgcc; then
   1.600 +      # If this is a --hash-style=gnu system, use --hash-style=both, why?
   1.601 +      # We have previously set HAS_GNU_HASH if this is the case
   1.602 +      if test -n "$HAS_GNU_HASH"; then
   1.603 +        LDFLAGS_JDK="${LDFLAGS_JDK} -Xlinker --hash-style=both "
   1.604 +      fi
   1.605 +      if test "x$OPENJDK_TARGET_OS" = xlinux; then
   1.606 +        # And since we now know that the linker is gnu, then add -z defs, to forbid
   1.607 +        # undefined symbols in object files.
   1.608 +        LDFLAGS_JDK="${LDFLAGS_JDK} -Xlinker -z -Xlinker defs"
   1.609 +        if test "x$DEBUG_LEVEL" = "xrelease"; then
   1.610 +          # When building release libraries, tell the linker optimize them.
   1.611 +          # Should this be supplied to the OSS linker as well?
   1.612 +          LDFLAGS_JDK="${LDFLAGS_JDK} -Xlinker -O1"
   1.613 +        fi
   1.614 +      fi
   1.615 +    fi
   1.616 +
   1.617 +    if test "x$TOOLCHAIN_TYPE" = xsolstudio; then
   1.618 +      LDFLAGS_JDK="$LDFLAGS_JDK -z defs -xildoff -ztext"
   1.619 +      LDFLAGS_CXX_JDK="$LDFLAGS_CXX_JDK -norunpath -xnolib"
   1.620 +    fi
   1.621 +
   1.622 +    LDFLAGS_JDKLIB="${LDFLAGS_JDK} $SHARED_LIBRARY_FLAGS \
   1.623 +        -L${JDK_OUTPUTDIR}/lib${OPENJDK_TARGET_CPU_LIBDIR}"
   1.624 +
   1.625 +    # On some platforms (mac) the linker warns about non existing -L dirs.
   1.626 +    # Add server first if available. Linking aginst client does not always produce the same results.
   1.627 +    # Only add client dir if client is being built. Add minimal (note not minimal1) if only building minimal1.
   1.628 +    # Default to server for other variants.
   1.629 +    if test "x$JVM_VARIANT_SERVER" = xtrue; then
   1.630 +      LDFLAGS_JDKLIB="${LDFLAGS_JDKLIB} -L${JDK_OUTPUTDIR}/lib${OPENJDK_TARGET_CPU_LIBDIR}/server"
   1.631 +    elif test "x$JVM_VARIANT_CLIENT" = xtrue; then
   1.632 +      LDFLAGS_JDKLIB="${LDFLAGS_JDKLIB} -L${JDK_OUTPUTDIR}/lib${OPENJDK_TARGET_CPU_LIBDIR}/client"
   1.633 +    elif test "x$JVM_VARIANT_MINIMAL1" = xtrue; then
   1.634 +      LDFLAGS_JDKLIB="${LDFLAGS_JDKLIB} -L${JDK_OUTPUTDIR}/lib${OPENJDK_TARGET_CPU_LIBDIR}/minimal"
   1.635 +    else
   1.636 +      LDFLAGS_JDKLIB="${LDFLAGS_JDKLIB} -L${JDK_OUTPUTDIR}/lib${OPENJDK_TARGET_CPU_LIBDIR}/server"
   1.637 +    fi
   1.638 +
   1.639 +    LDFLAGS_JDKLIB_SUFFIX="-ljava -ljvm"
   1.640 +    if test "x$TOOLCHAIN_TYPE" = xsolstudio; then
   1.641 +      LDFLAGS_JDKLIB_SUFFIX="$LDFLAGS_JDKLIB_SUFFIX -lc"
   1.642 +    fi
   1.643 +
   1.644 +    LDFLAGS_JDKEXE="${LDFLAGS_JDK}"
   1.645 +    if test "x$OPENJDK_TARGET_OS" = xlinux; then
   1.646 +      LDFLAGS_JDKEXE="$LDFLAGS_JDKEXE -Xlinker --allow-shlib-undefined"
   1.647 +    fi
   1.648 +  fi
   1.649 +  AC_SUBST(LDFLAGS_JDKLIB)
   1.650 +  AC_SUBST(LDFLAGS_JDKEXE)
   1.651 +  AC_SUBST(LDFLAGS_JDKLIB_SUFFIX)
   1.652 +  AC_SUBST(LDFLAGS_JDKEXE_SUFFIX)
   1.653 +  AC_SUBST(LDFLAGS_CXX_JDK)
   1.654 +])
   1.655 +
   1.656 +
   1.657 +# FLAGS_C_COMPILER_CHECK_ARGUMENTS([ARGUMENT], [RUN-IF-TRUE],
   1.658 +#                                  [RUN-IF-FALSE])
   1.659 +# ------------------------------------------------------------
   1.660 +# Check that the C compiler supports an argument
   1.661 +AC_DEFUN([FLAGS_C_COMPILER_CHECK_ARGUMENTS],
   1.662 +[
   1.663 +  AC_MSG_CHECKING([if the C compiler supports "$1"])
   1.664 +  supports=yes
   1.665 +
   1.666 +  saved_cflags="$CFLAGS"
   1.667 +  CFLAGS="$CFLAGS $1"
   1.668 +  AC_LANG_PUSH([C])
   1.669 +  AC_COMPILE_IFELSE([AC_LANG_SOURCE([[int i;]])], [], 
   1.670 +      [supports=no])
   1.671 +  AC_LANG_POP([C])
   1.672 +  CFLAGS="$saved_cflags"
   1.673 +
   1.674 +  AC_MSG_RESULT([$supports])
   1.675 +  if test "x$supports" = "xyes" ; then
   1.676 +    m4_ifval([$2], [$2], [:])
   1.677 +  else
   1.678 +    m4_ifval([$3], [$3], [:])
   1.679 +  fi
   1.680 +])
   1.681 +
   1.682 +# FLAGS_CXX_COMPILER_CHECK_ARGUMENTS([ARGUMENT], [RUN-IF-TRUE],
   1.683 +#                                    [RUN-IF-FALSE])
   1.684 +# ------------------------------------------------------------
   1.685 +# Check that the C++ compiler supports an argument
   1.686 +AC_DEFUN([FLAGS_CXX_COMPILER_CHECK_ARGUMENTS],
   1.687 +[
   1.688 +  AC_MSG_CHECKING([if the C++ compiler supports "$1"])
   1.689 +  supports=yes
   1.690 +
   1.691 +  saved_cxxflags="$CXXFLAGS"
   1.692 +  CXXFLAGS="$CXXFLAG $1"
   1.693 +  AC_LANG_PUSH([C++])
   1.694 +  AC_COMPILE_IFELSE([AC_LANG_SOURCE([[int i;]])], [], 
   1.695 +      [supports=no])
   1.696 +  AC_LANG_POP([C++])
   1.697 +  CXXFLAGS="$saved_cxxflags"
   1.698 +  
   1.699 +  AC_MSG_RESULT([$supports])
   1.700 +  if test "x$supports" = "xyes" ; then
   1.701 +    m4_ifval([$2], [$2], [:])
   1.702 +  else
   1.703 +    m4_ifval([$3], [$3], [:])
   1.704 +  fi
   1.705 +])
   1.706 +
   1.707 +# FLAGS_COMPILER_CHECK_ARGUMENTS([ARGUMENT], [RUN-IF-TRUE],
   1.708 +#                                [RUN-IF-FALSE])
   1.709 +# ------------------------------------------------------------
   1.710 +# Check that the C and C++ compilers support an argument
   1.711 +AC_DEFUN([FLAGS_COMPILER_CHECK_ARGUMENTS],
   1.712 +[
   1.713 +  FLAGS_C_COMPILER_CHECK_ARGUMENTS([$1],
   1.714 +                       [C_COMP_SUPPORTS="yes"],
   1.715 +                       [C_COMP_SUPPORTS="no"])
   1.716 +  FLAGS_CXX_COMPILER_CHECK_ARGUMENTS([$1],
   1.717 +                     [CXX_COMP_SUPPORTS="yes"],
   1.718 +                     [CXX_COMP_SUPPORTS="no"])
   1.719 +
   1.720 +  AC_MSG_CHECKING([if both compilers support "$1"])
   1.721 +  supports=no
   1.722 +  if test "x$C_COMP_SUPPORTS" = "xyes" -a "x$CXX_COMP_SUPPORTS" = "xyes"; then supports=yes; fi
   1.723 +  
   1.724 +  AC_MSG_RESULT([$supports])
   1.725 +  if test "x$supports" = "xyes" ; then
   1.726 +    m4_ifval([$2], [$2], [:])
   1.727 +  else
   1.728 +    m4_ifval([$3], [$3], [:])
   1.729 +  fi
   1.730 +])
   1.731 +
   1.732 +AC_DEFUN_ONCE([FLAGS_SETUP_COMPILER_FLAGS_MISC],
   1.733 +[
   1.734 +  # Some Zero and Shark settings.
   1.735 +  # ZERO_ARCHFLAG tells the compiler which mode to build for
   1.736 +  case "${OPENJDK_TARGET_CPU}" in
   1.737 +    s390)
   1.738 +      ZERO_ARCHFLAG="${COMPILER_TARGET_BITS_FLAG}31"
   1.739 +      ;;
   1.740 +    *)
   1.741 +      ZERO_ARCHFLAG="${COMPILER_TARGET_BITS_FLAG}${OPENJDK_TARGET_CPU_BITS}"
   1.742 +  esac
   1.743 +  FLAGS_COMPILER_CHECK_ARGUMENTS([$ZERO_ARCHFLAG], [], [ZERO_ARCHFLAG=""])
   1.744 +  AC_SUBST(ZERO_ARCHFLAG)
   1.745 +
   1.746 +  # Check that the compiler supports -mX (or -qX on AIX) flags
   1.747 +  # Set COMPILER_SUPPORTS_TARGET_BITS_FLAG to 'true' if it does
   1.748 +  FLAGS_COMPILER_CHECK_ARGUMENTS([${COMPILER_TARGET_BITS_FLAG}${OPENJDK_TARGET_CPU_BITS}],
   1.749 +      [COMPILER_SUPPORTS_TARGET_BITS_FLAG=true],
   1.750 +      [COMPILER_SUPPORTS_TARGET_BITS_FLAG=false])
   1.751 +  AC_SUBST(COMPILER_SUPPORTS_TARGET_BITS_FLAG)
   1.752 +])
   1.753 +
   1.754 +AC_DEFUN_ONCE([FLAGS_SETUP_GCC6_COMPILER_FLAGS],
   1.755 +[
   1.756 +  # These flags are required for GCC 6 builds as undefined behaviour in OpenJDK code
   1.757 +  # runs afoul of the more aggressive versions of these optimisations.
   1.758 +  # Notably, value range propagation now assumes that the this pointer of C++
   1.759 +  # member functions is non-null.
   1.760 +  NO_DELETE_NULL_POINTER_CHECKS_CFLAG="-fno-delete-null-pointer-checks"
   1.761 +  FLAGS_COMPILER_CHECK_ARGUMENTS([$NO_DELETE_NULL_POINTER_CHECKS_CFLAG -Werror],
   1.762 +                                     [], [NO_DELETE_NULL_POINTER_CHECKS_CFLAG=""])
   1.763 +  AC_SUBST([NO_DELETE_NULL_POINTER_CHECKS_CFLAG])
   1.764 +  NO_LIFETIME_DSE_CFLAG="-fno-lifetime-dse"
   1.765 +  FLAGS_COMPILER_CHECK_ARGUMENTS([$NO_LIFETIME_DSE_CFLAG -Werror],
   1.766 +                                     [], [NO_LIFETIME_DSE_CFLAG=""])
   1.767 +  CFLAGS_JDK="${CFLAGS_JDK} ${NO_DELETE_NULL_POINTER_CHECKS_CFLAG} ${NO_LIFETIME_DSE_CFLAG}"
   1.768 +  AC_SUBST([NO_LIFETIME_DSE_CFLAG])
   1.769 +])
   1.770 +

mercurial