1 # 2 # Copyright (c) 2011, 2014, 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 # Setup a number of variables describing how native output files are 36 # named on this platform/toolchain. 37 AC_DEFUN([TOOLCHAIN_SETUP_FILENAME_PATTERNS], 38 [ 39 # Define filename patterns 40 if test "x$OPENJDK_TARGET_OS" = xwindows; then 41 LIBRARY_PREFIX= 42 SHARED_LIBRARY_SUFFIX='.dll' 43 STATIC_LIBRARY_SUFFIX='.lib' 44 SHARED_LIBRARY='[$]1.dll' 45 STATIC_LIBRARY='[$]1.lib' 46 OBJ_SUFFIX='.obj' 47 EXE_SUFFIX='.exe' 48 else 49 LIBRARY_PREFIX=lib 50 SHARED_LIBRARY_SUFFIX='.so' 51 STATIC_LIBRARY_SUFFIX='.a' 52 SHARED_LIBRARY='lib[$]1.so' 53 STATIC_LIBRARY='lib[$]1.a' 54 OBJ_SUFFIX='.o' 55 EXE_SUFFIX='' 56 if test "x$OPENJDK_TARGET_OS" = xmacosx; then 57 SHARED_LIBRARY='lib[$]1.dylib' 58 SHARED_LIBRARY_SUFFIX='.dylib' 59 fi 60 fi 61 62 AC_SUBST(LIBRARY_PREFIX) 63 AC_SUBST(SHARED_LIBRARY_SUFFIX) 64 AC_SUBST(STATIC_LIBRARY_SUFFIX) 65 AC_SUBST(SHARED_LIBRARY) 66 AC_SUBST(STATIC_LIBRARY) 67 AC_SUBST(OBJ_SUFFIX) 68 AC_SUBST(EXE_SUFFIX) 69 ]) 70 71 # Determine which toolchain type to use, and make sure it is valid for this 72 # platform. Setup various information about the selected toolchain. 73 AC_DEFUN_ONCE([TOOLCHAIN_DETERMINE_TOOLCHAIN_TYPE], 74 [ 75 AVAILABLE_TOOLCHAINS_linux="gcc clang solstudio xlc" 76 AVAILABLE_TOOLCHAINS_solaris="solstudio gcc clang" 77 AVAILABLE_TOOLCHAINS_macosx="gcc clang" 78 AVAILABLE_TOOLCHAINS_aix="xlc gcc" 79 AVAILABLE_TOOLCHAINS_windows="microsoft gcc" 80 81 TOOLCHAIN_DESCRIPTION_clang="clang/LLVM" 82 TOOLCHAIN_DESCRIPTION_gcc="GNU Compiler Collection" 83 TOOLCHAIN_DESCRIPTION_microsoft="Microsoft Visual Studio" 84 TOOLCHAIN_DESCRIPTION_solstudio="Oracle Solaris Studio" 85 TOOLCHAIN_DESCRIPTION_xlc="IBM XL C/C++" 86 87 AC_ARG_WITH(toolchain-type, [AS_HELP_STRING([--with-toolchain-type], 88 [the toolchain type (or family) to use, 'list' to show all available @<:@platform dependent@:>@])]) 89 90 # Use indirect variable referencing 91 toolchain_var_name=AVAILABLE_TOOLCHAINS_$OPENJDK_BUILD_OS 92 AVAILABLE_TOOLCHAINS=${!toolchain_var_name} 93 # First toolchain type in the list is the default 94 DEFAULT_TOOLCHAIN=${AVAILABLE_TOOLCHAINS%% *} 95 96 if test "x$with_toolchain_type" = xlist; then 97 # List all toolchains 98 AC_MSG_NOTICE([The following toolchains are available on this platform:]) 99 for toolchain in $AVAILABLE_TOOLCHAINS; do 100 toolchain_var_name=TOOLCHAIN_DESCRIPTION_$toolchain 101 TOOLCHAIN_DESCRIPTION=${!toolchain_var_name} 102 $PRINTF " %-10s %s\n" $toolchain "$TOOLCHAIN_DESCRIPTION" 103 done 104 105 exit 0 106 elif test "x$with_toolchain_type" != x; then 107 # User override; check that it is valid 108 if test "x${AVAILABLE_TOOLCHAINS/$with_toolchain_type/}" = "x${AVAILABLE_TOOLCHAINS}"; then 109 AC_MSG_NOTICE([Toolchain type $with_toolchain_type is not valid on this platform.]) 110 AC_MSG_NOTICE([Available toolchains: $AVAILABLE_TOOLCHAINS.]) 111 AC_MSG_ERROR([Cannot continue.]) 112 fi 113 TOOLCHAIN_TYPE=$with_toolchain_type 114 else 115 # No flag given, use default 116 TOOLCHAIN_TYPE=$DEFAULT_TOOLCHAIN 117 fi 118 119 TOOLCHAIN_CC_BINARY_clang="clang" 120 TOOLCHAIN_CC_BINARY_gcc="gcc" 121 TOOLCHAIN_CC_BINARY_microsoft="cl" 122 TOOLCHAIN_CC_BINARY_solstudio="cc" 123 TOOLCHAIN_CC_BINARY_xlc="xlc_r" 124 125 TOOLCHAIN_CXX_BINARY_clang="clang++" 126 TOOLCHAIN_CXX_BINARY_gcc="g++" 127 TOOLCHAIN_CXX_BINARY_microsoft="cl" 128 TOOLCHAIN_CXX_BINARY_solstudio="CC" 129 TOOLCHAIN_CXX_BINARY_xlc="xlC_r" 130 131 # Use indirect variable referencing 132 toolchain_var_name=TOOLCHAIN_DESCRIPTION_$TOOLCHAIN_TYPE 133 TOOLCHAIN_DESCRIPTION=${!toolchain_var_name} 134 toolchain_var_name=TOOLCHAIN_CC_BINARY_$TOOLCHAIN_TYPE 135 TOOLCHAIN_CC_BINARY=${!toolchain_var_name} 136 toolchain_var_name=TOOLCHAIN_CXX_BINARY_$TOOLCHAIN_TYPE 137 TOOLCHAIN_CXX_BINARY=${!toolchain_var_name} 138 139 TOOLCHAIN_SETUP_FILENAME_PATTERNS 140 141 if test "x$TOOLCHAIN_TYPE" = "x$DEFAULT_TOOLCHAIN"; then 142 AC_MSG_NOTICE([Using default toolchain $TOOLCHAIN_TYPE ($TOOLCHAIN_DESCRIPTION)]) 143 else 144 AC_MSG_NOTICE([Using user selected toolchain $TOOLCHAIN_TYPE ($TOOLCHAIN_DESCRIPTION). Default toolchain is $DEFAULT_TOOLCHAIN.]) 145 fi 146 ]) 147 148 # Before we start detecting the toolchain executables, we might need some 149 # special setup, e.g. additional paths etc. 150 AC_DEFUN_ONCE([TOOLCHAIN_PRE_DETECTION], 151 [ 152 # FIXME: Is this needed? 153 AC_LANG(C++) 154 155 # Store the CFLAGS etc passed to the configure script. 156 ORG_CFLAGS="$CFLAGS" 157 ORG_CXXFLAGS="$CXXFLAGS" 158 ORG_OBJCFLAGS="$OBJCFLAGS" 159 160 # autoconf magic only relies on PATH, so update it if tools dir is specified 161 OLD_PATH="$PATH" 162 163 # For solaris we really need solaris tools, and not the GNU equivalent. 164 # The build tools on Solaris reside in /usr/ccs (C Compilation System), 165 # so add that to path before starting to probe. 166 # FIXME: This was originally only done for AS,NM,GNM,STRIP,MCS,OBJCOPY,OBJDUMP. 167 if test "x$OPENJDK_BUILD_OS" = xsolaris; then 168 PATH="/usr/ccs/bin:$PATH" 169 fi 170 171 # On Windows, we need to detext the visual studio installation first. 172 if test "x$OPENJDK_BUILD_OS" = "xwindows"; then 173 TOOLCHAIN_SETUP_VISUAL_STUDIO_ENV 174 fi 175 176 # Finally add TOOLS_DIR at the beginning, to allow --with-tools-dir to 177 # override all other locations. 178 if test "x$TOOLS_DIR" != x; then 179 PATH=$TOOLS_DIR:$PATH 180 fi 181 182 # If a devkit is found on the builddeps server, then prepend its path to the 183 # PATH variable. If there are cross compilers available in the devkit, these 184 # will be found by AC_PROG_CC et al. 185 DEVKIT= 186 BDEPS_CHECK_MODULE(DEVKIT, devkit, xxx, 187 [ 188 # Found devkit 189 PATH="$DEVKIT/bin:$PATH" 190 SYS_ROOT="$DEVKIT/${rewritten_target}/sys-root" 191 if test "x$x_includes" = "xNONE"; then 192 x_includes="$SYS_ROOT/usr/include/X11" 193 fi 194 if test "x$x_libraries" = "xNONE"; then 195 x_libraries="$SYS_ROOT/usr/lib" 196 fi 197 ], 198 []) 199 ]) 200 201 # Restore path, etc 202 AC_DEFUN_ONCE([TOOLCHAIN_POST_DETECTION], 203 [ 204 # Restore old path. 205 PATH="$OLD_PATH" 206 207 # Restore the flags to the user specified values. 208 # This is necessary since AC_PROG_CC defaults CFLAGS to "-g -O2" 209 CFLAGS="$ORG_CFLAGS" 210 CXXFLAGS="$ORG_CXXFLAGS" 211 OBJCFLAGS="$ORG_OBJCFLAGS" 212 ]) 213 214 # Check if a compiler is of the toolchain type we expect, and save the version 215 # information from it. If the compiler does not match the expected type, 216 # this function will abort using AC_MSG_ERROR. If it matches, the version will 217 # be stored in CC_VERSION_NUMBER/CXX_VERSION_NUMBER (as a dotted number), and 218 # the full version string in CC_VERSION_STRING/CXX_VERSION_STRING. 219 # 220 # $1 = compiler to test (CC or CXX) 221 # $2 = human readable name of compiler (C or C++) 222 AC_DEFUN([TOOLCHAIN_CHECK_COMPILER_VERSION], 223 [ 224 COMPILER=[$]$1 225 COMPILER_NAME=$2 226 227 if test "x$TOOLCHAIN_TYPE" = xsolstudio; then 228 # cc -V output typically looks like 229 # cc: Sun C 5.12 Linux_i386 2011/11/16 230 COMPILER_VERSION_OUTPUT=`$COMPILER -V 2>&1` 231 # Check that this is likely to be the Solaris Studio cc. 232 $ECHO "$COMPILER_VERSION_OUTPUT" | $GREP "^.*: Sun $COMPILER_NAME" > /dev/null 233 if test $? -ne 0; then 234 ALT_VERSION_OUTPUT=`$COMPILER --version 2>&1` 235 AC_MSG_NOTICE([The $COMPILER_NAME compiler (located as $COMPILER) does not seem to be the required $TOOLCHAIN_TYPE compiler.]) 236 AC_MSG_NOTICE([The result from running with -V was: "$COMPILER_VERSION_OUTPUT"]) 237 AC_MSG_NOTICE([The result from running with --version was: "$ALT_VERSION_OUTPUT"]) 238 AC_MSG_ERROR([A $TOOLCHAIN_TYPE compiler is required. Try setting --with-tools-dir.]) 239 fi 240 # Remove usage instructions (if present), and 241 # collapse compiler output into a single line 242 COMPILER_VERSION_STRING=`$ECHO $COMPILER_VERSION_OUTPUT | $SED -e 's/ *[Uu]sage:.*//'` 243 COMPILER_VERSION_STRING=`$ECHO $COMPILER_VERSION_OUTPUT` 244 COMPILER_VERSION_NUMBER=`$ECHO $COMPILER_VERSION_OUTPUT | $SED -e "s/^.*@<:@ ,\t@:>@$COMPILER_NAME@<:@ ,\t@:>@\(@<:@1-9@:>@\.@<:@0-9@:>@@<:@0-9@:>@*\).*/\1/"` 245 elif test "x$TOOLCHAIN_TYPE" = xxlc; then 246 # xlc -qversion output typically looks like 247 # IBM XL C/C++ for AIX, V11.1 (5724-X13) 248 # Version: 11.01.0000.0015 249 COMPILER_VERSION_OUTPUT=`$COMPILER -qversion 2>&1` 250 # Check that this is likely to be the IBM XL C compiler. 251 $ECHO "$COMPILER_VERSION_OUTPUT" | $GREP "IBM XL C" > /dev/null 252 if test $? -ne 0; then 253 ALT_VERSION_OUTPUT=`$COMPILER --version 2>&1` 254 AC_MSG_NOTICE([The $COMPILER_NAME compiler (located as $COMPILER) does not seem to be the required $TOOLCHAIN_TYPE compiler.]) 255 AC_MSG_NOTICE([The result from running with -qversion was: "$COMPILER_VERSION_OUTPUT"]) 256 AC_MSG_NOTICE([The result from running with --version was: "$ALT_VERSION_OUTPUT"]) 257 AC_MSG_ERROR([A $TOOLCHAIN_TYPE compiler is required. Try setting --with-tools-dir.]) 258 fi 259 # Collapse compiler output into a single line 260 COMPILER_VERSION_STRING=`$ECHO $COMPILER_VERSION_OUTPUT` 261 COMPILER_VERSION_NUMBER=`$ECHO $COMPILER_VERSION_OUTPUT | $SED -e 's/^.*, V\(@<:@1-9@:>@@<:@0-9.@:>@*\).*$/\1/'` 262 elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then 263 # There is no specific version flag, but all output starts with a version string. 264 # First line typically looks something like: 265 # Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.40219.01 for 80x86 266 COMPILER_VERSION_OUTPUT=`$COMPILER 2>&1 | $HEAD -n 1 | $TR -d '\r'` 267 # Check that this is likely to be Microsoft CL.EXE. 268 $ECHO "$COMPILER_VERSION_OUTPUT" | $GREP "Microsoft.*Compiler" > /dev/null 269 if test $? -ne 0; then 270 AC_MSG_NOTICE([The $COMPILER_NAME compiler (located as $COMPILER) does not seem to be the required $TOOLCHAIN_TYPE compiler.]) 271 AC_MSG_NOTICE([The result from running it was: "$COMPILER_VERSION_OUTPUT"]) 272 AC_MSG_ERROR([A $TOOLCHAIN_TYPE compiler is required. Try setting --with-tools-dir.]) 273 fi 274 # Collapse compiler output into a single line 275 COMPILER_VERSION_STRING=`$ECHO $COMPILER_VERSION_OUTPUT` 276 COMPILER_VERSION_NUMBER=`$ECHO $COMPILER_VERSION_OUTPUT | $SED -e 's/^.*ersion.\(@<:@1-9@:>@@<:@0-9.@:>@*\) .*$/\1/'` 277 elif test "x$TOOLCHAIN_TYPE" = xgcc; then 278 # gcc --version output typically looks like 279 # gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1 280 # Copyright (C) 2013 Free Software Foundation, Inc. 281 # This is free software; see the source for copying conditions. There is NO 282 # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 283 COMPILER_VERSION_OUTPUT=`$COMPILER --version 2>&1` 284 # Check that this is likely to be GCC. 285 $ECHO "$COMPILER_VERSION_OUTPUT" | $GREP "Free Software Foundation" > /dev/null 286 if test $? -ne 0; then 287 AC_MSG_NOTICE([The $COMPILER_NAME compiler (located as $COMPILER) does not seem to be the required $TOOLCHAIN_TYPE compiler.]) 288 AC_MSG_NOTICE([The result from running with --version was: "$COMPILER_VERSION"]) 289 AC_MSG_ERROR([A $TOOLCHAIN_TYPE compiler is required. Try setting --with-tools-dir.]) 290 fi 291 # Remove Copyright and legalese from version string, and 292 # collapse into a single line 293 COMPILER_VERSION_STRING=`$ECHO $COMPILER_VERSION_OUTPUT | $SED -e 's/ *Copyright .*//'` 294 COMPILER_VERSION_NUMBER=`$ECHO $COMPILER_VERSION_OUTPUT | $SED -e 's/^.* \(@<:@1-9@:>@\.@<:@0-9.@:>@*\) .*$/\1/'` 295 elif test "x$TOOLCHAIN_TYPE" = xclang; then 296 # clang --version output typically looks like 297 # Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn) 298 # clang version 3.3 (tags/RELEASE_33/final) 299 # or 300 # Debian clang version 3.2-7ubuntu1 (tags/RELEASE_32/final) (based on LLVM 3.2) 301 # Target: x86_64-pc-linux-gnu 302 # Thread model: posix 303 COMPILER_VERSION_OUTPUT=`$COMPILER --version 2>&1` 304 # Check that this is likely to be clang 305 $ECHO "$COMPILER_VERSION_OUTPUT" | $GREP "clang" > /dev/null 306 if test $? -ne 0; then 307 AC_MSG_NOTICE([The $COMPILER_NAME compiler (located as $COMPILER) does not seem to be the required $TOOLCHAIN_TYPE compiler.]) 308 AC_MSG_NOTICE([The result from running with --version was: "$COMPILER_VERSION_OUTPUT"]) 309 AC_MSG_ERROR([A $TOOLCHAIN_TYPE compiler is required. Try setting --with-tools-dir.]) 310 fi 311 # Collapse compiler output into a single line 312 COMPILER_VERSION_STRING=`$ECHO $COMPILER_VERSION_OUTPUT` 313 COMPILER_VERSION_NUMBER=`$ECHO $COMPILER_VERSION_OUTPUT | $SED -e 's/^.*clang version \(@<:@1-9@:>@@<:@0-9.@:>@*\).*$/\1/'` 314 else 315 AC_MSG_ERROR([Unknown toolchain type $TOOLCHAIN_TYPE.]) 316 fi 317 # This sets CC_VERSION_NUMBER or CXX_VERSION_NUMBER. (This comment is a grep marker) 318 $1_VERSION_NUMBER="$COMPILER_VERSION_NUMBER" 319 # This sets CC_VERSION_STRING or CXX_VERSION_STRING. (This comment is a grep marker) 320 $1_VERSION_STRING="$COMPILER_VERSION_STRING" 321 322 AC_MSG_NOTICE([Using $TOOLCHAIN_TYPE $COMPILER_NAME compiler version $COMPILER_VERSION_NUMBER @<:@$COMPILER_VERSION_STRING@:>@]) 323 ]) 324 325 # Try to locate the given C or C++ compiler in the path, or otherwise. 326 # 327 # $1 = compiler to test (CC or CXX) 328 # $2 = human readable name of compiler (C or C++) 329 # $3 = list of compiler names to search for 330 AC_DEFUN([TOOLCHAIN_FIND_COMPILER], 331 [ 332 COMPILER_NAME=$2 333 SEARCH_LIST="$3" 334 335 if test "x[$]$1" != x; then 336 # User has supplied compiler name already, always let that override. 337 AC_MSG_NOTICE([Will use user supplied compiler $1=[$]$1]) 338 if test "x`basename [$]$1`" = "x[$]$1"; then 339 # A command without a complete path is provided, search $PATH. 340 341 AC_PATH_PROGS(POTENTIAL_$1, [$]$1) 342 if test "x$POTENTIAL_$1" != x; then 343 $1=$POTENTIAL_$1 344 else 345 AC_MSG_ERROR([User supplied compiler $1=[$]$1 could not be found]) 346 fi 347 else 348 # Otherwise it might already be a complete path 349 if test ! -x "[$]$1"; then 350 AC_MSG_ERROR([User supplied compiler $1=[$]$1 does not exist]) 351 fi 352 fi 353 else 354 # No user supplied value. Locate compiler ourselves. 355 356 # If we are cross compiling, assume cross compilation tools follows the 357 # cross compilation standard where they are prefixed with the autoconf 358 # standard name for the target. For example the binary 359 # i686-sun-solaris2.10-gcc will cross compile for i686-sun-solaris2.10. 360 # If we are not cross compiling, then the default compiler name will be 361 # used. 362 363 $1= 364 # If TOOLS_DIR is set, check for all compiler names in there first 365 # before checking the rest of the PATH. 366 # FIXME: Now that we prefix the TOOLS_DIR to the PATH in the PRE_DETECTION 367 # step, this should not be necessary. 368 if test -n "$TOOLS_DIR"; then 369 PATH_save="$PATH" 370 PATH="$TOOLS_DIR" 371 AC_PATH_PROGS(TOOLS_DIR_$1, $SEARCH_LIST) 372 $1=$TOOLS_DIR_$1 373 PATH="$PATH_save" 374 fi 375 376 # AC_PATH_PROGS can't be run multiple times with the same variable, 377 # so create a new name for this run. 378 if test "x[$]$1" = x; then 379 AC_PATH_PROGS(POTENTIAL_$1, $SEARCH_LIST) 380 $1=$POTENTIAL_$1 381 fi 382 383 if test "x[$]$1" = x; then 384 HELP_MSG_MISSING_DEPENDENCY([devkit]) 385 AC_MSG_ERROR([Could not find a $COMPILER_NAME compiler. $HELP_MSG]) 386 fi 387 fi 388 389 # Now we have a compiler binary in $1. Make sure it's okay. 390 BASIC_FIXUP_EXECUTABLE($1) 391 TEST_COMPILER="[$]$1" 392 # Don't remove symbolic links on AIX because 'xlc_r' and 'xlC_r' may all be links 393 # to 'xlc' but it is crucial that we invoke the compiler with the right name! 394 if test "x$OPENJDK_BUILD_OS" != xaix; then 395 # FIXME: This test should not be needed anymore; we don't do that for any platform. 396 AC_MSG_CHECKING([resolved symbolic links for $1]) 397 BASIC_REMOVE_SYMBOLIC_LINKS(TEST_COMPILER) 398 AC_MSG_RESULT([$TEST_COMPILER]) 399 fi 400 AC_MSG_CHECKING([if $1 is disguised ccache]) 401 402 COMPILER_BASENAME=`$BASENAME "$TEST_COMPILER"` 403 if test "x$COMPILER_BASENAME" = "xccache"; then 404 AC_MSG_RESULT([yes, trying to find proper $COMPILER_NAME compiler]) 405 # We /usr/lib/ccache in the path, so cc is a symlink to /usr/bin/ccache. 406 # We want to control ccache invocation ourselves, so ignore this cc and try 407 # searching again. 408 409 # Remove the path to the fake ccache cc from the PATH 410 RETRY_COMPILER_SAVED_PATH="$PATH" 411 COMPILER_DIRNAME=`$DIRNAME [$]$1` 412 PATH="`$ECHO $PATH | $SED -e "s,$COMPILER_DIRNAME,,g" -e "s,::,:,g" -e "s,^:,,g"`" 413 414 # Try again looking for our compiler 415 AC_CHECK_TOOLS(PROPER_COMPILER_$1, $3) 416 BASIC_FIXUP_EXECUTABLE(PROPER_COMPILER_$1) 417 PATH="$RETRY_COMPILER_SAVED_PATH" 418 419 AC_MSG_CHECKING([for resolved symbolic links for $1]) 420 BASIC_REMOVE_SYMBOLIC_LINKS(PROPER_COMPILER_$1) 421 AC_MSG_RESULT([$PROPER_COMPILER_$1]) 422 $1="$PROPER_COMPILER_$1" 423 else 424 AC_MSG_RESULT([no, keeping $1]) 425 fi 426 427 TOOLCHAIN_CHECK_COMPILER_VERSION([$1], [$COMPILER_NAME]) 428 ]) 429 430 # Detect the core components of the toolchain, i.e. the compilers (CC and CXX), 431 # preprocessor (CPP and CXXCPP), the linker (LD), the assembler (AS) and the 432 # archiver (AR). Verify that the compilers are correct according to the 433 # toolchain type. 434 AC_DEFUN_ONCE([TOOLCHAIN_DETECT_TOOLCHAIN_CORE], 435 [ 436 # 437 # Setup the compilers (CC and CXX) 438 # 439 TOOLCHAIN_FIND_COMPILER([CC], [C], $TOOLCHAIN_CC_BINARY) 440 # Now that we have resolved CC ourself, let autoconf have its go at it 441 AC_PROG_CC([$CC]) 442 443 TOOLCHAIN_FIND_COMPILER([CXX], [C++], $TOOLCHAIN_CXX_BINARY) 444 # Now that we have resolved CXX ourself, let autoconf have its go at it 445 AC_PROG_CXX([$CXX]) 446 447 # 448 # Setup the preprocessor (CPP and CXXCPP) 449 # 450 AC_PROG_CPP 451 BASIC_FIXUP_EXECUTABLE(CPP) 452 AC_PROG_CXXCPP 453 BASIC_FIXUP_EXECUTABLE(CXXCPP) 454 455 # 456 # Setup the linker (LD) 457 # 458 if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then 459 # In the Microsoft toolchain we have a separate LD command "link". 460 # Make sure we reject /usr/bin/link (as determined in CYGWIN_LINK), which is 461 # a cygwin program for something completely different. 462 AC_CHECK_PROG([LD], [link],[link],,, [$CYGWIN_LINK]) 463 BASIC_FIXUP_EXECUTABLE(LD) 464 # Verify that we indeed succeeded with this trick. 465 AC_MSG_CHECKING([if the found link.exe is actually the Visual Studio linker]) 466 "$LD" --version > /dev/null 467 if test $? -eq 0 ; then 468 AC_MSG_RESULT([no]) 469 AC_MSG_ERROR([This is the Cygwin link tool. Please check your PATH and rerun configure.]) 470 else 471 AC_MSG_RESULT([yes]) 472 fi 473 LDCXX="$LD" 474 else 475 # All other toolchains use the compiler to link. 476 LD="$CC" 477 LDCXX="$CXX" 478 fi 479 AC_SUBST(LD) 480 # FIXME: it should be CXXLD, according to standard (cf CXXCPP) 481 AC_SUBST(LDCXX) 482 483 # 484 # Setup the assembler (AS) 485 # 486 if test "x$OPENJDK_TARGET_OS" = xsolaris; then 487 # FIXME: should this really be solaris, or solstudio? 488 BASIC_PATH_PROGS(AS, as) 489 BASIC_FIXUP_EXECUTABLE(AS) 490 else 491 # FIXME: is this correct for microsoft? 492 AS="$CC -c" 493 fi 494 AC_SUBST(AS) 495 496 # 497 # Setup the archiver (AR) 498 # 499 if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then 500 # The corresponding ar tool is lib.exe (used to create static libraries) 501 AC_CHECK_PROG([AR], [lib],[lib],,,) 502 else 503 BASIC_CHECK_TOOLS(AR, ar) 504 fi 505 BASIC_FIXUP_EXECUTABLE(AR) 506 ]) 507 508 # Setup additional tools that is considered a part of the toolchain, but not the 509 # core part. Many of these are highly platform-specific and do not exist, 510 # and/or are not needed on all platforms. 511 AC_DEFUN_ONCE([TOOLCHAIN_DETECT_TOOLCHAIN_EXTRA], 512 [ 513 if test "x$OPENJDK_TARGET_OS" = "xmacosx"; then 514 AC_PROG_OBJC 515 BASIC_FIXUP_EXECUTABLE(OBJC) 516 BASIC_PATH_PROGS(LIPO, lipo) 517 BASIC_FIXUP_EXECUTABLE(LIPO) 518 else 519 OBJC= 520 fi 521 522 if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then 523 AC_CHECK_PROG([MT], [mt], [mt],,, [/usr/bin/mt]) 524 BASIC_FIXUP_EXECUTABLE(MT) 525 # Setup the resource compiler (RC) 526 AC_CHECK_PROG([RC], [rc], [rc],,, [/usr/bin/rc]) 527 BASIC_FIXUP_EXECUTABLE(RC) 528 AC_CHECK_PROG([DUMPBIN], [dumpbin], [dumpbin],,,) 529 BASIC_FIXUP_EXECUTABLE(DUMPBIN) 530 fi 531 532 if test "x$OPENJDK_TARGET_OS" = xsolaris; then 533 BASIC_PATH_PROGS(STRIP, strip) 534 BASIC_FIXUP_EXECUTABLE(STRIP) 535 BASIC_PATH_PROGS(NM, nm) 536 BASIC_FIXUP_EXECUTABLE(NM) 537 BASIC_PATH_PROGS(GNM, gnm) 538 BASIC_FIXUP_EXECUTABLE(GNM) 539 540 BASIC_PATH_PROGS(MCS, mcs) 541 BASIC_FIXUP_EXECUTABLE(MCS) 542 elif test "x$OPENJDK_TARGET_OS" != xwindows; then 543 # FIXME: we should unify this with the solaris case above. 544 BASIC_CHECK_TOOLS(STRIP, strip) 545 BASIC_FIXUP_EXECUTABLE(STRIP) 546 BASIC_CHECK_TOOLS(NM, nm) 547 BASIC_FIXUP_EXECUTABLE(NM) 548 GNM="$NM" 549 AC_SUBST(GNM) 550 fi 551 552 # objcopy is used for moving debug symbols to separate files when 553 # full debug symbols are enabled. 554 if test "x$OPENJDK_TARGET_OS" = xsolaris || test "x$OPENJDK_TARGET_OS" = xlinux; then 555 BASIC_CHECK_TOOLS(OBJCOPY, [gobjcopy objcopy]) 556 # Only call fixup if objcopy was found. 557 if test -n "$OBJCOPY"; then 558 BASIC_FIXUP_EXECUTABLE(OBJCOPY) 559 fi 560 fi 561 562 BASIC_CHECK_TOOLS(OBJDUMP, [gobjdump objdump]) 563 if test "x$OBJDUMP" != x; then 564 # Only used for compare.sh; we can live without it. BASIC_FIXUP_EXECUTABLE 565 # bails if argument is missing. 566 BASIC_FIXUP_EXECUTABLE(OBJDUMP) 567 fi 568 ]) 569 570 # Setup the build tools (i.e, the compiler and linker used to build programs 571 # that should be run on the build platform, not the target platform, as a build 572 # helper). Since the non-cross-compile case uses the normal, target compilers 573 # for this, we can only do this after these have been setup. 574 AC_DEFUN_ONCE([TOOLCHAIN_SETUP_BUILD_COMPILERS], 575 [ 576 if test "x$COMPILE_TYPE" = "xcross"; then 577 # Now we need to find a C/C++ compiler that can build executables for the 578 # build platform. We can't use the AC_PROG_CC macro, since it can only be 579 # used once. Also, we need to do this without adding a tools dir to the 580 # path, otherwise we might pick up cross-compilers which don't use standard 581 # naming. 582 583 # FIXME: we should list the discovered compilers as an exclude pattern! 584 # If we do that, we can do this detection before POST_DETECTION, and still 585 # find the build compilers in the tools dir, if needed. 586 BASIC_PATH_PROGS(BUILD_CC, [cl cc gcc]) 587 BASIC_FIXUP_EXECUTABLE(BUILD_CC) 588 BASIC_PATH_PROGS(BUILD_CXX, [cl CC g++]) 589 BASIC_FIXUP_EXECUTABLE(BUILD_CXX) 590 BASIC_PATH_PROGS(BUILD_LD, ld) 591 BASIC_FIXUP_EXECUTABLE(BUILD_LD) 592 else 593 # If we are not cross compiling, use the normal target compilers for 594 # building the build platform executables. 595 BUILD_CC="$CC" 596 BUILD_CXX="$CXX" 597 BUILD_LD="$LD" 598 fi 599 600 AC_SUBST(BUILD_CC) 601 AC_SUBST(BUILD_CXX) 602 AC_SUBST(BUILD_LD) 603 ]) 604 605 # Setup legacy variables that is still needed as alternative ways to refer to 606 # parts of the toolchain. 607 AC_DEFUN_ONCE([TOOLCHAIN_SETUP_LEGACY], 608 [ 609 if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then 610 # For hotspot, we need these in Windows mixed path, 611 # so rewrite them all. Need added .exe suffix. 612 HOTSPOT_CXX="$CXX.exe" 613 HOTSPOT_LD="$LD.exe" 614 HOTSPOT_MT="$MT.exe" 615 HOTSPOT_RC="$RC.exe" 616 BASIC_WINDOWS_REWRITE_AS_WINDOWS_MIXED_PATH(HOTSPOT_CXX) 617 BASIC_WINDOWS_REWRITE_AS_WINDOWS_MIXED_PATH(HOTSPOT_LD) 618 BASIC_WINDOWS_REWRITE_AS_WINDOWS_MIXED_PATH(HOTSPOT_MT) 619 BASIC_WINDOWS_REWRITE_AS_WINDOWS_MIXED_PATH(HOTSPOT_RC) 620 AC_SUBST(HOTSPOT_MT) 621 AC_SUBST(HOTSPOT_RC) 622 else 623 HOTSPOT_CXX="$CXX" 624 HOTSPOT_LD="$LD" 625 fi 626 AC_SUBST(HOTSPOT_CXX) 627 AC_SUBST(HOTSPOT_LD) 628 629 if test "x$TOOLCHAIN_TYPE" = xclang; then 630 USE_CLANG=true 631 fi 632 AC_SUBST(USE_CLANG) 633 634 # LDEXE is the linker to use, when creating executables. Not really used. 635 # FIXME: These should just be removed! 636 LDEXE="$LD" 637 LDEXECXX="$LDCXX" 638 AC_SUBST(LDEXE) 639 AC_SUBST(LDEXECXX) 640 ]) 641 642 # Do some additional checks on the detected tools. 643 AC_DEFUN_ONCE([TOOLCHAIN_MISC_CHECKS], 644 [ 645 # The package path is used only on macosx? 646 # FIXME: clean this up, and/or move it elsewhere. 647 PACKAGE_PATH=/opt/local 648 AC_SUBST(PACKAGE_PATH) 649 650 if test "x$OPENJDK_TARGET_OS" = xmacosx; then 651 # Setting these parameters makes it an error to link to macosx APIs that are 652 # newer than the given OS version and makes the linked binaries compatible 653 # even if built on a newer version of the OS. 654 # The expected format is X.Y.Z 655 MACOSX_VERSION_MIN=10.7.0 656 AC_SUBST(MACOSX_VERSION_MIN) 657 658 # FIXME: This is used later on in our flag setup, but needs to be exported 659 # in spec.gmk due to closed legacy code. 660 # FIXME: clean this up, and/or move it elsewhere. 661 fi 662 663 # Check for extra potential brokenness. 664 665 if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then 666 # On Windows, double-check that we got the right compiler. 667 CC_VERSION_OUTPUT=`$CC 2>&1 | $HEAD -n 1 | $TR -d '\r'` 668 COMPILER_CPU_TEST=`$ECHO $CC_VERSION_OUTPUT | $SED -n "s/^.* \(.*\)$/\1/p"` 669 if test "x$OPENJDK_TARGET_CPU" = "xx86"; then 670 if test "x$COMPILER_CPU_TEST" != "x80x86"; then 671 AC_MSG_ERROR([Target CPU mismatch. We are building for $OPENJDK_TARGET_CPU but CL is for "$COMPILER_CPU_TEST"; expected "80x86".]) 672 fi 673 elif test "x$OPENJDK_TARGET_CPU" = "xx86_64"; then 674 if test "x$COMPILER_CPU_TEST" != "xx64"; then 675 AC_MSG_ERROR([Target CPU mismatch. We are building for $OPENJDK_TARGET_CPU but CL is for "$COMPILER_CPU_TEST"; expected "x64".]) 676 fi 677 fi 678 fi 679 680 if test "x$TOOLCHAIN_TYPE" = xgcc; then 681 # If this is a --hash-style=gnu system, use --hash-style=both, why? 682 HAS_GNU_HASH=`$CC -dumpspecs 2>/dev/null | $GREP 'hash-style=gnu'` 683 # This is later checked when setting flags. 684 fi 685 686 # Check for broken SuSE 'ld' for which 'Only anonymous version tag is allowed 687 # in executable.' 688 USING_BROKEN_SUSE_LD=no 689 if test "x$OPENJDK_TARGET_OS" = xlinux && test "x$TOOLCHAIN_TYPE" = xgcc; then 690 AC_MSG_CHECKING([for broken SuSE 'ld' which only understands anonymous version tags in executables]) 691 echo "SUNWprivate_1.1 { local: *; };" > version-script.map 692 echo "int main() { }" > main.c 693 if $CXX -Xlinker -version-script=version-script.map main.c 2>&AS_MESSAGE_LOG_FD >&AS_MESSAGE_LOG_FD; then 694 AC_MSG_RESULT(no) 695 USING_BROKEN_SUSE_LD=no 696 else 697 AC_MSG_RESULT(yes) 698 USING_BROKEN_SUSE_LD=yes 699 fi 700 rm -rf version-script.map main.c a.out 701 fi 702 AC_SUBST(USING_BROKEN_SUSE_LD) 703 ]) 704 705 # Setup the JTReg Regression Test Harness. 706 AC_DEFUN_ONCE([TOOLCHAIN_SETUP_JTREG], 707 [ 708 AC_ARG_WITH(jtreg, [AS_HELP_STRING([--with-jtreg], 709 [Regression Test Harness @<:@probed@:>@])], 710 [], 711 [with_jtreg=no]) 712 713 if test "x$with_jtreg" = xno; then 714 # jtreg disabled 715 AC_MSG_CHECKING([for jtreg]) 716 AC_MSG_RESULT(no) 717 else 718 if test "x$with_jtreg" != xyes; then 719 # with path specified. 720 JT_HOME="$with_jtreg" 721 fi 722 723 if test "x$JT_HOME" != x; then 724 AC_MSG_CHECKING([for jtreg]) 725 726 # use JT_HOME enviroment var. 727 BASIC_FIXUP_PATH([JT_HOME]) 728 729 # jtreg win32 script works for everybody 730 JTREGEXE="$JT_HOME/win32/bin/jtreg" 731 732 if test ! -f "$JTREGEXE"; then 733 AC_MSG_ERROR([JTReg executable does not exist: $JTREGEXE]) 734 fi 735 736 AC_MSG_RESULT($JTREGEXE) 737 else 738 # try to find jtreg on path 739 BASIC_REQUIRE_PROGS(JTREGEXE, jtreg) 740 JT_HOME="`$DIRNAME $JTREGEXE`" 741 fi 742 fi 743 744 AC_SUBST(JT_HOME) 745 AC_SUBST(JTREGEXE) 746 ])