common/autoconf/toolchain.m4

Thu, 24 May 2018 18:05:17 +0800

author
aoqi
date
Thu, 24 May 2018 18:05:17 +0800
changeset 2003
2224002fc647
parent 1862
73494e6ff8e5
parent 1482
8fb429038513
child 2186
5c86538f0b0d
permissions
-rw-r--r--

Merge

aoqi@0 1 #
ddehaven@1304 2 # Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
aoqi@0 3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
aoqi@0 4 #
aoqi@0 5 # This code is free software; you can redistribute it and/or modify it
aoqi@0 6 # under the terms of the GNU General Public License version 2 only, as
aoqi@0 7 # published by the Free Software Foundation. Oracle designates this
aoqi@0 8 # particular file as subject to the "Classpath" exception as provided
aoqi@0 9 # by Oracle in the LICENSE file that accompanied this code.
aoqi@0 10 #
aoqi@0 11 # This code is distributed in the hope that it will be useful, but WITHOUT
aoqi@0 12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
aoqi@0 13 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
aoqi@0 14 # version 2 for more details (a copy is included in the LICENSE file that
aoqi@0 15 # accompanied this code).
aoqi@0 16 #
aoqi@0 17 # You should have received a copy of the GNU General Public License version
aoqi@0 18 # 2 along with this work; if not, write to the Free Software Foundation,
aoqi@0 19 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
aoqi@0 20 #
aoqi@0 21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
aoqi@0 22 # or visit www.oracle.com if you need additional information or have any
aoqi@0 23 # questions.
aoqi@0 24 #
aoqi@0 25
andrew@1862 26 # Prepare the system so that TOOLCHAIN_CHECK_COMPILER_VERSION can be called.
andrew@1862 27 # Must have CC_VERSION_NUMBER and CXX_VERSION_NUMBER.
andrew@1862 28 AC_DEFUN([TOOLCHAIN_PREPARE_FOR_VERSION_COMPARISONS],
andrew@1862 29 [
andrew@1862 30 if test "x$CC_VERSION" != "x$CXX_VERSION"; then
andrew@1862 31 AC_MSG_WARN([C and C++ compiler has different version numbers, $CC_VERSION vs $CXX_VERSION.])
andrew@1862 32 AC_MSG_WARN([This typically indicates a broken setup, and is not supported])
andrew@1862 33 fi
andrew@1862 34
andrew@1862 35 # We only check CC_VERSION since we assume CXX_VERSION is equal.
andrew@1862 36 if [ [[ "$CC_VERSION" =~ (.*\.){3} ]] ]; then
andrew@1862 37 AC_MSG_WARN([C compiler version number has more than three parts (X.Y.Z): $CC_VERSION. Comparisons might be wrong.])
andrew@1862 38 fi
andrew@1862 39
andrew@1862 40 if [ [[ "$CC_VERSION" =~ [0-9]{6} ]] ]; then
andrew@1862 41 AC_MSG_WARN([C compiler version number has a part larger than 99999: $CC_VERSION. Comparisons might be wrong.])
andrew@1862 42 fi
andrew@1862 43
andrew@1862 44 COMPARABLE_ACTUAL_VERSION=`$AWK -F. '{ printf("%05d%05d%05d\n", [$]1, [$]2, [$]3) }' <<< "$CC_VERSION"`
andrew@1862 45 ])
andrew@1862 46
andrew@1862 47 # Check if the configured compiler (C and C++) is of a specific version or
andrew@1862 48 # newer. TOOLCHAIN_PREPARE_FOR_VERSION_COMPARISONS must have been called before.
andrew@1862 49 #
andrew@1862 50 # Arguments:
andrew@1862 51 # $1: The version string to check against the found version
andrew@1862 52 # $2: block to run if the compiler is at least this version (>=)
andrew@1862 53 # $3: block to run if the compiler is older than this version (<)
andrew@1862 54 AC_DEFUN([TOOLCHAIN_CHECK_COMPILER_VERSION],
andrew@1862 55 [
andrew@1862 56 REFERENCE_VERSION=$1
andrew@1862 57
andrew@1862 58 if [ [[ "$REFERENCE_VERSION" =~ (.*\.){3} ]] ]; then
andrew@1862 59 AC_MSG_ERROR([Internal error: Cannot compare to $REFERENCE_VERSION, only three parts (X.Y.Z) is supported])
andrew@1862 60 fi
andrew@1862 61
andrew@1862 62 if [ [[ "$REFERENCE_VERSION" =~ [0-9]{6} ]] ]; then
andrew@1862 63 AC_MSG_ERROR([Internal error: Cannot compare to $REFERENCE_VERSION, only parts < 99999 is supported])
andrew@1862 64 fi
andrew@1862 65
andrew@1862 66 # Version comparison method inspired by http://stackoverflow.com/a/24067243
andrew@1862 67 COMPARABLE_REFERENCE_VERSION=`$AWK -F. '{ printf("%05d%05d%05d\n", [$]1, [$]2, [$]3) }' <<< "$REFERENCE_VERSION"`
andrew@1862 68
andrew@1862 69 if test $COMPARABLE_ACTUAL_VERSION -ge $COMPARABLE_REFERENCE_VERSION ; then
andrew@1862 70 m4_ifval([$2], [$2], [:])
andrew@1862 71 else
andrew@1862 72 m4_ifval([$3], [$3], [:])
andrew@1862 73 fi
andrew@1862 74 ])
andrew@1862 75
aoqi@0 76 # $1 = compiler to test (CC or CXX)
aoqi@0 77 # $2 = human readable name of compiler (C or C++)
andrew@1862 78 AC_DEFUN([TOOLCHAIN_EXTRACT_COMPILER_VERSION],
aoqi@0 79 [
aoqi@0 80 COMPILER=[$]$1
aoqi@0 81 COMPILER_NAME=$2
aoqi@0 82
aoqi@0 83 if test "x$OPENJDK_TARGET_OS" = xsolaris; then
aoqi@0 84 # Make sure we use the Sun Studio compiler and not gcc on Solaris, which won't work
aoqi@0 85 COMPILER_VERSION_TEST=`$COMPILER -V 2>&1 | $HEAD -n 1`
aoqi@0 86 $ECHO $COMPILER_VERSION_TEST | $GREP "^.*: Sun $COMPILER_NAME" > /dev/null
aoqi@0 87 if test $? -ne 0; then
aoqi@0 88 GCC_VERSION_TEST=`$COMPILER --version 2>&1 | $HEAD -n 1`
aoqi@0 89
aoqi@0 90 AC_MSG_NOTICE([The $COMPILER_NAME compiler (located as $COMPILER) does not seem to be the required Sun Studio compiler.])
aoqi@0 91 AC_MSG_NOTICE([The result from running with -V was: "$COMPILER_VERSION_TEST" and with --version: "$GCC_VERSION_TEST"])
aoqi@0 92 AC_MSG_ERROR([Sun Studio compiler is required. Try setting --with-tools-dir.])
aoqi@0 93 else
aoqi@0 94 COMPILER_VERSION=`$ECHO $COMPILER_VERSION_TEST | $SED -n "s/^.*@<:@ ,\t@:>@$COMPILER_NAME@<:@ ,\t@:>@\(@<:@1-9@:>@\.@<:@0-9@:>@@<:@0-9@:>@*\).*/\1/p"`
aoqi@0 95 COMPILER_VENDOR="Sun Studio"
aoqi@0 96 fi
aoqi@0 97 elif test "x$OPENJDK_TARGET_OS" = xaix; then
aoqi@0 98 COMPILER_VERSION_TEST=`$COMPILER -qversion 2>&1 | $TAIL -n 1`
aoqi@0 99 $ECHO $COMPILER_VERSION_TEST | $GREP "^Version: " > /dev/null
aoqi@0 100 if test $? -ne 0; then
aoqi@0 101 AC_MSG_ERROR([Failed to detect the compiler version of $COMPILER ....])
aoqi@0 102 else
aoqi@0 103 COMPILER_VERSION=`$ECHO $COMPILER_VERSION_TEST | $SED -n 's/Version: \([0-9][0-9]\.[0-9][0-9]*\).*/\1/p'`
aoqi@0 104 COMPILER_VENDOR='IBM'
aoqi@0 105 fi
aoqi@0 106 elif test "x$OPENJDK_TARGET_OS" = xwindows; then
aoqi@0 107 # First line typically looks something like:
aoqi@0 108 # Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.40219.01 for 80x86
aoqi@0 109 COMPILER_VERSION_TEST=`$COMPILER 2>&1 | $HEAD -n 1 | $TR -d '\r'`
aoqi@0 110 COMPILER_VERSION=`$ECHO $COMPILER_VERSION_TEST | $SED -n "s/^.*Version \(@<:@1-9@:>@@<:@0-9.@:>@*\) .*/\1/p"`
aoqi@0 111 COMPILER_VENDOR="Microsoft CL.EXE"
aoqi@0 112 COMPILER_CPU_TEST=`$ECHO $COMPILER_VERSION_TEST | $SED -n "s/^.* for \(.*\)$/\1/p"`
aoqi@0 113 if test "x$OPENJDK_TARGET_CPU" = "xx86"; then
aoqi@0 114 if test "x$COMPILER_CPU_TEST" != "x80x86"; then
aoqi@0 115 AC_MSG_ERROR([Target CPU mismatch. We are building for $OPENJDK_TARGET_CPU but CL is for "$COMPILER_CPU_TEST"; expected "80x86".])
aoqi@0 116 fi
aoqi@0 117 elif test "x$OPENJDK_TARGET_CPU" = "xx86_64"; then
aoqi@0 118 if test "x$COMPILER_CPU_TEST" != "xx64"; then
aoqi@0 119 AC_MSG_ERROR([Target CPU mismatch. We are building for $OPENJDK_TARGET_CPU but CL is for "$COMPILER_CPU_TEST"; expected "x64".])
aoqi@0 120 fi
aoqi@0 121 fi
aoqi@0 122 else
aoqi@0 123 COMPILER_VERSION_TEST=`$COMPILER --version 2>&1 | $HEAD -n 1`
aoqi@0 124 # Check that this is likely to be GCC.
aoqi@0 125 $COMPILER --version 2>&1 | $GREP "Free Software Foundation" > /dev/null
aoqi@0 126 if test $? -ne 0; then
aoqi@0 127 AC_MSG_NOTICE([The $COMPILER_NAME compiler (located as $COMPILER) does not seem to be the required GCC compiler.])
aoqi@0 128 AC_MSG_NOTICE([The result from running with --version was: "$COMPILER_VERSION_TEST"])
aoqi@0 129 AC_MSG_ERROR([GCC compiler is required. Try setting --with-tools-dir.])
aoqi@0 130 fi
aoqi@0 131
aoqi@0 132 # First line typically looks something like:
aoqi@0 133 # gcc (Ubuntu/Linaro 4.5.2-8ubuntu4) 4.5.2
andrew@1862 134 COMPILER_VERSION=`$ECHO $COMPILER_VERSION_TEST | \
andrew@1862 135 $SED -e 's/^.* \(@<:@1-9@:>@\.@<:@0-9.@:>@*\)@<:@^0-9.@:>@.*$/\1/'`
aoqi@0 136 COMPILER_VENDOR=`$ECHO $COMPILER_VERSION_TEST | $SED -n "s/^\(.*\) @<:@1-9@:>@@<:@0-9.@:>@*/\1/p"`
aoqi@0 137 fi
aoqi@0 138 # This sets CC_VERSION or CXX_VERSION. (This comment is a grep marker)
aoqi@0 139 $1_VERSION="$COMPILER_VERSION"
aoqi@0 140 # This sets CC_VENDOR or CXX_VENDOR. (This comment is a grep marker)
aoqi@0 141 $1_VENDOR="$COMPILER_VENDOR"
aoqi@0 142
aoqi@0 143 AC_MSG_NOTICE([Using $COMPILER_VENDOR $COMPILER_NAME compiler version $COMPILER_VERSION (located at $COMPILER)])
aoqi@0 144 ])
aoqi@0 145
aoqi@0 146
aoqi@0 147 AC_DEFUN_ONCE([TOOLCHAIN_SETUP_SYSROOT_AND_OUT_OPTIONS],
aoqi@0 148 [
aoqi@0 149 ###############################################################################
aoqi@0 150 #
aoqi@0 151 # Configure the development tool paths and potential sysroot.
aoqi@0 152 #
aoqi@0 153 AC_LANG(C++)
aoqi@0 154
aoqi@0 155 # The option used to specify the target .o,.a or .so file.
aoqi@0 156 # When compiling, how to specify the to be created object file.
aoqi@0 157 CC_OUT_OPTION='-o$(SPACE)'
aoqi@0 158 # When linking, how to specify the to be created executable.
aoqi@0 159 EXE_OUT_OPTION='-o$(SPACE)'
aoqi@0 160 # When linking, how to specify the to be created dynamically linkable library.
aoqi@0 161 LD_OUT_OPTION='-o$(SPACE)'
aoqi@0 162 # When archiving, how to specify the to be create static archive for object files.
aoqi@0 163 AR_OUT_OPTION='rcs$(SPACE)'
aoqi@0 164 AC_SUBST(CC_OUT_OPTION)
aoqi@0 165 AC_SUBST(EXE_OUT_OPTION)
aoqi@0 166 AC_SUBST(LD_OUT_OPTION)
aoqi@0 167 AC_SUBST(AR_OUT_OPTION)
aoqi@0 168 ])
aoqi@0 169
aoqi@0 170 # $1 = compiler to test (CC or CXX)
aoqi@0 171 # $2 = human readable name of compiler (C or C++)
aoqi@0 172 # $3 = list of compiler names to search for
aoqi@0 173 AC_DEFUN([TOOLCHAIN_FIND_COMPILER],
aoqi@0 174 [
aoqi@0 175 COMPILER_NAME=$2
aoqi@0 176
aoqi@0 177 $1=
aoqi@0 178 # If TOOLS_DIR is set, check for all compiler names in there first
aoqi@0 179 # before checking the rest of the PATH.
aoqi@0 180 if test -n "$TOOLS_DIR"; then
aoqi@0 181 PATH_save="$PATH"
aoqi@0 182 PATH="$TOOLS_DIR"
aoqi@0 183 AC_PATH_PROGS(TOOLS_DIR_$1, $3)
aoqi@0 184 $1=$TOOLS_DIR_$1
aoqi@0 185 PATH="$PATH_save"
aoqi@0 186 fi
aoqi@0 187
aoqi@0 188 # AC_PATH_PROGS can't be run multiple times with the same variable,
aoqi@0 189 # so create a new name for this run.
aoqi@0 190 if test "x[$]$1" = x; then
aoqi@0 191 AC_PATH_PROGS(POTENTIAL_$1, $3)
aoqi@0 192 $1=$POTENTIAL_$1
aoqi@0 193 fi
aoqi@0 194
aoqi@0 195 if test "x[$]$1" = x; then
aoqi@0 196 HELP_MSG_MISSING_DEPENDENCY([devkit])
aoqi@0 197 AC_MSG_ERROR([Could not find a $COMPILER_NAME compiler. $HELP_MSG])
aoqi@0 198 fi
aoqi@0 199 BASIC_FIXUP_EXECUTABLE($1)
aoqi@0 200 TEST_COMPILER="[$]$1"
aoqi@0 201 # Don't remove symbolic links on AIX because 'xlc_r' and 'xlC_r' may all be links
aoqi@0 202 # to 'xlc' but it is crucial that we invoke the compiler with the right name!
aoqi@0 203 if test "x$OPENJDK_BUILD_OS" != xaix; then
aoqi@0 204 AC_MSG_CHECKING([resolved symbolic links for $1])
aoqi@0 205 BASIC_REMOVE_SYMBOLIC_LINKS(TEST_COMPILER)
aoqi@0 206 AC_MSG_RESULT([$TEST_COMPILER])
aoqi@0 207 fi
aoqi@0 208 AC_MSG_CHECKING([if $1 is disguised ccache])
aoqi@0 209
aoqi@0 210 COMPILER_BASENAME=`$BASENAME "$TEST_COMPILER"`
aoqi@0 211 if test "x$COMPILER_BASENAME" = "xccache"; then
aoqi@0 212 AC_MSG_RESULT([yes, trying to find proper $COMPILER_NAME compiler])
aoqi@0 213 # We /usr/lib/ccache in the path, so cc is a symlink to /usr/bin/ccache.
aoqi@0 214 # We want to control ccache invocation ourselves, so ignore this cc and try
aoqi@0 215 # searching again.
aoqi@0 216
aoqi@0 217 # Remove the path to the fake ccache cc from the PATH
aoqi@0 218 RETRY_COMPILER_SAVED_PATH="$PATH"
aoqi@0 219 COMPILER_DIRNAME=`$DIRNAME [$]$1`
aoqi@0 220 PATH="`$ECHO $PATH | $SED -e "s,$COMPILER_DIRNAME,,g" -e "s,::,:,g" -e "s,^:,,g"`"
aoqi@0 221
aoqi@0 222 # Try again looking for our compiler
aoqi@0 223 AC_CHECK_TOOLS(PROPER_COMPILER_$1, $3)
aoqi@0 224 BASIC_FIXUP_EXECUTABLE(PROPER_COMPILER_$1)
aoqi@0 225 PATH="$RETRY_COMPILER_SAVED_PATH"
aoqi@0 226
aoqi@0 227 AC_MSG_CHECKING([for resolved symbolic links for $1])
aoqi@0 228 BASIC_REMOVE_SYMBOLIC_LINKS(PROPER_COMPILER_$1)
aoqi@0 229 AC_MSG_RESULT([$PROPER_COMPILER_$1])
aoqi@0 230 $1="$PROPER_COMPILER_$1"
aoqi@0 231 else
aoqi@0 232 AC_MSG_RESULT([no, keeping $1])
aoqi@0 233 $1="$TEST_COMPILER"
aoqi@0 234 fi
andrew@1862 235 TOOLCHAIN_EXTRACT_COMPILER_VERSION([$1], [$COMPILER_NAME])
aoqi@0 236 ])
aoqi@0 237
aoqi@0 238
aoqi@0 239 AC_DEFUN([TOOLCHAIN_SETUP_PATHS],
aoqi@0 240 [
aoqi@0 241 if test "x$OPENJDK_TARGET_OS" = "xwindows"; then
aoqi@0 242 TOOLCHAIN_SETUP_VISUAL_STUDIO_ENV
aoqi@0 243 TOOLCHAIN_SETUP_MSVCR_DLL
aoqi@0 244 BASIC_DEPRECATED_ARG_WITH([dxsdk])
aoqi@0 245 BASIC_DEPRECATED_ARG_WITH([dxsdk-lib])
aoqi@0 246 BASIC_DEPRECATED_ARG_WITH([dxsdk-include])
aoqi@0 247 fi
aoqi@0 248
aoqi@0 249 AC_SUBST(MSVCR_DLL)
aoqi@0 250
aoqi@0 251 # If --build AND --host is set, then the configure script will find any
aoqi@0 252 # cross compilation tools in the PATH. Cross compilation tools
aoqi@0 253 # follows the cross compilation standard where they are prefixed with ${host}.
aoqi@0 254 # For example the binary i686-sun-solaris2.10-gcc
aoqi@0 255 # will cross compile for i686-sun-solaris2.10
aoqi@0 256 # If neither of build and host is not set, then build=host and the
aoqi@0 257 # default compiler found in the path will be used.
aoqi@0 258 # Setting only --host, does not seem to be really supported.
aoqi@0 259 # Please set both --build and --host if you want to cross compile.
aoqi@0 260
aoqi@0 261 if test "x$COMPILE_TYPE" = "xcross"; then
aoqi@0 262 # Now we to find a C/C++ compiler that can build executables for the build
aoqi@0 263 # platform. We can't use the AC_PROG_CC macro, since it can only be used
aoqi@0 264 # once. Also, we need to do this before adding a tools dir to the path,
aoqi@0 265 # otherwise we might pick up cross-compilers which don't use standard naming.
aoqi@0 266 # Otherwise, we'll set the BUILD_tools to the native tools, but that'll have
aoqi@0 267 # to wait until they are properly discovered.
aoqi@0 268 AC_PATH_PROGS(BUILD_CC, [cl cc gcc])
aoqi@0 269 BASIC_FIXUP_EXECUTABLE(BUILD_CC)
aoqi@0 270 AC_PATH_PROGS(BUILD_CXX, [cl CC g++])
aoqi@0 271 BASIC_FIXUP_EXECUTABLE(BUILD_CXX)
aoqi@0 272 AC_PATH_PROG(BUILD_LD, ld)
aoqi@0 273 BASIC_FIXUP_EXECUTABLE(BUILD_LD)
aoqi@0 274 fi
aoqi@0 275 AC_SUBST(BUILD_CC)
aoqi@0 276 AC_SUBST(BUILD_CXX)
aoqi@0 277 AC_SUBST(BUILD_LD)
aoqi@0 278
aoqi@0 279 # If a devkit is found on the builddeps server, then prepend its path to the
aoqi@0 280 # PATH variable. If there are cross compilers available in the devkit, these
aoqi@0 281 # will be found by AC_PROG_CC et al.
aoqi@0 282 DEVKIT=
aoqi@0 283 BDEPS_CHECK_MODULE(DEVKIT, devkit, xxx,
aoqi@0 284 [
aoqi@0 285 # Found devkit
aoqi@0 286 PATH="$DEVKIT/bin:$PATH"
aoqi@0 287 SYS_ROOT="$DEVKIT/${rewritten_target}/sys-root"
aoqi@0 288 if test "x$x_includes" = "xNONE"; then
aoqi@0 289 x_includes="$SYS_ROOT/usr/include/X11"
aoqi@0 290 fi
aoqi@0 291 if test "x$x_libraries" = "xNONE"; then
aoqi@0 292 x_libraries="$SYS_ROOT/usr/lib"
aoqi@0 293 fi
aoqi@0 294 ],
aoqi@0 295 [])
aoqi@0 296
aoqi@0 297 # Store the CFLAGS etal passed to the configure script.
aoqi@0 298 ORG_CFLAGS="$CFLAGS"
aoqi@0 299 ORG_CXXFLAGS="$CXXFLAGS"
aoqi@0 300 ORG_OBJCFLAGS="$OBJCFLAGS"
aoqi@0 301
aoqi@0 302 # autoconf magic only relies on PATH, so update it if tools dir is specified
aoqi@0 303 OLD_PATH="$PATH"
aoqi@0 304 if test "x$TOOLS_DIR" != x; then
aoqi@0 305 PATH=$TOOLS_DIR:$PATH
aoqi@0 306 fi
aoqi@0 307
ddehaven@1304 308 # Before we locate the compilers, we need to sanitize the Xcode build environment
ddehaven@1304 309 if test "x$OPENJDK_TARGET_OS" = "xmacosx"; then
ddehaven@1304 310 # determine path to Xcode developer directory
ddehaven@1304 311 # can be empty in which case all the tools will rely on a sane Xcode 4 installation
ddehaven@1304 312 SET_DEVELOPER_DIR=
ddehaven@1304 313
ddehaven@1304 314 if test -n "$XCODE_PATH"; then
ddehaven@1304 315 DEVELOPER_DIR="$XCODE_PATH"/Contents/Developer
ddehaven@1304 316 fi
ddehaven@1304 317
ddehaven@1304 318 # DEVELOPER_DIR could also be provided directly
ddehaven@1304 319 AC_MSG_CHECKING([Determining if we need to set DEVELOPER_DIR])
ddehaven@1304 320 if test -n "$DEVELOPER_DIR"; then
ddehaven@1304 321 if test ! -d "$DEVELOPER_DIR"; then
ddehaven@1304 322 AC_MSG_ERROR([Xcode Developer path does not exist: $DEVELOPER_DIR, please provide a path to the Xcode 4 application bundle using --with-xcode-path])
ddehaven@1304 323 fi
ddehaven@1304 324 if test ! -f "$DEVELOPER_DIR"/usr/bin/xcodebuild; then
ddehaven@1304 325 AC_MSG_ERROR([Xcode Developer path is not valid: $DEVELOPER_DIR, it must point to Contents/Developer inside an Xcode application bundle])
ddehaven@1304 326 fi
ddehaven@1304 327 # make it visible to all the tools immediately
ddehaven@1304 328 export DEVELOPER_DIR
ddehaven@1304 329 SET_DEVELOPER_DIR="export DEVELOPER_DIR := $DEVELOPER_DIR"
ddehaven@1304 330 AC_MSG_RESULT([yes ($DEVELOPER_DIR)])
ddehaven@1304 331 else
ddehaven@1304 332 AC_MSG_RESULT([no])
ddehaven@1304 333 fi
ddehaven@1304 334 AC_SUBST(SET_DEVELOPER_DIR)
ddehaven@1304 335
ddehaven@1304 336 AC_PATH_PROG(XCODEBUILD, xcodebuild)
ddehaven@1304 337 if test -z "$XCODEBUILD"; then
ddehaven@1304 338 AC_MSG_ERROR([The xcodebuild tool was not found, the Xcode command line tools are required to build on Mac OS X])
ddehaven@1304 339 fi
ddehaven@1304 340
ddehaven@1304 341 # Fail-fast: verify we're building on Xcode 4, we cannot build with Xcode 5 or later
ddehaven@1304 342 XCODE_VERSION=`$XCODEBUILD -version | grep '^Xcode ' | sed 's/Xcode //'`
ddehaven@1304 343 XC_VERSION_PARTS=( ${XCODE_VERSION//./ } )
ddehaven@1304 344 if test ! "${XC_VERSION_PARTS[[0]]}" = "4"; then
ddehaven@1304 345 AC_MSG_ERROR([Xcode 4 is required to build JDK 8, the version found was $XCODE_VERSION. Use --with-xcode-path to specify the location of Xcode 4 or make Xcode 4 active by using xcode-select.])
ddehaven@1304 346 fi
ddehaven@1304 347
ddehaven@1304 348 # Some versions of Xcode 5 command line tools install gcc and g++ as symlinks to
ddehaven@1304 349 # clang and clang++, which will break the build. So handle that here if we need to.
ddehaven@1304 350 if test -L "/usr/bin/gcc" -o -L "/usr/bin/g++"; then
ddehaven@1304 351 # use xcrun to find the real gcc and add it's directory to PATH
ddehaven@1304 352 # then autoconf magic will find it
ddehaven@1304 353 AC_MSG_NOTICE([Found gcc symlinks to clang in /usr/bin, adding path to real gcc to PATH])
ddehaven@1304 354 XCODE_BIN_PATH=$(dirname `xcrun -find gcc`)
ddehaven@1304 355 PATH="$XCODE_BIN_PATH":$PATH
ddehaven@1304 356 fi
ddehaven@1304 357
ddehaven@1304 358 # Determine appropriate SDKPATH, don't use SDKROOT as it interferes with the stub tools
ddehaven@1304 359 AC_MSG_CHECKING([Determining Xcode SDK path])
ddehaven@1304 360 # allow SDKNAME to be set to override the default SDK selection
ddehaven@1304 361 SDKPATH=`"$XCODEBUILD" -sdk ${SDKNAME:-macosx} -version | grep '^Path: ' | sed 's/Path: //'`
ddehaven@1304 362 if test -n "$SDKPATH"; then
ddehaven@1304 363 AC_MSG_RESULT([$SDKPATH])
ddehaven@1304 364 else
ddehaven@1304 365 AC_MSG_RESULT([(none, will use system headers and frameworks)])
ddehaven@1304 366 fi
ddehaven@1304 367 AC_SUBST(SDKPATH)
ddehaven@1304 368
ddehaven@1304 369 # Perform a basic sanity test
ddehaven@1304 370 if test ! -f "$SDKPATH/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h"; then
ddehaven@1304 371 AC_MSG_ERROR([Unable to find required framework headers, provide a valid path to Xcode 4 using --with-xcode-path])
ddehaven@1304 372 fi
ddehaven@1304 373
ddehaven@1304 374 # if SDKPATH is non-empty then we need to add -isysroot and -iframework for gcc and g++
ddehaven@1304 375 if test -n "$SDKPATH"; then
ddehaven@1304 376 # We need -isysroot <path> and -iframework<path>/System/Library/Frameworks
ddehaven@1304 377 CFLAGS_JDK="${CFLAGS_JDK} -isysroot \"$SDKPATH\" -iframework\"$SDKPATH/System/Library/Frameworks\""
ddehaven@1304 378 CXXFLAGS_JDK="${CXXFLAGS_JDK} -isysroot \"$SDKPATH\" -iframework\"$SDKPATH/System/Library/Frameworks\""
ddehaven@1304 379 LDFLAGS_JDK="${LDFLAGS_JDK} -isysroot \"$SDKPATH\" -iframework\"$SDKPATH/System/Library/Frameworks\""
ddehaven@1304 380 fi
ddehaven@1304 381
ddehaven@1304 382 # These always need to be set, or we can't find the frameworks embedded in JavaVM.framework
ddehaven@1304 383 # setting this here means it doesn't have to be peppered throughout the forest
ddehaven@1304 384 CFLAGS_JDK="$CFLAGS_JDK -F\"$SDKPATH/System/Library/Frameworks/JavaVM.framework/Frameworks\""
ddehaven@1304 385 CXXFLAGS_JDK="$CXXFLAGS_JDK -F\"$SDKPATH/System/Library/Frameworks/JavaVM.framework/Frameworks\""
ddehaven@1304 386 LDFLAGS_JDK="$LDFLAGS_JDK -F\"$SDKPATH/System/Library/Frameworks/JavaVM.framework/Frameworks\""
ddehaven@1304 387 fi
aoqi@0 388
aoqi@0 389 ### Locate C compiler (CC)
aoqi@0 390
aoqi@0 391 # On windows, only cl.exe is supported.
aoqi@0 392 # On Solaris, cc is preferred to gcc.
aoqi@0 393 # Elsewhere, gcc is preferred to cc.
aoqi@0 394
aoqi@0 395 if test "x$CC" != x; then
aoqi@0 396 COMPILER_CHECK_LIST="$CC"
aoqi@0 397 elif test "x$OPENJDK_TARGET_OS" = "xwindows"; then
aoqi@0 398 COMPILER_CHECK_LIST="cl"
aoqi@0 399 elif test "x$OPENJDK_TARGET_OS" = "xsolaris"; then
aoqi@0 400 COMPILER_CHECK_LIST="cc gcc"
aoqi@0 401 elif test "x$OPENJDK_TARGET_OS" = "xaix"; then
aoqi@0 402 # Do not probe for cc on AIX.
aoqi@0 403 COMPILER_CHECK_LIST="xlc_r"
aoqi@0 404 else
aoqi@0 405 COMPILER_CHECK_LIST="gcc cc"
aoqi@0 406 fi
aoqi@0 407
aoqi@0 408 TOOLCHAIN_FIND_COMPILER([CC],[C],[$COMPILER_CHECK_LIST])
aoqi@0 409 # Now that we have resolved CC ourself, let autoconf have its go at it
aoqi@0 410 AC_PROG_CC([$CC])
aoqi@0 411
aoqi@0 412 # Option used to tell the compiler whether to create 32- or 64-bit executables
aoqi@0 413 # Notice that CC contains the full compiler path at this point.
aoqi@0 414 case $CC in
aoqi@0 415 *xlc_r) COMPILER_TARGET_BITS_FLAG="-q";;
aoqi@0 416 *) COMPILER_TARGET_BITS_FLAG="-m";;
aoqi@0 417 esac
aoqi@0 418 AC_SUBST(COMPILER_TARGET_BITS_FLAG)
aoqi@0 419
aoqi@0 420 ### Locate C++ compiler (CXX)
aoqi@0 421
aoqi@0 422 if test "x$CXX" != x; then
aoqi@0 423 COMPILER_CHECK_LIST="$CXX"
aoqi@0 424 elif test "x$OPENJDK_TARGET_OS" = "xwindows"; then
aoqi@0 425 COMPILER_CHECK_LIST="cl"
aoqi@0 426 elif test "x$OPENJDK_TARGET_OS" = "xsolaris"; then
aoqi@0 427 COMPILER_CHECK_LIST="CC g++"
aoqi@0 428 elif test "x$OPENJDK_TARGET_OS" = "xaix"; then
aoqi@0 429 # Do not probe for CC on AIX .
aoqi@0 430 COMPILER_CHECK_LIST="xlC_r"
aoqi@0 431 else
aoqi@0 432 COMPILER_CHECK_LIST="g++ CC"
aoqi@0 433 fi
aoqi@0 434
aoqi@0 435 TOOLCHAIN_FIND_COMPILER([CXX],[C++],[$COMPILER_CHECK_LIST])
aoqi@0 436 # Now that we have resolved CXX ourself, let autoconf have its go at it
aoqi@0 437 AC_PROG_CXX([$CXX])
aoqi@0 438
andrew@1862 439 # This is the compiler version number on the form X.Y[.Z]
andrew@1862 440 AC_SUBST(CC_VERSION)
andrew@1862 441 AC_SUBST(CXX_VERSION)
andrew@1862 442
andrew@1862 443 TOOLCHAIN_PREPARE_FOR_VERSION_COMPARISONS
andrew@1862 444
aoqi@0 445 ### Locate other tools
aoqi@0 446
aoqi@0 447 if test "x$OPENJDK_TARGET_OS" = xmacosx; then
aoqi@0 448 AC_PROG_OBJC
aoqi@0 449 BASIC_FIXUP_EXECUTABLE(OBJC)
aoqi@0 450 else
aoqi@0 451 OBJC=
aoqi@0 452 fi
aoqi@0 453
aoqi@0 454 # Restore the flags to the user specified values.
aoqi@0 455 # This is necessary since AC_PROG_CC defaults CFLAGS to "-g -O2"
aoqi@0 456 CFLAGS="$ORG_CFLAGS"
aoqi@0 457 CXXFLAGS="$ORG_CXXFLAGS"
aoqi@0 458 OBJCFLAGS="$ORG_OBJCFLAGS"
aoqi@0 459
aoqi@0 460 LD="$CC"
aoqi@0 461 LDEXE="$CC"
aoqi@0 462 LDCXX="$CXX"
aoqi@0 463 LDEXECXX="$CXX"
aoqi@0 464 AC_SUBST(LD)
aoqi@0 465 # LDEXE is the linker to use, when creating executables.
aoqi@0 466 AC_SUBST(LDEXE)
aoqi@0 467 # Linking C++ libraries.
aoqi@0 468 AC_SUBST(LDCXX)
aoqi@0 469 # Linking C++ executables.
aoqi@0 470 AC_SUBST(LDEXECXX)
aoqi@0 471
aoqi@0 472 if test "x$OPENJDK_TARGET_OS" != xwindows; then
aoqi@0 473 AC_CHECK_TOOL(AR, ar)
aoqi@0 474 BASIC_FIXUP_EXECUTABLE(AR)
aoqi@0 475 fi
aoqi@0 476 if test "x$OPENJDK_TARGET_OS" = xmacosx; then
aoqi@0 477 ARFLAGS="-r"
aoqi@0 478 elif test "x$OPENJDK_TARGET_OS" = xaix; then
aoqi@0 479 ARFLAGS="-X64"
aoqi@0 480 else
aoqi@0 481 ARFLAGS=""
aoqi@0 482 fi
aoqi@0 483 AC_SUBST(ARFLAGS)
aoqi@0 484
aoqi@0 485 # For hotspot, we need these in Windows mixed path; other platforms keep them the same
aoqi@0 486 HOTSPOT_CXX="$CXX"
aoqi@0 487 HOTSPOT_LD="$LD"
aoqi@0 488 AC_SUBST(HOTSPOT_CXX)
aoqi@0 489 AC_SUBST(HOTSPOT_LD)
aoqi@0 490
aoqi@0 491 COMPILER_NAME=gcc
aoqi@0 492 COMPILER_TYPE=CC
aoqi@0 493 AS_IF([test "x$OPENJDK_TARGET_OS" = xwindows], [
aoqi@0 494 # For now, assume that we are always compiling using cl.exe.
aoqi@0 495 CC_OUT_OPTION=-Fo
aoqi@0 496 EXE_OUT_OPTION=-out:
aoqi@0 497 LD_OUT_OPTION=-out:
aoqi@0 498 AR_OUT_OPTION=-out:
aoqi@0 499 # On Windows, reject /usr/bin/link (as determined in CYGWIN_LINK), which is a cygwin
aoqi@0 500 # program for something completely different.
aoqi@0 501 AC_CHECK_PROG([WINLD], [link],[link],,, [$CYGWIN_LINK])
aoqi@0 502 # Since we must ignore the first found link, WINLD will contain
aoqi@0 503 # the full path to the link.exe program.
aoqi@0 504 BASIC_FIXUP_EXECUTABLE(WINLD)
aoqi@0 505 printf "Windows linker was found at $WINLD\n"
aoqi@0 506 AC_MSG_CHECKING([if the found link.exe is actually the Visual Studio linker])
aoqi@0 507 "$WINLD" --version > /dev/null
aoqi@0 508 if test $? -eq 0 ; then
aoqi@0 509 AC_MSG_RESULT([no])
aoqi@0 510 AC_MSG_ERROR([This is the Cygwin link tool. Please check your PATH and rerun configure.])
aoqi@0 511 else
aoqi@0 512 AC_MSG_RESULT([yes])
aoqi@0 513 fi
aoqi@0 514 LD="$WINLD"
aoqi@0 515 LDEXE="$WINLD"
aoqi@0 516 LDCXX="$WINLD"
aoqi@0 517 LDEXECXX="$WINLD"
aoqi@0 518
aoqi@0 519 AC_CHECK_PROG([MT], [mt], [mt],,, [/usr/bin/mt])
aoqi@0 520 BASIC_FIXUP_EXECUTABLE(MT)
aoqi@0 521 # The resource compiler
aoqi@0 522 AC_CHECK_PROG([RC], [rc], [rc],,, [/usr/bin/rc])
aoqi@0 523 BASIC_FIXUP_EXECUTABLE(RC)
aoqi@0 524
aoqi@0 525 # For hotspot, we need these in Windows mixed path,
aoqi@0 526 # so rewrite them all. Need added .exe suffix.
aoqi@0 527 HOTSPOT_CXX="$CXX.exe"
aoqi@0 528 HOTSPOT_LD="$LD.exe"
aoqi@0 529 HOTSPOT_MT="$MT.exe"
aoqi@0 530 HOTSPOT_RC="$RC.exe"
aoqi@0 531 BASIC_WINDOWS_REWRITE_AS_WINDOWS_MIXED_PATH(HOTSPOT_CXX)
aoqi@0 532 BASIC_WINDOWS_REWRITE_AS_WINDOWS_MIXED_PATH(HOTSPOT_LD)
aoqi@0 533 BASIC_WINDOWS_REWRITE_AS_WINDOWS_MIXED_PATH(HOTSPOT_MT)
aoqi@0 534 BASIC_WINDOWS_REWRITE_AS_WINDOWS_MIXED_PATH(HOTSPOT_RC)
aoqi@0 535 AC_SUBST(HOTSPOT_MT)
aoqi@0 536 AC_SUBST(HOTSPOT_RC)
aoqi@0 537
aoqi@0 538 RC_FLAGS="-nologo -l 0x409 -r"
aoqi@0 539 AS_IF([test "x$VARIANT" = xOPT], [
aoqi@0 540 RC_FLAGS="$RC_FLAGS -d NDEBUG"
aoqi@0 541 ])
aoqi@0 542
aoqi@0 543 # The version variables used to create RC_FLAGS may be overridden
aoqi@0 544 # in a custom configure script, or possibly the command line.
aoqi@0 545 # Let those variables be expanded at make time in spec.gmk.
aoqi@0 546 # The \$ are escaped to the shell, and the $(...) variables
aoqi@0 547 # are evaluated by make.
aoqi@0 548 RC_FLAGS="$RC_FLAGS \
aoqi@0 549 -d \"JDK_BUILD_ID=\$(FULL_VERSION)\" \
aoqi@0 550 -d \"JDK_COMPANY=\$(COMPANY_NAME)\" \
aoqi@0 551 -d \"JDK_COMPONENT=\$(PRODUCT_NAME) \$(JDK_RC_PLATFORM_NAME) binary\" \
erikj@1404 552 -d \"JDK_VER=\$(JDK_MINOR_VERSION).\$(JDK_MICRO_VERSION).\$(COOKED_JDK_UPDATE_VERSION).\$(COOKED_BUILD_NUMBER)\" \
aoqi@0 553 -d \"JDK_COPYRIGHT=Copyright \xA9 $COPYRIGHT_YEAR\" \
aoqi@0 554 -d \"JDK_NAME=\$(PRODUCT_NAME) \$(JDK_RC_PLATFORM_NAME) \$(JDK_MINOR_VERSION) \$(JDK_UPDATE_META_TAG)\" \
erikj@1404 555 -d \"JDK_FVER=\$(JDK_MINOR_VERSION),\$(JDK_MICRO_VERSION),\$(COOKED_JDK_UPDATE_VERSION),\$(COOKED_BUILD_NUMBER)\""
aoqi@0 556
aoqi@0 557 # lib.exe is used to create static libraries.
aoqi@0 558 AC_CHECK_PROG([WINAR], [lib],[lib],,,)
aoqi@0 559 BASIC_FIXUP_EXECUTABLE(WINAR)
aoqi@0 560 AR="$WINAR"
aoqi@0 561 ARFLAGS="-nologo -NODEFAULTLIB:MSVCRT"
aoqi@0 562
aoqi@0 563 AC_CHECK_PROG([DUMPBIN], [dumpbin], [dumpbin],,,)
aoqi@0 564 BASIC_FIXUP_EXECUTABLE(DUMPBIN)
aoqi@0 565
aoqi@0 566 COMPILER_TYPE=CL
andrew@1862 567 # silence copyright notice and other headers.
andrew@1862 568 COMMON_CCXXFLAGS="$COMMON_CCXXFLAGS -nologo"
aoqi@0 569 ])
aoqi@0 570 AC_SUBST(RC_FLAGS)
aoqi@0 571 AC_SUBST(COMPILER_TYPE)
aoqi@0 572
aoqi@0 573 AC_PROG_CPP
aoqi@0 574 BASIC_FIXUP_EXECUTABLE(CPP)
aoqi@0 575
aoqi@0 576 AC_PROG_CXXCPP
aoqi@0 577 BASIC_FIXUP_EXECUTABLE(CXXCPP)
aoqi@0 578
aoqi@0 579 if test "x$COMPILE_TYPE" != "xcross"; then
aoqi@0 580 # If we are not cross compiling, use the same compilers for
aoqi@0 581 # building the build platform executables. The cross-compilation
aoqi@0 582 # case needed to be done earlier, but this can only be done after
aoqi@0 583 # the native tools have been localized.
aoqi@0 584 BUILD_CC="$CC"
aoqi@0 585 BUILD_CXX="$CXX"
aoqi@0 586 BUILD_LD="$LD"
aoqi@0 587 fi
aoqi@0 588
aoqi@0 589 # for solaris we really need solaris tools, and not gnu equivalent
aoqi@0 590 # these seems to normally reside in /usr/ccs/bin so add that to path before
aoqi@0 591 # starting to probe
aoqi@0 592 #
aoqi@0 593 # NOTE: I add this /usr/ccs/bin after TOOLS but before OLD_PATH
aoqi@0 594 # so that it can be overriden --with-tools-dir
aoqi@0 595 if test "x$OPENJDK_BUILD_OS" = xsolaris; then
aoqi@0 596 PATH="${TOOLS_DIR}:/usr/ccs/bin:${OLD_PATH}"
aoqi@0 597 fi
aoqi@0 598
aoqi@0 599 # Find the right assembler.
aoqi@0 600 if test "x$OPENJDK_TARGET_OS" = xsolaris; then
aoqi@0 601 AC_PATH_PROG(AS, as)
aoqi@0 602 BASIC_FIXUP_EXECUTABLE(AS)
aoqi@0 603 else
aoqi@0 604 AS="$CC -c"
aoqi@0 605 fi
aoqi@0 606 AC_SUBST(AS)
aoqi@0 607
aoqi@0 608 if test "x$OPENJDK_TARGET_OS" = xsolaris; then
aoqi@0 609 AC_PATH_PROG(NM, nm)
aoqi@0 610 BASIC_FIXUP_EXECUTABLE(NM)
aoqi@0 611 AC_PATH_PROG(GNM, gnm)
aoqi@0 612 BASIC_FIXUP_EXECUTABLE(GNM)
aoqi@0 613 AC_PATH_PROG(STRIP, strip)
aoqi@0 614 BASIC_FIXUP_EXECUTABLE(STRIP)
aoqi@0 615 AC_PATH_PROG(MCS, mcs)
aoqi@0 616 BASIC_FIXUP_EXECUTABLE(MCS)
aoqi@0 617 elif test "x$OPENJDK_TARGET_OS" != xwindows; then
ddehaven@1304 618 AC_PATH_PROG(OTOOL, otool)
ddehaven@1304 619 if test "x$OTOOL" = "x"; then
ddehaven@1304 620 OTOOL="true"
ddehaven@1304 621 fi
aoqi@0 622 AC_CHECK_TOOL(NM, nm)
aoqi@0 623 BASIC_FIXUP_EXECUTABLE(NM)
aoqi@0 624 GNM="$NM"
aoqi@0 625 AC_SUBST(GNM)
aoqi@0 626 AC_CHECK_TOOL(STRIP, strip)
aoqi@0 627 BASIC_FIXUP_EXECUTABLE(STRIP)
aoqi@0 628 fi
aoqi@0 629
aoqi@0 630 # objcopy is used for moving debug symbols to separate files when
aoqi@0 631 # full debug symbols are enabled.
aoqi@0 632 if test "x$OPENJDK_TARGET_OS" = xsolaris || test "x$OPENJDK_TARGET_OS" = xlinux; then
aoqi@0 633 AC_CHECK_TOOLS(OBJCOPY, [gobjcopy objcopy])
aoqi@0 634 # Only call fixup if objcopy was found.
aoqi@0 635 if test -n "$OBJCOPY"; then
aoqi@0 636 BASIC_FIXUP_EXECUTABLE(OBJCOPY)
aoqi@0 637 fi
aoqi@0 638 fi
aoqi@0 639
aoqi@0 640 AC_CHECK_TOOLS(OBJDUMP, [gobjdump objdump])
aoqi@0 641 if test "x$OBJDUMP" != x; then
aoqi@0 642 # Only used for compare.sh; we can live without it. BASIC_FIXUP_EXECUTABLE bails if argument is missing.
aoqi@0 643 BASIC_FIXUP_EXECUTABLE(OBJDUMP)
aoqi@0 644 fi
aoqi@0 645
aoqi@0 646 TOOLCHAIN_SETUP_JTREG
aoqi@0 647
aoqi@0 648 # Restore old path without tools dir
aoqi@0 649 PATH="$OLD_PATH"
aoqi@0 650 ])
aoqi@0 651
aoqi@0 652
aoqi@0 653 AC_DEFUN_ONCE([TOOLCHAIN_SETUP_COMPILER_FLAGS_FOR_LIBS],
aoqi@0 654 [
aoqi@0 655
aoqi@0 656 ###############################################################################
aoqi@0 657 #
aoqi@0 658 # How to compile shared libraries.
aoqi@0 659 #
aoqi@0 660
aoqi@0 661 if test "x$GCC" = xyes; then
aoqi@0 662 COMPILER_NAME=gcc
aoqi@0 663 PICFLAG="-fPIC"
aoqi@0 664 LIBRARY_PREFIX=lib
aoqi@0 665 SHARED_LIBRARY='lib[$]1.so'
aoqi@0 666 STATIC_LIBRARY='lib[$]1.a'
aoqi@0 667 SHARED_LIBRARY_FLAGS="-shared"
aoqi@0 668 SHARED_LIBRARY_SUFFIX='.so'
aoqi@0 669 STATIC_LIBRARY_SUFFIX='.a'
aoqi@0 670 OBJ_SUFFIX='.o'
aoqi@0 671 EXE_SUFFIX=''
aoqi@0 672 SET_SHARED_LIBRARY_NAME='-Xlinker -soname=[$]1'
aoqi@0 673 SET_SHARED_LIBRARY_MAPFILE='-Xlinker -version-script=[$]1'
aoqi@0 674 C_FLAG_REORDER=''
aoqi@0 675 CXX_FLAG_REORDER=''
aoqi@0 676 SET_SHARED_LIBRARY_ORIGIN='-Xlinker -z -Xlinker origin -Xlinker -rpath -Xlinker \$$$$ORIGIN[$]1'
aoqi@0 677 SET_EXECUTABLE_ORIGIN='-Xlinker -rpath -Xlinker \$$$$ORIGIN[$]1'
aoqi@0 678 LD="$CC"
aoqi@0 679 LDEXE="$CC"
aoqi@0 680 LDCXX="$CXX"
aoqi@0 681 LDEXECXX="$CXX"
aoqi@0 682 POST_STRIP_CMD="$STRIP -g"
aoqi@0 683
aoqi@0 684 # Linking is different on MacOSX
aoqi@0 685 if test "x$OPENJDK_TARGET_OS" = xmacosx; then
aoqi@0 686 # Might change in the future to clang.
aoqi@0 687 COMPILER_NAME=gcc
aoqi@0 688 SHARED_LIBRARY='lib[$]1.dylib'
aoqi@0 689 SHARED_LIBRARY_FLAGS="-dynamiclib -compatibility_version 1.0.0 -current_version 1.0.0 $PICFLAG"
aoqi@0 690 SHARED_LIBRARY_SUFFIX='.dylib'
aoqi@0 691 EXE_SUFFIX=''
aoqi@0 692 SET_SHARED_LIBRARY_NAME='-Xlinker -install_name -Xlinker @rpath/[$]1'
aoqi@0 693 SET_SHARED_LIBRARY_MAPFILE=''
aoqi@0 694 SET_SHARED_LIBRARY_ORIGIN='-Xlinker -rpath -Xlinker @loader_path/.'
aoqi@0 695 SET_EXECUTABLE_ORIGIN="$SET_SHARED_LIBRARY_ORIGIN"
aoqi@0 696 POST_STRIP_CMD="$STRIP -S"
aoqi@0 697 fi
aoqi@0 698 else
aoqi@0 699 if test "x$OPENJDK_TARGET_OS" = xsolaris; then
aoqi@0 700 # If it is not gcc, then assume it is the Oracle Solaris Studio Compiler
aoqi@0 701 COMPILER_NAME=ossc
aoqi@0 702 PICFLAG="-KPIC"
aoqi@0 703 LIBRARY_PREFIX=lib
aoqi@0 704 SHARED_LIBRARY='lib[$]1.so'
aoqi@0 705 STATIC_LIBRARY='lib[$]1.a'
aoqi@0 706 SHARED_LIBRARY_FLAGS="-G"
aoqi@0 707 SHARED_LIBRARY_SUFFIX='.so'
aoqi@0 708 STATIC_LIBRARY_SUFFIX='.a'
aoqi@0 709 OBJ_SUFFIX='.o'
aoqi@0 710 EXE_SUFFIX=''
aoqi@0 711 SET_SHARED_LIBRARY_NAME=''
aoqi@0 712 SET_SHARED_LIBRARY_MAPFILE='-M[$]1'
aoqi@0 713 C_FLAG_REORDER='-xF'
aoqi@0 714 CXX_FLAG_REORDER='-xF'
aoqi@0 715 SET_SHARED_LIBRARY_ORIGIN='-R\$$$$ORIGIN[$]1'
aoqi@0 716 SET_EXECUTABLE_ORIGIN="$SET_SHARED_LIBRARY_ORIGIN"
aoqi@0 717 CFLAGS_JDK="${CFLAGS_JDK} -D__solaris__"
aoqi@0 718 CXXFLAGS_JDK="${CXXFLAGS_JDK} -D__solaris__"
aoqi@0 719 CFLAGS_JDKLIB_EXTRA='-xstrconst'
aoqi@0 720 POST_STRIP_CMD="$STRIP -x"
aoqi@0 721 POST_MCS_CMD="$MCS -d -a \"JDK $FULL_VERSION\""
aoqi@0 722 fi
aoqi@0 723 if test "x$OPENJDK_TARGET_OS" = xaix; then
aoqi@0 724 COMPILER_NAME=xlc
aoqi@0 725 PICFLAG="-qpic=large"
aoqi@0 726 LIBRARY_PREFIX=lib
aoqi@0 727 SHARED_LIBRARY='lib[$]1.so'
aoqi@0 728 STATIC_LIBRARY='lib[$]1.a'
aoqi@0 729 SHARED_LIBRARY_FLAGS="-qmkshrobj"
aoqi@0 730 SHARED_LIBRARY_SUFFIX='.so'
aoqi@0 731 STATIC_LIBRARY_SUFFIX='.a'
aoqi@0 732 OBJ_SUFFIX='.o'
aoqi@0 733 EXE_SUFFIX=''
aoqi@0 734 SET_SHARED_LIBRARY_NAME=''
aoqi@0 735 SET_SHARED_LIBRARY_MAPFILE=''
aoqi@0 736 C_FLAG_REORDER=''
aoqi@0 737 CXX_FLAG_REORDER=''
aoqi@0 738 SET_SHARED_LIBRARY_ORIGIN=''
aoqi@0 739 SET_EXECUTABLE_ORIGIN=""
aoqi@0 740 CFLAGS_JDK=""
aoqi@0 741 CXXFLAGS_JDK=""
aoqi@0 742 CFLAGS_JDKLIB_EXTRA=''
aoqi@0 743 POST_STRIP_CMD="$STRIP -X32_64"
aoqi@0 744 POST_MCS_CMD=""
aoqi@0 745 fi
aoqi@0 746 if test "x$OPENJDK_TARGET_OS" = xwindows; then
aoqi@0 747 # If it is not gcc, then assume it is the MS Visual Studio compiler
aoqi@0 748 COMPILER_NAME=cl
aoqi@0 749 PICFLAG=""
aoqi@0 750 LIBRARY_PREFIX=
aoqi@0 751 SHARED_LIBRARY='[$]1.dll'
aoqi@0 752 STATIC_LIBRARY='[$]1.lib'
aoqi@0 753 SHARED_LIBRARY_FLAGS="-LD"
aoqi@0 754 SHARED_LIBRARY_SUFFIX='.dll'
aoqi@0 755 STATIC_LIBRARY_SUFFIX='.lib'
aoqi@0 756 OBJ_SUFFIX='.obj'
aoqi@0 757 EXE_SUFFIX='.exe'
aoqi@0 758 SET_SHARED_LIBRARY_NAME=''
aoqi@0 759 SET_SHARED_LIBRARY_MAPFILE=''
aoqi@0 760 SET_SHARED_LIBRARY_ORIGIN=''
aoqi@0 761 SET_EXECUTABLE_ORIGIN=''
aoqi@0 762 fi
aoqi@0 763 fi
aoqi@0 764
aoqi@0 765 AC_SUBST(COMPILER_NAME)
aoqi@0 766 AC_SUBST(OBJ_SUFFIX)
aoqi@0 767 AC_SUBST(SHARED_LIBRARY)
aoqi@0 768 AC_SUBST(STATIC_LIBRARY)
aoqi@0 769 AC_SUBST(LIBRARY_PREFIX)
aoqi@0 770 AC_SUBST(SHARED_LIBRARY_SUFFIX)
aoqi@0 771 AC_SUBST(STATIC_LIBRARY_SUFFIX)
aoqi@0 772 AC_SUBST(EXE_SUFFIX)
aoqi@0 773 AC_SUBST(SHARED_LIBRARY_FLAGS)
aoqi@0 774 AC_SUBST(SET_SHARED_LIBRARY_NAME)
aoqi@0 775 AC_SUBST(SET_SHARED_LIBRARY_MAPFILE)
aoqi@0 776 AC_SUBST(C_FLAG_REORDER)
aoqi@0 777 AC_SUBST(CXX_FLAG_REORDER)
aoqi@0 778 AC_SUBST(SET_SHARED_LIBRARY_ORIGIN)
aoqi@0 779 AC_SUBST(SET_EXECUTABLE_ORIGIN)
aoqi@0 780 AC_SUBST(POST_STRIP_CMD)
aoqi@0 781 AC_SUBST(POST_MCS_CMD)
aoqi@0 782
aoqi@0 783 # The (cross) compiler is now configured, we can now test capabilities
aoqi@0 784 # of the target platform.
aoqi@0 785 ])
aoqi@0 786
aoqi@0 787 AC_DEFUN_ONCE([TOOLCHAIN_SETUP_COMPILER_FLAGS_FOR_OPTIMIZATION],
aoqi@0 788 [
aoqi@0 789
aoqi@0 790 ###############################################################################
aoqi@0 791 #
aoqi@0 792 # Setup the opt flags for different compilers
aoqi@0 793 # and different operating systems.
aoqi@0 794 #
aoqi@0 795
aoqi@0 796 #
aoqi@0 797 # NOTE: check for -mstackrealign needs to be below potential addition of -m32
aoqi@0 798 #
aoqi@0 799 if test "x$OPENJDK_TARGET_CPU_BITS" = x32 && test "x$OPENJDK_TARGET_OS" = xmacosx; then
aoqi@0 800 # On 32-bit MacOSX the OS requires C-entry points to be 16 byte aligned.
aoqi@0 801 # While waiting for a better solution, the current workaround is to use -mstackrealign.
aoqi@0 802 CFLAGS="$CFLAGS -mstackrealign"
aoqi@0 803 AC_MSG_CHECKING([if 32-bit compiler supports -mstackrealign])
aoqi@0 804 AC_LINK_IFELSE([AC_LANG_SOURCE([[int main() { return 0; }]])],
aoqi@0 805 [
aoqi@0 806 AC_MSG_RESULT([yes])
aoqi@0 807 ],
aoqi@0 808 [
aoqi@0 809 AC_MSG_RESULT([no])
aoqi@0 810 AC_MSG_ERROR([The selected compiler $CXX does not support -mstackrealign! Try to put another compiler in the path.])
aoqi@0 811 ]
aoqi@0 812 )
aoqi@0 813 fi
aoqi@0 814
aoqi@0 815 C_FLAG_DEPS="-MMD -MF"
aoqi@0 816 CXX_FLAG_DEPS="-MMD -MF"
aoqi@0 817
aoqi@0 818 case $COMPILER_TYPE in
aoqi@0 819 CC )
aoqi@0 820 case $COMPILER_NAME in
aoqi@0 821 gcc )
aoqi@0 822 case $OPENJDK_TARGET_OS in
aoqi@0 823 macosx )
aoqi@0 824 # On MacOSX we optimize for size, something
aoqi@0 825 # we should do for all platforms?
aoqi@0 826 C_O_FLAG_HI="-Os"
aoqi@0 827 C_O_FLAG_NORM="-Os"
aoqi@0 828 C_O_FLAG_NONE=""
aoqi@0 829 ;;
aoqi@0 830 *)
aoqi@0 831 C_O_FLAG_HI="-O3"
aoqi@0 832 C_O_FLAG_NORM="-O2"
aoqi@0 833 C_O_FLAG_NONE="-O0"
aoqi@0 834 ;;
aoqi@0 835 esac
aoqi@0 836 CXX_O_FLAG_HI="$C_O_FLAG_HI"
aoqi@0 837 CXX_O_FLAG_NORM="$C_O_FLAG_NORM"
aoqi@0 838 CXX_O_FLAG_NONE="$C_O_FLAG_NONE"
aoqi@0 839 CFLAGS_DEBUG_SYMBOLS="-g"
aoqi@0 840 CXXFLAGS_DEBUG_SYMBOLS="-g"
aoqi@0 841 if test "x$OPENJDK_TARGET_CPU_BITS" = "x64" && test "x$DEBUG_LEVEL" = "xfastdebug"; then
aoqi@0 842 CFLAGS_DEBUG_SYMBOLS="-g1"
aoqi@0 843 CXXFLAGS_DEBUG_SYMBOLS="-g1"
aoqi@0 844 fi
aoqi@0 845 ;;
aoqi@0 846 ossc )
aoqi@0 847 #
aoqi@0 848 # Forte has different names for this with their C++ compiler...
aoqi@0 849 #
aoqi@0 850 C_FLAG_DEPS="-xMMD -xMF"
aoqi@0 851 CXX_FLAG_DEPS="-xMMD -xMF"
aoqi@0 852
aoqi@0 853 # Extra options used with HIGHEST
aoqi@0 854 #
aoqi@0 855 # WARNING: Use of OPTIMIZATION_LEVEL=HIGHEST in your Makefile needs to be
aoqi@0 856 # done with care, there are some assumptions below that need to
aoqi@0 857 # be understood about the use of pointers, and IEEE behavior.
aoqi@0 858 #
aoqi@0 859 # Use non-standard floating point mode (not IEEE 754)
aoqi@0 860 CC_HIGHEST="$CC_HIGHEST -fns"
aoqi@0 861 # Do some simplification of floating point arithmetic (not IEEE 754)
aoqi@0 862 CC_HIGHEST="$CC_HIGHEST -fsimple"
aoqi@0 863 # Use single precision floating point with 'float'
aoqi@0 864 CC_HIGHEST="$CC_HIGHEST -fsingle"
aoqi@0 865 # Assume memory references via basic pointer types do not alias
aoqi@0 866 # (Source with excessing pointer casting and data access with mixed
aoqi@0 867 # pointer types are not recommended)
aoqi@0 868 CC_HIGHEST="$CC_HIGHEST -xalias_level=basic"
aoqi@0 869 # Use intrinsic or inline versions for math/std functions
aoqi@0 870 # (If you expect perfect errno behavior, do not use this)
aoqi@0 871 CC_HIGHEST="$CC_HIGHEST -xbuiltin=%all"
aoqi@0 872 # Loop data dependency optimizations (need -xO3 or higher)
aoqi@0 873 CC_HIGHEST="$CC_HIGHEST -xdepend"
aoqi@0 874 # Pointer parameters to functions do not overlap
aoqi@0 875 # (Similar to -xalias_level=basic usage, but less obvious sometimes.
aoqi@0 876 # If you pass in multiple pointers to the same data, do not use this)
aoqi@0 877 CC_HIGHEST="$CC_HIGHEST -xrestrict"
aoqi@0 878 # Inline some library routines
aoqi@0 879 # (If you expect perfect errno behavior, do not use this)
aoqi@0 880 CC_HIGHEST="$CC_HIGHEST -xlibmil"
aoqi@0 881 # Use optimized math routines
aoqi@0 882 # (If you expect perfect errno behavior, do not use this)
aoqi@0 883 # Can cause undefined external on Solaris 8 X86 on __sincos, removing for now
aoqi@0 884 #CC_HIGHEST="$CC_HIGHEST -xlibmopt"
aoqi@0 885
aoqi@0 886 if test "x$OPENJDK_TARGET_CPU" = xsparc; then
aoqi@0 887 CFLAGS_JDK="${CFLAGS_JDK} -xmemalign=4s"
aoqi@0 888 CXXFLAGS_JDK="${CXXFLAGS_JDK} -xmemalign=4s"
aoqi@0 889 fi
aoqi@0 890
aoqi@0 891 case $OPENJDK_TARGET_CPU_ARCH in
aoqi@0 892 x86)
aoqi@0 893 C_O_FLAG_HIGHEST="-xO4 -Wu,-O4~yz $CC_HIGHEST -xregs=no%frameptr"
aoqi@0 894 C_O_FLAG_HI="-xO4 -Wu,-O4~yz -xregs=no%frameptr"
aoqi@0 895 C_O_FLAG_NORM="-xO2 -Wu,-O2~yz -xregs=no%frameptr"
aoqi@0 896 C_O_FLAG_NONE="-xregs=no%frameptr"
aoqi@0 897 CXX_O_FLAG_HIGHEST="-xO4 -Qoption ube -O4~yz $CC_HIGHEST -xregs=no%frameptr"
aoqi@0 898 CXX_O_FLAG_HI="-xO4 -Qoption ube -O4~yz -xregs=no%frameptr"
aoqi@0 899 CXX_O_FLAG_NORM="-xO2 -Qoption ube -O2~yz -xregs=no%frameptr"
aoqi@0 900 CXX_O_FLAG_NONE="-xregs=no%frameptr"
aoqi@0 901 if test "x$OPENJDK_TARGET_CPU" = xx86; then
aoqi@0 902 C_O_FLAG_HIGHEST="$C_O_FLAG_HIGHEST -xchip=pentium"
aoqi@0 903 CXX_O_FLAG_HIGHEST="$CXX_O_FLAG_HIGHEST -xchip=pentium"
aoqi@0 904 fi
aoqi@0 905 ;;
aoqi@0 906 sparc)
aoqi@0 907 CFLAGS_JDKLIB_EXTRA="${CFLAGS_JDKLIB_EXTRA} -xregs=no%appl"
aoqi@0 908 CXXFLAGS_JDKLIB_EXTRA="${CXXFLAGS_JDKLIB_EXTRA} -xregs=no%appl"
aoqi@0 909 C_O_FLAG_HIGHEST="-xO4 -Wc,-Qrm-s -Wc,-Qiselect-T0 $CC_HIGHEST -xprefetch=auto,explicit -xchip=ultra"
aoqi@0 910 C_O_FLAG_HI="-xO4 -Wc,-Qrm-s -Wc,-Qiselect-T0"
aoqi@0 911 C_O_FLAG_NORM="-xO2 -Wc,-Qrm-s -Wc,-Qiselect-T0"
aoqi@0 912 C_O_FLAG_NONE=""
aoqi@0 913 CXX_O_FLAG_HIGHEST="-xO4 -Qoption cg -Qrm-s -Qoption cg -Qiselect-T0 $CC_HIGHEST -xprefetch=auto,explicit -xchip=ultra"
aoqi@0 914 CXX_O_FLAG_HI="-xO4 -Qoption cg -Qrm-s -Qoption cg -Qiselect-T0"
aoqi@0 915 CXX_O_FLAG_NORM="-xO2 -Qoption cg -Qrm-s -Qoption cg -Qiselect-T0"
aoqi@0 916 CXX_O_FLAG_NONE=""
aoqi@0 917 ;;
aoqi@0 918 esac
aoqi@0 919
aoqi@0 920 CFLAGS_DEBUG_SYMBOLS="-g -xs"
aoqi@0 921 CXXFLAGS_DEBUG_SYMBOLS="-g0 -xs"
aoqi@0 922 ;;
aoqi@0 923 xlc )
aoqi@0 924 C_FLAG_DEPS="-qmakedep=gcc -MF"
aoqi@0 925 CXX_FLAG_DEPS="-qmakedep=gcc -MF"
aoqi@0 926 C_O_FLAG_HIGHEST="-O3"
aoqi@0 927 C_O_FLAG_HI="-O3 -qstrict"
aoqi@0 928 C_O_FLAG_NORM="-O2"
aoqi@0 929 C_O_FLAG_NONE=""
aoqi@0 930 CXX_O_FLAG_HIGHEST="-O3"
aoqi@0 931 CXX_O_FLAG_HI="-O3 -qstrict"
aoqi@0 932 CXX_O_FLAG_NORM="-O2"
aoqi@0 933 CXX_O_FLAG_NONE=""
aoqi@0 934 CFLAGS_DEBUG_SYMBOLS="-g"
aoqi@0 935 CXXFLAGS_DEBUG_SYMBOLS="-g"
aoqi@0 936 LDFLAGS_JDK="${LDFLAGS_JDK} -q64 -brtl -bnolibpath -liconv -bexpall"
aoqi@0 937 CFLAGS_JDK="${CFLAGS_JDK} -qchars=signed -q64 -qfullpath -qsaveopt"
aoqi@0 938 CXXFLAGS_JDK="${CXXFLAGS_JDK} -qchars=signed -q64 -qfullpath -qsaveopt"
aoqi@0 939 ;;
aoqi@0 940 esac
aoqi@0 941 ;;
aoqi@0 942 CL )
aoqi@0 943 C_O_FLAG_HIGHEST="-O2"
aoqi@0 944 C_O_FLAG_HI="-O1"
aoqi@0 945 C_O_FLAG_NORM="-O1"
aoqi@0 946 C_O_FLAG_NONE="-Od"
aoqi@0 947 CXX_O_FLAG_HIGHEST="$C_O_FLAG_HIGHEST"
aoqi@0 948 CXX_O_FLAG_HI="$C_O_FLAG_HI"
aoqi@0 949 CXX_O_FLAG_NORM="$C_O_FLAG_NORM"
aoqi@0 950 CXX_O_FLAG_NONE="$C_O_FLAG_NONE"
aoqi@0 951 ;;
aoqi@0 952 esac
aoqi@0 953
aoqi@0 954 if test -z "$C_O_FLAG_HIGHEST"; then
aoqi@0 955 C_O_FLAG_HIGHEST="$C_O_FLAG_HI"
aoqi@0 956 fi
aoqi@0 957
aoqi@0 958 if test -z "$CXX_O_FLAG_HIGHEST"; then
aoqi@0 959 CXX_O_FLAG_HIGHEST="$CXX_O_FLAG_HI"
aoqi@0 960 fi
aoqi@0 961
aoqi@0 962 AC_SUBST(C_O_FLAG_HIGHEST)
aoqi@0 963 AC_SUBST(C_O_FLAG_HI)
aoqi@0 964 AC_SUBST(C_O_FLAG_NORM)
aoqi@0 965 AC_SUBST(C_O_FLAG_NONE)
aoqi@0 966 AC_SUBST(CXX_O_FLAG_HIGHEST)
aoqi@0 967 AC_SUBST(CXX_O_FLAG_HI)
aoqi@0 968 AC_SUBST(CXX_O_FLAG_NORM)
aoqi@0 969 AC_SUBST(CXX_O_FLAG_NONE)
aoqi@0 970 AC_SUBST(C_FLAG_DEPS)
aoqi@0 971 AC_SUBST(CXX_FLAG_DEPS)
aoqi@0 972 ])
aoqi@0 973
aoqi@0 974 AC_DEFUN_ONCE([TOOLCHAIN_SETUP_COMPILER_FLAGS_FOR_JDK],
aoqi@0 975 [
aoqi@0 976
aoqi@0 977 if test "x$CFLAGS" != "x${ADDED_CFLAGS}"; then
aoqi@0 978 AC_MSG_WARN([Ignoring CFLAGS($CFLAGS) found in environment. Use --with-extra-cflags])
aoqi@0 979 fi
aoqi@0 980
aoqi@0 981 if test "x$CXXFLAGS" != "x${ADDED_CXXFLAGS}"; then
aoqi@0 982 AC_MSG_WARN([Ignoring CXXFLAGS($CXXFLAGS) found in environment. Use --with-extra-cxxflags])
aoqi@0 983 fi
aoqi@0 984
aoqi@0 985 if test "x$LDFLAGS" != "x${ADDED_LDFLAGS}"; then
aoqi@0 986 AC_MSG_WARN([Ignoring LDFLAGS($LDFLAGS) found in environment. Use --with-extra-ldflags])
aoqi@0 987 fi
aoqi@0 988
aoqi@0 989 AC_ARG_WITH(extra-cflags, [AS_HELP_STRING([--with-extra-cflags],
aoqi@0 990 [extra flags to be used when compiling jdk c-files])])
aoqi@0 991
aoqi@0 992 AC_ARG_WITH(extra-cxxflags, [AS_HELP_STRING([--with-extra-cxxflags],
aoqi@0 993 [extra flags to be used when compiling jdk c++-files])])
aoqi@0 994
aoqi@0 995 AC_ARG_WITH(extra-ldflags, [AS_HELP_STRING([--with-extra-ldflags],
aoqi@0 996 [extra flags to be used when linking jdk])])
aoqi@0 997
aoqi@0 998 CFLAGS_JDK="${CFLAGS_JDK} $with_extra_cflags"
aoqi@0 999 CXXFLAGS_JDK="${CXXFLAGS_JDK} $with_extra_cxxflags"
aoqi@0 1000 LDFLAGS_JDK="${LDFLAGS_JDK} $with_extra_ldflags"
aoqi@0 1001
aoqi@0 1002 # Hotspot needs these set in their legacy form
aoqi@0 1003 LEGACY_EXTRA_CFLAGS=$with_extra_cflags
aoqi@0 1004 LEGACY_EXTRA_CXXFLAGS=$with_extra_cxxflags
aoqi@0 1005 LEGACY_EXTRA_LDFLAGS=$with_extra_ldflags
aoqi@0 1006
aoqi@0 1007 AC_SUBST(LEGACY_EXTRA_CFLAGS)
aoqi@0 1008 AC_SUBST(LEGACY_EXTRA_CXXFLAGS)
aoqi@0 1009 AC_SUBST(LEGACY_EXTRA_LDFLAGS)
aoqi@0 1010
aoqi@0 1011 ###############################################################################
aoqi@0 1012 #
aoqi@0 1013 # Now setup the CFLAGS and LDFLAGS for the JDK build.
aoqi@0 1014 # Later we will also have CFLAGS and LDFLAGS for the hotspot subrepo build.
andrew@1862 1015 # CFLAGS_JDK - C Compiler flags
andrew@1862 1016 # CXXFLAGS_JDK - C++ Compiler flags
andrew@1862 1017 # COMMON_CCXXFLAGS_JDK - common to C and C++
aoqi@0 1018 #
aoqi@0 1019 case $COMPILER_NAME in
aoqi@0 1020 gcc )
andrew@1862 1021 COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS $COMMON_CCXXFLAGS_JDK -W -Wall -Wno-unused -Wno-parentheses \
aoqi@0 1022 -pipe \
aoqi@0 1023 -D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE"
andrew@1862 1024 CXXSTD_CXXFLAG="-std=gnu++98"
andrew@1862 1025 TOOLCHAIN_CXX_COMPILER_CHECK_ARGUMENTS([$CXXSTD_CXXFLAG $CFLAGS_WARNINGS_ARE_ERRORS],
andrew@1862 1026 [], [CXXSTD_CXXFLAG=""])
andrew@1862 1027 CXXFLAGS_JDK="${CXXFLAGS_JDK} ${CXXSTD_CXXFLAG}"
andrew@1862 1028 AC_SUBST([CXXSTD_CXXFLAG])
aoqi@0 1029 case $OPENJDK_TARGET_CPU_ARCH in
aoqi@0 1030 arm )
aoqi@0 1031 # on arm we don't prevent gcc to omit frame pointer but do prevent strict aliasing
aoqi@0 1032 CFLAGS_JDK="${CFLAGS_JDK} -fno-strict-aliasing"
aoqi@0 1033 ;;
aoqi@0 1034 ppc )
aoqi@0 1035 # on ppc we don't prevent gcc to omit frame pointer nor strict-aliasing
aoqi@0 1036 ;;
aoqi@0 1037 * )
andrew@1862 1038 COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -fno-omit-frame-pointer"
aoqi@0 1039 CFLAGS_JDK="${CFLAGS_JDK} -fno-strict-aliasing"
aoqi@0 1040 ;;
aoqi@0 1041 esac
andrew@1862 1042 TOOLCHAIN_CHECK_COMPILER_VERSION(6, TOOLCHAIN_SETUP_GCC6_COMPILER_FLAGS)
aoqi@0 1043 ;;
aoqi@0 1044 ossc )
andrew@1862 1045 COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS $COMMON_CCXXFLAGS_JDK -DTRACING -DMACRO_MEMSYS_OPS -DBREAKPTS"
aoqi@0 1046 case $OPENJDK_TARGET_CPU_ARCH in
aoqi@0 1047 x86 )
andrew@1862 1048 COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DcpuIntel -Di586 -D$OPENJDK_TARGET_CPU_LEGACY_LIB"
aoqi@0 1049 CFLAGS_JDK="$CFLAGS_JDK -erroff=E_BAD_PRAGMA_PACK_VALUE"
aoqi@0 1050 ;;
aoqi@0 1051 esac
aoqi@0 1052
aoqi@0 1053 CFLAGS_JDK="$CFLAGS_JDK -xc99=%none -xCC -errshort=tags -Xa -v -mt -W0,-noglobal"
aoqi@0 1054 CXXFLAGS_JDK="$CXXFLAGS_JDK -errtags=yes +w -mt -features=no%except -DCC_NOEX -norunpath -xnolib"
aoqi@0 1055
aoqi@0 1056 LDFLAGS_JDK="$LDFLAGS_JDK -z defs -xildoff -ztext"
aoqi@0 1057 LDFLAGS_CXX_JDK="$LDFLAGS_CXX_JDK -norunpath -xnolib"
aoqi@0 1058 ;;
aoqi@0 1059 xlc )
aoqi@0 1060 CFLAGS_JDK="$CFLAGS_JDK -D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE -DSTDC"
aoqi@0 1061 CXXFLAGS_JDK="$CXXFLAGS_JDK -D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE -DSTDC"
aoqi@0 1062
aoqi@0 1063 LDFLAGS_JDK="$LDFLAGS_JDK"
aoqi@0 1064 LDFLAGS_CXX_JDK="$LDFLAGS_CXX_JDK"
aoqi@0 1065 ;;
aoqi@0 1066 cl )
andrew@1862 1067 COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS $COMMON_CCXXFLAGS_JDK -Zi -MD -Zc:wchar_t- -W3 -wd4800 \
aoqi@0 1068 -D_STATIC_CPPLIB -D_DISABLE_DEPRECATE_STATIC_CPPLIB -DWIN32_LEAN_AND_MEAN \
aoqi@0 1069 -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE \
aoqi@0 1070 -DWIN32 -DIAL"
aoqi@0 1071 case $OPENJDK_TARGET_CPU in
aoqi@0 1072 x86 )
andrew@1862 1073 COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D_X86_ -Dx86"
aoqi@0 1074 ;;
aoqi@0 1075 x86_64 )
andrew@1862 1076 COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D_AMD64_ -Damd64"
aoqi@0 1077 ;;
aoqi@0 1078 esac
aoqi@0 1079 ;;
aoqi@0 1080 esac
aoqi@0 1081
aoqi@0 1082 ###############################################################################
aoqi@0 1083
aoqi@0 1084 # Adjust flags according to debug level.
aoqi@0 1085 case $DEBUG_LEVEL in
aoqi@0 1086 fastdebug )
aoqi@0 1087 CFLAGS_JDK="$CFLAGS_JDK $CFLAGS_DEBUG_SYMBOLS"
aoqi@0 1088 CXXFLAGS_JDK="$CXXFLAGS_JDK $CXXFLAGS_DEBUG_SYMBOLS"
aoqi@0 1089 C_O_FLAG_HI="$C_O_FLAG_NORM"
aoqi@0 1090 C_O_FLAG_NORM="$C_O_FLAG_NORM"
aoqi@0 1091 CXX_O_FLAG_HI="$CXX_O_FLAG_NORM"
aoqi@0 1092 CXX_O_FLAG_NORM="$CXX_O_FLAG_NORM"
aoqi@0 1093 JAVAC_FLAGS="$JAVAC_FLAGS -g"
aoqi@0 1094 ;;
aoqi@0 1095 slowdebug )
aoqi@0 1096 CFLAGS_JDK="$CFLAGS_JDK $CFLAGS_DEBUG_SYMBOLS"
aoqi@0 1097 CXXFLAGS_JDK="$CXXFLAGS_JDK $CXXFLAGS_DEBUG_SYMBOLS"
aoqi@0 1098 C_O_FLAG_HI="$C_O_FLAG_NONE"
aoqi@0 1099 C_O_FLAG_NORM="$C_O_FLAG_NONE"
aoqi@0 1100 CXX_O_FLAG_HI="$CXX_O_FLAG_NONE"
aoqi@0 1101 CXX_O_FLAG_NORM="$CXX_O_FLAG_NONE"
aoqi@0 1102 JAVAC_FLAGS="$JAVAC_FLAGS -g"
aoqi@0 1103 ;;
aoqi@0 1104 esac
aoqi@0 1105
andrew@1862 1106 COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK $ADD_LP64"
aoqi@0 1107
aoqi@0 1108 # The package path is used only on macosx?
aoqi@0 1109 PACKAGE_PATH=/opt/local
aoqi@0 1110 AC_SUBST(PACKAGE_PATH)
aoqi@0 1111
aoqi@0 1112 if test "x$OPENJDK_TARGET_CPU_ENDIAN" = xlittle; then
aoqi@0 1113 # The macro _LITTLE_ENDIAN needs to be defined the same to avoid the
aoqi@0 1114 # Sun C compiler warning message: warning: macro redefined: _LITTLE_ENDIAN
aoqi@0 1115 # (The Solaris X86 system defines this in file /usr/include/sys/isa_defs.h).
aoqi@0 1116 # Note: -Dmacro is the same as #define macro 1
aoqi@0 1117 # -Dmacro= is the same as #define macro
aoqi@0 1118 if test "x$OPENJDK_TARGET_OS" = xsolaris; then
andrew@1862 1119 COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D_LITTLE_ENDIAN="
aoqi@0 1120 else
andrew@1862 1121 COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D_LITTLE_ENDIAN"
aoqi@0 1122 fi
aoqi@0 1123 else
andrew@1862 1124 COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D_BIG_ENDIAN"
aoqi@0 1125 fi
aoqi@0 1126 if test "x$OPENJDK_TARGET_OS" = xlinux; then
andrew@1862 1127 COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DLINUX"
aoqi@0 1128 fi
aoqi@0 1129 if test "x$OPENJDK_TARGET_OS" = xwindows; then
andrew@1862 1130 COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DWINDOWS"
aoqi@0 1131 fi
aoqi@0 1132 if test "x$OPENJDK_TARGET_OS" = xsolaris; then
andrew@1862 1133 COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DSOLARIS"
aoqi@0 1134 fi
aoqi@0 1135 if test "x$OPENJDK_TARGET_OS" = xaix; then
andrew@1862 1136 COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DAIX -DPPC64"
aoqi@0 1137 fi
aoqi@0 1138 if test "x$OPENJDK_TARGET_OS" = xmacosx; then
andrew@1862 1139 COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DMACOSX -D_ALLBSD_SOURCE -D_DARWIN_UNLIMITED_SELECT"
aoqi@0 1140 # Setting these parameters makes it an error to link to macosx APIs that are
aoqi@0 1141 # newer than the given OS version and makes the linked binaries compatible even
aoqi@0 1142 # if built on a newer version of the OS.
aoqi@0 1143 # The expected format is X.Y.Z
aoqi@0 1144 MACOSX_VERSION_MIN=10.7.0
aoqi@0 1145 AC_SUBST(MACOSX_VERSION_MIN)
aoqi@0 1146 # The macro takes the version with no dots, ex: 1070
aoqi@0 1147 # Let the flags variables get resolved in make for easier override on make
aoqi@0 1148 # command line.
andrew@1862 1149 COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DMAC_OS_X_VERSION_MAX_ALLOWED=\$(subst .,,\$(MACOSX_VERSION_MIN)) -mmacosx-version-min=\$(MACOSX_VERSION_MIN)"
aoqi@0 1150 LDFLAGS_JDK="$LDFLAGS_JDK -mmacosx-version-min=\$(MACOSX_VERSION_MIN)"
aoqi@0 1151 fi
aoqi@0 1152 if test "x$OPENJDK_TARGET_OS" = xbsd; then
andrew@1862 1153 COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DBSD -D_ALLBSD_SOURCE"
aoqi@0 1154 fi
aoqi@0 1155 if test "x$DEBUG_LEVEL" = xrelease; then
andrew@1862 1156 COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DNDEBUG"
aoqi@0 1157 if test "x$OPENJDK_TARGET_OS" = xsolaris; then
andrew@1862 1158 COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DTRIMMED"
aoqi@0 1159 fi
aoqi@0 1160 else
andrew@1862 1161 COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DDEBUG"
aoqi@0 1162 fi
aoqi@0 1163
andrew@1862 1164 COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DARCH='\"$OPENJDK_TARGET_CPU_LEGACY\"' -D$OPENJDK_TARGET_CPU_LEGACY"
andrew@1862 1165 COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DRELEASE='\"\$(RELEASE)\"'"
aoqi@0 1166
andrew@1862 1167 COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK \
aoqi@0 1168 -I${JDK_OUTPUTDIR}/include \
aoqi@0 1169 -I${JDK_OUTPUTDIR}/include/$OPENJDK_TARGET_OS \
aoqi@0 1170 -I${JDK_TOPDIR}/src/share/javavm/export \
aoqi@0 1171 -I${JDK_TOPDIR}/src/$OPENJDK_TARGET_OS_EXPORT_DIR/javavm/export \
aoqi@0 1172 -I${JDK_TOPDIR}/src/share/native/common \
aoqi@0 1173 -I${JDK_TOPDIR}/src/$OPENJDK_TARGET_OS_API_DIR/native/common"
aoqi@0 1174
aoqi@0 1175 # The shared libraries are compiled using the picflag.
andrew@1862 1176 CFLAGS_JDKLIB="$COMMON_CCXXFLAGS_JDK $CFLAGS_JDK $PICFLAG $CFLAGS_JDKLIB_EXTRA"
andrew@1862 1177 CXXFLAGS_JDKLIB="$COMMON_CCXXFLAGS_JDK $CXXFLAGS_JDK $PICFLAG $CXXFLAGS_JDKLIB_EXTRA "
aoqi@0 1178
aoqi@0 1179 # Executable flags
andrew@1862 1180 CFLAGS_JDKEXE="$COMMON_CCXXFLAGS_JDK $CFLAGS_JDK"
andrew@1862 1181 CXXFLAGS_JDKEXE="$COMMON_CCXXFLAGS_JDK $CXXFLAGS_JDK"
aoqi@0 1182
aoqi@0 1183 # Now this is odd. The JDK native libraries have to link against libjvm.so
aoqi@0 1184 # On 32-bit machines there is normally two distinct libjvm.so:s, client and server.
aoqi@0 1185 # Which should we link to? Are we lucky enough that the binary api to the libjvm.so library
aoqi@0 1186 # is identical for client and server? Yes. Which is picked at runtime (client or server)?
aoqi@0 1187 # Neither, since the chosen libjvm.so has already been loaded by the launcher, all the following
aoqi@0 1188 # libraries will link to whatever is in memory. Yuck.
aoqi@0 1189 #
aoqi@0 1190 # Thus we offer the compiler to find libjvm.so first in server then in client. It works. Ugh.
aoqi@0 1191 if test "x$COMPILER_NAME" = xcl; then
aoqi@0 1192 LDFLAGS_JDK="$LDFLAGS_JDK -nologo -opt:ref -incremental:no"
aoqi@0 1193 if test "x$OPENJDK_TARGET_CPU" = xx86; then
aoqi@0 1194 LDFLAGS_JDK="$LDFLAGS_JDK -safeseh"
aoqi@0 1195 fi
aoqi@0 1196 # TODO: make -debug optional "--disable-full-debug-symbols"
aoqi@0 1197 LDFLAGS_JDK="$LDFLAGS_JDK -debug"
aoqi@0 1198 LDFLAGS_JDKLIB="${LDFLAGS_JDK} -dll -libpath:${JDK_OUTPUTDIR}/lib"
aoqi@0 1199 LDFLAGS_JDKLIB_SUFFIX=""
aoqi@0 1200 if test "x$OPENJDK_TARGET_CPU_BITS" = "x64"; then
aoqi@0 1201 LDFLAGS_STACK_SIZE=1048576
aoqi@0 1202 else
aoqi@0 1203 LDFLAGS_STACK_SIZE=327680
aoqi@0 1204 fi
aoqi@0 1205 LDFLAGS_JDKEXE="${LDFLAGS_JDK} /STACK:$LDFLAGS_STACK_SIZE"
aoqi@0 1206 else
aoqi@0 1207 if test "x$COMPILER_NAME" = xgcc; then
aoqi@0 1208 # If this is a --hash-style=gnu system, use --hash-style=both, why?
aoqi@0 1209 HAS_GNU_HASH=`$CC -dumpspecs 2>/dev/null | $GREP 'hash-style=gnu'`
aoqi@0 1210 if test -n "$HAS_GNU_HASH"; then
aoqi@0 1211 LDFLAGS_JDK="${LDFLAGS_JDK} -Xlinker --hash-style=both "
aoqi@0 1212 fi
aoqi@0 1213 if test "x$OPENJDK_TARGET_OS" = xlinux; then
aoqi@0 1214 # And since we now know that the linker is gnu, then add -z defs, to forbid
aoqi@0 1215 # undefined symbols in object files.
aoqi@0 1216 LDFLAGS_JDK="${LDFLAGS_JDK} -Xlinker -z -Xlinker defs"
aoqi@0 1217 if test "x$DEBUG_LEVEL" = "xrelease"; then
aoqi@0 1218 # When building release libraries, tell the linker optimize them.
aoqi@0 1219 # Should this be supplied to the OSS linker as well?
aoqi@0 1220 LDFLAGS_JDK="${LDFLAGS_JDK} -Xlinker -O1"
aoqi@0 1221 fi
aoqi@0 1222 fi
aoqi@0 1223 fi
aoqi@0 1224 LDFLAGS_JDKLIB="${LDFLAGS_JDK} $SHARED_LIBRARY_FLAGS \
aoqi@0 1225 -L${JDK_OUTPUTDIR}/lib${OPENJDK_TARGET_CPU_LIBDIR}"
aoqi@0 1226
aoqi@0 1227 # On some platforms (mac) the linker warns about non existing -L dirs.
aoqi@0 1228 # Add server first if available. Linking aginst client does not always produce the same results.
aoqi@0 1229 # Only add client dir if client is being built. Add minimal (note not minimal1) if only building minimal1.
aoqi@0 1230 # Default to server for other variants.
aoqi@0 1231 if test "x$JVM_VARIANT_SERVER" = xtrue; then
aoqi@0 1232 LDFLAGS_JDKLIB="${LDFLAGS_JDKLIB} -L${JDK_OUTPUTDIR}/lib${OPENJDK_TARGET_CPU_LIBDIR}/server"
aoqi@0 1233 elif test "x$JVM_VARIANT_CLIENT" = xtrue; then
aoqi@0 1234 LDFLAGS_JDKLIB="${LDFLAGS_JDKLIB} -L${JDK_OUTPUTDIR}/lib${OPENJDK_TARGET_CPU_LIBDIR}/client"
aoqi@0 1235 elif test "x$JVM_VARIANT_MINIMAL1" = xtrue; then
aoqi@0 1236 LDFLAGS_JDKLIB="${LDFLAGS_JDKLIB} -L${JDK_OUTPUTDIR}/lib${OPENJDK_TARGET_CPU_LIBDIR}/minimal"
aoqi@0 1237 else
aoqi@0 1238 LDFLAGS_JDKLIB="${LDFLAGS_JDKLIB} -L${JDK_OUTPUTDIR}/lib${OPENJDK_TARGET_CPU_LIBDIR}/server"
aoqi@0 1239 fi
aoqi@0 1240
aoqi@0 1241 LDFLAGS_JDKLIB_SUFFIX="-ljava -ljvm"
aoqi@0 1242 if test "x$COMPILER_NAME" = xossc; then
aoqi@0 1243 LDFLAGS_JDKLIB_SUFFIX="$LDFLAGS_JDKLIB_SUFFIX -lc"
aoqi@0 1244 fi
aoqi@0 1245
aoqi@0 1246 LDFLAGS_JDKEXE="${LDFLAGS_JDK}"
aoqi@0 1247 if test "x$OPENJDK_TARGET_OS" = xlinux; then
aoqi@0 1248 LDFLAGS_JDKEXE="$LDFLAGS_JDKEXE -Xlinker --allow-shlib-undefined"
aoqi@0 1249 fi
aoqi@0 1250 fi
aoqi@0 1251
aoqi@0 1252 AC_SUBST(CFLAGS_JDKLIB)
aoqi@0 1253 AC_SUBST(CFLAGS_JDKEXE)
aoqi@0 1254
aoqi@0 1255 AC_SUBST(CXXFLAGS_JDKLIB)
aoqi@0 1256 AC_SUBST(CXXFLAGS_JDKEXE)
aoqi@0 1257
aoqi@0 1258 AC_SUBST(LDFLAGS_JDKLIB)
aoqi@0 1259 AC_SUBST(LDFLAGS_JDKEXE)
aoqi@0 1260 AC_SUBST(LDFLAGS_JDKLIB_SUFFIX)
aoqi@0 1261 AC_SUBST(LDFLAGS_JDKEXE_SUFFIX)
aoqi@0 1262 AC_SUBST(LDFLAGS_CXX_JDK)
aoqi@0 1263 ])
aoqi@0 1264
aoqi@0 1265
andrew@1862 1266 # TOOLCHAIN_C_COMPILER_CHECK_ARGUMENTS([ARGUMENT], [RUN-IF-TRUE],
andrew@1862 1267 # [RUN-IF-FALSE])
aoqi@0 1268 # ------------------------------------------------------------
andrew@1862 1269 # Check that the C compiler supports an argument
andrew@1862 1270 AC_DEFUN([TOOLCHAIN_C_COMPILER_CHECK_ARGUMENTS],
aoqi@0 1271 [
andrew@1862 1272 AC_MSG_CHECKING([if the C compiler supports "$1"])
aoqi@0 1273 supports=yes
aoqi@0 1274
aoqi@0 1275 saved_cflags="$CFLAGS"
aoqi@0 1276 CFLAGS="$CFLAGS $1"
aoqi@0 1277 AC_LANG_PUSH([C])
aoqi@0 1278 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[int i;]])], [],
aoqi@0 1279 [supports=no])
aoqi@0 1280 AC_LANG_POP([C])
aoqi@0 1281 CFLAGS="$saved_cflags"
aoqi@0 1282
andrew@1862 1283 AC_MSG_RESULT([$supports])
andrew@1862 1284 if test "x$supports" = "xyes" ; then
andrew@1862 1285 m4_ifval([$2], [$2], [:])
andrew@1862 1286 else
andrew@1862 1287 m4_ifval([$3], [$3], [:])
andrew@1862 1288 fi
andrew@1862 1289 ])
andrew@1862 1290
andrew@1862 1291 # TOOLCHAIN_CXX_COMPILER_CHECK_ARGUMENTS([ARGUMENT], [RUN-IF-TRUE],
andrew@1862 1292 # [RUN-IF-FALSE])
andrew@1862 1293 # ------------------------------------------------------------
andrew@1862 1294 # Check that the C++ compiler supports an argument
andrew@1862 1295 AC_DEFUN([TOOLCHAIN_CXX_COMPILER_CHECK_ARGUMENTS],
andrew@1862 1296 [
andrew@1862 1297 AC_MSG_CHECKING([if the C++ compiler supports "$1"])
andrew@1862 1298 supports=yes
andrew@1862 1299
aoqi@0 1300 saved_cxxflags="$CXXFLAGS"
aoqi@0 1301 CXXFLAGS="$CXXFLAG $1"
aoqi@0 1302 AC_LANG_PUSH([C++])
aoqi@0 1303 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[int i;]])], [],
aoqi@0 1304 [supports=no])
aoqi@0 1305 AC_LANG_POP([C++])
aoqi@0 1306 CXXFLAGS="$saved_cxxflags"
andrew@1862 1307
andrew@1862 1308 AC_MSG_RESULT([$supports])
andrew@1862 1309 if test "x$supports" = "xyes" ; then
andrew@1862 1310 m4_ifval([$2], [$2], [:])
andrew@1862 1311 else
andrew@1862 1312 m4_ifval([$3], [$3], [:])
andrew@1862 1313 fi
andrew@1862 1314 ])
aoqi@0 1315
andrew@1862 1316 # TOOLCHAIN_COMPILER_CHECK_ARGUMENTS([ARGUMENT], [RUN-IF-TRUE],
andrew@1862 1317 # [RUN-IF-FALSE])
andrew@1862 1318 # ------------------------------------------------------------
andrew@1862 1319 # Check that the C and C++ compilers support an argument
andrew@1862 1320 AC_DEFUN([TOOLCHAIN_COMPILER_CHECK_ARGUMENTS],
andrew@1862 1321 [
andrew@1862 1322 TOOLCHAIN_C_COMPILER_CHECK_ARGUMENTS([$1],
andrew@1862 1323 [C_COMP_SUPPORTS="yes"],
andrew@1862 1324 [C_COMP_SUPPORTS="no"])
andrew@1862 1325 TOOLCHAIN_CXX_COMPILER_CHECK_ARGUMENTS([$1],
andrew@1862 1326 [CXX_COMP_SUPPORTS="yes"],
andrew@1862 1327 [CXX_COMP_SUPPORTS="no"])
andrew@1862 1328
andrew@1862 1329 AC_MSG_CHECKING([if both compilers support "$1"])
andrew@1862 1330 supports=no
andrew@1862 1331 if test "x$C_COMP_SUPPORTS" = "xyes" -a "x$CXX_COMP_SUPPORTS" = "xyes"; then supports=yes; fi
andrew@1862 1332
aoqi@0 1333 AC_MSG_RESULT([$supports])
aoqi@0 1334 if test "x$supports" = "xyes" ; then
aoqi@0 1335 m4_ifval([$2], [$2], [:])
aoqi@0 1336 else
aoqi@0 1337 m4_ifval([$3], [$3], [:])
aoqi@0 1338 fi
aoqi@0 1339 ])
aoqi@0 1340
aoqi@0 1341 AC_DEFUN_ONCE([TOOLCHAIN_SETUP_COMPILER_FLAGS_MISC],
aoqi@0 1342 [
aoqi@0 1343 # Some Zero and Shark settings.
aoqi@0 1344 # ZERO_ARCHFLAG tells the compiler which mode to build for
aoqi@0 1345 case "${OPENJDK_TARGET_CPU}" in
aoqi@0 1346 s390)
aoqi@0 1347 ZERO_ARCHFLAG="${COMPILER_TARGET_BITS_FLAG}31"
aoqi@0 1348 ;;
aoqi@0 1349 *)
aoqi@0 1350 ZERO_ARCHFLAG="${COMPILER_TARGET_BITS_FLAG}${OPENJDK_TARGET_CPU_BITS}"
aoqi@0 1351 esac
aoqi@0 1352 TOOLCHAIN_COMPILER_CHECK_ARGUMENTS([$ZERO_ARCHFLAG], [], [ZERO_ARCHFLAG=""])
aoqi@0 1353 AC_SUBST(ZERO_ARCHFLAG)
aoqi@0 1354
aoqi@0 1355 # Check that the compiler supports -mX (or -qX on AIX) flags
aoqi@0 1356 # Set COMPILER_SUPPORTS_TARGET_BITS_FLAG to 'true' if it does
aoqi@0 1357 TOOLCHAIN_COMPILER_CHECK_ARGUMENTS([${COMPILER_TARGET_BITS_FLAG}${OPENJDK_TARGET_CPU_BITS}],
aoqi@0 1358 [COMPILER_SUPPORTS_TARGET_BITS_FLAG=true],
aoqi@0 1359 [COMPILER_SUPPORTS_TARGET_BITS_FLAG=false])
aoqi@0 1360 AC_SUBST(COMPILER_SUPPORTS_TARGET_BITS_FLAG)
aoqi@0 1361
aoqi@0 1362
aoqi@0 1363 # Check for broken SuSE 'ld' for which 'Only anonymous version tag is allowed in executable.'
aoqi@0 1364 USING_BROKEN_SUSE_LD=no
aoqi@0 1365 if test "x$OPENJDK_TARGET_OS" = xlinux && test "x$GCC" = xyes; then
aoqi@0 1366 AC_MSG_CHECKING([for broken SuSE 'ld' which only understands anonymous version tags in executables])
aoqi@0 1367 echo "SUNWprivate_1.1 { local: *; };" > version-script.map
aoqi@0 1368 echo "int main() { }" > main.c
aoqi@0 1369 if $CXX -Xlinker -version-script=version-script.map main.c 2>&AS_MESSAGE_LOG_FD >&AS_MESSAGE_LOG_FD; then
aoqi@0 1370 AC_MSG_RESULT(no)
aoqi@0 1371 USING_BROKEN_SUSE_LD=no
aoqi@0 1372 else
aoqi@0 1373 AC_MSG_RESULT(yes)
aoqi@0 1374 USING_BROKEN_SUSE_LD=yes
aoqi@0 1375 fi
aoqi@0 1376 rm -rf version-script.map main.c
aoqi@0 1377 fi
aoqi@0 1378 AC_SUBST(USING_BROKEN_SUSE_LD)
aoqi@0 1379 ])
aoqi@0 1380
aoqi@0 1381 # Setup the JTREG paths
aoqi@0 1382 AC_DEFUN_ONCE([TOOLCHAIN_SETUP_JTREG],
aoqi@0 1383 [
aoqi@0 1384 AC_ARG_WITH(jtreg, [AS_HELP_STRING([--with-jtreg],
aoqi@0 1385 [Regression Test Harness @<:@probed@:>@])],
aoqi@0 1386 [],
aoqi@0 1387 [with_jtreg=no])
aoqi@0 1388
aoqi@0 1389 if test "x$with_jtreg" = xno; then
aoqi@0 1390 # jtreg disabled
aoqi@0 1391 AC_MSG_CHECKING([for jtreg])
aoqi@0 1392 AC_MSG_RESULT(no)
aoqi@0 1393 else
aoqi@0 1394 if test "x$with_jtreg" != xyes; then
aoqi@0 1395 # with path specified.
aoqi@0 1396 JT_HOME="$with_jtreg"
aoqi@0 1397 fi
aoqi@0 1398
aoqi@0 1399 if test "x$JT_HOME" != x; then
aoqi@0 1400 AC_MSG_CHECKING([for jtreg])
aoqi@0 1401
aoqi@0 1402 # use JT_HOME enviroment var.
aoqi@0 1403 BASIC_FIXUP_PATH([JT_HOME])
aoqi@0 1404
aoqi@0 1405 # jtreg win32 script works for everybody
erikj@1328 1406 JTREGEXE="$JT_HOME/bin/jtreg"
aoqi@0 1407
aoqi@0 1408 if test ! -f "$JTREGEXE"; then
aoqi@0 1409 AC_MSG_ERROR([JTReg executable does not exist: $JTREGEXE])
aoqi@0 1410 fi
aoqi@0 1411
aoqi@0 1412 AC_MSG_RESULT($JTREGEXE)
aoqi@0 1413 else
aoqi@0 1414 # try to find jtreg on path
aoqi@0 1415 BASIC_REQUIRE_PROG(JTREGEXE, jtreg)
aoqi@0 1416 JT_HOME="`$DIRNAME $JTREGEXE`"
aoqi@0 1417 fi
aoqi@0 1418 fi
aoqi@0 1419
aoqi@0 1420 AC_SUBST(JT_HOME)
aoqi@0 1421 AC_SUBST(JTREGEXE)
aoqi@0 1422 ])
andrew@1862 1423
andrew@1862 1424 AC_DEFUN_ONCE([TOOLCHAIN_SETUP_GCC6_COMPILER_FLAGS],
andrew@1862 1425 [
andrew@1862 1426 # These flags are required for GCC 6 builds as undefined behaviour in OpenJDK code
andrew@1862 1427 # runs afoul of the more aggressive versions of these optimisations.
andrew@1862 1428 # Notably, value range propagation now assumes that the this pointer of C++
andrew@1862 1429 # member functions is non-null.
andrew@1862 1430 NO_DELETE_NULL_POINTER_CHECKS_CFLAG="-fno-delete-null-pointer-checks"
andrew@1862 1431 TOOLCHAIN_COMPILER_CHECK_ARGUMENTS([$NO_DELETE_NULL_POINTER_CHECKS_CFLAG -Werror],
andrew@1862 1432 [], [NO_DELETE_NULL_POINTER_CHECKS_CFLAG=""])
andrew@1862 1433 AC_SUBST([NO_DELETE_NULL_POINTER_CHECKS_CFLAG])
andrew@1862 1434 NO_LIFETIME_DSE_CFLAG="-fno-lifetime-dse"
andrew@1862 1435 TOOLCHAIN_COMPILER_CHECK_ARGUMENTS([$NO_LIFETIME_DSE_CFLAG -Werror],
andrew@1862 1436 [], [NO_LIFETIME_DSE_CFLAG=""])
andrew@1862 1437 CFLAGS_JDK="${CFLAGS_JDK} ${NO_DELETE_NULL_POINTER_CHECKS_CFLAG} ${NO_LIFETIME_DSE_CFLAG}"
andrew@1862 1438 AC_SUBST([NO_LIFETIME_DSE_CFLAG])
andrew@1862 1439 ])

mercurial