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