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