common/autoconf/toolchain.m4

Fri, 06 Apr 2018 04:13:09 -0700

author
kevinw
date
Fri, 06 Apr 2018 04:13:09 -0700
changeset 2208
feba63b3fa36
parent 2207
ddf2d8bf87c0
child 2215
7a73b8b4ac8a
permissions
-rw-r--r--

8035751: Clean up Visual Studio detection logic
Reviewed-by: ihse, erikj, tbell

erikj@459 1 #
dbuck@2172 2 # Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
erikj@459 3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
erikj@459 4 #
erikj@459 5 # This code is free software; you can redistribute it and/or modify it
erikj@459 6 # under the terms of the GNU General Public License version 2 only, as
erikj@459 7 # published by the Free Software Foundation. Oracle designates this
erikj@459 8 # particular file as subject to the "Classpath" exception as provided
erikj@459 9 # by Oracle in the LICENSE file that accompanied this code.
erikj@459 10 #
erikj@459 11 # This code is distributed in the hope that it will be useful, but WITHOUT
erikj@459 12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
erikj@459 13 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
erikj@459 14 # version 2 for more details (a copy is included in the LICENSE file that
erikj@459 15 # accompanied this code).
erikj@459 16 #
erikj@459 17 # You should have received a copy of the GNU General Public License version
erikj@459 18 # 2 along with this work; if not, write to the Free Software Foundation,
erikj@459 19 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
erikj@459 20 #
erikj@459 21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
erikj@459 22 # or visit www.oracle.com if you need additional information or have any
erikj@459 23 # questions.
erikj@459 24 #
erikj@459 25
kevinw@2206 26 ########################################################################
kevinw@2206 27 # This file is responsible for detecting, verifying and setting up the
kevinw@2206 28 # toolchain, i.e. the compiler, linker and related utilities. It will setup
kevinw@2206 29 # proper paths to the binaries, but it will not setup any flags.
kevinw@2206 30 #
kevinw@2206 31 # The binaries used is determined by the toolchain type, which is the family of
kevinw@2206 32 # compilers and related tools that are used.
kevinw@2206 33 ########################################################################
kevinw@2206 34
kevinw@2206 35
kevinw@2206 36 # All valid toolchains, regardless of platform (used by help.m4)
kevinw@2206 37 VALID_TOOLCHAINS_all="gcc clang solstudio xlc microsoft"
kevinw@2206 38
kevinw@2206 39 # These toolchains are valid on different platforms
kevinw@2206 40 VALID_TOOLCHAINS_linux="gcc clang"
kevinw@2206 41 VALID_TOOLCHAINS_solaris="solstudio"
kevinw@2206 42 VALID_TOOLCHAINS_macosx="gcc clang"
kevinw@2206 43 VALID_TOOLCHAINS_aix="xlc"
kevinw@2206 44 VALID_TOOLCHAINS_windows="microsoft"
kevinw@2206 45
kevinw@2206 46 # Toolchain descriptions
kevinw@2206 47 TOOLCHAIN_DESCRIPTION_clang="clang/LLVM"
kevinw@2206 48 TOOLCHAIN_DESCRIPTION_gcc="GNU Compiler Collection"
kevinw@2206 49 TOOLCHAIN_DESCRIPTION_microsoft="Microsoft Visual Studio"
kevinw@2206 50 TOOLCHAIN_DESCRIPTION_solstudio="Oracle Solaris Studio"
kevinw@2206 51 TOOLCHAIN_DESCRIPTION_xlc="IBM XL C/C++"
kevinw@2206 52
andrew@1862 53 # Prepare the system so that TOOLCHAIN_CHECK_COMPILER_VERSION can be called.
andrew@1862 54 # Must have CC_VERSION_NUMBER and CXX_VERSION_NUMBER.
kevinw@2206 55 # $1 - optional variable prefix for compiler and version variables (BUILD_)
kevinw@2206 56 # $2 - optional variable prefix for comparable variable (OPENJDK_BUILD_)
andrew@1862 57 AC_DEFUN([TOOLCHAIN_PREPARE_FOR_VERSION_COMPARISONS],
andrew@1862 58 [
andrew@1862 59 if test "x$CC_VERSION" != "x$CXX_VERSION"; then
andrew@1862 60 AC_MSG_WARN([C and C++ compiler has different version numbers, $CC_VERSION vs $CXX_VERSION.])
andrew@1862 61 AC_MSG_WARN([This typically indicates a broken setup, and is not supported])
andrew@1862 62 fi
andrew@1862 63
andrew@1862 64 # We only check CC_VERSION since we assume CXX_VERSION is equal.
andrew@1862 65 if [ [[ "$CC_VERSION" =~ (.*\.){3} ]] ]; then
andrew@1862 66 AC_MSG_WARN([C compiler version number has more than three parts (X.Y.Z): $CC_VERSION. Comparisons might be wrong.])
andrew@1862 67 fi
andrew@1862 68
andrew@1862 69 if [ [[ "$CC_VERSION" =~ [0-9]{6} ]] ]; then
andrew@1862 70 AC_MSG_WARN([C compiler version number has a part larger than 99999: $CC_VERSION. Comparisons might be wrong.])
andrew@1862 71 fi
andrew@1862 72
kevinw@2206 73 $2COMPARABLE_ACTUAL_VERSION=`$AWK -F. '{ printf("%05d%05d%05d\n", [$]1, [$]2, [$]3) }' <<< "$CC_VERSION"`
andrew@1862 74 ])
andrew@1862 75
andrew@1862 76 # Check if the configured compiler (C and C++) is of a specific version or
andrew@1862 77 # newer. TOOLCHAIN_PREPARE_FOR_VERSION_COMPARISONS must have been called before.
andrew@1862 78 #
andrew@1862 79 # Arguments:
andrew@1862 80 # $1: The version string to check against the found version
andrew@1862 81 # $2: block to run if the compiler is at least this version (>=)
andrew@1862 82 # $3: block to run if the compiler is older than this version (<)
andrew@1862 83 AC_DEFUN([TOOLCHAIN_CHECK_COMPILER_VERSION],
andrew@1862 84 [
andrew@1862 85 REFERENCE_VERSION=$1
andrew@1862 86
andrew@1862 87 if [ [[ "$REFERENCE_VERSION" =~ (.*\.){3} ]] ]; then
andrew@1862 88 AC_MSG_ERROR([Internal error: Cannot compare to $REFERENCE_VERSION, only three parts (X.Y.Z) is supported])
andrew@1862 89 fi
andrew@1862 90
andrew@1862 91 if [ [[ "$REFERENCE_VERSION" =~ [0-9]{6} ]] ]; then
andrew@1862 92 AC_MSG_ERROR([Internal error: Cannot compare to $REFERENCE_VERSION, only parts < 99999 is supported])
andrew@1862 93 fi
andrew@1862 94
andrew@1862 95 # Version comparison method inspired by http://stackoverflow.com/a/24067243
andrew@1862 96 COMPARABLE_REFERENCE_VERSION=`$AWK -F. '{ printf("%05d%05d%05d\n", [$]1, [$]2, [$]3) }' <<< "$REFERENCE_VERSION"`
andrew@1862 97
andrew@1862 98 if test $COMPARABLE_ACTUAL_VERSION -ge $COMPARABLE_REFERENCE_VERSION ; then
andrew@1862 99 m4_ifval([$2], [$2], [:])
andrew@1862 100 else
andrew@1862 101 m4_ifval([$3], [$3], [:])
andrew@1862 102 fi
andrew@1862 103 ])
andrew@1862 104
kevinw@2206 105
kevinw@2206 106 # Setup a number of variables describing how native output files are
kevinw@2206 107 # named on this platform/toolchain.
kevinw@2206 108 AC_DEFUN([TOOLCHAIN_SETUP_FILENAME_PATTERNS],
erikj@459 109 [
kevinw@2206 110 # Define filename patterns
kevinw@2206 111 if test "x$OPENJDK_TARGET_OS" = xwindows; then
kevinw@2206 112 LIBRARY_PREFIX=
kevinw@2206 113 SHARED_LIBRARY_SUFFIX='.dll'
kevinw@2206 114 STATIC_LIBRARY_SUFFIX='.lib'
kevinw@2206 115 SHARED_LIBRARY='[$]1.dll'
kevinw@2206 116 STATIC_LIBRARY='[$]1.lib'
kevinw@2206 117 OBJ_SUFFIX='.obj'
kevinw@2206 118 EXE_SUFFIX='.exe'
kevinw@2206 119 else
kevinw@2206 120 LIBRARY_PREFIX=lib
kevinw@2206 121 SHARED_LIBRARY_SUFFIX='.so'
kevinw@2206 122 STATIC_LIBRARY_SUFFIX='.a'
kevinw@2206 123 SHARED_LIBRARY='lib[$]1.so'
kevinw@2206 124 STATIC_LIBRARY='lib[$]1.a'
kevinw@2206 125 OBJ_SUFFIX='.o'
kevinw@2206 126 EXE_SUFFIX=''
kevinw@2206 127 if test "x$OPENJDK_TARGET_OS" = xmacosx; then
kevinw@2206 128 SHARED_LIBRARY='lib[$]1.dylib'
kevinw@2206 129 SHARED_LIBRARY_SUFFIX='.dylib'
kevinw@2206 130 fi
kevinw@2206 131 fi
erikj@459 132
kevinw@2206 133 AC_SUBST(LIBRARY_PREFIX)
kevinw@2206 134 AC_SUBST(SHARED_LIBRARY_SUFFIX)
kevinw@2206 135 AC_SUBST(STATIC_LIBRARY_SUFFIX)
kevinw@2206 136 AC_SUBST(SHARED_LIBRARY)
kevinw@2206 137 AC_SUBST(STATIC_LIBRARY)
kevinw@2206 138 AC_SUBST(OBJ_SUFFIX)
kevinw@2206 139 AC_SUBST(EXE_SUFFIX)
erikj@459 140 ])
erikj@459 141
kevinw@2206 142 # Determine which toolchain type to use, and make sure it is valid for this
kevinw@2206 143 # platform. Setup various information about the selected toolchain.
kevinw@2206 144 AC_DEFUN_ONCE([TOOLCHAIN_DETERMINE_TOOLCHAIN_TYPE],
kevinw@2206 145 [
kevinw@2206 146 AC_ARG_WITH(toolchain-type, [AS_HELP_STRING([--with-toolchain-type],
kevinw@2206 147 [the toolchain type (or family) to use, use '--help' to show possible values @<:@platform dependent@:>@])])
ohair@494 148
kevinw@2206 149 # Use indirect variable referencing
kevinw@2206 150 toolchain_var_name=VALID_TOOLCHAINS_$OPENJDK_BUILD_OS
kevinw@2206 151 VALID_TOOLCHAINS=${!toolchain_var_name}
kevinw@2206 152 # First toolchain type in the list is the default
kevinw@2206 153 DEFAULT_TOOLCHAIN=${VALID_TOOLCHAINS%% *}
erikj@459 154
kevinw@2206 155 if test "x$with_toolchain_type" = xlist; then
kevinw@2206 156 # List all toolchains
kevinw@2206 157 AC_MSG_NOTICE([The following toolchains are valid on this platform:])
kevinw@2206 158 for toolchain in $VALID_TOOLCHAINS; do
kevinw@2206 159 toolchain_var_name=TOOLCHAIN_DESCRIPTION_$toolchain
kevinw@2206 160 TOOLCHAIN_DESCRIPTION=${!toolchain_var_name}
kevinw@2206 161 $PRINTF " %-10s %s\n" $toolchain "$TOOLCHAIN_DESCRIPTION"
kevinw@2206 162 done
kevinw@2206 163
kevinw@2206 164 exit 0
kevinw@2206 165 elif test "x$with_toolchain_type" != x; then
kevinw@2206 166 # User override; check that it is valid
kevinw@2206 167 if test "x${VALID_TOOLCHAINS/$with_toolchain_type/}" = "x${VALID_TOOLCHAINS}"; then
kevinw@2206 168 AC_MSG_NOTICE([Toolchain type $with_toolchain_type is not valid on this platform.])
kevinw@2206 169 AC_MSG_NOTICE([Valid toolchains: $VALID_TOOLCHAINS.])
kevinw@2206 170 AC_MSG_ERROR([Cannot continue.])
kevinw@2206 171 fi
kevinw@2206 172 TOOLCHAIN_TYPE=$with_toolchain_type
kevinw@2206 173 else
kevinw@2206 174 # No flag given, use default
kevinw@2206 175 TOOLCHAIN_TYPE=$DEFAULT_TOOLCHAIN
kevinw@2206 176 fi
kevinw@2206 177 AC_SUBST(TOOLCHAIN_TYPE)
kevinw@2206 178
kevinw@2206 179 TOOLCHAIN_CC_BINARY_clang="clang"
kevinw@2206 180 TOOLCHAIN_CC_BINARY_gcc="gcc"
kevinw@2206 181 TOOLCHAIN_CC_BINARY_microsoft="cl"
kevinw@2206 182 TOOLCHAIN_CC_BINARY_solstudio="cc"
kevinw@2206 183 TOOLCHAIN_CC_BINARY_xlc="xlc_r"
kevinw@2206 184
kevinw@2206 185 TOOLCHAIN_CXX_BINARY_clang="clang++"
kevinw@2206 186 TOOLCHAIN_CXX_BINARY_gcc="g++"
kevinw@2206 187 TOOLCHAIN_CXX_BINARY_microsoft="cl"
kevinw@2206 188 TOOLCHAIN_CXX_BINARY_solstudio="CC"
kevinw@2206 189 TOOLCHAIN_CXX_BINARY_xlc="xlC_r"
kevinw@2206 190
kevinw@2206 191 # Use indirect variable referencing
kevinw@2206 192 toolchain_var_name=TOOLCHAIN_DESCRIPTION_$TOOLCHAIN_TYPE
kevinw@2206 193 TOOLCHAIN_DESCRIPTION=${!toolchain_var_name}
kevinw@2206 194 toolchain_var_name=TOOLCHAIN_CC_BINARY_$TOOLCHAIN_TYPE
kevinw@2206 195 TOOLCHAIN_CC_BINARY=${!toolchain_var_name}
kevinw@2206 196 toolchain_var_name=TOOLCHAIN_CXX_BINARY_$TOOLCHAIN_TYPE
kevinw@2206 197 TOOLCHAIN_CXX_BINARY=${!toolchain_var_name}
kevinw@2206 198
kevinw@2206 199 TOOLCHAIN_SETUP_FILENAME_PATTERNS
kevinw@2206 200
kevinw@2206 201 if test "x$TOOLCHAIN_TYPE" = "x$DEFAULT_TOOLCHAIN"; then
kevinw@2206 202 AC_MSG_NOTICE([Using default toolchain $TOOLCHAIN_TYPE ($TOOLCHAIN_DESCRIPTION)])
kevinw@2206 203 else
kevinw@2206 204 AC_MSG_NOTICE([Using user selected toolchain $TOOLCHAIN_TYPE ($TOOLCHAIN_DESCRIPTION). Default toolchain is $DEFAULT_TOOLCHAIN.])
kevinw@2206 205 fi
erikj@459 206 ])
erikj@459 207
kevinw@2206 208 # Before we start detecting the toolchain executables, we might need some
kevinw@2206 209 # special setup, e.g. additional paths etc.
kevinw@2206 210 AC_DEFUN_ONCE([TOOLCHAIN_PRE_DETECTION],
erikj@459 211 [
kevinw@2206 212 # FIXME: Is this needed?
kevinw@2206 213 AC_LANG(C++)
erikj@459 214
ihse@839 215 # Store the CFLAGS etal passed to the configure script.
ihse@839 216 ORG_CFLAGS="$CFLAGS"
ihse@839 217 ORG_CXXFLAGS="$CXXFLAGS"
ihse@839 218 ORG_OBJCFLAGS="$OBJCFLAGS"
erikj@459 219
kevinw@2207 220 # On Windows, we need to detect the visual studio installation first.
kevinw@2207 221 # This will change the PATH, but we need to keep that new PATH even
kevinw@2207 222 # after toolchain detection is done, since the compiler (on x86) uses
kevinw@2207 223 # it for DLL resolution in runtime.
kevinw@2207 224 if test "x$OPENJDK_BUILD_OS" = "xwindows" && test "x$TOOLCHAIN_TYPE" = "xmicrosoft"; then
kevinw@2207 225 TOOLCHAIN_SETUP_VISUAL_STUDIO_ENV
kevinw@2208 226 # Reset path to VS_PATH. It will include everything that was on PATH at the time we
kevinw@2208 227 # ran TOOLCHAIN_SETUP_VISUAL_STUDIO_ENV.
kevinw@2208 228 PATH="$VS_PATH"
kevinw@2208 229 # The microsoft toolchain also requires INCLUDE and LIB to be set.
kevinw@2208 230 export INCLUDE="$VS_INCLUDE"
kevinw@2208 231 export LIB="$VS_LIB"
kevinw@2207 232 fi
kevinw@2207 233
ihse@839 234 # autoconf magic only relies on PATH, so update it if tools dir is specified
ihse@839 235 OLD_PATH="$PATH"
erikj@459 236
ddehaven@1304 237 # Before we locate the compilers, we need to sanitize the Xcode build environment
ddehaven@1304 238 if test "x$OPENJDK_TARGET_OS" = "xmacosx"; then
ddehaven@1304 239 # determine path to Xcode developer directory
ddehaven@1304 240 # can be empty in which case all the tools will rely on a sane Xcode 4 installation
ddehaven@1304 241 SET_DEVELOPER_DIR=
ddehaven@1304 242
ddehaven@1304 243 if test -n "$XCODE_PATH"; then
ddehaven@1304 244 DEVELOPER_DIR="$XCODE_PATH"/Contents/Developer
ddehaven@1304 245 fi
ddehaven@1304 246
ddehaven@1304 247 # DEVELOPER_DIR could also be provided directly
ddehaven@1304 248 AC_MSG_CHECKING([Determining if we need to set DEVELOPER_DIR])
ddehaven@1304 249 if test -n "$DEVELOPER_DIR"; then
ddehaven@1304 250 if test ! -d "$DEVELOPER_DIR"; then
ddehaven@1304 251 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 252 fi
ddehaven@1304 253 if test ! -f "$DEVELOPER_DIR"/usr/bin/xcodebuild; then
ddehaven@1304 254 AC_MSG_ERROR([Xcode Developer path is not valid: $DEVELOPER_DIR, it must point to Contents/Developer inside an Xcode application bundle])
ddehaven@1304 255 fi
ddehaven@1304 256 # make it visible to all the tools immediately
ddehaven@1304 257 export DEVELOPER_DIR
ddehaven@1304 258 SET_DEVELOPER_DIR="export DEVELOPER_DIR := $DEVELOPER_DIR"
ddehaven@1304 259 AC_MSG_RESULT([yes ($DEVELOPER_DIR)])
ddehaven@1304 260 else
ddehaven@1304 261 AC_MSG_RESULT([no])
ddehaven@1304 262 fi
ddehaven@1304 263 AC_SUBST(SET_DEVELOPER_DIR)
ddehaven@1304 264
ddehaven@1304 265 AC_PATH_PROG(XCODEBUILD, xcodebuild)
ddehaven@1304 266 if test -z "$XCODEBUILD"; then
ddehaven@1304 267 AC_MSG_ERROR([The xcodebuild tool was not found, the Xcode command line tools are required to build on Mac OS X])
ddehaven@1304 268 fi
ddehaven@1304 269
ddehaven@1304 270 # Fail-fast: verify we're building on Xcode 4, we cannot build with Xcode 5 or later
ddehaven@1304 271 XCODE_VERSION=`$XCODEBUILD -version | grep '^Xcode ' | sed 's/Xcode //'`
ddehaven@1304 272 XC_VERSION_PARTS=( ${XCODE_VERSION//./ } )
ddehaven@1304 273 if test ! "${XC_VERSION_PARTS[[0]]}" = "4"; then
ddehaven@1304 274 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 275 fi
ddehaven@1304 276
ddehaven@1304 277 # Some versions of Xcode 5 command line tools install gcc and g++ as symlinks to
ddehaven@1304 278 # clang and clang++, which will break the build. So handle that here if we need to.
ddehaven@1304 279 if test -L "/usr/bin/gcc" -o -L "/usr/bin/g++"; then
ddehaven@1304 280 # use xcrun to find the real gcc and add it's directory to PATH
ddehaven@1304 281 # then autoconf magic will find it
ddehaven@1304 282 AC_MSG_NOTICE([Found gcc symlinks to clang in /usr/bin, adding path to real gcc to PATH])
ddehaven@1304 283 XCODE_BIN_PATH=$(dirname `xcrun -find gcc`)
ddehaven@1304 284 PATH="$XCODE_BIN_PATH":$PATH
ddehaven@1304 285 fi
ddehaven@1304 286
ddehaven@1304 287 # Determine appropriate SDKPATH, don't use SDKROOT as it interferes with the stub tools
ddehaven@1304 288 AC_MSG_CHECKING([Determining Xcode SDK path])
ddehaven@1304 289 # allow SDKNAME to be set to override the default SDK selection
ddehaven@1304 290 SDKPATH=`"$XCODEBUILD" -sdk ${SDKNAME:-macosx} -version | grep '^Path: ' | sed 's/Path: //'`
ddehaven@1304 291 if test -n "$SDKPATH"; then
ddehaven@1304 292 AC_MSG_RESULT([$SDKPATH])
ddehaven@1304 293 else
ddehaven@1304 294 AC_MSG_RESULT([(none, will use system headers and frameworks)])
ddehaven@1304 295 fi
ddehaven@1304 296 AC_SUBST(SDKPATH)
ddehaven@1304 297
ddehaven@1304 298 # Perform a basic sanity test
ddehaven@1304 299 if test ! -f "$SDKPATH/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h"; then
ddehaven@1304 300 AC_MSG_ERROR([Unable to find required framework headers, provide a valid path to Xcode 4 using --with-xcode-path])
ddehaven@1304 301 fi
ddehaven@1304 302
ddehaven@1304 303 # if SDKPATH is non-empty then we need to add -isysroot and -iframework for gcc and g++
ddehaven@1304 304 if test -n "$SDKPATH"; then
ddehaven@1304 305 # We need -isysroot <path> and -iframework<path>/System/Library/Frameworks
ddehaven@1304 306 CFLAGS_JDK="${CFLAGS_JDK} -isysroot \"$SDKPATH\" -iframework\"$SDKPATH/System/Library/Frameworks\""
ddehaven@1304 307 CXXFLAGS_JDK="${CXXFLAGS_JDK} -isysroot \"$SDKPATH\" -iframework\"$SDKPATH/System/Library/Frameworks\""
ddehaven@1304 308 LDFLAGS_JDK="${LDFLAGS_JDK} -isysroot \"$SDKPATH\" -iframework\"$SDKPATH/System/Library/Frameworks\""
ddehaven@1304 309 fi
ddehaven@1304 310
ddehaven@1304 311 # These always need to be set, or we can't find the frameworks embedded in JavaVM.framework
ddehaven@1304 312 # setting this here means it doesn't have to be peppered throughout the forest
ddehaven@1304 313 CFLAGS_JDK="$CFLAGS_JDK -F\"$SDKPATH/System/Library/Frameworks/JavaVM.framework/Frameworks\""
ddehaven@1304 314 CXXFLAGS_JDK="$CXXFLAGS_JDK -F\"$SDKPATH/System/Library/Frameworks/JavaVM.framework/Frameworks\""
ddehaven@1304 315 LDFLAGS_JDK="$LDFLAGS_JDK -F\"$SDKPATH/System/Library/Frameworks/JavaVM.framework/Frameworks\""
ddehaven@1304 316 fi
ohair@494 317
kevinw@2206 318 # For solaris we really need solaris tools, and not the GNU equivalent.
kevinw@2206 319 # The build tools on Solaris reside in /usr/ccs (C Compilation System),
kevinw@2206 320 # so add that to path before starting to probe.
kevinw@2206 321 # FIXME: This was originally only done for AS,NM,GNM,STRIP,MCS,OBJCOPY,OBJDUMP.
kevinw@2206 322 if test "x$OPENJDK_BUILD_OS" = xsolaris; then
kevinw@2206 323 PATH="/usr/ccs/bin:$PATH"
ihse@839 324 fi
erikj@459 325
kevinw@2206 326 # Finally add TOOLS_DIR at the beginning, to allow --with-tools-dir to
kevinw@2206 327 # override all other locations.
kevinw@2206 328 if test "x$TOOLS_DIR" != x; then
kevinw@2206 329 PATH=$TOOLS_DIR:$PATH
kevinw@2206 330 fi
ohair@494 331
kevinw@2206 332 # If a devkit is found on the builddeps server, then prepend its path to the
kevinw@2206 333 # PATH variable. If there are cross compilers available in the devkit, these
kevinw@2206 334 # will be found by AC_PROG_CC et al.
kevinw@2206 335 DEVKIT=
kevinw@2206 336 BDEPS_CHECK_MODULE(DEVKIT, devkit, xxx,
kevinw@2206 337 [
kevinw@2206 338 # Found devkit
kevinw@2206 339 PATH="$DEVKIT/bin:$PATH"
kevinw@2206 340 SYS_ROOT="$DEVKIT/${rewritten_target}/sys-root"
kevinw@2206 341 if test "x$x_includes" = "xNONE"; then
kevinw@2206 342 x_includes="$SYS_ROOT/usr/include/X11"
kevinw@2206 343 fi
kevinw@2206 344 if test "x$x_libraries" = "xNONE"; then
kevinw@2206 345 x_libraries="$SYS_ROOT/usr/lib"
kevinw@2206 346 fi
kevinw@2206 347 ],
kevinw@2206 348 [])
kevinw@2206 349 ])
andrew@1862 350
kevinw@2206 351 # Restore path, etc
kevinw@2206 352 AC_DEFUN_ONCE([TOOLCHAIN_POST_DETECTION],
kevinw@2206 353 [
kevinw@2206 354 # Restore old path.
kevinw@2206 355 PATH="$OLD_PATH"
erikj@459 356
ihse@839 357 # Restore the flags to the user specified values.
ihse@839 358 # This is necessary since AC_PROG_CC defaults CFLAGS to "-g -O2"
ihse@839 359 CFLAGS="$ORG_CFLAGS"
ihse@839 360 CXXFLAGS="$ORG_CXXFLAGS"
ihse@839 361 OBJCFLAGS="$ORG_OBJCFLAGS"
kevinw@2206 362 ])
erikj@459 363
kevinw@2206 364 # Check if a compiler is of the toolchain type we expect, and save the version
kevinw@2206 365 # information from it. If the compiler does not match the expected type,
kevinw@2206 366 # this function will abort using AC_MSG_ERROR. If it matches, the version will
kevinw@2206 367 # be stored in CC_VERSION_NUMBER/CXX_VERSION_NUMBER (as a dotted number), and
kevinw@2206 368 # the full version string in CC_VERSION_STRING/CXX_VERSION_STRING.
kevinw@2206 369 #
kevinw@2206 370 # $1 = compiler to test (CC or CXX)
kevinw@2206 371 # $2 = human readable name of compiler (C or C++)
kevinw@2206 372 AC_DEFUN([TOOLCHAIN_EXTRACT_COMPILER_VERSION],
kevinw@2206 373 [
kevinw@2206 374 COMPILER=[$]$1
kevinw@2206 375 COMPILER_NAME=$2
erikj@459 376
kevinw@2206 377 if test "x$TOOLCHAIN_TYPE" = xsolstudio; then
kevinw@2206 378 # cc -V output typically looks like
kevinw@2206 379 # cc: Sun C 5.12 Linux_i386 2011/11/16
kevinw@2206 380 COMPILER_VERSION_OUTPUT=`$COMPILER -V 2>&1`
kevinw@2206 381 # Check that this is likely to be the Solaris Studio cc.
kevinw@2206 382 $ECHO "$COMPILER_VERSION_OUTPUT" | $GREP "^.*: Sun $COMPILER_NAME" > /dev/null
kevinw@2206 383 if test $? -ne 0; then
kevinw@2206 384 ALT_VERSION_OUTPUT=`$COMPILER --version 2>&1`
kevinw@2206 385 AC_MSG_NOTICE([The $COMPILER_NAME compiler (located as $COMPILER) does not seem to be the required $TOOLCHAIN_TYPE compiler.])
kevinw@2206 386 AC_MSG_NOTICE([The result from running with -V was: "$COMPILER_VERSION_OUTPUT"])
kevinw@2206 387 AC_MSG_NOTICE([The result from running with --version was: "$ALT_VERSION_OUTPUT"])
kevinw@2206 388 AC_MSG_ERROR([A $TOOLCHAIN_TYPE compiler is required. Try setting --with-tools-dir.])
kevinw@2206 389 fi
kevinw@2206 390 # Remove usage instructions (if present), and
kevinw@2206 391 # collapse compiler output into a single line
kevinw@2206 392 COMPILER_VERSION_STRING=`$ECHO $COMPILER_VERSION_OUTPUT | \
kevinw@2206 393 $SED -e 's/ *@<:@Uu@:>@sage:.*//'`
kevinw@2206 394 COMPILER_VERSION_NUMBER=`$ECHO $COMPILER_VERSION_OUTPUT | \
kevinw@2206 395 $SED -e "s/^.*@<:@ ,\t@:>@$COMPILER_NAME@<:@ ,\t@:>@\(@<:@1-9@:>@\.@<:@0-9@:>@@<:@0-9@:>@*\).*/\1/"`
kevinw@2206 396 elif test "x$TOOLCHAIN_TYPE" = xxlc; then
kevinw@2206 397 # xlc -qversion output typically looks like
kevinw@2206 398 # IBM XL C/C++ for AIX, V11.1 (5724-X13)
kevinw@2206 399 # Version: 11.01.0000.0015
kevinw@2206 400 COMPILER_VERSION_OUTPUT=`$COMPILER -qversion 2>&1`
kevinw@2206 401 # Check that this is likely to be the IBM XL C compiler.
kevinw@2206 402 $ECHO "$COMPILER_VERSION_OUTPUT" | $GREP "IBM XL C" > /dev/null
kevinw@2206 403 if test $? -ne 0; then
kevinw@2206 404 ALT_VERSION_OUTPUT=`$COMPILER --version 2>&1`
kevinw@2206 405 AC_MSG_NOTICE([The $COMPILER_NAME compiler (located as $COMPILER) does not seem to be the required $TOOLCHAIN_TYPE compiler.])
kevinw@2206 406 AC_MSG_NOTICE([The result from running with -qversion was: "$COMPILER_VERSION_OUTPUT"])
kevinw@2206 407 AC_MSG_NOTICE([The result from running with --version was: "$ALT_VERSION_OUTPUT"])
kevinw@2206 408 AC_MSG_ERROR([A $TOOLCHAIN_TYPE compiler is required. Try setting --with-tools-dir.])
kevinw@2206 409 fi
kevinw@2206 410 # Collapse compiler output into a single line
kevinw@2206 411 COMPILER_VERSION_STRING=`$ECHO $COMPILER_VERSION_OUTPUT`
kevinw@2206 412 COMPILER_VERSION_NUMBER=`$ECHO $COMPILER_VERSION_OUTPUT | \
kevinw@2206 413 $SED -e 's/^.*, V\(@<:@1-9@:>@@<:@0-9.@:>@*\).*$/\1/'`
kevinw@2206 414 elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
kevinw@2206 415 # There is no specific version flag, but all output starts with a version string.
kevinw@2206 416 # First line typically looks something like:
kevinw@2206 417 # Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.40219.01 for 80x86
kevinw@2206 418 COMPILER_VERSION_OUTPUT=`$COMPILER 2>&1 | $HEAD -n 1 | $TR -d '\r'`
kevinw@2206 419 # Check that this is likely to be Microsoft CL.EXE.
kevinw@2206 420 $ECHO "$COMPILER_VERSION_OUTPUT" | $GREP "Microsoft.*Compiler" > /dev/null
kevinw@2206 421 if test $? -ne 0; then
kevinw@2206 422 AC_MSG_NOTICE([The $COMPILER_NAME compiler (located as $COMPILER) does not seem to be the required $TOOLCHAIN_TYPE compiler.])
kevinw@2206 423 AC_MSG_NOTICE([The result from running it was: "$COMPILER_VERSION_OUTPUT"])
kevinw@2206 424 AC_MSG_ERROR([A $TOOLCHAIN_TYPE compiler is required. Try setting --with-tools-dir.])
kevinw@2206 425 fi
kevinw@2206 426 # Collapse compiler output into a single line
kevinw@2206 427 COMPILER_VERSION_STRING=`$ECHO $COMPILER_VERSION_OUTPUT`
kevinw@2206 428 COMPILER_VERSION_NUMBER=`$ECHO $COMPILER_VERSION_OUTPUT | \
kevinw@2206 429 $SED -e 's/^.*ersion.\(@<:@1-9@:>@@<:@0-9.@:>@*\) .*$/\1/'`
kevinw@2206 430 elif test "x$TOOLCHAIN_TYPE" = xgcc; then
kevinw@2206 431 # gcc --version output typically looks like
kevinw@2206 432 # gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
kevinw@2206 433 # Copyright (C) 2013 Free Software Foundation, Inc.
kevinw@2206 434 # This is free software; see the source for copying conditions. There is NO
kevinw@2206 435 # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
kevinw@2206 436 COMPILER_VERSION_OUTPUT=`$COMPILER --version 2>&1`
kevinw@2206 437 # Check that this is likely to be GCC.
kevinw@2206 438 $ECHO "$COMPILER_VERSION_OUTPUT" | $GREP "Free Software Foundation" > /dev/null
kevinw@2206 439 if test $? -ne 0; then
kevinw@2206 440 AC_MSG_NOTICE([The $COMPILER_NAME compiler (located as $COMPILER) does not seem to be the required $TOOLCHAIN_TYPE compiler.])
kevinw@2206 441 AC_MSG_NOTICE([The result from running with --version was: "$COMPILER_VERSION"])
kevinw@2206 442 AC_MSG_ERROR([A $TOOLCHAIN_TYPE compiler is required. Try setting --with-tools-dir.])
kevinw@2206 443 fi
kevinw@2206 444 # Remove Copyright and legalese from version string, and
kevinw@2206 445 # collapse into a single line
kevinw@2206 446 COMPILER_VERSION_STRING=`$ECHO $COMPILER_VERSION_OUTPUT | \
kevinw@2206 447 $SED -e 's/ *Copyright .*//'`
kevinw@2206 448 COMPILER_VERSION_NUMBER=`$ECHO $COMPILER_VERSION_OUTPUT | \
kevinw@2206 449 $SED -e 's/^.* \(@<:@1-9@:>@\.@<:@0-9.@:>@*\) .*$/\1/'`
kevinw@2206 450 elif test "x$TOOLCHAIN_TYPE" = xclang; then
kevinw@2206 451 # clang --version output typically looks like
kevinw@2206 452 # Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn)
kevinw@2206 453 # clang version 3.3 (tags/RELEASE_33/final)
kevinw@2206 454 # or
kevinw@2206 455 # Debian clang version 3.2-7ubuntu1 (tags/RELEASE_32/final) (based on LLVM 3.2)
kevinw@2206 456 # Target: x86_64-pc-linux-gnu
kevinw@2206 457 # Thread model: posix
kevinw@2206 458 COMPILER_VERSION_OUTPUT=`$COMPILER --version 2>&1`
kevinw@2206 459 # Check that this is likely to be clang
kevinw@2206 460 $ECHO "$COMPILER_VERSION_OUTPUT" | $GREP "clang" > /dev/null
kevinw@2206 461 if test $? -ne 0; then
kevinw@2206 462 AC_MSG_NOTICE([The $COMPILER_NAME compiler (located as $COMPILER) does not seem to be the required $TOOLCHAIN_TYPE compiler.])
kevinw@2206 463 AC_MSG_NOTICE([The result from running with --version was: "$COMPILER_VERSION_OUTPUT"])
kevinw@2206 464 AC_MSG_ERROR([A $TOOLCHAIN_TYPE compiler is required. Try setting --with-tools-dir.])
kevinw@2206 465 fi
kevinw@2206 466 # Collapse compiler output into a single line
kevinw@2206 467 COMPILER_VERSION_STRING=`$ECHO $COMPILER_VERSION_OUTPUT`
kevinw@2206 468 COMPILER_VERSION_NUMBER=`$ECHO $COMPILER_VERSION_OUTPUT | \
kevinw@2206 469 $SED -e 's/^.*clang version \(@<:@1-9@:>@@<:@0-9.@:>@*\).*$/\1/'`
kevinw@2206 470
kevinw@2206 471 else
kevinw@2206 472 AC_MSG_ERROR([Unknown toolchain type $TOOLCHAIN_TYPE.])
ihse@839 473 fi
kevinw@2206 474 # This sets CC_VERSION_NUMBER or CXX_VERSION_NUMBER. (This comment is a grep marker)
kevinw@2206 475 $1_VERSION_NUMBER="$COMPILER_VERSION_NUMBER"
kevinw@2206 476 # This sets CC_VERSION_STRING or CXX_VERSION_STRING. (This comment is a grep marker)
kevinw@2206 477 $1_VERSION_STRING="$COMPILER_VERSION_STRING"
kevinw@2206 478
kevinw@2206 479 AC_MSG_NOTICE([Using $TOOLCHAIN_TYPE $COMPILER_NAME compiler version $COMPILER_VERSION_NUMBER @<:@$COMPILER_VERSION_STRING@:>@])
kevinw@2206 480 ])
kevinw@2206 481
kevinw@2206 482
kevinw@2206 483 # Try to locate the given C or C++ compiler in the path, or otherwise.
kevinw@2206 484 #
kevinw@2206 485 # $1 = compiler to test (CC or CXX)
kevinw@2206 486 # $2 = human readable name of compiler (C or C++)
kevinw@2206 487 # $3 = list of compiler names to search for
kevinw@2206 488 AC_DEFUN([TOOLCHAIN_FIND_COMPILER],
kevinw@2206 489 [
kevinw@2206 490 COMPILER_NAME=$2
kevinw@2206 491 SEARCH_LIST="$3"
kevinw@2206 492
kevinw@2206 493 if test "x[$]$1" != x; then
kevinw@2206 494 # User has supplied compiler name already, always let that override.
kevinw@2206 495 AC_MSG_NOTICE([Will use user supplied compiler $1=[$]$1])
kevinw@2206 496 if test "x`basename [$]$1`" = "x[$]$1"; then
kevinw@2206 497 # A command without a complete path is provided, search $PATH.
kevinw@2206 498
kevinw@2206 499 AC_PATH_PROGS(POTENTIAL_$1, [$]$1)
kevinw@2206 500 if test "x$POTENTIAL_$1" != x; then
kevinw@2206 501 $1=$POTENTIAL_$1
kevinw@2206 502 else
kevinw@2206 503 AC_MSG_ERROR([User supplied compiler $1=[$]$1 could not be found])
kevinw@2206 504 fi
kevinw@2206 505 else
kevinw@2206 506 # Otherwise it might already be a complete path
kevinw@2206 507 if test ! -x "[$]$1"; then
kevinw@2206 508 AC_MSG_ERROR([User supplied compiler $1=[$]$1 does not exist])
kevinw@2206 509 fi
kevinw@2206 510 fi
ihse@839 511 else
kevinw@2206 512 # No user supplied value. Locate compiler ourselves.
kevinw@2206 513
kevinw@2206 514 # If we are cross compiling, assume cross compilation tools follows the
kevinw@2206 515 # cross compilation standard where they are prefixed with the autoconf
kevinw@2206 516 # standard name for the target. For example the binary
kevinw@2206 517 # i686-sun-solaris2.10-gcc will cross compile for i686-sun-solaris2.10.
kevinw@2206 518 # If we are not cross compiling, then the default compiler name will be
kevinw@2206 519 # used.
kevinw@2206 520
kevinw@2206 521 $1=
kevinw@2206 522 # If TOOLS_DIR is set, check for all compiler names in there first
kevinw@2206 523 # before checking the rest of the PATH.
kevinw@2206 524 # FIXME: Now that we prefix the TOOLS_DIR to the PATH in the PRE_DETECTION
kevinw@2206 525 # step, this should not be necessary.
kevinw@2206 526 if test -n "$TOOLS_DIR"; then
kevinw@2206 527 PATH_save="$PATH"
kevinw@2206 528 PATH="$TOOLS_DIR"
kevinw@2206 529 AC_PATH_PROGS(TOOLS_DIR_$1, $3)
kevinw@2206 530 $1=$TOOLS_DIR_$1
kevinw@2206 531 PATH="$PATH_save"
kevinw@2206 532 fi
kevinw@2206 533
kevinw@2206 534 # AC_PATH_PROGS can't be run multiple times with the same variable,
kevinw@2206 535 # so create a new name for this run.
kevinw@2206 536 if test "x[$]$1" = x; then
kevinw@2206 537 AC_PATH_PROGS(POTENTIAL_$1, $3)
kevinw@2206 538 $1=$POTENTIAL_$1
kevinw@2206 539 fi
kevinw@2206 540
kevinw@2206 541 if test "x[$]$1" = x; then
kevinw@2206 542 HELP_MSG_MISSING_DEPENDENCY([devkit])
kevinw@2206 543 AC_MSG_ERROR([Could not find a $COMPILER_NAME compiler. $HELP_MSG])
kevinw@2206 544 fi
ihse@839 545 fi
erikj@459 546
kevinw@2206 547 # Now we have a compiler binary in $1. Make sure it's okay.
kevinw@2206 548 BASIC_FIXUP_EXECUTABLE($1)
kevinw@2206 549 TEST_COMPILER="[$]$1"
kevinw@2206 550 # Don't remove symbolic links on AIX because 'xlc_r' and 'xlC_r' may all be links
kevinw@2206 551 # to 'xlc' but it is crucial that we invoke the compiler with the right name!
kevinw@2206 552 if test "x$OPENJDK_BUILD_OS" != xaix; then
kevinw@2206 553 # FIXME: This test should not be needed anymore; we don't do that for any platform.
kevinw@2206 554 AC_MSG_CHECKING([resolved symbolic links for $1])
kevinw@2206 555 BASIC_REMOVE_SYMBOLIC_LINKS(TEST_COMPILER)
kevinw@2206 556 AC_MSG_RESULT([$TEST_COMPILER])
kevinw@2206 557 fi
kevinw@2206 558 AC_MSG_CHECKING([if $1 is disguised ccache])
ohair@494 559
kevinw@2206 560 COMPILER_BASENAME=`$BASENAME "$TEST_COMPILER"`
kevinw@2206 561 if test "x$COMPILER_BASENAME" = "xccache"; then
kevinw@2206 562 AC_MSG_RESULT([yes, trying to find proper $COMPILER_NAME compiler])
kevinw@2206 563 # We /usr/lib/ccache in the path, so cc is a symlink to /usr/bin/ccache.
kevinw@2206 564 # We want to control ccache invocation ourselves, so ignore this cc and try
kevinw@2206 565 # searching again.
kevinw@2206 566
kevinw@2206 567 # Remove the path to the fake ccache cc from the PATH
kevinw@2206 568 RETRY_COMPILER_SAVED_PATH="$PATH"
kevinw@2206 569 COMPILER_DIRNAME=`$DIRNAME [$]$1`
kevinw@2206 570 PATH="`$ECHO $PATH | $SED -e "s,$COMPILER_DIRNAME,,g" -e "s,::,:,g" -e "s,^:,,g"`"
kevinw@2206 571
kevinw@2206 572 # Try again looking for our compiler
kevinw@2206 573 AC_CHECK_TOOLS(PROPER_COMPILER_$1, $3)
kevinw@2206 574 BASIC_FIXUP_EXECUTABLE(PROPER_COMPILER_$1)
kevinw@2206 575 PATH="$RETRY_COMPILER_SAVED_PATH"
kevinw@2206 576
kevinw@2206 577 AC_MSG_CHECKING([for resolved symbolic links for $1])
kevinw@2206 578 BASIC_REMOVE_SYMBOLIC_LINKS(PROPER_COMPILER_$1)
kevinw@2206 579 AC_MSG_RESULT([$PROPER_COMPILER_$1])
kevinw@2206 580 $1="$PROPER_COMPILER_$1"
kevinw@2206 581 else
kevinw@2206 582 AC_MSG_RESULT([no, keeping $1])
kevinw@2206 583 $1="$TEST_COMPILER"
kevinw@2206 584 fi
kevinw@2206 585
kevinw@2206 586 TOOLCHAIN_EXTRACT_COMPILER_VERSION([$1], [$COMPILER_NAME])
kevinw@2206 587 ])
kevinw@2206 588
kevinw@2206 589 # Detect the core components of the toolchain, i.e. the compilers (CC and CXX),
kevinw@2206 590 # preprocessor (CPP and CXXCPP), the linker (LD), the assembler (AS) and the
kevinw@2206 591 # archiver (AR). Verify that the compilers are correct according to the
kevinw@2206 592 # toolchain type.
kevinw@2206 593 AC_DEFUN_ONCE([TOOLCHAIN_DETECT_TOOLCHAIN_CORE],
kevinw@2206 594 [
kevinw@2206 595 #
kevinw@2206 596 # Setup the compilers (CC and CXX)
kevinw@2206 597 #
kevinw@2206 598 TOOLCHAIN_FIND_COMPILER([CC], [C], $TOOLCHAIN_CC_BINARY)
kevinw@2206 599 # Now that we have resolved CC ourself, let autoconf have its go at it
kevinw@2206 600 AC_PROG_CC([$CC])
kevinw@2206 601
kevinw@2206 602 TOOLCHAIN_FIND_COMPILER([CXX], [C++], $TOOLCHAIN_CXX_BINARY)
kevinw@2206 603 # Now that we have resolved CXX ourself, let autoconf have its go at it
kevinw@2206 604 AC_PROG_CXX([$CXX])
kevinw@2206 605
kevinw@2206 606 # This is the compiler version number on the form X.Y[.Z]
kevinw@2206 607 AC_SUBST(CC_VERSION_NUMBER)
kevinw@2206 608 AC_SUBST(CXX_VERSION_NUMBER)
kevinw@2206 609
kevinw@2206 610 TOOLCHAIN_PREPARE_FOR_VERSION_COMPARISONS
kevinw@2206 611
kevinw@2206 612 #
kevinw@2206 613 # Setup the preprocessor (CPP and CXXCPP)
kevinw@2206 614 #
kevinw@2206 615 AC_PROG_CPP
kevinw@2206 616 BASIC_FIXUP_EXECUTABLE(CPP)
kevinw@2206 617 AC_PROG_CXXCPP
kevinw@2206 618 BASIC_FIXUP_EXECUTABLE(CXXCPP)
kevinw@2206 619
kevinw@2206 620 #
kevinw@2206 621 # Setup the linker (LD)
kevinw@2206 622 #
kevinw@2206 623 if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
kevinw@2206 624 # In the Microsoft toolchain we have a separate LD command "link".
kevinw@2206 625 # Make sure we reject /usr/bin/link (as determined in CYGWIN_LINK), which is
kevinw@2206 626 # a cygwin program for something completely different.
kevinw@2206 627 AC_CHECK_PROG([LD], [link],[link],,, [$CYGWIN_LINK])
kevinw@2206 628 BASIC_FIXUP_EXECUTABLE(LD)
kevinw@2206 629 # Verify that we indeed succeeded with this trick.
ohair@478 630 AC_MSG_CHECKING([if the found link.exe is actually the Visual Studio linker])
kevinw@2206 631 "$LD" --version > /dev/null
ohair@478 632 if test $? -eq 0 ; then
ohair@478 633 AC_MSG_RESULT([no])
ohair@478 634 AC_MSG_ERROR([This is the Cygwin link tool. Please check your PATH and rerun configure.])
ohair@478 635 else
ohair@478 636 AC_MSG_RESULT([yes])
ohair@478 637 fi
kevinw@2206 638 LDCXX="$LD"
kevinw@2206 639 else
kevinw@2206 640 # All other toolchains use the compiler to link.
kevinw@2206 641 LD="$CC"
kevinw@2206 642 LDCXX="$CXX"
kevinw@2206 643 fi
kevinw@2206 644 AC_SUBST(LD)
kevinw@2206 645 # FIXME: it should be CXXLD, according to standard (cf CXXCPP)
kevinw@2206 646 AC_SUBST(LDCXX)
erikj@459 647
ihse@839 648 #
kevinw@2206 649 # Setup the assembler (AS)
kevinw@2206 650 #
ihse@839 651 if test "x$OPENJDK_TARGET_OS" = xsolaris; then
kevinw@2206 652 # FIXME: should this really be solaris, or solstudio?
kevinw@2204 653 BASIC_PATH_PROGS(AS, as)
ohair@494 654 BASIC_FIXUP_EXECUTABLE(AS)
ihse@839 655 else
kevinw@2206 656 # FIXME: is this correct for microsoft?
erikj@459 657 AS="$CC -c"
ihse@839 658 fi
ihse@839 659 AC_SUBST(AS)
erikj@459 660
kevinw@2206 661 #
kevinw@2206 662 # Setup the archiver (AR)
kevinw@2206 663 #
kevinw@2206 664 if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
kevinw@2206 665 # The corresponding ar tool is lib.exe (used to create static libraries)
kevinw@2206 666 AC_CHECK_PROG([AR], [lib],[lib],,,)
kevinw@2206 667 else
kevinw@2206 668 BASIC_CHECK_TOOLS(AR, ar)
kevinw@2206 669 fi
kevinw@2206 670 BASIC_FIXUP_EXECUTABLE(AR)
kevinw@2206 671 ])
kevinw@2206 672
kevinw@2206 673 # Setup additional tools that is considered a part of the toolchain, but not the
kevinw@2206 674 # core part. Many of these are highly platform-specific and do not exist,
kevinw@2206 675 # and/or are not needed on all platforms.
kevinw@2206 676 AC_DEFUN_ONCE([TOOLCHAIN_DETECT_TOOLCHAIN_EXTRA],
kevinw@2206 677 [
kevinw@2206 678 if test "x$OPENJDK_TARGET_OS" = "xmacosx"; then
kevinw@2206 679 AC_PROG_OBJC
kevinw@2206 680 BASIC_FIXUP_EXECUTABLE(OBJC)
kevinw@2206 681 BASIC_PATH_PROGS(LIPO, lipo)
kevinw@2206 682 BASIC_FIXUP_EXECUTABLE(LIPO)
kevinw@2206 683 else
kevinw@2206 684 OBJC=
kevinw@2206 685 fi
kevinw@2206 686
kevinw@2206 687 if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
kevinw@2206 688 AC_CHECK_PROG([MT], [mt], [mt],,, [/usr/bin/mt])
kevinw@2206 689 BASIC_FIXUP_EXECUTABLE(MT)
kevinw@2206 690 # Setup the resource compiler (RC)
kevinw@2206 691 AC_CHECK_PROG([RC], [rc], [rc],,, [/usr/bin/rc])
kevinw@2206 692 BASIC_FIXUP_EXECUTABLE(RC)
kevinw@2206 693 AC_CHECK_PROG([DUMPBIN], [dumpbin], [dumpbin],,,)
kevinw@2206 694 BASIC_FIXUP_EXECUTABLE(DUMPBIN)
kevinw@2206 695 fi
kevinw@2206 696
ihse@839 697 if test "x$OPENJDK_TARGET_OS" = xsolaris; then
kevinw@2206 698 BASIC_PATH_PROGS(STRIP, strip)
kevinw@2206 699 BASIC_FIXUP_EXECUTABLE(STRIP)
kevinw@2204 700 BASIC_PATH_PROGS(NM, nm)
ohair@494 701 BASIC_FIXUP_EXECUTABLE(NM)
kevinw@2204 702 BASIC_PATH_PROGS(GNM, gnm)
erikj@672 703 BASIC_FIXUP_EXECUTABLE(GNM)
kevinw@2206 704
kevinw@2204 705 BASIC_PATH_PROGS(MCS, mcs)
ohair@494 706 BASIC_FIXUP_EXECUTABLE(MCS)
ihse@839 707 elif test "x$OPENJDK_TARGET_OS" != xwindows; then
kevinw@2206 708 # FIXME: we should unify this with the solaris case above.
kevinw@2206 709 BASIC_CHECK_TOOLS(STRIP, strip)
kevinw@2206 710 BASIC_FIXUP_EXECUTABLE(STRIP)
ddehaven@1304 711 AC_PATH_PROG(OTOOL, otool)
ddehaven@1304 712 if test "x$OTOOL" = "x"; then
ddehaven@1304 713 OTOOL="true"
ddehaven@1304 714 fi
kevinw@2204 715 BASIC_CHECK_TOOLS(NM, nm)
ohair@494 716 BASIC_FIXUP_EXECUTABLE(NM)
erikj@672 717 GNM="$NM"
erikj@672 718 AC_SUBST(GNM)
ihse@839 719 fi
erikj@459 720
ihse@839 721 # objcopy is used for moving debug symbols to separate files when
ihse@839 722 # full debug symbols are enabled.
ihse@839 723 if test "x$OPENJDK_TARGET_OS" = xsolaris || test "x$OPENJDK_TARGET_OS" = xlinux; then
kevinw@2204 724 BASIC_CHECK_TOOLS(OBJCOPY, [gobjcopy objcopy])
tbell@516 725 # Only call fixup if objcopy was found.
tbell@516 726 if test -n "$OBJCOPY"; then
ihse@839 727 BASIC_FIXUP_EXECUTABLE(OBJCOPY)
tbell@516 728 fi
ihse@839 729 fi
ohair@494 730
kevinw@2204 731 BASIC_CHECK_TOOLS(OBJDUMP, [gobjdump objdump])
ihse@839 732 if test "x$OBJDUMP" != x; then
kevinw@2206 733 # Only used for compare.sh; we can live without it. BASIC_FIXUP_EXECUTABLE
kevinw@2206 734 # bails if argument is missing.
ihse@839 735 BASIC_FIXUP_EXECUTABLE(OBJDUMP)
ihse@839 736 fi
erikj@459 737 ])
erikj@459 738
kevinw@2206 739 # Setup the build tools (i.e, the compiler and linker used to build programs
kevinw@2206 740 # that should be run on the build platform, not the target platform, as a build
kevinw@2206 741 # helper). Since the non-cross-compile case uses the normal, target compilers
kevinw@2206 742 # for this, we can only do this after these have been setup.
kevinw@2206 743 AC_DEFUN_ONCE([TOOLCHAIN_SETUP_BUILD_COMPILERS],
kevinw@2206 744 [
kevinw@2206 745 if test "x$COMPILE_TYPE" = "xcross"; then
kevinw@2206 746 # Now we need to find a C/C++ compiler that can build executables for the
kevinw@2206 747 # build platform. We can't use the AC_PROG_CC macro, since it can only be
kevinw@2206 748 # used once. Also, we need to do this without adding a tools dir to the
kevinw@2206 749 # path, otherwise we might pick up cross-compilers which don't use standard
kevinw@2206 750 # naming.
erikj@459 751
kevinw@2206 752 # FIXME: we should list the discovered compilers as an exclude pattern!
kevinw@2206 753 # If we do that, we can do this detection before POST_DETECTION, and still
kevinw@2206 754 # find the build compilers in the tools dir, if needed.
kevinw@2206 755 BASIC_PATH_PROGS(BUILD_CC, [cl cc gcc])
kevinw@2206 756 BASIC_FIXUP_EXECUTABLE(BUILD_CC)
kevinw@2206 757 BASIC_PATH_PROGS(BUILD_CXX, [cl CC g++])
kevinw@2206 758 BASIC_FIXUP_EXECUTABLE(BUILD_CXX)
kevinw@2206 759 BASIC_PATH_PROGS(BUILD_LD, ld)
kevinw@2206 760 BASIC_FIXUP_EXECUTABLE(BUILD_LD)
kevinw@2206 761 else
kevinw@2206 762 # If we are not cross compiling, use the normal target compilers for
kevinw@2206 763 # building the build platform executables.
kevinw@2206 764 BUILD_CC="$CC"
kevinw@2206 765 BUILD_CXX="$CXX"
kevinw@2206 766 BUILD_LD="$LD"
kevinw@2206 767 fi
kevinw@2206 768 ])
kevinw@2206 769
kevinw@2206 770 # Setup legacy variables that are still needed as alternative ways to refer to
kevinw@2206 771 # parts of the toolchain.
kevinw@2206 772 AC_DEFUN_ONCE([TOOLCHAIN_SETUP_LEGACY],
erikj@459 773 [
kevinw@2206 774 if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
kevinw@2206 775 # For hotspot, we need these in Windows mixed path,
kevinw@2206 776 # so rewrite them all. Need added .exe suffix.
kevinw@2206 777 HOTSPOT_CXX="$CXX.exe"
kevinw@2206 778 HOTSPOT_LD="$LD.exe"
kevinw@2206 779 HOTSPOT_MT="$MT.exe"
kevinw@2206 780 HOTSPOT_RC="$RC.exe"
kevinw@2206 781 BASIC_WINDOWS_REWRITE_AS_WINDOWS_MIXED_PATH(HOTSPOT_CXX)
kevinw@2206 782 BASIC_WINDOWS_REWRITE_AS_WINDOWS_MIXED_PATH(HOTSPOT_LD)
kevinw@2206 783 BASIC_WINDOWS_REWRITE_AS_WINDOWS_MIXED_PATH(HOTSPOT_MT)
kevinw@2206 784 BASIC_WINDOWS_REWRITE_AS_WINDOWS_MIXED_PATH(HOTSPOT_RC)
kevinw@2206 785 AC_SUBST(HOTSPOT_MT)
kevinw@2206 786 AC_SUBST(HOTSPOT_RC)
kevinw@2206 787 else
kevinw@2206 788 HOTSPOT_CXX="$CXX"
kevinw@2206 789 HOTSPOT_LD="$LD"
kevinw@2206 790 fi
kevinw@2206 791 AC_SUBST(HOTSPOT_CXX)
kevinw@2206 792 AC_SUBST(HOTSPOT_LD)
erikj@459 793
kevinw@2206 794 if test "x$TOOLCHAIN_TYPE" = xclang; then
kevinw@2206 795 USE_CLANG=true
kevinw@2206 796 fi
kevinw@2206 797 AC_SUBST(USE_CLANG)
erikj@459 798
kevinw@2206 799 # LDEXE is the linker to use, when creating executables. Not really used.
kevinw@2206 800 # FIXME: These should just be removed!
kevinw@2206 801 LDEXE="$LD"
kevinw@2206 802 LDEXECXX="$LDCXX"
kevinw@2206 803 AC_SUBST(LDEXE)
kevinw@2206 804 AC_SUBST(LDEXECXX)
kevinw@2206 805 ])
erikj@459 806
kevinw@2206 807 # Do some additional checks on the detected tools.
kevinw@2206 808 AC_DEFUN_ONCE([TOOLCHAIN_MISC_CHECKS],
kevinw@2206 809 [
kevinw@2206 810 # The package path is used only on macosx?
kevinw@2206 811 # FIXME: clean this up, and/or move it elsewhere.
kevinw@2206 812 PACKAGE_PATH=/opt/local
kevinw@2206 813 AC_SUBST(PACKAGE_PATH)
kevinw@2206 814
kevinw@2206 815 # Check for extra potential brokenness.
kevinw@2206 816 if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
kevinw@2206 817 # On Windows, double-check that we got the right compiler.
kevinw@2206 818 CC_VERSION_OUTPUT=`$CC 2>&1 | $HEAD -n 1 | $TR -d '\r'`
kevinw@2206 819 COMPILER_CPU_TEST=`$ECHO $CC_VERSION_OUTPUT | $SED -n "s/^.* \(.*\)$/\1/p"`
kevinw@2206 820 if test "x$OPENJDK_TARGET_CPU" = "xx86"; then
kevinw@2206 821 if test "x$COMPILER_CPU_TEST" != "x80x86"; then
kevinw@2206 822 AC_MSG_ERROR([Target CPU mismatch. We are building for $OPENJDK_TARGET_CPU but CL is for "$COMPILER_CPU_TEST"; expected "80x86".])
kevinw@2206 823 fi
kevinw@2206 824 elif test "x$OPENJDK_TARGET_CPU" = "xx86_64"; then
kevinw@2206 825 if test "x$COMPILER_CPU_TEST" != "xx64"; then
kevinw@2206 826 AC_MSG_ERROR([Target CPU mismatch. We are building for $OPENJDK_TARGET_CPU but CL is for "$COMPILER_CPU_TEST"; expected "x64".])
kevinw@2206 827 fi
erikj@459 828 fi
ihse@839 829 fi
erikj@459 830
kevinw@2206 831 if test "x$TOOLCHAIN_TYPE" = xgcc; then
kevinw@2206 832 # If this is a --hash-style=gnu system, use --hash-style=both, why?
kevinw@2206 833 HAS_GNU_HASH=`$CC -dumpspecs 2>/dev/null | $GREP 'hash-style=gnu'`
kevinw@2206 834 # This is later checked when setting flags.
ihse@839 835 fi
ohair@478 836
kevinw@2206 837 # Check for broken SuSE 'ld' for which 'Only anonymous version tag is allowed
kevinw@2206 838 # in executable.'
simonis@965 839 USING_BROKEN_SUSE_LD=no
kevinw@2206 840 if test "x$OPENJDK_TARGET_OS" = xlinux && test "x$TOOLCHAIN_TYPE" = xgcc; then
simonis@965 841 AC_MSG_CHECKING([for broken SuSE 'ld' which only understands anonymous version tags in executables])
simonis@965 842 echo "SUNWprivate_1.1 { local: *; };" > version-script.map
simonis@965 843 echo "int main() { }" > main.c
simonis@965 844 if $CXX -Xlinker -version-script=version-script.map main.c 2>&AS_MESSAGE_LOG_FD >&AS_MESSAGE_LOG_FD; then
simonis@965 845 AC_MSG_RESULT(no)
simonis@965 846 USING_BROKEN_SUSE_LD=no
simonis@965 847 else
simonis@965 848 AC_MSG_RESULT(yes)
simonis@965 849 USING_BROKEN_SUSE_LD=yes
simonis@965 850 fi
simonis@965 851 rm -rf version-script.map main.c
simonis@965 852 fi
simonis@965 853 AC_SUBST(USING_BROKEN_SUSE_LD)
erikj@698 854 ])
erikj@718 855
kevinw@2206 856 # Setup the JTReg Regression Test Harness.
mduigou@728 857 AC_DEFUN_ONCE([TOOLCHAIN_SETUP_JTREG],
mduigou@728 858 [
mduigou@728 859 AC_ARG_WITH(jtreg, [AS_HELP_STRING([--with-jtreg],
ihse@839 860 [Regression Test Harness @<:@probed@:>@])],
ihse@839 861 [],
ihse@839 862 [with_jtreg=no])
mduigou@728 863
mduigou@728 864 if test "x$with_jtreg" = xno; then
mduigou@728 865 # jtreg disabled
mduigou@728 866 AC_MSG_CHECKING([for jtreg])
mduigou@728 867 AC_MSG_RESULT(no)
mduigou@728 868 else
mduigou@728 869 if test "x$with_jtreg" != xyes; then
mduigou@728 870 # with path specified.
mduigou@728 871 JT_HOME="$with_jtreg"
erikj@718 872 fi
mduigou@728 873
mduigou@728 874 if test "x$JT_HOME" != x; then
mduigou@728 875 AC_MSG_CHECKING([for jtreg])
mduigou@728 876
mduigou@728 877 # use JT_HOME enviroment var.
mduigou@728 878 BASIC_FIXUP_PATH([JT_HOME])
mduigou@728 879
mduigou@728 880 # jtreg win32 script works for everybody
erikj@1328 881 JTREGEXE="$JT_HOME/bin/jtreg"
mduigou@728 882
mduigou@728 883 if test ! -f "$JTREGEXE"; then
mduigou@728 884 AC_MSG_ERROR([JTReg executable does not exist: $JTREGEXE])
mduigou@728 885 fi
mduigou@728 886
mduigou@728 887 AC_MSG_RESULT($JTREGEXE)
mduigou@728 888 else
mduigou@728 889 # try to find jtreg on path
kevinw@2204 890 BASIC_REQUIRE_PROGS(JTREGEXE, jtreg)
mduigou@728 891 JT_HOME="`$DIRNAME $JTREGEXE`"
mduigou@728 892 fi
mduigou@728 893 fi
mduigou@728 894
mduigou@728 895 AC_SUBST(JT_HOME)
mduigou@728 896 AC_SUBST(JTREGEXE)
erikj@718 897 ])
andrew@1862 898

mercurial