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