toolchain.m4 revision 2181:d57780478145
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) 37VALID_TOOLCHAINS_all="gcc clang solstudio xlc microsoft" 38 39# These toolchains are valid on different platforms 40VALID_TOOLCHAINS_linux="gcc clang" 41VALID_TOOLCHAINS_solaris="solstudio" 42VALID_TOOLCHAINS_macosx="gcc clang" 43VALID_TOOLCHAINS_aix="xlc" 44VALID_TOOLCHAINS_windows="microsoft" 45 46# Toolchain descriptions 47TOOLCHAIN_DESCRIPTION_clang="clang/LLVM" 48TOOLCHAIN_DESCRIPTION_gcc="GNU Compiler Collection" 49TOOLCHAIN_DESCRIPTION_microsoft="Microsoft Visual Studio" 50TOOLCHAIN_DESCRIPTION_solstudio="Oracle Solaris Studio" 51TOOLCHAIN_DESCRIPTION_xlc="IBM XL C/C++" 52 53# Minimum supported versions, empty means unspecified 54TOOLCHAIN_MINIMUM_VERSION_clang="3.2" 55TOOLCHAIN_MINIMUM_VERSION_gcc="4.3" 56TOOLCHAIN_MINIMUM_VERSION_microsoft="" 57TOOLCHAIN_MINIMUM_VERSION_solstudio="5.12" 58TOOLCHAIN_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_) 64AC_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" =~ (.*\.){3} ]] ]; then 73 AC_MSG_WARN([C compiler version number has more than three parts (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\n", [$]1, [$]2, [$]3) }' <<< "[$]$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_) 91BASIC_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" =~ (.*\.){3} ]] ]; then 98 AC_MSG_ERROR([Internal error: Cannot compare to ARG_VERSION, only three parts (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\n", [$]1, [$]2, [$]3) }' <<< "$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. 119AC_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. 166AC_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. 260AC_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" 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 # For solaris we really need solaris tools, and not the GNU equivalent. 298 # The build tools on Solaris reside in /usr/ccs (C Compilation System), 299 # so add that to path before starting to probe. 300 # FIXME: This was originally only done for AS,NM,GNM,STRIP,OBJCOPY,OBJDUMP. 301 if test "x$OPENJDK_BUILD_OS" = xsolaris; then 302 PATH="/usr/ccs/bin:$PATH" 303 fi 304 305 # Finally add TOOLCHAIN_PATH at the beginning, to allow --with-tools-dir to 306 # override all other locations. 307 if test "x$TOOLCHAIN_PATH" != x; then 308 PATH=$TOOLCHAIN_PATH:$PATH 309 fi 310]) 311 312# Restore path, etc 313AC_DEFUN_ONCE([TOOLCHAIN_POST_DETECTION], 314[ 315 # Restore old path, except for the microsoft toolchain, which requires VS_PATH 316 # to remain in place. Otherwise the compiler will not work in some siutations 317 # in later configure checks. 318 if test "x$TOOLCHAIN_TYPE" != "xmicrosoft"; then 319 PATH="$OLD_PATH" 320 fi 321 322 # Restore the flags to the user specified values. 323 # This is necessary since AC_PROG_CC defaults CFLAGS to "-g -O2" 324 CFLAGS="$ORG_CFLAGS" 325 CXXFLAGS="$ORG_CXXFLAGS" 326]) 327 328# Check if a compiler is of the toolchain type we expect, and save the version 329# information from it. If the compiler does not match the expected type, 330# this function will abort using AC_MSG_ERROR. If it matches, the version will 331# be stored in CC_VERSION_NUMBER/CXX_VERSION_NUMBER (as a dotted number), and 332# the full version string in CC_VERSION_STRING/CXX_VERSION_STRING. 333# 334# $1 = compiler to test (CC or CXX) 335# $2 = human readable name of compiler (C or C++) 336AC_DEFUN([TOOLCHAIN_EXTRACT_COMPILER_VERSION], 337[ 338 COMPILER=[$]$1 339 COMPILER_NAME=$2 340 341 if test "x$TOOLCHAIN_TYPE" = xsolstudio; then 342 # cc -V output typically looks like 343 # cc: Sun C 5.12 Linux_i386 2011/11/16 344 COMPILER_VERSION_OUTPUT=`$COMPILER -V 2>&1` 345 # Check that this is likely to be the Solaris Studio cc. 346 $ECHO "$COMPILER_VERSION_OUTPUT" | $GREP "^.*: Sun $COMPILER_NAME" > /dev/null 347 if test $? -ne 0; then 348 ALT_VERSION_OUTPUT=`$COMPILER --version 2>&1` 349 AC_MSG_NOTICE([The $COMPILER_NAME compiler (located as $COMPILER) does not seem to be the required $TOOLCHAIN_TYPE compiler.]) 350 AC_MSG_NOTICE([The result from running with -V was: "$COMPILER_VERSION_OUTPUT"]) 351 AC_MSG_NOTICE([The result from running with --version was: "$ALT_VERSION_OUTPUT"]) 352 AC_MSG_ERROR([A $TOOLCHAIN_TYPE compiler is required. Try setting --with-tools-dir.]) 353 fi 354 # Remove usage instructions (if present), and 355 # collapse compiler output into a single line 356 COMPILER_VERSION_STRING=`$ECHO $COMPILER_VERSION_OUTPUT | \ 357 $SED -e 's/ *@<:@Uu@:>@sage:.*//'` 358 COMPILER_VERSION_NUMBER=`$ECHO $COMPILER_VERSION_OUTPUT | \ 359 $SED -e "s/^.*@<:@ ,\t@:>@$COMPILER_NAME@<:@ ,\t@:>@\(@<:@1-9@:>@\.@<:@0-9@:>@@<:@0-9@:>@*\).*/\1/"` 360 elif test "x$TOOLCHAIN_TYPE" = xxlc; then 361 # xlc -qversion output typically looks like 362 # IBM XL C/C++ for AIX, V11.1 (5724-X13) 363 # Version: 11.01.0000.0015 364 COMPILER_VERSION_OUTPUT=`$COMPILER -qversion 2>&1` 365 # Check that this is likely to be the IBM XL C compiler. 366 $ECHO "$COMPILER_VERSION_OUTPUT" | $GREP "IBM XL C" > /dev/null 367 if test $? -ne 0; then 368 ALT_VERSION_OUTPUT=`$COMPILER --version 2>&1` 369 AC_MSG_NOTICE([The $COMPILER_NAME compiler (located as $COMPILER) does not seem to be the required $TOOLCHAIN_TYPE compiler.]) 370 AC_MSG_NOTICE([The result from running with -qversion was: "$COMPILER_VERSION_OUTPUT"]) 371 AC_MSG_NOTICE([The result from running with --version was: "$ALT_VERSION_OUTPUT"]) 372 AC_MSG_ERROR([A $TOOLCHAIN_TYPE compiler is required. Try setting --with-tools-dir.]) 373 fi 374 # Collapse compiler output into a single line 375 COMPILER_VERSION_STRING=`$ECHO $COMPILER_VERSION_OUTPUT` 376 COMPILER_VERSION_NUMBER=`$ECHO $COMPILER_VERSION_OUTPUT | \ 377 $SED -e 's/^.*, V\(@<:@1-9@:>@@<:@0-9.@:>@*\).*$/\1/'` 378 elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then 379 # There is no specific version flag, but all output starts with a version string. 380 # First line typically looks something like: 381 # Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.40219.01 for 80x86 382 COMPILER_VERSION_OUTPUT=`$COMPILER 2>&1 | $HEAD -n 1 | $TR -d '\r'` 383 # Check that this is likely to be Microsoft CL.EXE. 384 $ECHO "$COMPILER_VERSION_OUTPUT" | $GREP "Microsoft.*Compiler" > /dev/null 385 if test $? -ne 0; then 386 AC_MSG_NOTICE([The $COMPILER_NAME compiler (located as $COMPILER) does not seem to be the required $TOOLCHAIN_TYPE compiler.]) 387 AC_MSG_NOTICE([The result from running it was: "$COMPILER_VERSION_OUTPUT"]) 388 AC_MSG_ERROR([A $TOOLCHAIN_TYPE compiler is required. Try setting --with-tools-dir.]) 389 fi 390 # Collapse compiler output into a single line 391 COMPILER_VERSION_STRING=`$ECHO $COMPILER_VERSION_OUTPUT` 392 COMPILER_VERSION_NUMBER=`$ECHO $COMPILER_VERSION_OUTPUT | \ 393 $SED -e 's/^.*ersion.\(@<:@1-9@:>@@<:@0-9.@:>@*\) .*$/\1/'` 394 elif test "x$TOOLCHAIN_TYPE" = xgcc; then 395 # gcc --version output typically looks like 396 # gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1 397 # Copyright (C) 2013 Free Software Foundation, Inc. 398 # This is free software; see the source for copying conditions. There is NO 399 # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 400 COMPILER_VERSION_OUTPUT=`$COMPILER --version 2>&1` 401 # Check that this is likely to be GCC. 402 $ECHO "$COMPILER_VERSION_OUTPUT" | $GREP "Free Software Foundation" > /dev/null 403 if test $? -ne 0; then 404 AC_MSG_NOTICE([The $COMPILER_NAME compiler (located as $COMPILER) does not seem to be the required $TOOLCHAIN_TYPE compiler.]) 405 AC_MSG_NOTICE([The result from running with --version was: "$COMPILER_VERSION"]) 406 AC_MSG_ERROR([A $TOOLCHAIN_TYPE compiler is required. Try setting --with-tools-dir.]) 407 fi 408 # Remove Copyright and legalese from version string, and 409 # collapse into a single line 410 COMPILER_VERSION_STRING=`$ECHO $COMPILER_VERSION_OUTPUT | \ 411 $SED -e 's/ *Copyright .*//'` 412 COMPILER_VERSION_NUMBER=`$ECHO $COMPILER_VERSION_OUTPUT | \ 413 $SED -e 's/^.* \(@<:@1-9@:>@\.@<:@0-9.@:>@*\)@<:@^0-9.@:>@.*$/\1/'` 414 elif test "x$TOOLCHAIN_TYPE" = xclang; then 415 # clang --version output typically looks like 416 # Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn) 417 # clang version 3.3 (tags/RELEASE_33/final) 418 # or 419 # Debian clang version 3.2-7ubuntu1 (tags/RELEASE_32/final) (based on LLVM 3.2) 420 # Target: x86_64-pc-linux-gnu 421 # Thread model: posix 422 COMPILER_VERSION_OUTPUT=`$COMPILER --version 2>&1` 423 # Check that this is likely to be clang 424 $ECHO "$COMPILER_VERSION_OUTPUT" | $GREP "clang" > /dev/null 425 if test $? -ne 0; then 426 AC_MSG_NOTICE([The $COMPILER_NAME compiler (located as $COMPILER) does not seem to be the required $TOOLCHAIN_TYPE compiler.]) 427 AC_MSG_NOTICE([The result from running with --version was: "$COMPILER_VERSION_OUTPUT"]) 428 AC_MSG_ERROR([A $TOOLCHAIN_TYPE compiler is required. Try setting --with-tools-dir.]) 429 fi 430 # Collapse compiler output into a single line 431 COMPILER_VERSION_STRING=`$ECHO $COMPILER_VERSION_OUTPUT` 432 COMPILER_VERSION_NUMBER=`$ECHO $COMPILER_VERSION_OUTPUT | \ 433 $SED -e 's/^.* version \(@<:@1-9@:>@@<:@0-9.@:>@*\).*$/\1/'` 434 else 435 AC_MSG_ERROR([Unknown toolchain type $TOOLCHAIN_TYPE.]) 436 fi 437 # This sets CC_VERSION_NUMBER or CXX_VERSION_NUMBER. (This comment is a grep marker) 438 $1_VERSION_NUMBER="$COMPILER_VERSION_NUMBER" 439 # This sets CC_VERSION_STRING or CXX_VERSION_STRING. (This comment is a grep marker) 440 $1_VERSION_STRING="$COMPILER_VERSION_STRING" 441 442 AC_MSG_NOTICE([Using $TOOLCHAIN_TYPE $COMPILER_NAME compiler version $COMPILER_VERSION_NUMBER @<:@$COMPILER_VERSION_STRING@:>@]) 443]) 444 445# Try to locate the given C or C++ compiler in the path, or otherwise. 446# 447# $1 = compiler to test (CC or CXX) 448# $2 = human readable name of compiler (C or C++) 449# $3 = list of compiler names to search for 450AC_DEFUN([TOOLCHAIN_FIND_COMPILER], 451[ 452 COMPILER_NAME=$2 453 SEARCH_LIST="$3" 454 455 if test "x[$]$1" != x; then 456 # User has supplied compiler name already, always let that override. 457 AC_MSG_NOTICE([Will use user supplied compiler $1=[$]$1]) 458 if test "x`basename [$]$1`" = "x[$]$1"; then 459 # A command without a complete path is provided, search $PATH. 460 461 AC_PATH_PROGS(POTENTIAL_$1, [$]$1) 462 if test "x$POTENTIAL_$1" != x; then 463 $1=$POTENTIAL_$1 464 else 465 AC_MSG_ERROR([User supplied compiler $1=[$]$1 could not be found]) 466 fi 467 else 468 # Otherwise it might already be a complete path 469 if test ! -x "[$]$1"; then 470 AC_MSG_ERROR([User supplied compiler $1=[$]$1 does not exist]) 471 fi 472 fi 473 else 474 # No user supplied value. Locate compiler ourselves. 475 476 # If we are cross compiling, assume cross compilation tools follows the 477 # cross compilation standard where they are prefixed with the autoconf 478 # standard name for the target. For example the binary 479 # i686-sun-solaris2.10-gcc will cross compile for i686-sun-solaris2.10. 480 # If we are not cross compiling, then the default compiler name will be 481 # used. 482 483 $1= 484 # If TOOLCHAIN_PATH is set, check for all compiler names in there first 485 # before checking the rest of the PATH. 486 # FIXME: Now that we prefix the TOOLS_DIR to the PATH in the PRE_DETECTION 487 # step, this should not be necessary. 488 if test -n "$TOOLCHAIN_PATH"; then 489 PATH_save="$PATH" 490 PATH="$TOOLCHAIN_PATH" 491 AC_PATH_PROGS(TOOLCHAIN_PATH_$1, $SEARCH_LIST) 492 $1=$TOOLCHAIN_PATH_$1 493 PATH="$PATH_save" 494 fi 495 496 # AC_PATH_PROGS can't be run multiple times with the same variable, 497 # so create a new name for this run. 498 if test "x[$]$1" = x; then 499 AC_PATH_PROGS(POTENTIAL_$1, $SEARCH_LIST) 500 $1=$POTENTIAL_$1 501 fi 502 503 if test "x[$]$1" = x; then 504 HELP_MSG_MISSING_DEPENDENCY([devkit]) 505 AC_MSG_ERROR([Could not find a $COMPILER_NAME compiler. $HELP_MSG]) 506 fi 507 fi 508 509 # Now we have a compiler binary in $1. Make sure it's okay. 510 BASIC_FIXUP_EXECUTABLE($1) 511 TEST_COMPILER="[$]$1" 512 513 AC_MSG_CHECKING([resolved symbolic links for $1]) 514 SYMLINK_ORIGINAL="$TEST_COMPILER" 515 BASIC_REMOVE_SYMBOLIC_LINKS(SYMLINK_ORIGINAL) 516 if test "x$TEST_COMPILER" = "x$SYMLINK_ORIGINAL"; then 517 AC_MSG_RESULT([no symlink]) 518 else 519 AC_MSG_RESULT([$SYMLINK_ORIGINAL]) 520 521 # We can't handle ccache by gcc wrappers, since we need to know if we're 522 # using ccache. Instead ccache usage must be controlled by a configure option. 523 COMPILER_BASENAME=`$BASENAME "$SYMLINK_ORIGINAL"` 524 if test "x$COMPILER_BASENAME" = "xccache"; then 525 AC_MSG_NOTICE([Please use --enable-ccache instead of providing a wrapped compiler.]) 526 AC_MSG_ERROR([$TEST_COMPILER is a symbolic link to ccache. This is not supported.]) 527 fi 528 fi 529 530 TOOLCHAIN_EXTRACT_COMPILER_VERSION([$1], [$COMPILER_NAME]) 531]) 532 533# Detect the core components of the toolchain, i.e. the compilers (CC and CXX), 534# preprocessor (CPP and CXXCPP), the linker (LD), the assembler (AS) and the 535# archiver (AR). Verify that the compilers are correct according to the 536# toolchain type. 537AC_DEFUN_ONCE([TOOLCHAIN_DETECT_TOOLCHAIN_CORE], 538[ 539 # 540 # Setup the compilers (CC and CXX) 541 # 542 TOOLCHAIN_FIND_COMPILER([CC], [C], $TOOLCHAIN_CC_BINARY) 543 # Now that we have resolved CC ourself, let autoconf have its go at it 544 AC_PROG_CC([$CC]) 545 546 TOOLCHAIN_FIND_COMPILER([CXX], [C++], $TOOLCHAIN_CXX_BINARY) 547 # Now that we have resolved CXX ourself, let autoconf have its go at it 548 AC_PROG_CXX([$CXX]) 549 550 # This is the compiler version number on the form X.Y[.Z] 551 AC_SUBST(CC_VERSION_NUMBER) 552 AC_SUBST(CXX_VERSION_NUMBER) 553 554 TOOLCHAIN_PREPARE_FOR_VERSION_COMPARISONS 555 556 if test "x$TOOLCHAIN_MINIMUM_VERSION" != x; then 557 TOOLCHAIN_CHECK_COMPILER_VERSION(VERSION: $TOOLCHAIN_MINIMUM_VERSION, 558 IF_OLDER_THAN: [ 559 AC_MSG_WARN([You are using $TOOLCHAIN_TYPE older than $TOOLCHAIN_MINIMUM_VERSION. This is not a supported configuration.]) 560 ] 561 ) 562 fi 563 564 # 565 # Setup the preprocessor (CPP and CXXCPP) 566 # 567 AC_PROG_CPP 568 BASIC_FIXUP_EXECUTABLE(CPP) 569 AC_PROG_CXXCPP 570 BASIC_FIXUP_EXECUTABLE(CXXCPP) 571 572 # 573 # Setup the linker (LD) 574 # 575 if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then 576 # In the Microsoft toolchain we have a separate LD command "link". 577 # Make sure we reject /usr/bin/link (as determined in CYGWIN_LINK), which is 578 # a cygwin program for something completely different. 579 AC_CHECK_PROG([LD], [link],[link],,, [$CYGWIN_LINK]) 580 BASIC_FIXUP_EXECUTABLE(LD) 581 # Verify that we indeed succeeded with this trick. 582 AC_MSG_CHECKING([if the found link.exe is actually the Visual Studio linker]) 583 "$LD" --version > /dev/null 584 if test $? -eq 0 ; then 585 AC_MSG_RESULT([no]) 586 AC_MSG_ERROR([This is the Cygwin link tool. Please check your PATH and rerun configure.]) 587 else 588 AC_MSG_RESULT([yes]) 589 fi 590 LDCXX="$LD" 591 else 592 # All other toolchains use the compiler to link. 593 LD="$CC" 594 LDCXX="$CXX" 595 fi 596 AC_SUBST(LD) 597 # FIXME: it should be CXXLD, according to standard (cf CXXCPP) 598 AC_SUBST(LDCXX) 599 600 # 601 # Setup the assembler (AS) 602 # 603 if test "x$OPENJDK_TARGET_OS" = xsolaris; then 604 BASIC_PATH_PROGS(AS, as) 605 BASIC_FIXUP_EXECUTABLE(AS) 606 if test "x$AS" = x; then 607 AC_MSG_ERROR([Solaris assembler (as) is required. Please install via "pkg install pkg:/developer/assembler".]) 608 fi 609 else 610 # FIXME: is this correct for microsoft? 611 AS="$CC -c" 612 fi 613 AC_SUBST(AS) 614 615 # 616 # Setup the archiver (AR) 617 # 618 if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then 619 # The corresponding ar tool is lib.exe (used to create static libraries) 620 AC_CHECK_PROG([AR], [lib],[lib],,,) 621 elif test "x$TOOLCHAIN_TYPE" = xgcc; then 622 BASIC_CHECK_TOOLS(AR, ar gcc-ar) 623 else 624 BASIC_CHECK_TOOLS(AR, ar) 625 fi 626 BASIC_FIXUP_EXECUTABLE(AR) 627]) 628 629# Setup additional tools that is considered a part of the toolchain, but not the 630# core part. Many of these are highly platform-specific and do not exist, 631# and/or are not needed on all platforms. 632AC_DEFUN_ONCE([TOOLCHAIN_DETECT_TOOLCHAIN_EXTRA], 633[ 634 if test "x$OPENJDK_TARGET_OS" = "xmacosx"; then 635 BASIC_PATH_PROGS(LIPO, lipo) 636 BASIC_FIXUP_EXECUTABLE(LIPO) 637 fi 638 639 if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then 640 AC_CHECK_PROG([MT], [mt], [mt],,, [/usr/bin/mt]) 641 BASIC_FIXUP_EXECUTABLE(MT) 642 # Setup the resource compiler (RC) 643 AC_CHECK_PROG([RC], [rc], [rc],,, [/usr/bin/rc]) 644 BASIC_FIXUP_EXECUTABLE(RC) 645 AC_CHECK_PROG([DUMPBIN], [dumpbin], [dumpbin],,,) 646 BASIC_FIXUP_EXECUTABLE(DUMPBIN) 647 # We need to check for 'msbuild.exe' because at the place where we expect to 648 # find 'msbuild.exe' there's also a directory called 'msbuild' and configure 649 # won't find the 'msbuild.exe' executable in that case (and the 650 # 'ac_executable_extensions' is unusable due to performance reasons). 651 # Notice that we intentionally don't fix up the path to MSBUILD because we 652 # will call it in a DOS shell during freetype detection on Windows (see 653 # 'LIB_SETUP_FREETYPE' in "libraries.m4" 654 AC_CHECK_PROG([MSBUILD], [msbuild.exe], [msbuild.exe],,,) 655 fi 656 657 if test "x$OPENJDK_TARGET_OS" = xsolaris; then 658 BASIC_PATH_PROGS(STRIP, strip) 659 BASIC_FIXUP_EXECUTABLE(STRIP) 660 BASIC_PATH_PROGS(NM, nm) 661 BASIC_FIXUP_EXECUTABLE(NM) 662 BASIC_PATH_PROGS(GNM, gnm) 663 BASIC_FIXUP_EXECUTABLE(GNM) 664 elif test "x$OPENJDK_TARGET_OS" != xwindows; then 665 # FIXME: we should unify this with the solaris case above. 666 BASIC_CHECK_TOOLS(STRIP, strip) 667 BASIC_FIXUP_EXECUTABLE(STRIP) 668 if test "x$TOOLCHAIN_TYPE" = xgcc; then 669 BASIC_CHECK_TOOLS(NM, nm gcc-nm) 670 else 671 BASIC_CHECK_TOOLS(NM, nm) 672 fi 673 BASIC_FIXUP_EXECUTABLE(NM) 674 GNM="$NM" 675 AC_SUBST(GNM) 676 fi 677 678 # objcopy is used for moving debug symbols to separate files when 679 # full debug symbols are enabled. 680 if test "x$OPENJDK_TARGET_OS" = xsolaris || test "x$OPENJDK_TARGET_OS" = xlinux; then 681 BASIC_CHECK_TOOLS(OBJCOPY, [gobjcopy objcopy]) 682 # Only call fixup if objcopy was found. 683 if test -n "$OBJCOPY"; then 684 BASIC_FIXUP_EXECUTABLE(OBJCOPY) 685 if test "x$OPENJDK_BUILD_OS" = xsolaris; then 686 # objcopy prior to 2.21.1 on solaris is broken and is not usable. 687 # Rewrite objcopy version output to VALID_VERSION or BAD_VERSION. 688 # - version number is last blank separate word on first line 689 # - version number formats that have been seen: 690 # - <major>.<minor> 691 # - <major>.<minor>.<micro> 692 OBJCOPY_VERSION=`$OBJCOPY --version | $HEAD -n 1` 693 # The outer [ ] is to prevent m4 from eating the [] in the sed expression. 694 [ OBJCOPY_VERSION_CHECK=`$ECHO $OBJCOPY_VERSION | $SED -n \ 695 -e 's/.* //' \ 696 -e '/^[01]\./b bad' \ 697 -e '/^2\./{' \ 698 -e ' s/^2\.//' \ 699 -e ' /^[0-9]$/b bad' \ 700 -e ' /^[0-9]\./b bad' \ 701 -e ' /^1[0-9]$/b bad' \ 702 -e ' /^1[0-9]\./b bad' \ 703 -e ' /^20\./b bad' \ 704 -e ' /^21\.0$/b bad' \ 705 -e ' /^21\.0\./b bad' \ 706 -e '}' \ 707 -e ':good' \ 708 -e 's/.*/VALID_VERSION/p' \ 709 -e 'q' \ 710 -e ':bad' \ 711 -e 's/.*/BAD_VERSION/p' \ 712 -e 'q'` ] 713 if test "x$OBJCOPY_VERSION_CHECK" = xBAD_VERSION; then 714 OBJCOPY= 715 AC_MSG_WARN([Ignoring found objcopy since it is broken (prior to 2.21.1). No debug symbols will be generated.]) 716 AC_MSG_NOTICE([objcopy reports version $OBJCOPY_VERSION]) 717 AC_MSG_NOTICE([Note: patch 149063-01 or newer contains the correct Solaris 10 SPARC version]) 718 AC_MSG_NOTICE([Note: patch 149064-01 or newer contains the correct Solaris 10 X86 version]) 719 AC_MSG_NOTICE([Note: Solaris 11 Update 1 contains the correct version]) 720 fi 721 fi 722 fi 723 fi 724 725 BASIC_CHECK_TOOLS(OBJDUMP, [gobjdump objdump]) 726 if test "x$OBJDUMP" != x; then 727 # Only used for compare.sh; we can live without it. BASIC_FIXUP_EXECUTABLE 728 # bails if argument is missing. 729 BASIC_FIXUP_EXECUTABLE(OBJDUMP) 730 fi 731]) 732 733# Setup the build tools (i.e, the compiler and linker used to build programs 734# that should be run on the build platform, not the target platform, as a build 735# helper). Since the non-cross-compile case uses the normal, target compilers 736# for this, we can only do this after these have been setup. 737AC_DEFUN_ONCE([TOOLCHAIN_SETUP_BUILD_COMPILERS], 738[ 739 if test "x$COMPILE_TYPE" = "xcross"; then 740 # Now we need to find a C/C++ compiler that can build executables for the 741 # build platform. We can't use the AC_PROG_CC macro, since it can only be 742 # used once. Also, we need to do this without adding a tools dir to the 743 # path, otherwise we might pick up cross-compilers which don't use standard 744 # naming. 745 746 OLDPATH="$PATH" 747 748 AC_ARG_WITH(build-devkit, [AS_HELP_STRING([--with-build-devkit], 749 [Devkit to use for the build platform toolchain])]) 750 if test "x$with_build_devkit" = "xyes"; then 751 AC_MSG_ERROR([--with-build-devkit must have a value]) 752 elif test -n "$with_build_devkit"; then 753 if test ! -d "$with_build_devkit"; then 754 AC_MSG_ERROR([--with-build-devkit points to non existing dir: $with_build_devkit]) 755 else 756 BASIC_FIXUP_PATH([with_build_devkit]) 757 BUILD_DEVKIT_ROOT="$with_build_devkit" 758 # Check for a meta data info file in the root of the devkit 759 if test -f "$BUILD_DEVKIT_ROOT/devkit.info"; then 760 # Process devkit.info so that existing devkit variables are not 761 # modified by this 762 $SED -e "s/^DEVKIT_/BUILD_DEVKIT_/g" \ 763 -e "s/\$DEVKIT_ROOT/\$BUILD_DEVKIT_ROOT/g" \ 764 -e "s/\$host/\$build/g" \ 765 $BUILD_DEVKIT_ROOT/devkit.info \ 766 > $CONFIGURESUPPORT_OUTPUTDIR/build-devkit.info 767 . $CONFIGURESUPPORT_OUTPUTDIR/build-devkit.info 768 # This potentially sets the following: 769 # A descriptive name of the devkit 770 BASIC_EVAL_DEVKIT_VARIABLE([BUILD_DEVKIT_NAME]) 771 # Corresponds to --with-extra-path 772 BASIC_EVAL_DEVKIT_VARIABLE([BUILD_DEVKIT_EXTRA_PATH]) 773 # Corresponds to --with-toolchain-path 774 BASIC_EVAL_DEVKIT_VARIABLE([BUILD_DEVKIT_TOOLCHAIN_PATH]) 775 # Corresponds to --with-sysroot 776 BASIC_EVAL_DEVKIT_VARIABLE([BUILD_DEVKIT_SYSROOT]) 777 # Skip the Window specific parts 778 fi 779 780 AC_MSG_CHECKING([for build platform devkit]) 781 if test "x$BUILD_DEVKIT_NAME" != x; then 782 AC_MSG_RESULT([$BUILD_DEVKIT_NAME in $BUILD_DEVKIT_ROOT]) 783 else 784 AC_MSG_RESULT([$BUILD_DEVKIT_ROOT]) 785 fi 786 787 BUILD_SYSROOT="$BUILD_DEVKIT_SYSROOT" 788 FLAGS_SETUP_SYSROOT_FLAGS([BUILD_]) 789 790 # Fallback default of just /bin if DEVKIT_PATH is not defined 791 if test "x$BUILD_DEVKIT_TOOLCHAIN_PATH" = x; then 792 BUILD_DEVKIT_TOOLCHAIN_PATH="$BUILD_DEVKIT_ROOT/bin" 793 fi 794 PATH="$BUILD_DEVKIT_TOOLCHAIN_PATH:$BUILD_DEVKIT_EXTRA_PATH" 795 fi 796 fi 797 798 # FIXME: we should list the discovered compilers as an exclude pattern! 799 # If we do that, we can do this detection before POST_DETECTION, and still 800 # find the build compilers in the tools dir, if needed. 801 BASIC_REQUIRE_PROGS(BUILD_CC, [cl cc gcc]) 802 BASIC_FIXUP_EXECUTABLE(BUILD_CC) 803 BASIC_REQUIRE_PROGS(BUILD_CXX, [cl CC g++]) 804 BASIC_FIXUP_EXECUTABLE(BUILD_CXX) 805 BASIC_PATH_PROGS(BUILD_NM, nm gcc-nm) 806 BASIC_FIXUP_EXECUTABLE(BUILD_NM) 807 BASIC_PATH_PROGS(BUILD_AR, ar gcc-ar) 808 BASIC_FIXUP_EXECUTABLE(BUILD_AR) 809 BASIC_PATH_PROGS(BUILD_OBJCOPY, objcopy) 810 BASIC_FIXUP_EXECUTABLE(BUILD_OBJCOPY) 811 BASIC_PATH_PROGS(BUILD_STRIP, strip) 812 BASIC_FIXUP_EXECUTABLE(BUILD_STRIP) 813 # Assume the C compiler is the assembler 814 BUILD_AS="$BUILD_CC -c" 815 # Just like for the target compiler, use the compiler as linker 816 BUILD_LD="$BUILD_CC" 817 BUILD_LDCXX="$BUILD_CXX" 818 819 PATH="$OLDPATH" 820 821 TOOLCHAIN_EXTRACT_COMPILER_VERSION(BUILD_CC, [BuildC]) 822 TOOLCHAIN_EXTRACT_COMPILER_VERSION(BUILD_CXX, [BuildC++]) 823 TOOLCHAIN_PREPARE_FOR_VERSION_COMPARISONS([BUILD_], [OPENJDK_BUILD_]) 824 else 825 # If we are not cross compiling, use the normal target compilers for 826 # building the build platform executables. 827 BUILD_CC="$CC" 828 BUILD_CXX="$CXX" 829 BUILD_LD="$LD" 830 BUILD_LDCXX="$LDCXX" 831 BUILD_NM="$NM" 832 BUILD_AS="$AS" 833 BUILD_OBJCOPY="$OBJCOPY" 834 BUILD_STRIP="$STRIP" 835 BUILD_SYSROOT_CFLAGS="$SYSROOT_CFLAGS" 836 BUILD_SYSROOT_LDFLAGS="$SYSROOT_LDFLAGS" 837 BUILD_AR="$AR" 838 fi 839 840 AC_SUBST(BUILD_CC) 841 AC_SUBST(BUILD_CXX) 842 AC_SUBST(BUILD_LD) 843 AC_SUBST(BUILD_LDCXX) 844 AC_SUBST(BUILD_NM) 845 AC_SUBST(BUILD_AS) 846 AC_SUBST(BUILD_SYSROOT_CFLAGS) 847 AC_SUBST(BUILD_SYSROOT_LDFLAGS) 848 AC_SUBST(BUILD_AR) 849]) 850 851# Setup legacy variables that are still needed as alternative ways to refer to 852# parts of the toolchain. 853AC_DEFUN_ONCE([TOOLCHAIN_SETUP_LEGACY], 854[ 855 if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then 856 # For hotspot, we need these in Windows mixed path, 857 # so rewrite them all. Need added .exe suffix. 858 HOTSPOT_CXX="$CXX.exe" 859 HOTSPOT_LD="$LD.exe" 860 HOTSPOT_MT="$MT.exe" 861 HOTSPOT_RC="$RC.exe" 862 BASIC_WINDOWS_REWRITE_AS_WINDOWS_MIXED_PATH(HOTSPOT_CXX) 863 BASIC_WINDOWS_REWRITE_AS_WINDOWS_MIXED_PATH(HOTSPOT_LD) 864 BASIC_WINDOWS_REWRITE_AS_WINDOWS_MIXED_PATH(HOTSPOT_MT) 865 BASIC_WINDOWS_REWRITE_AS_WINDOWS_MIXED_PATH(HOTSPOT_RC) 866 AC_SUBST(HOTSPOT_MT) 867 AC_SUBST(HOTSPOT_RC) 868 else 869 HOTSPOT_CXX="$CXX" 870 HOTSPOT_LD="$LD" 871 fi 872 AC_SUBST(HOTSPOT_CXX) 873 AC_SUBST(HOTSPOT_LD) 874 875 if test "x$TOOLCHAIN_TYPE" = xclang; then 876 USE_CLANG=true 877 fi 878 AC_SUBST(USE_CLANG) 879]) 880 881# Do some additional checks on the detected tools. 882AC_DEFUN_ONCE([TOOLCHAIN_MISC_CHECKS], 883[ 884 # The package path is used only on macosx? 885 # FIXME: clean this up, and/or move it elsewhere. 886 PACKAGE_PATH=/opt/local 887 AC_SUBST(PACKAGE_PATH) 888 889 # Check for extra potential brokenness. 890 if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then 891 # On Windows, double-check that we got the right compiler. 892 CC_VERSION_OUTPUT=`$CC 2>&1 | $HEAD -n 1 | $TR -d '\r'` 893 COMPILER_CPU_TEST=`$ECHO $CC_VERSION_OUTPUT | $SED -n "s/^.* \(.*\)$/\1/p"` 894 if test "x$OPENJDK_TARGET_CPU" = "xx86"; then 895 if test "x$COMPILER_CPU_TEST" != "x80x86" -a "x$COMPILER_CPU_TEST" != "xx86"; then 896 AC_MSG_ERROR([Target CPU mismatch. We are building for $OPENJDK_TARGET_CPU but CL is for "$COMPILER_CPU_TEST"; expected "80x86" or "x86".]) 897 fi 898 elif test "x$OPENJDK_TARGET_CPU" = "xx86_64"; then 899 if test "x$COMPILER_CPU_TEST" != "xx64"; then 900 AC_MSG_ERROR([Target CPU mismatch. We are building for $OPENJDK_TARGET_CPU but CL is for "$COMPILER_CPU_TEST"; expected "x64".]) 901 fi 902 fi 903 fi 904 905 if test "x$TOOLCHAIN_TYPE" = xgcc; then 906 # If this is a --hash-style=gnu system, use --hash-style=both, why? 907 HAS_GNU_HASH=`$CC -dumpspecs 2>/dev/null | $GREP 'hash-style=gnu'` 908 # This is later checked when setting flags. 909 910 # "-Og" suppported for GCC 4.8 and later 911 CFLAG_OPTIMIZE_DEBUG_FLAG="-Og" 912 FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [$CFLAG_OPTIMIZE_DEBUG_FLAG], 913 IF_TRUE: [HAS_CFLAG_OPTIMIZE_DEBUG=true], 914 IF_FALSE: [HAS_CFLAG_OPTIMIZE_DEBUG=false]) 915 916 # "-z relro" supported in GNU binutils 2.17 and later 917 LINKER_RELRO_FLAG="-Wl,-z,relro" 918 FLAGS_LINKER_CHECK_ARGUMENTS(ARGUMENT: [$LINKER_RELRO_FLAG], 919 IF_TRUE: [HAS_LINKER_RELRO=true], 920 IF_FALSE: [HAS_LINKER_RELRO=false]) 921 922 # "-z now" supported in GNU binutils 2.11 and later 923 LINKER_NOW_FLAG="-Wl,-z,now" 924 FLAGS_LINKER_CHECK_ARGUMENTS(ARGUMENT: [$LINKER_NOW_FLAG], 925 IF_TRUE: [HAS_LINKER_NOW=true], 926 IF_FALSE: [HAS_LINKER_NOW=false]) 927 fi 928 929 # Check for broken SuSE 'ld' for which 'Only anonymous version tag is allowed 930 # in executable.' 931 USING_BROKEN_SUSE_LD=no 932 if test "x$OPENJDK_TARGET_OS" = xlinux && test "x$TOOLCHAIN_TYPE" = xgcc; then 933 AC_MSG_CHECKING([for broken SuSE 'ld' which only understands anonymous version tags in executables]) 934 $ECHO "SUNWprivate_1.1 { local: *; };" > version-script.map 935 $ECHO "int main() { }" > main.c 936 if $CXX -Wl,-version-script=version-script.map main.c 2>&AS_MESSAGE_LOG_FD >&AS_MESSAGE_LOG_FD; then 937 AC_MSG_RESULT(no) 938 USING_BROKEN_SUSE_LD=no 939 else 940 AC_MSG_RESULT(yes) 941 USING_BROKEN_SUSE_LD=yes 942 fi 943 $RM version-script.map main.c a.out 944 fi 945 AC_SUBST(USING_BROKEN_SUSE_LD) 946 947 # Setup hotspot lecagy names for toolchains 948 HOTSPOT_TOOLCHAIN_TYPE=$TOOLCHAIN_TYPE 949 if test "x$TOOLCHAIN_TYPE" = xclang; then 950 HOTSPOT_TOOLCHAIN_TYPE=gcc 951 elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then 952 HOTSPOT_TOOLCHAIN_TYPE=sparcWorks 953 elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then 954 HOTSPOT_TOOLCHAIN_TYPE=visCPP 955 fi 956 AC_SUBST(HOTSPOT_TOOLCHAIN_TYPE) 957]) 958 959# Setup the JTReg Regression Test Harness. 960AC_DEFUN_ONCE([TOOLCHAIN_SETUP_JTREG], 961[ 962 AC_ARG_WITH(jtreg, [AS_HELP_STRING([--with-jtreg], 963 [Regression Test Harness @<:@probed@:>@])], 964 [], 965 [with_jtreg=no]) 966 967 if test "x$with_jtreg" = xno; then 968 # jtreg disabled 969 AC_MSG_CHECKING([for jtreg]) 970 AC_MSG_RESULT(no) 971 else 972 if test "x$with_jtreg" != xyes; then 973 # with path specified. 974 JT_HOME="$with_jtreg" 975 fi 976 977 if test "x$JT_HOME" != x; then 978 AC_MSG_CHECKING([for jtreg]) 979 980 # use JT_HOME enviroment var. 981 BASIC_FIXUP_PATH([JT_HOME]) 982 983 # jtreg win32 script works for everybody 984 JTREGEXE="$JT_HOME/bin/jtreg" 985 986 if test ! -f "$JTREGEXE"; then 987 AC_MSG_ERROR([JTReg executable does not exist: $JTREGEXE]) 988 fi 989 990 AC_MSG_RESULT($JTREGEXE) 991 else 992 # try to find jtreg on path 993 BASIC_REQUIRE_PROGS(JTREGEXE, jtreg) 994 JT_HOME="`$DIRNAME $JTREGEXE`" 995 fi 996 fi 997 998 AC_SUBST(JT_HOME) 999 AC_SUBST(JTREGEXE) 1000]) 1001