1 # 2 # Copyright (c) 2011, 2022, Oracle and/or its affiliates. All rights reserved. 3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 # 5 # This code is free software; you can redistribute it and/or modify it 6 # under the terms of the GNU General Public License version 2 only, as 7 # published by the Free Software Foundation. Oracle designates this 8 # particular file as subject to the "Classpath" exception as provided 9 # by Oracle in the LICENSE file that accompanied this code. 10 # 11 # This code is distributed in the hope that it will be useful, but WITHOUT 12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 # version 2 for more details (a copy is included in the LICENSE file that 15 # accompanied this code). 16 # 17 # You should have received a copy of the GNU General Public License version 18 # 2 along with this work; if not, write to the Free Software Foundation, 19 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 # 21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 # or visit www.oracle.com if you need additional information or have any 23 # questions. 24 # 25 26 ######################################################################## 27 # This file is responsible for detecting, verifying and setting up the 28 # toolchain, i.e. the compiler, linker and related utilities. It will setup 29 # proper paths to the binaries, but it will not setup any flags. 30 # 31 # The binaries used is determined by the toolchain type, which is the family of 32 # compilers and related tools that are used. 33 ######################################################################## 34 35 m4_include([toolchain_microsoft.m4]) 36 37 # All valid toolchains, regardless of platform (used by help.m4) 38 VALID_TOOLCHAINS_all="gcc clang xlc microsoft" 39 40 # These toolchains are valid on different platforms 41 VALID_TOOLCHAINS_linux="gcc clang" 42 VALID_TOOLCHAINS_macosx="clang" 43 VALID_TOOLCHAINS_aix="xlc" 44 VALID_TOOLCHAINS_windows="microsoft" 45 46 # Toolchain descriptions 47 TOOLCHAIN_DESCRIPTION_clang="clang/LLVM" 48 TOOLCHAIN_DESCRIPTION_gcc="GNU Compiler Collection" 49 TOOLCHAIN_DESCRIPTION_microsoft="Microsoft Visual Studio" 50 TOOLCHAIN_DESCRIPTION_xlc="IBM XL C/C++" 51 52 # Minimum supported versions, empty means unspecified 53 TOOLCHAIN_MINIMUM_VERSION_clang="3.5" 54 TOOLCHAIN_MINIMUM_VERSION_gcc="6.0" 55 TOOLCHAIN_MINIMUM_VERSION_microsoft="19.10.0.0" # VS2017 56 TOOLCHAIN_MINIMUM_VERSION_xlc="" 57 58 # Minimum supported linker versions, empty means unspecified 59 TOOLCHAIN_MINIMUM_LD_VERSION_gcc="2.18" 60 61 # Prepare the system so that TOOLCHAIN_CHECK_COMPILER_VERSION can be called. 62 # Must have CC_VERSION_NUMBER and CXX_VERSION_NUMBER. 63 # $1 - optional variable prefix for compiler and version variables (BUILD_) 64 # $2 - optional variable prefix for comparable variable (OPENJDK_BUILD_) 65 # $3 - optional human readable description for the type of compilers ("build " or "") 66 AC_DEFUN([TOOLCHAIN_PREPARE_FOR_VERSION_COMPARISONS], 67 [ 68 if test "x[$]$1CC_VERSION_NUMBER" != "x[$]$1CXX_VERSION_NUMBER"; then 69 AC_MSG_WARN([The $3C and C++ compilers have different version numbers, [$]$1CC_VERSION_NUMBER vs [$]$1CXX_VERSION_NUMBER.]) 70 AC_MSG_WARN([This typically indicates a broken setup, and is not supported]) 71 fi 72 73 # We only check CC_VERSION_NUMBER since we assume CXX_VERSION_NUMBER is equal. 74 if [ [[ "[$]$1CC_VERSION_NUMBER" =~ (.*\.){4} ]] ]; then 75 AC_MSG_WARN([C compiler version number has more than four parts (W.X.Y.Z): [$]$1CC_VERSION_NUMBER. Comparisons might be wrong.]) 76 fi 77 78 if [ [[ "[$]$1CC_VERSION_NUMBER" =~ [0-9]{6} ]] ]; then 79 AC_MSG_WARN([C compiler version number has a part larger than 99999: [$]$1CC_VERSION_NUMBER. Comparisons might be wrong.]) 80 fi 81 82 $2COMPARABLE_ACTUAL_VERSION=`$AWK -F. '{ printf("%05d%05d%05d%05d\n", [$]1, [$]2, [$]3, [$]4) }' <<< "[$]$1CC_VERSION_NUMBER"` 83 ]) 84 85 # Check if the configured compiler (C and C++) is of a specific version or 86 # newer. TOOLCHAIN_PREPARE_FOR_VERSION_COMPARISONS must have been called before. 87 # 88 # Arguments: 89 # VERSION: The version string to check against the found version 90 # IF_AT_LEAST: block to run if the compiler is at least this version (>=) 91 # IF_OLDER_THAN: block to run if the compiler is older than this version (<) 92 # PREFIX: Optional variable prefix for compiler to compare version for (OPENJDK_BUILD_) 93 UTIL_DEFUN_NAMED([TOOLCHAIN_CHECK_COMPILER_VERSION], 94 [*VERSION PREFIX IF_AT_LEAST IF_OLDER_THAN], [$@], 95 [ 96 # Need to assign to a variable since m4 is blocked from modifying parts in []. 97 REFERENCE_VERSION=ARG_VERSION 98 99 if [ [[ "$REFERENCE_VERSION" =~ (.*\.){4} ]] ]; then 100 AC_MSG_ERROR([Internal error: Cannot compare to ARG_VERSION, only four parts (W.X.Y.Z) is supported]) 101 fi 102 103 if [ [[ "$REFERENCE_VERSION" =~ [0-9]{6} ]] ]; then 104 AC_MSG_ERROR([Internal error: Cannot compare to ARG_VERSION, only parts < 99999 is supported]) 105 fi 106 107 # Version comparison method inspired by http://stackoverflow.com/a/24067243 108 COMPARABLE_REFERENCE_VERSION=`$AWK -F. '{ printf("%05d%05d%05d%05d\n", [$]1, [$]2, [$]3, [$]4) }' <<< "$REFERENCE_VERSION"` 109 110 if test [$]ARG_PREFIX[COMPARABLE_ACTUAL_VERSION] -ge $COMPARABLE_REFERENCE_VERSION ; then 111 : 112 ARG_IF_AT_LEAST 113 else 114 : 115 ARG_IF_OLDER_THAN 116 fi 117 ]) 118 119 # Prepare the system so that TOOLCHAIN_CHECK_COMPILER_VERSION can be called. 120 # Must have LD_VERSION_NUMBER. 121 # $1 - optional variable prefix for compiler and version variables (BUILD_) 122 # $2 - optional variable prefix for comparable variable (OPENJDK_BUILD_) 123 AC_DEFUN([TOOLCHAIN_PREPARE_FOR_LD_VERSION_COMPARISONS], 124 [ 125 if [ [[ "[$]$1LD_VERSION_NUMBER" =~ (.*\.){4} ]] ]; then 126 AC_MSG_WARN([Linker version number has more than four parts (W.X.Y.Z): [$]$1LD_VERSION_NUMBER. Comparisons might be wrong.]) 127 fi 128 129 if [ [[ "[$]$1LD_VERSION_NUMBER" =~ [0-9]{6} ]] ]; then 130 AC_MSG_WARN([Linker version number has a part larger than 99999: [$]$1LD_VERSION_NUMBER. Comparisons might be wrong.]) 131 fi 132 133 $2COMPARABLE_ACTUAL_LD_VERSION=`$AWK -F. '{ printf("%05d%05d%05d%05d\n", [$]1, [$]2, [$]3, [$]4) }' <<< "[$]$1LD_VERSION_NUMBER"` 134 ]) 135 136 # Check if the configured linker is of a specific version or 137 # newer. TOOLCHAIN_PREPARE_FOR_LD_VERSION_COMPARISONS must have been called before. 138 # 139 # Arguments: 140 # VERSION: The version string to check against the found version 141 # IF_AT_LEAST: block to run if the compiler is at least this version (>=) 142 # IF_OLDER_THAN: block to run if the compiler is older than this version (<) 143 # PREFIX: Optional variable prefix for compiler to compare version for (OPENJDK_BUILD_) 144 UTIL_DEFUN_NAMED([TOOLCHAIN_CHECK_LINKER_VERSION], 145 [*VERSION PREFIX IF_AT_LEAST IF_OLDER_THAN], [$@], 146 [ 147 # Need to assign to a variable since m4 is blocked from modifying parts in []. 148 REFERENCE_VERSION=ARG_VERSION 149 150 if [ [[ "$REFERENCE_VERSION" =~ (.*\.){4} ]] ]; then 151 AC_MSG_ERROR([Internal error: Cannot compare to ARG_VERSION, only four parts (W.X.Y.Z) is supported]) 152 fi 153 154 if [ [[ "$REFERENCE_VERSION" =~ [0-9]{6} ]] ]; then 155 AC_MSG_ERROR([Internal error: Cannot compare to ARG_VERSION, only parts < 99999 is supported]) 156 fi 157 158 # Version comparison method inspired by http://stackoverflow.com/a/24067243 159 COMPARABLE_REFERENCE_VERSION=`$AWK -F. '{ printf("%05d%05d%05d%05d\n", [$]1, [$]2, [$]3, [$]4) }' <<< "$REFERENCE_VERSION"` 160 161 if test [$]ARG_PREFIX[COMPARABLE_ACTUAL_LD_VERSION] -ge $COMPARABLE_REFERENCE_VERSION ; then 162 : 163 ARG_IF_AT_LEAST 164 else 165 : 166 ARG_IF_OLDER_THAN 167 fi 168 ]) 169 170 # Setup a number of variables describing how native output files are 171 # named on this platform/toolchain. 172 AC_DEFUN([TOOLCHAIN_SETUP_FILENAME_PATTERNS], 173 [ 174 # Define filename patterns 175 if test "x$OPENJDK_TARGET_OS" = xwindows; then 176 LIBRARY_PREFIX= 177 SHARED_LIBRARY_SUFFIX='.dll' 178 STATIC_LIBRARY_SUFFIX='.lib' 179 SHARED_LIBRARY='[$]1.dll' 180 STATIC_LIBRARY='[$]1.lib' 181 OBJ_SUFFIX='.obj' 182 EXECUTABLE_SUFFIX='.exe' 183 else 184 LIBRARY_PREFIX=lib 185 SHARED_LIBRARY_SUFFIX='.so' 186 STATIC_LIBRARY_SUFFIX='.a' 187 SHARED_LIBRARY='lib[$]1.so' 188 STATIC_LIBRARY='lib[$]1.a' 189 OBJ_SUFFIX='.o' 190 EXECUTABLE_SUFFIX='' 191 if test "x$OPENJDK_TARGET_OS" = xmacosx; then 192 # For full static builds, we're overloading the SHARED_LIBRARY 193 # variables in order to limit the amount of changes required. 194 # It would be better to remove SHARED and just use LIBRARY and 195 # LIBRARY_SUFFIX for libraries that can be built either 196 # shared or static and use STATIC_* for libraries that are 197 # always built statically. 198 if test "x$STATIC_BUILD" = xtrue; then 199 SHARED_LIBRARY='lib[$]1.a' 200 SHARED_LIBRARY_SUFFIX='.a' 201 else 202 SHARED_LIBRARY='lib[$]1.dylib' 203 SHARED_LIBRARY_SUFFIX='.dylib' 204 fi 205 fi 206 fi 207 208 AC_SUBST(LIBRARY_PREFIX) 209 AC_SUBST(SHARED_LIBRARY_SUFFIX) 210 AC_SUBST(STATIC_LIBRARY_SUFFIX) 211 AC_SUBST(SHARED_LIBRARY) 212 AC_SUBST(STATIC_LIBRARY) 213 AC_SUBST(OBJ_SUFFIX) 214 AC_SUBST(EXECUTABLE_SUFFIX) 215 ]) 216 217 # Determine which toolchain type to use, and make sure it is valid for this 218 # platform. Setup various information about the selected toolchain. 219 AC_DEFUN_ONCE([TOOLCHAIN_DETERMINE_TOOLCHAIN_TYPE], 220 [ 221 AC_ARG_WITH(toolchain-type, [AS_HELP_STRING([--with-toolchain-type], 222 [the toolchain type (or family) to use, use '--help' to show possible values @<:@platform dependent@:>@])]) 223 224 # Linux x86_64 needs higher binutils after 8265783 225 # (this really is a dependency on as version, but we take ld as a check for a general binutils version) 226 if test "x$OPENJDK_TARGET_CPU" = "xx86_64"; then 227 TOOLCHAIN_MINIMUM_LD_VERSION_gcc="2.25" 228 fi 229 230 # Use indirect variable referencing 231 toolchain_var_name=VALID_TOOLCHAINS_$OPENJDK_BUILD_OS 232 VALID_TOOLCHAINS=${!toolchain_var_name} 233 234 if test "x$OPENJDK_TARGET_OS" = xmacosx; then 235 if test -n "$XCODEBUILD"; then 236 # On Mac OS X, default toolchain to clang after Xcode 5 237 XCODE_VERSION_OUTPUT=`"$XCODEBUILD" -version | $HEAD -n 1` 238 $ECHO "$XCODE_VERSION_OUTPUT" | $GREP "Xcode " > /dev/null 239 if test $? -ne 0; then 240 AC_MSG_NOTICE([xcodebuild output: $XCODE_VERSION_OUTPUT]) 241 AC_MSG_ERROR([Failed to determine Xcode version.]) 242 fi 243 XCODE_MAJOR_VERSION=`$ECHO $XCODE_VERSION_OUTPUT | \ 244 $SED -e 's/^Xcode \(@<:@1-9@:>@@<:@0-9.@:>@*\)/\1/' | \ 245 $CUT -f 1 -d .` 246 AC_MSG_NOTICE([Xcode major version: $XCODE_MAJOR_VERSION]) 247 if test $XCODE_MAJOR_VERSION -ge 5; then 248 DEFAULT_TOOLCHAIN="clang" 249 else 250 DEFAULT_TOOLCHAIN="gcc" 251 fi 252 else 253 # If Xcode is not installed, but the command line tools are 254 # then we can't run xcodebuild. On these systems we should 255 # default to clang 256 DEFAULT_TOOLCHAIN="clang" 257 fi 258 else 259 # First toolchain type in the list is the default 260 DEFAULT_TOOLCHAIN=${VALID_TOOLCHAINS%% *} 261 fi 262 263 if test "x$with_toolchain_type" = xlist; then 264 # List all toolchains 265 AC_MSG_NOTICE([The following toolchains are valid on this platform:]) 266 for toolchain in $VALID_TOOLCHAINS; do 267 toolchain_var_name=TOOLCHAIN_DESCRIPTION_$toolchain 268 TOOLCHAIN_DESCRIPTION=${!toolchain_var_name} 269 $PRINTF " %-10s %s\n" $toolchain "$TOOLCHAIN_DESCRIPTION" 270 done 271 272 exit 0 273 elif test "x$with_toolchain_type" != x; then 274 # User override; check that it is valid 275 if test "x${VALID_TOOLCHAINS/$with_toolchain_type/}" = "x${VALID_TOOLCHAINS}"; then 276 AC_MSG_NOTICE([Toolchain type $with_toolchain_type is not valid on this platform.]) 277 AC_MSG_NOTICE([Valid toolchains: $VALID_TOOLCHAINS.]) 278 AC_MSG_ERROR([Cannot continue.]) 279 fi 280 TOOLCHAIN_TYPE=$with_toolchain_type 281 else 282 # No flag given, use default 283 TOOLCHAIN_TYPE=$DEFAULT_TOOLCHAIN 284 fi 285 AC_SUBST(TOOLCHAIN_TYPE) 286 287 # on AIX, check for xlclang++ on the PATH and TOOLCHAIN_PATH and use it if it is available 288 if test "x$OPENJDK_TARGET_OS" = xaix; then 289 if test "x$TOOLCHAIN_PATH" != x; then 290 XLC_TEST_PATH=${TOOLCHAIN_PATH}/ 291 fi 292 293 XLCLANG_VERSION_OUTPUT=`${XLC_TEST_PATH}xlclang++ -qversion 2>&1 | $HEAD -n 1` 294 $ECHO "$XLCLANG_VERSION_OUTPUT" | $GREP "IBM XL C/C++ for AIX" > /dev/null 295 if test $? -eq 0; then 296 AC_MSG_NOTICE([xlclang++ output: $XLCLANG_VERSION_OUTPUT]) 297 else 298 AC_MSG_ERROR([xlclang++ version output check failed, output: $XLCLANG_VERSION_OUTPUT]) 299 fi 300 fi 301 302 TOOLCHAIN_CC_BINARY_clang="clang" 303 TOOLCHAIN_CC_BINARY_gcc="gcc" 304 TOOLCHAIN_CC_BINARY_microsoft="cl" 305 TOOLCHAIN_CC_BINARY_xlc="xlclang" 306 307 TOOLCHAIN_CXX_BINARY_clang="clang++" 308 TOOLCHAIN_CXX_BINARY_gcc="g++" 309 TOOLCHAIN_CXX_BINARY_microsoft="cl" 310 TOOLCHAIN_CXX_BINARY_xlc="xlclang++" 311 312 # Use indirect variable referencing 313 toolchain_var_name=TOOLCHAIN_DESCRIPTION_$TOOLCHAIN_TYPE 314 TOOLCHAIN_DESCRIPTION=${!toolchain_var_name} 315 toolchain_var_name=TOOLCHAIN_MINIMUM_VERSION_$TOOLCHAIN_TYPE 316 TOOLCHAIN_MINIMUM_VERSION=${!toolchain_var_name} 317 toolchain_var_name=TOOLCHAIN_MINIMUM_LD_VERSION_$TOOLCHAIN_TYPE 318 TOOLCHAIN_MINIMUM_LD_VERSION=${!toolchain_var_name} 319 toolchain_var_name=TOOLCHAIN_CC_BINARY_$TOOLCHAIN_TYPE 320 TOOLCHAIN_CC_BINARY=${!toolchain_var_name} 321 toolchain_var_name=TOOLCHAIN_CXX_BINARY_$TOOLCHAIN_TYPE 322 TOOLCHAIN_CXX_BINARY=${!toolchain_var_name} 323 324 TOOLCHAIN_SETUP_FILENAME_PATTERNS 325 326 if test "x$TOOLCHAIN_TYPE" = "x$DEFAULT_TOOLCHAIN"; then 327 AC_MSG_NOTICE([Using default toolchain $TOOLCHAIN_TYPE ($TOOLCHAIN_DESCRIPTION)]) 328 else 329 AC_MSG_NOTICE([Using user selected toolchain $TOOLCHAIN_TYPE ($TOOLCHAIN_DESCRIPTION). Default toolchain is $DEFAULT_TOOLCHAIN.]) 330 fi 331 ]) 332 333 # Before we start detecting the toolchain executables, we might need some 334 # special setup, e.g. additional paths etc. 335 AC_DEFUN_ONCE([TOOLCHAIN_PRE_DETECTION], 336 [ 337 # Store the CFLAGS etc passed to the configure script. 338 ORG_CFLAGS="$CFLAGS" 339 ORG_CXXFLAGS="$CXXFLAGS" 340 341 # autoconf magic only relies on PATH, so update it if tools dir is specified 342 OLD_PATH="$PATH" 343 344 if test "x$XCODE_VERSION_OUTPUT" != x; then 345 # For Xcode, we set the Xcode version as TOOLCHAIN_VERSION 346 TOOLCHAIN_VERSION=`$ECHO $XCODE_VERSION_OUTPUT | $CUT -f 2 -d ' '` 347 TOOLCHAIN_DESCRIPTION="$TOOLCHAIN_DESCRIPTION from Xcode $TOOLCHAIN_VERSION" 348 fi 349 AC_SUBST(TOOLCHAIN_VERSION) 350 351 # Finally prepend TOOLCHAIN_PATH to the PATH, to allow --with-tools-dir to 352 # override all other locations. 353 if test "x$TOOLCHAIN_PATH" != x; then 354 export PATH=$TOOLCHAIN_PATH:$PATH 355 fi 356 ]) 357 358 # Restore path, etc 359 AC_DEFUN_ONCE([TOOLCHAIN_POST_DETECTION], 360 [ 361 # Restore old path, except for the microsoft toolchain, which requires the 362 # toolchain path to remain in place. Otherwise the compiler will not work in 363 # some siutations in later configure checks. 364 if test "x$TOOLCHAIN_TYPE" != "xmicrosoft"; then 365 PATH="$OLD_PATH" 366 fi 367 368 # Restore the flags to the user specified values. 369 # This is necessary since AC_PROG_CC defaults CFLAGS to "-g -O2" 370 CFLAGS="$ORG_CFLAGS" 371 CXXFLAGS="$ORG_CXXFLAGS" 372 ]) 373 374 # Check if a compiler is of the toolchain type we expect, and save the version 375 # information from it. If the compiler does not match the expected type, 376 # this function will abort using AC_MSG_ERROR. If it matches, the version will 377 # be stored in CC_VERSION_NUMBER/CXX_VERSION_NUMBER (as a dotted number), and 378 # the full version string in CC_VERSION_STRING/CXX_VERSION_STRING. 379 # 380 # $1 = compiler to test (CC or CXX) 381 # $2 = human readable name of compiler (C or C++) 382 AC_DEFUN([TOOLCHAIN_EXTRACT_COMPILER_VERSION], 383 [ 384 COMPILER=[$]$1 385 COMPILER_NAME=$2 386 387 if test "x$TOOLCHAIN_TYPE" = xxlc; then 388 # xlc -qversion output typically looks like 389 # IBM XL C/C++ for AIX, V11.1 (5724-X13) 390 # Version: 11.01.0000.0015 391 COMPILER_VERSION_OUTPUT=`$COMPILER -qversion 2>&1` 392 # Check that this is likely to be the IBM XL C compiler. 393 $ECHO "$COMPILER_VERSION_OUTPUT" | $GREP "IBM XL C" > /dev/null 394 if test $? -ne 0; then 395 ALT_VERSION_OUTPUT=`$COMPILER --version 2>&1` 396 AC_MSG_NOTICE([The $COMPILER_NAME compiler (located as $COMPILER) does not seem to be the required $TOOLCHAIN_TYPE compiler.]) 397 AC_MSG_NOTICE([The result from running with -qversion was: "$COMPILER_VERSION_OUTPUT"]) 398 AC_MSG_NOTICE([The result from running with --version was: "$ALT_VERSION_OUTPUT"]) 399 AC_MSG_ERROR([A $TOOLCHAIN_TYPE compiler is required. Try setting --with-tools-dir.]) 400 fi 401 # Collapse compiler output into a single line 402 COMPILER_VERSION_STRING=`$ECHO $COMPILER_VERSION_OUTPUT` 403 COMPILER_VERSION_NUMBER=`$ECHO $COMPILER_VERSION_OUTPUT | \ 404 $SED -e 's/^.*, V\(@<:@1-9@:>@@<:@0-9.@:>@*\).*$/\1/'` 405 elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then 406 # There is no specific version flag, but all output starts with a version string. 407 # First line typically looks something like: 408 # Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.40219.01 for 80x86 409 # but the compiler name may vary depending on locale. 410 COMPILER_VERSION_OUTPUT=`$COMPILER 2>&1 1>/dev/null | $HEAD -n 1 | $TR -d '\r'` 411 # Check that this is likely to be Microsoft CL.EXE. 412 $ECHO "$COMPILER_VERSION_OUTPUT" | $GREP "Microsoft" > /dev/null 413 if test $? -ne 0; then 414 AC_MSG_NOTICE([The $COMPILER_NAME compiler (located as $COMPILER) does not seem to be the required $TOOLCHAIN_TYPE compiler.]) 415 AC_MSG_NOTICE([The result from running it was: "$COMPILER_VERSION_OUTPUT"]) 416 AC_MSG_ERROR([A $TOOLCHAIN_TYPE compiler is required. Try setting --with-tools-dir.]) 417 fi 418 # Collapse compiler output into a single line 419 COMPILER_VERSION_STRING=`$ECHO $COMPILER_VERSION_OUTPUT` 420 COMPILER_VERSION_NUMBER=`$ECHO $COMPILER_VERSION_OUTPUT | \ 421 $SED -e 's/^.*ersion.\(@<:@1-9@:>@@<:@0-9.@:>@*\) .*$/\1/'` 422 elif test "x$TOOLCHAIN_TYPE" = xgcc; then 423 # gcc --version output typically looks like 424 # gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1 425 # Copyright (C) 2013 Free Software Foundation, Inc. 426 # This is free software; see the source for copying conditions. There is NO 427 # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 428 COMPILER_VERSION_OUTPUT=`$COMPILER --version 2>&1` 429 # Check that this is likely to be GCC. 430 $ECHO "$COMPILER_VERSION_OUTPUT" | $GREP "Free Software Foundation" > /dev/null 431 if test $? -ne 0; then 432 AC_MSG_NOTICE([The $COMPILER_NAME compiler (located as $COMPILER) does not seem to be the required $TOOLCHAIN_TYPE compiler.]) 433 AC_MSG_NOTICE([The result from running with --version was: "$COMPILER_VERSION"]) 434 AC_MSG_ERROR([A $TOOLCHAIN_TYPE compiler is required. Try setting --with-tools-dir.]) 435 fi 436 # Remove Copyright and legalese from version string, and 437 # collapse into a single line 438 COMPILER_VERSION_STRING=`$ECHO $COMPILER_VERSION_OUTPUT | \ 439 $SED -e 's/ *Copyright .*//'` 440 COMPILER_VERSION_NUMBER=`$ECHO $COMPILER_VERSION_OUTPUT | \ 441 $SED -e 's/^.* \(@<:@1-9@:>@<:@0-9@:>@*\.@<:@0-9.@:>@*\)@<:@^0-9.@:>@.*$/\1/'` 442 elif test "x$TOOLCHAIN_TYPE" = xclang; then 443 # clang --version output typically looks like 444 # Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn) 445 # clang version 3.3 (tags/RELEASE_33/final) 446 # or 447 # Debian clang version 3.2-7ubuntu1 (tags/RELEASE_32/final) (based on LLVM 3.2) 448 # Target: x86_64-pc-linux-gnu 449 # Thread model: posix 450 COMPILER_VERSION_OUTPUT=`$COMPILER --version 2>&1` 451 # Check that this is likely to be clang 452 $ECHO "$COMPILER_VERSION_OUTPUT" | $GREP "clang" > /dev/null 453 if test $? -ne 0; then 454 AC_MSG_NOTICE([The $COMPILER_NAME compiler (located as $COMPILER) does not seem to be the required $TOOLCHAIN_TYPE compiler.]) 455 AC_MSG_NOTICE([The result from running with --version was: "$COMPILER_VERSION_OUTPUT"]) 456 AC_MSG_ERROR([A $TOOLCHAIN_TYPE compiler is required. Try setting --with-tools-dir.]) 457 fi 458 # Collapse compiler output into a single line 459 COMPILER_VERSION_STRING=`$ECHO $COMPILER_VERSION_OUTPUT` 460 COMPILER_VERSION_NUMBER=`$ECHO $COMPILER_VERSION_OUTPUT | \ 461 $SED -e 's/^.* version \(@<:@1-9@:>@@<:@0-9.@:>@*\).*$/\1/'` 462 else 463 AC_MSG_ERROR([Unknown toolchain type $TOOLCHAIN_TYPE.]) 464 fi 465 # This sets CC_VERSION_NUMBER or CXX_VERSION_NUMBER. (This comment is a grep marker) 466 $1_VERSION_NUMBER="$COMPILER_VERSION_NUMBER" 467 # This sets CC_VERSION_STRING or CXX_VERSION_STRING. (This comment is a grep marker) 468 $1_VERSION_STRING="$COMPILER_VERSION_STRING" 469 470 AC_MSG_NOTICE([Using $TOOLCHAIN_TYPE $COMPILER_NAME compiler version $COMPILER_VERSION_NUMBER @<:@$COMPILER_VERSION_STRING@:>@]) 471 ]) 472 473 # Try to locate the given C or C++ compiler in the path, or otherwise. 474 # 475 # $1 = compiler to test (CC or CXX) 476 # $2 = human readable name of compiler (C or C++) 477 # $3 = compiler name to search for 478 AC_DEFUN([TOOLCHAIN_FIND_COMPILER], 479 [ 480 COMPILER_NAME=$2 481 SEARCH_LIST="$3" 482 483 if test "x[$]$1" != x; then 484 # User has supplied compiler name already, always let that override. 485 AC_MSG_NOTICE([Will use user supplied compiler $1=[$]$1]) 486 if test "x`basename [$]$1`" = "x[$]$1"; then 487 # A command without a complete path is provided, search $PATH. 488 489 UTIL_LOOKUP_PROGS(POTENTIAL_$1, [$]$1) 490 if test "x$POTENTIAL_$1" != x; then 491 $1=$POTENTIAL_$1 492 else 493 AC_MSG_ERROR([User supplied compiler $1=[$]$1 could not be found]) 494 fi 495 else 496 # Otherwise it might already be a complete path 497 if test ! -x "[$]$1"; then 498 AC_MSG_ERROR([User supplied compiler $1=[$]$1 does not exist]) 499 fi 500 fi 501 else 502 # No user supplied value. Locate compiler ourselves. 503 504 # If we are cross compiling, assume cross compilation tools follows the 505 # cross compilation standard where they are prefixed with the autoconf 506 # standard name for the target. For example the binary 507 # i686-sun-solaris2.10-gcc will cross compile for i686-sun-solaris2.10. 508 # If we are not cross compiling, then the default compiler name will be 509 # used. 510 511 UTIL_LOOKUP_TOOLCHAIN_PROGS(POTENTIAL_$1, $SEARCH_LIST) 512 if test "x$POTENTIAL_$1" != x; then 513 $1=$POTENTIAL_$1 514 else 515 HELP_MSG_MISSING_DEPENDENCY([devkit]) 516 AC_MSG_ERROR([Could not find a $COMPILER_NAME compiler. $HELP_MSG]) 517 fi 518 fi 519 520 # Now we have a compiler binary in $1. Make sure it's okay. 521 TEST_COMPILER="[$]$1" 522 523 AC_MSG_CHECKING([resolved symbolic links for $1]) 524 SYMLINK_ORIGINAL="$TEST_COMPILER" 525 UTIL_REMOVE_SYMBOLIC_LINKS(SYMLINK_ORIGINAL) 526 if test "x$TEST_COMPILER" = "x$SYMLINK_ORIGINAL"; then 527 AC_MSG_RESULT([no symlink]) 528 else 529 AC_MSG_RESULT([$SYMLINK_ORIGINAL]) 530 531 # We can't handle ccache by gcc wrappers, since we need to know if we're 532 # using ccache. Instead ccache usage must be controlled by a configure option. 533 COMPILER_BASENAME=`$BASENAME "$SYMLINK_ORIGINAL"` 534 if test "x$COMPILER_BASENAME" = "xccache"; then 535 AC_MSG_NOTICE([Please use --enable-ccache instead of providing a wrapped compiler.]) 536 AC_MSG_ERROR([$TEST_COMPILER is a symbolic link to ccache. This is not supported.]) 537 fi 538 fi 539 540 TOOLCHAIN_EXTRACT_COMPILER_VERSION([$1], [$COMPILER_NAME]) 541 ]) 542 543 # Retrieve the linker version number and store it in LD_VERSION_NUMBER 544 # (as a dotted number), and 545 # the full version string in LD_VERSION_STRING. 546 # 547 # $1 = linker to test (LD or BUILD_LD) 548 # $2 = human readable name of linker (Linker or BuildLinker) 549 AC_DEFUN([TOOLCHAIN_EXTRACT_LD_VERSION], 550 [ 551 LINKER=[$]$1 552 LINKER_NAME="$2" 553 554 if test "x$TOOLCHAIN_TYPE" = xxlc; then 555 LINKER_VERSION_STRING="Unknown" 556 LINKER_VERSION_NUMBER="0.0" 557 elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then 558 # There is no specific version flag, but all output starts with a version string. 559 # First line typically looks something like: 560 # Microsoft (R) Incremental Linker Version 12.00.31101.0 561 LINKER_VERSION_STRING=`$LINKER 2>&1 | $HEAD -n 1 | $TR -d '\r'` 562 # Extract version number 563 [ LINKER_VERSION_NUMBER=`$ECHO $LINKER_VERSION_STRING | \ 564 $SED -e 's/.* \([0-9][0-9]*\(\.[0-9][0-9]*\)*\).*/\1/'` ] 565 elif test "x$TOOLCHAIN_TYPE" = xgcc; then 566 # gcc -Wl,-version output typically looks like: 567 # GNU ld (GNU Binutils for Ubuntu) 2.26.1 568 # Copyright (C) 2015 Free Software Foundation, Inc. 569 # This program is free software; [...] 570 # If using gold it will look like: 571 # GNU gold (GNU Binutils 2.30) 1.15 572 LINKER_VERSION_STRING=`$LINKER -Wl,--version 2> /dev/null | $HEAD -n 1` 573 # Extract version number 574 if [ [[ "$LINKER_VERSION_STRING" == *gold* ]] ]; then 575 [ LINKER_VERSION_NUMBER=`$ECHO $LINKER_VERSION_STRING | \ 576 $SED -e 's/.* \([0-9][0-9]*\(\.[0-9][0-9]*\)*\).*) .*/\1/'` ] 577 else 578 [ LINKER_VERSION_NUMBER=`$ECHO $LINKER_VERSION_STRING | \ 579 $SED -e 's/.* \([0-9][0-9]*\(\.[0-9][0-9]*\)*\).*/\1/'` ] 580 fi 581 elif test "x$TOOLCHAIN_TYPE" = xclang; then 582 # clang -Wl,-v output typically looks like 583 # @(#)PROGRAM:ld PROJECT:ld64-305 584 # configured to support archs: armv6 armv7 armv7s arm64 i386 x86_64 x86_64h armv6m armv7k armv7m armv7em (tvOS) 585 # Library search paths: [...] 586 # or 587 # GNU ld (GNU Binutils for Ubuntu) 2.26.1 588 589 LINKER_VERSION_STRING=`$LINKER -Wl,-v 2>&1 | $HEAD -n 1` 590 # Check if we're using the GNU ld 591 $ECHO "$LINKER_VERSION_STRING" | $GREP "GNU" > /dev/null 592 if test $? -eq 0; then 593 # Extract version number 594 [ LINKER_VERSION_NUMBER=`$ECHO $LINKER_VERSION_STRING | \ 595 $SED -e 's/.* \([0-9][0-9]*\(\.[0-9][0-9]*\)*\).*/\1/'` ] 596 else 597 # Extract version number 598 [ LINKER_VERSION_NUMBER=`$ECHO $LINKER_VERSION_STRING | \ 599 $SED -e 's/.*-\([0-9][0-9]*\)/\1/'` ] 600 fi 601 fi 602 603 $1_VERSION_NUMBER="$LINKER_VERSION_NUMBER" 604 $1_VERSION_STRING="$LINKER_VERSION_STRING" 605 606 AC_MSG_NOTICE([Using $TOOLCHAIN_TYPE $LINKER_NAME version $LINKER_VERSION_NUMBER @<:@$LINKER_VERSION_STRING@:>@]) 607 ]) 608 609 # Make sure we did not pick up /usr/bin/link, which is the unix-style link 610 # executable. 611 # 612 # $1 = linker to test (LD or BUILD_LD) 613 AC_DEFUN(TOOLCHAIN_VERIFY_LINK_BINARY, 614 [ 615 LINKER=[$]$1 616 617 AC_MSG_CHECKING([if the found link.exe is actually the Visual Studio linker]) 618 $LINKER --version > /dev/null 619 if test $? -eq 0 ; then 620 AC_MSG_RESULT([no]) 621 AC_MSG_ERROR([$LINKER is the winenv link tool. Please check your PATH and rerun configure.]) 622 else 623 AC_MSG_RESULT([yes]) 624 fi 625 ]) 626 # Detect the core components of the toolchain, i.e. the compilers (CC and CXX), 627 # preprocessor (CPP and CXXCPP), the linker (LD), the assembler (AS) and the 628 # archiver (AR). Verify that the compilers are correct according to the 629 # toolchain type. 630 AC_DEFUN_ONCE([TOOLCHAIN_DETECT_TOOLCHAIN_CORE], 631 [ 632 # 633 # Setup the compilers (CC and CXX) 634 # 635 TOOLCHAIN_FIND_COMPILER([CC], [C], $TOOLCHAIN_CC_BINARY) 636 # Now that we have resolved CC ourself, let autoconf have its go at it 637 AC_PROG_CC([$CC]) 638 639 TOOLCHAIN_FIND_COMPILER([CXX], [C++], $TOOLCHAIN_CXX_BINARY) 640 # Now that we have resolved CXX ourself, let autoconf have its go at it 641 AC_PROG_CXX([$CXX]) 642 643 # This is the compiler version number on the form X.Y[.Z] 644 AC_SUBST(CC_VERSION_NUMBER) 645 AC_SUBST(CXX_VERSION_NUMBER) 646 647 TOOLCHAIN_PREPARE_FOR_VERSION_COMPARISONS 648 649 if test "x$TOOLCHAIN_MINIMUM_VERSION" != x; then 650 TOOLCHAIN_CHECK_COMPILER_VERSION(VERSION: $TOOLCHAIN_MINIMUM_VERSION, 651 IF_OLDER_THAN: [ 652 AC_MSG_WARN([You are using $TOOLCHAIN_TYPE older than $TOOLCHAIN_MINIMUM_VERSION. This is not a supported configuration.]) 653 ] 654 ) 655 fi 656 657 # 658 # Setup the preprocessor (CPP and CXXCPP) 659 # 660 AC_PROG_CPP 661 UTIL_FIXUP_EXECUTABLE(CPP) 662 AC_PROG_CXXCPP 663 UTIL_FIXUP_EXECUTABLE(CXXCPP) 664 665 # 666 # Setup the linker (LD) 667 # 668 if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then 669 # In the Microsoft toolchain we have a separate LD command "link". 670 UTIL_LOOKUP_TOOLCHAIN_PROGS(LD, link) 671 TOOLCHAIN_VERIFY_LINK_BINARY(LD) 672 LDCXX="$LD" 673 else 674 # All other toolchains use the compiler to link. 675 LD="$CC" 676 LDCXX="$CXX" 677 fi 678 AC_SUBST(LD) 679 # FIXME: it should be CXXLD, according to standard (cf CXXCPP) 680 AC_SUBST(LDCXX) 681 682 TOOLCHAIN_EXTRACT_LD_VERSION([LD], [linker]) 683 TOOLCHAIN_PREPARE_FOR_LD_VERSION_COMPARISONS 684 685 if test "x$TOOLCHAIN_MINIMUM_LD_VERSION" != x; then 686 AC_MSG_NOTICE([comparing linker version to minimum version $TOOLCHAIN_MINIMUM_LD_VERSION]) 687 TOOLCHAIN_CHECK_LINKER_VERSION(VERSION: $TOOLCHAIN_MINIMUM_LD_VERSION, 688 IF_OLDER_THAN: [ 689 AC_MSG_ERROR([You are using a linker older than $TOOLCHAIN_MINIMUM_LD_VERSION. This is not a supported configuration.]) 690 ] 691 ) 692 fi 693 694 # 695 # Setup the assembler (AS) 696 # 697 if test "x$TOOLCHAIN_TYPE" != xmicrosoft; then 698 AS="$CC -c" 699 else 700 if test "x$OPENJDK_TARGET_CPU_BITS" = "x64"; then 701 # On 64 bit windows, the assembler is "ml64.exe" 702 UTIL_LOOKUP_TOOLCHAIN_PROGS(AS, ml64) 703 else 704 # otherwise, the assembler is "ml.exe" 705 UTIL_LOOKUP_TOOLCHAIN_PROGS(AS, ml) 706 fi 707 fi 708 AC_SUBST(AS) 709 710 # 711 # Setup the archiver (AR) 712 # 713 if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then 714 # The corresponding ar tool is lib.exe (used to create static libraries) 715 UTIL_LOOKUP_TOOLCHAIN_PROGS(AR, lib) 716 elif test "x$TOOLCHAIN_TYPE" = xgcc; then 717 UTIL_LOOKUP_TOOLCHAIN_PROGS(AR, ar gcc-ar) 718 else 719 UTIL_LOOKUP_TOOLCHAIN_PROGS(AR, ar) 720 fi 721 ]) 722 723 # Setup additional tools that is considered a part of the toolchain, but not the 724 # core part. Many of these are highly platform-specific and do not exist, 725 # and/or are not needed on all platforms. 726 AC_DEFUN_ONCE([TOOLCHAIN_DETECT_TOOLCHAIN_EXTRA], 727 [ 728 if test "x$OPENJDK_TARGET_OS" = "xmacosx"; then 729 UTIL_LOOKUP_PROGS(LIPO, lipo) 730 UTIL_REQUIRE_PROGS(OTOOL, otool) 731 UTIL_REQUIRE_PROGS(INSTALL_NAME_TOOL, install_name_tool) 732 733 UTIL_LOOKUP_TOOLCHAIN_PROGS(METAL, metal) 734 if test "x$METAL" = x; then 735 AC_MSG_CHECKING([if metal can be run using xcrun]) 736 METAL="xcrun -sdk macosx metal" 737 test_metal=`$METAL --version 2>&1` 738 if test $? -ne 0; then 739 AC_MSG_RESULT([no]) 740 AC_MSG_ERROR([XCode tool 'metal' neither found in path nor with xcrun]) 741 else 742 AC_MSG_RESULT([yes, will be using '$METAL']) 743 fi 744 fi 745 746 UTIL_LOOKUP_TOOLCHAIN_PROGS(METALLIB, metallib) 747 if test "x$METALLIB" = x; then 748 AC_MSG_CHECKING([if metallib can be run using xcrun]) 749 METALLIB="xcrun -sdk macosx metallib" 750 test_metallib=`$METALLIB --version 2>&1` 751 if test $? -ne 0; then 752 AC_MSG_RESULT([no]) 753 AC_MSG_ERROR([XCode tool 'metallib' neither found in path nor with xcrun]) 754 else 755 AC_MSG_RESULT([yes, will be using '$METALLIB']) 756 fi 757 fi 758 fi 759 760 if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then 761 # Setup the manifest tool (MT) 762 UTIL_LOOKUP_TOOLCHAIN_PROGS(MT, mt) 763 # Setup the resource compiler (RC) 764 UTIL_LOOKUP_TOOLCHAIN_PROGS(RC, rc) 765 UTIL_LOOKUP_TOOLCHAIN_PROGS(DUMPBIN, dumpbin) 766 fi 767 768 if test "x$OPENJDK_TARGET_OS" != xwindows; then 769 UTIL_LOOKUP_TOOLCHAIN_PROGS(STRIP, strip) 770 if test "x$TOOLCHAIN_TYPE" = xgcc; then 771 UTIL_LOOKUP_TOOLCHAIN_PROGS(NM, nm gcc-nm) 772 else 773 UTIL_LOOKUP_TOOLCHAIN_PROGS(NM, nm) 774 fi 775 fi 776 777 # objcopy is used for moving debug symbols to separate files when 778 # full debug symbols are enabled. 779 if test "x$OPENJDK_TARGET_OS" = xlinux; then 780 UTIL_LOOKUP_TOOLCHAIN_PROGS(OBJCOPY, gobjcopy objcopy) 781 fi 782 783 UTIL_LOOKUP_TOOLCHAIN_PROGS(OBJDUMP, gobjdump objdump) 784 785 case $TOOLCHAIN_TYPE in 786 gcc|clang) 787 UTIL_REQUIRE_TOOLCHAIN_PROGS(CXXFILT, c++filt) 788 ;; 789 esac 790 ]) 791 792 # Setup the build tools (i.e, the compiler and linker used to build programs 793 # that should be run on the build platform, not the target platform, as a build 794 # helper). Since the non-cross-compile case uses the normal, target compilers 795 # for this, we can only do this after these have been setup. 796 AC_DEFUN_ONCE([TOOLCHAIN_SETUP_BUILD_COMPILERS], 797 [ 798 if test "x$COMPILE_TYPE" = "xcross"; then 799 # Now we need to find a C/C++ compiler that can build executables for the 800 # build platform. We can't use the AC_PROG_CC macro, since it can only be 801 # used once. Also, we need to do this without adding a tools dir to the 802 # path, otherwise we might pick up cross-compilers which don't use standard 803 # naming. 804 805 OLDPATH="$PATH" 806 807 AC_ARG_WITH(build-devkit, [AS_HELP_STRING([--with-build-devkit], 808 [Devkit to use for the build platform toolchain])]) 809 if test "x$with_build_devkit" = "xyes"; then 810 AC_MSG_ERROR([--with-build-devkit must have a value]) 811 elif test -n "$with_build_devkit"; then 812 if test ! -d "$with_build_devkit"; then 813 AC_MSG_ERROR([--with-build-devkit points to non existing dir: $with_build_devkit]) 814 else 815 UTIL_FIXUP_PATH([with_build_devkit]) 816 BUILD_DEVKIT_ROOT="$with_build_devkit" 817 # Check for a meta data info file in the root of the devkit 818 if test -f "$BUILD_DEVKIT_ROOT/devkit.info"; then 819 # Process devkit.info so that existing devkit variables are not 820 # modified by this 821 $SED -e "s/^DEVKIT_/BUILD_DEVKIT_/g" \ 822 -e "s/\$DEVKIT_ROOT/\$BUILD_DEVKIT_ROOT/g" \ 823 -e "s/\$host/\$build/g" \ 824 $BUILD_DEVKIT_ROOT/devkit.info \ 825 > $CONFIGURESUPPORT_OUTPUTDIR/build-devkit.info 826 . $CONFIGURESUPPORT_OUTPUTDIR/build-devkit.info 827 # This potentially sets the following: 828 # A descriptive name of the devkit 829 BASIC_EVAL_BUILD_DEVKIT_VARIABLE([BUILD_DEVKIT_NAME]) 830 # Corresponds to --with-extra-path 831 BASIC_EVAL_BUILD_DEVKIT_VARIABLE([BUILD_DEVKIT_EXTRA_PATH]) 832 # Corresponds to --with-toolchain-path 833 BASIC_EVAL_BUILD_DEVKIT_VARIABLE([BUILD_DEVKIT_TOOLCHAIN_PATH]) 834 # Corresponds to --with-sysroot 835 BASIC_EVAL_BUILD_DEVKIT_VARIABLE([BUILD_DEVKIT_SYSROOT]) 836 837 if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then 838 BASIC_EVAL_BUILD_DEVKIT_VARIABLE([BUILD_DEVKIT_VS_INCLUDE]) 839 BASIC_EVAL_BUILD_DEVKIT_VARIABLE([BUILD_DEVKIT_VS_LIB]) 840 fi 841 fi 842 843 AC_MSG_CHECKING([for build platform devkit]) 844 if test "x$BUILD_DEVKIT_NAME" != x; then 845 AC_MSG_RESULT([$BUILD_DEVKIT_NAME in $BUILD_DEVKIT_ROOT]) 846 else 847 AC_MSG_RESULT([$BUILD_DEVKIT_ROOT]) 848 fi 849 850 # Fallback default of just /bin if DEVKIT_PATH is not defined 851 if test "x$BUILD_DEVKIT_TOOLCHAIN_PATH" = x; then 852 BUILD_DEVKIT_TOOLCHAIN_PATH="$BUILD_DEVKIT_ROOT/bin" 853 fi 854 PATH="$BUILD_DEVKIT_TOOLCHAIN_PATH:$BUILD_DEVKIT_EXTRA_PATH" 855 856 BUILD_SYSROOT="$BUILD_DEVKIT_SYSROOT" 857 858 if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then 859 # For historical reasons, paths are separated by ; in devkit.info 860 BUILD_VS_INCLUDE="${BUILD_DEVKIT_VS_INCLUDE//;/:}" 861 BUILD_VS_LIB="${BUILD_DEVKIT_VS_LIB//;/:}" 862 863 TOOLCHAIN_SETUP_VISUAL_STUDIO_SYSROOT_FLAGS(BUILD_, BUILD_) 864 fi 865 fi 866 else 867 if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then 868 # If we got no devkit, we need to go hunting for the proper env 869 TOOLCHAIN_FIND_VISUAL_STUDIO_BAT_FILE($OPENJDK_BUILD_CPU, [$TOOLCHAIN_VERSION]) 870 TOOLCHAIN_EXTRACT_VISUAL_STUDIO_ENV($OPENJDK_BUILD_CPU, BUILD_) 871 872 # We cannot currently export the VS_PATH to spec.gmk. This is probably 873 # strictly not correct, but seems to work anyway. 874 875 # Convert VS_INCLUDE and VS_LIB into sysroot flags 876 TOOLCHAIN_SETUP_VISUAL_STUDIO_SYSROOT_FLAGS(BUILD_) 877 fi 878 fi 879 880 if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then 881 UTIL_REQUIRE_PROGS(BUILD_CC, cl, [$VS_PATH]) 882 UTIL_REQUIRE_PROGS(BUILD_CXX, cl, [$VS_PATH]) 883 884 # On windows, the assembler is "ml.exe". We currently don't need this so 885 # do not require. 886 if test "x$OPENJDK_BUILD_CPU_BITS" = "x64"; then 887 # On 64 bit windows, the assembler is "ml64.exe" 888 UTIL_LOOKUP_PROGS(BUILD_AS, ml64, [$VS_PATH]) 889 else 890 # otherwise the assembler is "ml.exe" 891 UTIL_LOOKUP_PROGS(BUILD_AS, ml, [$VS_PATH]) 892 fi 893 894 # On windows, the ar tool is lib.exe (used to create static libraries). 895 # We currently don't need this so do not require. 896 UTIL_LOOKUP_PROGS(BUILD_AR, lib, [$VS_PATH]) 897 898 # In the Microsoft toolchain we have a separate LD command "link". 899 UTIL_REQUIRE_PROGS(BUILD_LD, link, [$VS_PATH]) 900 TOOLCHAIN_VERIFY_LINK_BINARY(BUILD_LD) 901 BUILD_LDCXX="$BUILD_LD" 902 else 903 if test "x$OPENJDK_BUILD_OS" = xmacosx; then 904 UTIL_REQUIRE_PROGS(BUILD_CC, clang) 905 UTIL_REQUIRE_PROGS(BUILD_CXX, clang++) 906 else 907 UTIL_REQUIRE_PROGS(BUILD_CC, cc gcc) 908 UTIL_REQUIRE_PROGS(BUILD_CXX, CC g++) 909 fi 910 UTIL_LOOKUP_PROGS(BUILD_NM, nm gcc-nm) 911 UTIL_LOOKUP_PROGS(BUILD_AR, ar gcc-ar lib) 912 UTIL_LOOKUP_PROGS(BUILD_OBJCOPY, objcopy) 913 UTIL_LOOKUP_PROGS(BUILD_STRIP, strip) 914 # Assume the C compiler is the assembler 915 BUILD_AS="$BUILD_CC -c" 916 # Just like for the target compiler, use the compiler as linker 917 BUILD_LD="$BUILD_CC" 918 BUILD_LDCXX="$BUILD_CXX" 919 fi 920 921 PATH="$OLDPATH" 922 923 TOOLCHAIN_EXTRACT_COMPILER_VERSION(BUILD_CC, [BuildC]) 924 TOOLCHAIN_EXTRACT_COMPILER_VERSION(BUILD_CXX, [BuildC++]) 925 TOOLCHAIN_PREPARE_FOR_VERSION_COMPARISONS([BUILD_], [OPENJDK_BUILD_], [build ]) 926 TOOLCHAIN_EXTRACT_LD_VERSION(BUILD_LD, [build linker]) 927 TOOLCHAIN_PREPARE_FOR_LD_VERSION_COMPARISONS([BUILD_], [OPENJDK_BUILD_]) 928 else 929 # If we are not cross compiling, use the normal target compilers for 930 # building the build platform executables. 931 BUILD_CC="$CC" 932 BUILD_CXX="$CXX" 933 BUILD_LD="$LD" 934 BUILD_LDCXX="$LDCXX" 935 BUILD_NM="$NM" 936 BUILD_AS="$AS" 937 BUILD_OBJCOPY="$OBJCOPY" 938 BUILD_STRIP="$STRIP" 939 BUILD_AR="$AR" 940 941 TOOLCHAIN_PREPARE_FOR_VERSION_COMPARISONS([], [OPENJDK_BUILD_], [build ]) 942 TOOLCHAIN_PREPARE_FOR_LD_VERSION_COMPARISONS([BUILD_], [OPENJDK_BUILD_]) 943 fi 944 945 AC_SUBST(BUILD_CC) 946 AC_SUBST(BUILD_CXX) 947 AC_SUBST(BUILD_LD) 948 AC_SUBST(BUILD_LDCXX) 949 AC_SUBST(BUILD_NM) 950 AC_SUBST(BUILD_AS) 951 AC_SUBST(BUILD_AR) 952 ]) 953 954 # Do some additional checks on the detected tools. 955 AC_DEFUN_ONCE([TOOLCHAIN_MISC_CHECKS], 956 [ 957 # Check for extra potential brokenness. 958 if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then 959 # On Windows, double-check that we got the right compiler. 960 CC_VERSION_OUTPUT=`$CC 2>&1 1>/dev/null | $HEAD -n 1 | $TR -d '\r'` 961 COMPILER_CPU_TEST=`$ECHO $CC_VERSION_OUTPUT | $SED -n "s/^.* \(.*\)$/\1/p"` 962 if test "x$OPENJDK_TARGET_CPU" = "xx86"; then 963 if test "x$COMPILER_CPU_TEST" != "x80x86" -a "x$COMPILER_CPU_TEST" != "xx86"; then 964 AC_MSG_ERROR([Target CPU mismatch. We are building for $OPENJDK_TARGET_CPU but CL is for "$COMPILER_CPU_TEST"; expected "80x86" or "x86".]) 965 fi 966 elif test "x$OPENJDK_TARGET_CPU" = "xx86_64"; then 967 if test "x$COMPILER_CPU_TEST" != "xx64"; then 968 AC_MSG_ERROR([Target CPU mismatch. We are building for $OPENJDK_TARGET_CPU but CL is for "$COMPILER_CPU_TEST"; expected "x64".]) 969 fi 970 elif test "x$OPENJDK_TARGET_CPU" = "xaarch64"; then 971 if test "x$COMPILER_CPU_TEST" != "xARM64"; then 972 AC_MSG_ERROR([Target CPU mismatch. We are building for $OPENJDK_TARGET_CPU but CL is for "$COMPILER_CPU_TEST"; expected "arm64".]) 973 fi 974 fi 975 fi 976 977 if test "x$TOOLCHAIN_TYPE" = xgcc || test "x$TOOLCHAIN_TYPE" = xclang; then 978 # Check if linker has -z noexecstack. 979 HAS_NOEXECSTACK=`$CC -Wl,--help 2>/dev/null | $GREP 'z noexecstack'` 980 # This is later checked when setting flags. 981 fi 982 983 # Setup hotspot lecagy names for toolchains 984 HOTSPOT_TOOLCHAIN_TYPE=$TOOLCHAIN_TYPE 985 if test "x$TOOLCHAIN_TYPE" = xclang; then 986 HOTSPOT_TOOLCHAIN_TYPE=gcc 987 elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then 988 HOTSPOT_TOOLCHAIN_TYPE=visCPP 989 fi 990 AC_SUBST(HOTSPOT_TOOLCHAIN_TYPE) 991 ]) 992 993 # Setup the JTReg Regression Test Harness. 994 AC_DEFUN_ONCE([TOOLCHAIN_SETUP_JTREG], 995 [ 996 AC_ARG_WITH(jtreg, [AS_HELP_STRING([--with-jtreg], 997 [Regression Test Harness @<:@probed@:>@])]) 998 999 if test "x$with_jtreg" = xno; then 1000 # jtreg disabled 1001 AC_MSG_CHECKING([for jtreg test harness]) 1002 AC_MSG_RESULT([no, disabled]) 1003 elif test "x$with_jtreg" != xyes && test "x$with_jtreg" != x; then 1004 if test -d "$with_jtreg"; then 1005 # An explicit path is specified, use it. 1006 JT_HOME="$with_jtreg" 1007 else 1008 case "$with_jtreg" in 1009 *.zip ) 1010 JTREG_SUPPORT_DIR=$CONFIGURESUPPORT_OUTPUTDIR/jtreg 1011 $RM -rf $JTREG_SUPPORT_DIR 1012 $MKDIR -p $JTREG_SUPPORT_DIR 1013 $UNZIP -qq -d $JTREG_SUPPORT_DIR $with_jtreg 1014 1015 # Try to find jtreg to determine JT_HOME path 1016 JTREG_PATH=`$FIND $JTREG_SUPPORT_DIR | $GREP "/bin/jtreg"` 1017 if test "x$JTREG_PATH" != x; then 1018 JT_HOME=$($DIRNAME $($DIRNAME $JTREG_PATH)) 1019 fi 1020 ;; 1021 * ) 1022 ;; 1023 esac 1024 fi 1025 UTIL_FIXUP_PATH([JT_HOME]) 1026 if test ! -d "$JT_HOME"; then 1027 AC_MSG_ERROR([jtreg home directory from --with-jtreg=$with_jtreg does not exist]) 1028 fi 1029 1030 if test ! -e "$JT_HOME/lib/jtreg.jar"; then 1031 AC_MSG_ERROR([jtreg home directory from --with-jtreg=$with_jtreg is not a valid jtreg home]) 1032 fi 1033 1034 AC_MSG_CHECKING([for jtreg test harness]) 1035 AC_MSG_RESULT([$JT_HOME]) 1036 else 1037 # Try to locate jtreg using the JT_HOME environment variable 1038 if test "x$JT_HOME" != x; then 1039 # JT_HOME set in environment, use it 1040 if test ! -d "$JT_HOME"; then 1041 AC_MSG_WARN([Ignoring JT_HOME pointing to invalid directory: $JT_HOME]) 1042 JT_HOME= 1043 else 1044 if test ! -e "$JT_HOME/lib/jtreg.jar"; then 1045 AC_MSG_WARN([Ignoring JT_HOME which is not a valid jtreg home: $JT_HOME]) 1046 JT_HOME= 1047 else 1048 AC_MSG_NOTICE([Located jtreg using JT_HOME from environment]) 1049 fi 1050 fi 1051 fi 1052 1053 if test "x$JT_HOME" = x; then 1054 # JT_HOME is not set in environment, or was deemed invalid. 1055 # Try to find jtreg on path 1056 UTIL_LOOKUP_PROGS(JTREGEXE, jtreg) 1057 if test "x$JTREGEXE" != x; then 1058 # That's good, now try to derive JT_HOME 1059 JT_HOME=`(cd $($DIRNAME $JTREGEXE)/.. && pwd)` 1060 if test ! -e "$JT_HOME/lib/jtreg.jar"; then 1061 AC_MSG_WARN([Ignoring jtreg from path since a valid jtreg home cannot be found]) 1062 JT_HOME= 1063 else 1064 AC_MSG_NOTICE([Located jtreg using jtreg executable in path]) 1065 fi 1066 fi 1067 fi 1068 1069 AC_MSG_CHECKING([for jtreg test harness]) 1070 if test "x$JT_HOME" != x; then 1071 AC_MSG_RESULT([$JT_HOME]) 1072 else 1073 AC_MSG_RESULT([no, not found]) 1074 1075 if test "x$with_jtreg" = xyes; then 1076 AC_MSG_ERROR([--with-jtreg was specified, but no jtreg found.]) 1077 fi 1078 fi 1079 fi 1080 1081 UTIL_FIXUP_PATH(JT_HOME) 1082 AC_SUBST(JT_HOME) 1083 ]) 1084 1085 # Setup the JIB dependency resolver 1086 AC_DEFUN_ONCE([TOOLCHAIN_SETUP_JIB], 1087 [ 1088 AC_ARG_WITH(jib, [AS_HELP_STRING([--with-jib], 1089 [Jib dependency management tool @<:@not used@:>@])]) 1090 1091 if test "x$with_jib" = xno || test "x$with_jib" = x; then 1092 # jib disabled 1093 AC_MSG_CHECKING([for jib]) 1094 AC_MSG_RESULT(no) 1095 elif test "x$with_jib" = xyes; then 1096 AC_MSG_ERROR([Must supply a value to --with-jib]) 1097 else 1098 JIB_HOME="${with_jib}" 1099 AC_MSG_CHECKING([for jib]) 1100 AC_MSG_RESULT(${JIB_HOME}) 1101 if test ! -d "${JIB_HOME}"; then 1102 AC_MSG_ERROR([--with-jib must be a directory]) 1103 fi 1104 JIB_JAR=$(ls ${JIB_HOME}/lib/jib-*.jar) 1105 if test ! -f "${JIB_JAR}"; then 1106 AC_MSG_ERROR([Could not find jib jar file in ${JIB_HOME}]) 1107 fi 1108 fi 1109 1110 AC_SUBST(JIB_HOME) 1111 ]) --- EOF ---