< prev index next >

make/autoconf/toolchain.m4

Print this page




 163     :
 164     ARG_IF_AT_LEAST
 165   else
 166     :
 167     ARG_IF_OLDER_THAN
 168   fi
 169 ])
 170 
 171 # Setup a number of variables describing how native output files are
 172 # named on this platform/toolchain.
 173 AC_DEFUN([TOOLCHAIN_SETUP_FILENAME_PATTERNS],
 174 [
 175   # Define filename patterns
 176   if test "x$OPENJDK_TARGET_OS" = xwindows; then
 177     LIBRARY_PREFIX=
 178     SHARED_LIBRARY_SUFFIX='.dll'
 179     STATIC_LIBRARY_SUFFIX='.lib'
 180     SHARED_LIBRARY='[$]1.dll'
 181     STATIC_LIBRARY='[$]1.lib'
 182     OBJ_SUFFIX='.obj'

 183   else
 184     LIBRARY_PREFIX=lib
 185     SHARED_LIBRARY_SUFFIX='.so'
 186     STATIC_LIBRARY_SUFFIX='.a'
 187     SHARED_LIBRARY='lib[$]1.so'
 188     STATIC_LIBRARY='lib[$]1.a'
 189     OBJ_SUFFIX='.o'

 190     if test "x$OPENJDK_TARGET_OS" = xmacosx; then
 191       # For full static builds, we're overloading the SHARED_LIBRARY
 192       # variables in order to limit the amount of changes required.
 193       # It would be better to remove SHARED and just use LIBRARY and
 194       # LIBRARY_SUFFIX for libraries that can be built either
 195       # shared or static and use STATIC_* for libraries that are
 196       # always built statically.
 197       if test "x$STATIC_BUILD" = xtrue; then
 198         SHARED_LIBRARY='lib[$]1.a'
 199         SHARED_LIBRARY_SUFFIX='.a'
 200       else
 201         SHARED_LIBRARY='lib[$]1.dylib'
 202         SHARED_LIBRARY_SUFFIX='.dylib'
 203       fi
 204     fi
 205   fi
 206 
 207   AC_SUBST(LIBRARY_PREFIX)
 208   AC_SUBST(SHARED_LIBRARY_SUFFIX)
 209   AC_SUBST(STATIC_LIBRARY_SUFFIX)
 210   AC_SUBST(SHARED_LIBRARY)
 211   AC_SUBST(STATIC_LIBRARY)
 212   AC_SUBST(OBJ_SUFFIX)

 213 ])
 214 
 215 # Determine which toolchain type to use, and make sure it is valid for this
 216 # platform. Setup various information about the selected toolchain.
 217 AC_DEFUN_ONCE([TOOLCHAIN_DETERMINE_TOOLCHAIN_TYPE],
 218 [
 219   AC_ARG_WITH(toolchain-type, [AS_HELP_STRING([--with-toolchain-type],
 220       [the toolchain type (or family) to use, use '--help' to show possible values @<:@platform dependent@:>@])])
 221 
 222   # Use indirect variable referencing
 223   toolchain_var_name=VALID_TOOLCHAINS_$OPENJDK_BUILD_OS
 224   VALID_TOOLCHAINS=${!toolchain_var_name}
 225 
 226   if test "x$OPENJDK_TARGET_OS" = xmacosx; then
 227     if test -n "$XCODEBUILD"; then
 228       # On Mac OS X, default toolchain to clang after Xcode 5
 229       XCODE_VERSION_OUTPUT=`"$XCODEBUILD" -version 2>&1 | $HEAD -n 1`
 230       $ECHO "$XCODE_VERSION_OUTPUT" | $GREP "Xcode " > /dev/null
 231       if test $? -ne 0; then
 232         AC_MSG_NOTICE([xcodebuild output: $XCODE_VERSION_OUTPUT])


 259       toolchain_var_name=TOOLCHAIN_DESCRIPTION_$toolchain
 260       TOOLCHAIN_DESCRIPTION=${!toolchain_var_name}
 261       $PRINTF "  %-10s  %s\n" $toolchain "$TOOLCHAIN_DESCRIPTION"
 262     done
 263 
 264     exit 0
 265   elif test "x$with_toolchain_type" != x; then
 266     # User override; check that it is valid
 267     if test "x${VALID_TOOLCHAINS/$with_toolchain_type/}" = "x${VALID_TOOLCHAINS}"; then
 268       AC_MSG_NOTICE([Toolchain type $with_toolchain_type is not valid on this platform.])
 269       AC_MSG_NOTICE([Valid toolchains: $VALID_TOOLCHAINS.])
 270       AC_MSG_ERROR([Cannot continue.])
 271     fi
 272     TOOLCHAIN_TYPE=$with_toolchain_type
 273   else
 274     # No flag given, use default
 275     TOOLCHAIN_TYPE=$DEFAULT_TOOLCHAIN
 276   fi
 277   AC_SUBST(TOOLCHAIN_TYPE)
 278 
 279   # on AIX, check for xlclang++ on the PATH and TOOLCHAIN_PATH and use it if it is available
 280   if test "x$OPENJDK_TARGET_OS" = xaix; then
 281     if test "x$TOOLCHAIN_PATH" != x; then
 282       XLC_TEST_PATH=${TOOLCHAIN_PATH}/
 283     fi
 284 
 285     XLCLANG_VERSION_OUTPUT=`${XLC_TEST_PATH}xlclang++ -qversion 2>&1 | $HEAD -n 1`
 286     $ECHO "$XLCLANG_VERSION_OUTPUT" | $GREP "IBM XL C/C++ for AIX" > /dev/null
 287     if test $? -eq 0; then
 288       AC_MSG_NOTICE([xlclang++ output: $XLCLANG_VERSION_OUTPUT])
 289       XLC_USES_CLANG=true
 290     fi
 291   fi
 292 
 293   TOOLCHAIN_CC_BINARY_clang="clang"
 294   TOOLCHAIN_CC_BINARY_gcc="gcc"
 295   TOOLCHAIN_CC_BINARY_microsoft="cl$EXE_SUFFIX"
 296   TOOLCHAIN_CC_BINARY_solstudio="cc"
 297   TOOLCHAIN_CC_BINARY_xlc="xlc_r"
 298 
 299   TOOLCHAIN_CXX_BINARY_clang="clang++"
 300   TOOLCHAIN_CXX_BINARY_gcc="g++"
 301   TOOLCHAIN_CXX_BINARY_microsoft="cl$EXE_SUFFIX"
 302   TOOLCHAIN_CXX_BINARY_solstudio="CC"
 303   TOOLCHAIN_CXX_BINARY_xlc="xlC_r"
 304 
 305   if test "x$OPENJDK_TARGET_OS" = xaix; then
 306     if test "x$XLC_USES_CLANG" = xtrue; then
 307       AC_MSG_NOTICE([xlclang++ detected, using it])
 308       TOOLCHAIN_CC_BINARY_xlc="xlclang"
 309       TOOLCHAIN_CXX_BINARY_xlc="xlclang++"
 310     fi
 311   fi
 312 
 313   # Use indirect variable referencing
 314   toolchain_var_name=TOOLCHAIN_DESCRIPTION_$TOOLCHAIN_TYPE
 315   TOOLCHAIN_DESCRIPTION=${!toolchain_var_name}
 316   toolchain_var_name=TOOLCHAIN_MINIMUM_VERSION_$TOOLCHAIN_TYPE
 317   TOOLCHAIN_MINIMUM_VERSION=${!toolchain_var_name}
 318   toolchain_var_name=TOOLCHAIN_MINIMUM_LD_VERSION_$TOOLCHAIN_TYPE
 319   TOOLCHAIN_MINIMUM_LD_VERSION=${!toolchain_var_name}
 320   toolchain_var_name=TOOLCHAIN_CC_BINARY_$TOOLCHAIN_TYPE
 321   TOOLCHAIN_CC_BINARY=${!toolchain_var_name}
 322   toolchain_var_name=TOOLCHAIN_CXX_BINARY_$TOOLCHAIN_TYPE
 323   TOOLCHAIN_CXX_BINARY=${!toolchain_var_name}
 324 
 325   TOOLCHAIN_SETUP_FILENAME_PATTERNS
 326 
 327   if test "x$TOOLCHAIN_TYPE" = "x$DEFAULT_TOOLCHAIN"; then
 328     AC_MSG_NOTICE([Using default toolchain $TOOLCHAIN_TYPE ($TOOLCHAIN_DESCRIPTION)])
 329   else
 330     AC_MSG_NOTICE([Using user selected toolchain $TOOLCHAIN_TYPE ($TOOLCHAIN_DESCRIPTION). Default toolchain is $DEFAULT_TOOLCHAIN.])
 331   fi
 332 ])


 335 # special setup, e.g. additional paths etc.
 336 AC_DEFUN_ONCE([TOOLCHAIN_PRE_DETECTION],
 337 [
 338   # FIXME: Is this needed?
 339   AC_LANG(C++)
 340 
 341   # Store the CFLAGS etc passed to the configure script.
 342   ORG_CFLAGS="$CFLAGS"
 343   ORG_CXXFLAGS="$CXXFLAGS"
 344 
 345   # autoconf magic only relies on PATH, so update it if tools dir is specified
 346   OLD_PATH="$PATH"
 347 
 348   # On Windows, we need to detect the visual studio installation first.
 349   # This will change the PATH, but we need to keep that new PATH even
 350   # after toolchain detection is done, since the compiler (on x86) uses
 351   # it for DLL resolution in runtime.
 352   if test "x$OPENJDK_BUILD_OS" = "xwindows" \
 353       && test "x$TOOLCHAIN_TYPE" = "xmicrosoft"; then
 354     TOOLCHAIN_SETUP_VISUAL_STUDIO_ENV
 355     if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.wsl"; then
 356       # Append VS_PATH. In WSL, VS_PATH will not contain the WSL env path needed
 357       # for using basic Unix tools, so need to keep the original PATH.
 358       BASIC_APPEND_TO_PATH(PATH, $VS_PATH)
 359       BASIC_APPEND_TO_PATH(WSLENV, "PATH/l:LIB:INCLUDE")
 360       export WSLENV
 361     else
 362       # Reset path to VS_PATH. It will include everything that was on PATH at the time we
 363       # ran TOOLCHAIN_SETUP_VISUAL_STUDIO_ENV.
 364       PATH="$VS_PATH"
 365     fi
 366     # The microsoft toolchain also requires INCLUDE and LIB to be set.
 367     export INCLUDE="$VS_INCLUDE"
 368     export LIB="$VS_LIB"
 369   else
 370     if test "x$XCODE_VERSION_OUTPUT" != x; then
 371       # For Xcode, we set the Xcode version as TOOLCHAIN_VERSION
 372       TOOLCHAIN_VERSION=`$ECHO $XCODE_VERSION_OUTPUT | $CUT -f 2 -d ' '`
 373       TOOLCHAIN_DESCRIPTION="$TOOLCHAIN_DESCRIPTION from Xcode $TOOLCHAIN_VERSION"
 374     else
 375       # Currently we do not define this for other toolchains. This might change as the need arise.
 376       TOOLCHAIN_VERSION=
 377     fi
 378   fi
 379   AC_SUBST(TOOLCHAIN_VERSION)
 380 
 381   # Finally add TOOLCHAIN_PATH at the beginning, to allow --with-tools-dir to
 382   # override all other locations.
 383   if test "x$TOOLCHAIN_PATH" != x; then
 384     PATH=$TOOLCHAIN_PATH:$PATH
 385   fi


 440     #     IBM XL C/C++ for AIX, V11.1 (5724-X13)
 441     #     Version: 11.01.0000.0015
 442     COMPILER_VERSION_OUTPUT=`$COMPILER -qversion 2>&1`
 443     # Check that this is likely to be the IBM XL C compiler.
 444     $ECHO "$COMPILER_VERSION_OUTPUT" | $GREP "IBM XL C" > /dev/null
 445     if test $? -ne 0; then
 446       ALT_VERSION_OUTPUT=`$COMPILER --version 2>&1`
 447       AC_MSG_NOTICE([The $COMPILER_NAME compiler (located as $COMPILER) does not seem to be the required $TOOLCHAIN_TYPE compiler.])
 448       AC_MSG_NOTICE([The result from running with -qversion was: "$COMPILER_VERSION_OUTPUT"])
 449       AC_MSG_NOTICE([The result from running with --version was: "$ALT_VERSION_OUTPUT"])
 450       AC_MSG_ERROR([A $TOOLCHAIN_TYPE compiler is required. Try setting --with-tools-dir.])
 451     fi
 452     # Collapse compiler output into a single line
 453     COMPILER_VERSION_STRING=`$ECHO $COMPILER_VERSION_OUTPUT`
 454     COMPILER_VERSION_NUMBER=`$ECHO $COMPILER_VERSION_OUTPUT | \
 455         $SED -e 's/^.*, V\(@<:@1-9@:>@@<:@0-9.@:>@*\).*$/\1/'`
 456   elif test  "x$TOOLCHAIN_TYPE" = xmicrosoft; then
 457     # There is no specific version flag, but all output starts with a version string.
 458     # First line typically looks something like:
 459     # Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.40219.01 for 80x86
 460     COMPILER_VERSION_OUTPUT=`"$COMPILER" 2>&1 | $GREP -v 'ERROR.*UtilTranslatePathList' | $HEAD -n 1 | $TR -d '\r'`
 461     # Check that this is likely to be Microsoft CL.EXE.
 462     $ECHO "$COMPILER_VERSION_OUTPUT" | $GREP "Microsoft.*Compiler" > /dev/null
 463     if test $? -ne 0; then
 464       AC_MSG_NOTICE([The $COMPILER_NAME compiler (located as $COMPILER) does not seem to be the required $TOOLCHAIN_TYPE compiler.])
 465       AC_MSG_NOTICE([The result from running it was: "$COMPILER_VERSION_OUTPUT"])
 466       AC_MSG_ERROR([A $TOOLCHAIN_TYPE compiler is required. Try setting --with-tools-dir.])
 467     fi
 468     # Collapse compiler output into a single line
 469     COMPILER_VERSION_STRING=`$ECHO $COMPILER_VERSION_OUTPUT`
 470     COMPILER_VERSION_NUMBER=`$ECHO $COMPILER_VERSION_OUTPUT | \
 471         $SED -e 's/^.*ersion.\(@<:@1-9@:>@@<:@0-9.@:>@*\) .*$/\1/'`
 472   elif test  "x$TOOLCHAIN_TYPE" = xgcc; then
 473     # gcc --version output typically looks like
 474     #     gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
 475     #     Copyright (C) 2013 Free Software Foundation, Inc.
 476     #     This is free software; see the source for copying conditions.  There is NO
 477     #     warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 478     COMPILER_VERSION_OUTPUT=`$COMPILER --version 2>&1`
 479     # Check that this is likely to be GCC.
 480     $ECHO "$COMPILER_VERSION_OUTPUT" | $GREP "Free Software Foundation" > /dev/null


 600     # using ccache. Instead ccache usage must be controlled by a configure option.
 601     COMPILER_BASENAME=`$BASENAME "$SYMLINK_ORIGINAL"`
 602     if test "x$COMPILER_BASENAME" = "xccache"; then
 603       AC_MSG_NOTICE([Please use --enable-ccache instead of providing a wrapped compiler.])
 604       AC_MSG_ERROR([$TEST_COMPILER is a symbolic link to ccache. This is not supported.])
 605     fi
 606   fi
 607 
 608   TOOLCHAIN_EXTRACT_COMPILER_VERSION([$1], [$COMPILER_NAME])
 609 ])
 610 
 611 # Retrieve the linker version number and store it in LD_VERSION_NUMBER
 612 # (as a dotted number), and
 613 # the full version string in LD_VERSION_STRING.
 614 #
 615 # $1 = linker to test (LD or BUILD_LD)
 616 # $2 = human readable name of linker (Linker or BuildLinker)
 617 AC_DEFUN([TOOLCHAIN_EXTRACT_LD_VERSION],
 618 [
 619   LINKER=[$]$1
 620   LINKER_NAME="$2"
 621 
 622   if test "x$TOOLCHAIN_TYPE" = xsolstudio; then
 623     # cc -Wl,-V output typically looks like
 624     #   ld: Software Generation Utilities - Solaris Link Editors: 5.11-1.2329
 625 
 626     # solstudio cc requires us to have an existing file to pass as argument,
 627     # but it need not be a syntactically correct C file, so just use
 628     # ourself. :) The intermediate 'cat' is needed to stop ld from leaving
 629     # a lingering a.out (!).
 630     LINKER_VERSION_STRING=`$LD -Wl,-V $TOPDIR/configure 2>&1 | $CAT | $HEAD -n 1 | $SED -e 's/ld: //'`
 631     # Extract version number
 632     [ LINKER_VERSION_NUMBER=`$ECHO $LINKER_VERSION_STRING | \
 633         $SED -e 's/.* \([0-9][0-9]*\.[0-9][0-9]*\)-\([0-9][0-9]*\.[0-9][0-9]*\)/\1.\2/'` ]
 634   elif test  "x$TOOLCHAIN_TYPE" = xxlc; then
 635     LINKER_VERSION_STRING="Unknown"
 636     LINKER_VERSION_NUMBER="0.0"
 637   elif test  "x$TOOLCHAIN_TYPE" = xmicrosoft; then
 638     # There is no specific version flag, but all output starts with a version string.
 639     # First line typically looks something like:
 640     #   Microsoft (R) Incremental Linker Version 12.00.31101.0
 641     LINKER_VERSION_STRING=`$LD 2>&1 | $HEAD -n 1 | $TR -d '\r'`
 642     # Extract version number
 643     [ LINKER_VERSION_NUMBER=`$ECHO $LINKER_VERSION_STRING | \
 644         $SED -e 's/.* \([0-9][0-9]*\(\.[0-9][0-9]*\)*\).*/\1/'` ]
 645   elif test  "x$TOOLCHAIN_TYPE" = xgcc; then
 646     # gcc -Wl,-version output typically looks like:
 647     #   GNU ld (GNU Binutils for Ubuntu) 2.26.1
 648     #   Copyright (C) 2015 Free Software Foundation, Inc.
 649     #   This program is free software; [...]
 650     # If using gold it will look like:
 651     #   GNU gold (GNU Binutils 2.30) 1.15
 652     LINKER_VERSION_STRING=`$LD -Wl,--version 2> /dev/null | $HEAD -n 1`
 653     # Extract version number
 654     if [ [[ "$LINKER_VERSION_STRING" == *gold* ]] ]; then
 655       [ LINKER_VERSION_NUMBER=`$ECHO $LINKER_VERSION_STRING | \
 656           $SED -e 's/.* \([0-9][0-9]*\(\.[0-9][0-9]*\)*\).*) .*/\1/'` ]
 657     else
 658       [ LINKER_VERSION_NUMBER=`$ECHO $LINKER_VERSION_STRING | \
 659           $SED -e 's/.* \([0-9][0-9]*\(\.[0-9][0-9]*\)*\).*/\1/'` ]
 660     fi
 661   elif test  "x$TOOLCHAIN_TYPE" = xclang; then
 662     # clang -Wl,-v output typically looks like
 663     #   @(#)PROGRAM:ld  PROJECT:ld64-305
 664     #   configured to support archs: armv6 armv7 armv7s arm64 i386 x86_64 x86_64h armv6m armv7k armv7m armv7em (tvOS)
 665     #   Library search paths: [...]
 666     # or
 667     #   GNU ld (GNU Binutils for Ubuntu) 2.26.1
 668 
 669     LINKER_VERSION_STRING=`$LD -Wl,-v 2>&1 | $HEAD -n 1`
 670     # Check if we're using the GNU ld
 671     $ECHO "$LINKER_VERSION_STRING" | $GREP "GNU" > /dev/null
 672     if test $? -eq 0; then
 673       # Extract version number
 674       [ LINKER_VERSION_NUMBER=`$ECHO $LINKER_VERSION_STRING | \
 675           $SED -e 's/.* \([0-9][0-9]*\(\.[0-9][0-9]*\)*\).*/\1/'` ]
 676     else
 677       # Extract version number
 678       [ LINKER_VERSION_NUMBER=`$ECHO $LINKER_VERSION_STRING | \
 679           $SED -e 's/.*-\([0-9][0-9]*\)/\1/'` ]
 680     fi


 715           AC_MSG_WARN([You are using $TOOLCHAIN_TYPE older than $TOOLCHAIN_MINIMUM_VERSION. This is not a supported configuration.])
 716         ]
 717     )
 718   fi
 719 
 720   #
 721   # Setup the preprocessor (CPP and CXXCPP)
 722   #
 723   AC_PROG_CPP
 724   BASIC_FIXUP_EXECUTABLE(CPP)
 725   AC_PROG_CXXCPP
 726   BASIC_FIXUP_EXECUTABLE(CXXCPP)
 727 
 728   #
 729   # Setup the linker (LD)
 730   #
 731   if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
 732     # In the Microsoft toolchain we have a separate LD command "link".
 733     # Make sure we reject /usr/bin/link (as determined in CYGWIN_LINK), which is
 734     # a cygwin program for something completely different.
 735     AC_CHECK_PROG([LD], [link$EXE_SUFFIX],[link$EXE_SUFFIX],,, [$CYGWIN_LINK])
 736     BASIC_FIXUP_EXECUTABLE(LD)
 737     # Verify that we indeed succeeded with this trick.
 738     AC_MSG_CHECKING([if the found link.exe is actually the Visual Studio linker])
 739     "$LD" --version > /dev/null
 740     if test $? -eq 0 ; then
 741       AC_MSG_RESULT([no])
 742       AC_MSG_ERROR([This is the Cygwin link tool. Please check your PATH and rerun configure.])
 743     else
 744       AC_MSG_RESULT([yes])
 745     fi
 746     LDCXX="$LD"
 747     # jaotc being a windows program expects the linker to be supplied with exe suffix.
 748     LD_JAOTC="$LD$EXE_SUFFIX"
 749   else
 750     # All other toolchains use the compiler to link.
 751     LD="$CC"
 752     LDCXX="$CXX"
 753     # jaotc expects 'ld' as the linker rather than the compiler.
 754     BASIC_CHECK_TOOLS([LD_JAOTC], ld)
 755     BASIC_FIXUP_EXECUTABLE(LD_JAOTC)
 756   fi
 757   AC_SUBST(LD)
 758   AC_SUBST(LD_JAOTC)
 759   # FIXME: it should be CXXLD, according to standard (cf CXXCPP)
 760   AC_SUBST(LDCXX)
 761 
 762   TOOLCHAIN_EXTRACT_LD_VERSION([LD], [linker])
 763   TOOLCHAIN_PREPARE_FOR_LD_VERSION_COMPARISONS
 764 
 765   if test "x$TOOLCHAIN_MINIMUM_LD_VERSION" != x; then
 766     TOOLCHAIN_CHECK_LINKER_VERSION(VERSION: $TOOLCHAIN_MINIMUM_LD_VERSION,
 767         IF_OLDER_THAN: [
 768           AC_MSG_WARN([You are using a linker older than $TOOLCHAIN_MINIMUM_LD_VERSION. This is not a supported configuration.])
 769         ]
 770     )
 771   fi
 772 
 773   #
 774   # Setup the assembler (AS)
 775   #
 776   if test "x$OPENJDK_TARGET_OS" = xsolaris; then
 777     BASIC_PATH_PROGS(AS, as)
 778     BASIC_FIXUP_EXECUTABLE(AS)
 779     if test "x$AS" = x; then
 780       AC_MSG_ERROR([Solaris assembler (as) is required. Please install via "pkg install pkg:/developer/assembler".])
 781     fi
 782   else
 783     # FIXME: is this correct for microsoft?
 784     AS="$CC -c"
 785   fi
 786   AC_SUBST(AS)
 787 
 788   #
 789   # Setup the archiver (AR)
 790   #
 791   if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
 792     # The corresponding ar tool is lib.exe (used to create static libraries)
 793     AC_CHECK_PROG([AR], [lib$EXE_SUFFIX],[lib$EXE_SUFFIX],,,)
 794   elif test "x$TOOLCHAIN_TYPE" = xgcc; then
 795     BASIC_CHECK_TOOLS(AR, ar gcc-ar)
 796   else
 797     BASIC_CHECK_TOOLS(AR, ar)
 798   fi
 799   BASIC_FIXUP_EXECUTABLE(AR)
 800 ])
 801 
 802 # Setup additional tools that is considered a part of the toolchain, but not the
 803 # core part. Many of these are highly platform-specific and do not exist,
 804 # and/or are not needed on all platforms.
 805 AC_DEFUN_ONCE([TOOLCHAIN_DETECT_TOOLCHAIN_EXTRA],
 806 [
 807   if test "x$OPENJDK_TARGET_OS" = "xmacosx"; then
 808     BASIC_PATH_PROGS(LIPO, lipo)
 809     BASIC_FIXUP_EXECUTABLE(LIPO)
 810     BASIC_REQUIRE_PROGS(OTOOL, otool)
 811     BASIC_FIXUP_EXECUTABLE(OTOOL)
 812     BASIC_REQUIRE_PROGS(INSTALL_NAME_TOOL, install_name_tool)
 813     BASIC_FIXUP_EXECUTABLE(INSTALL_NAME_TOOL)
 814   fi
 815 
 816   if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
 817     AC_CHECK_PROG([MT], [mt$EXE_SUFFIX], [mt$EXE_SUFFIX],,, [/usr/bin/mt])
 818     BASIC_FIXUP_EXECUTABLE(MT)
 819     # Setup the resource compiler (RC)
 820     AC_CHECK_PROG([RC], [rc$EXE_SUFFIX], [rc$EXE_SUFFIX],,, [/usr/bin/rc])
 821     BASIC_FIXUP_EXECUTABLE(RC)
 822     AC_CHECK_PROG([DUMPBIN], [dumpbin$EXE_SUFFIX], [dumpbin$EXE_SUFFIX],,,)
 823     BASIC_FIXUP_EXECUTABLE(DUMPBIN)
 824     # We need to check for 'msbuild.exe' because at the place where we expect to
 825     # find 'msbuild.exe' there's also a directory called 'msbuild' and configure
 826     # won't find the 'msbuild.exe' executable in that case (and the
 827     # 'ac_executable_extensions' is unusable due to performance reasons).
 828     # Notice that we intentionally don't fix up the path to MSBUILD because we
 829     # will call it in a DOS shell during freetype detection on Windows (see
 830     # 'LIB_SETUP_FREETYPE' in "libraries.m4"
 831     AC_CHECK_PROG([MSBUILD], [msbuild$EXE_SUFFIX], [msbuild$EXE_SUFFIX],,,)
 832   fi
 833 
 834   if test "x$OPENJDK_TARGET_OS" = xsolaris; then
 835     BASIC_PATH_PROGS(STRIP, strip)
 836     BASIC_FIXUP_EXECUTABLE(STRIP)
 837     BASIC_PATH_PROGS(NM, nm)
 838     BASIC_FIXUP_EXECUTABLE(NM)
 839     BASIC_PATH_PROGS(GNM, gnm)
 840     BASIC_FIXUP_EXECUTABLE(GNM)
 841   elif test "x$OPENJDK_TARGET_OS" != xwindows; then
 842     # FIXME: we should unify this with the solaris case above.
 843     BASIC_CHECK_TOOLS(STRIP, strip)
 844     BASIC_FIXUP_EXECUTABLE(STRIP)
 845     if test "x$TOOLCHAIN_TYPE" = xgcc; then
 846       BASIC_CHECK_TOOLS(NM, nm gcc-nm)
 847     else
 848       BASIC_CHECK_TOOLS(NM, nm)
 849     fi
 850     BASIC_FIXUP_EXECUTABLE(NM)
 851     GNM="$NM"


1022 
1023     TOOLCHAIN_PREPARE_FOR_VERSION_COMPARISONS([], [OPENJDK_BUILD_])
1024     TOOLCHAIN_PREPARE_FOR_LD_VERSION_COMPARISONS([BUILD_], [OPENJDK_BUILD_])
1025   fi
1026 
1027   AC_SUBST(BUILD_CC)
1028   AC_SUBST(BUILD_CXX)
1029   AC_SUBST(BUILD_LD)
1030   AC_SUBST(BUILD_LDCXX)
1031   AC_SUBST(BUILD_NM)
1032   AC_SUBST(BUILD_AS)
1033   AC_SUBST(BUILD_AR)
1034 ])
1035 
1036 # Do some additional checks on the detected tools.
1037 AC_DEFUN_ONCE([TOOLCHAIN_MISC_CHECKS],
1038 [
1039   # Check for extra potential brokenness.
1040   if test  "x$TOOLCHAIN_TYPE" = xmicrosoft; then
1041     # On Windows, double-check that we got the right compiler.
1042     CC_VERSION_OUTPUT=`$CC 2>&1 | $GREP -v 'ERROR.*UtilTranslatePathList' | $HEAD -n 1 | $TR -d '\r'`
1043     COMPILER_CPU_TEST=`$ECHO $CC_VERSION_OUTPUT | $SED -n "s/^.* \(.*\)$/\1/p"`
1044     if test "x$OPENJDK_TARGET_CPU" = "xx86"; then
1045       if test "x$COMPILER_CPU_TEST" != "x80x86" -a "x$COMPILER_CPU_TEST" != "xx86"; then
1046         AC_MSG_ERROR([Target CPU mismatch. We are building for $OPENJDK_TARGET_CPU but CL is for "$COMPILER_CPU_TEST"; expected "80x86" or "x86".])
1047       fi
1048     elif test "x$OPENJDK_TARGET_CPU" = "xx86_64"; then
1049       if test "x$COMPILER_CPU_TEST" != "xx64"; then
1050         AC_MSG_ERROR([Target CPU mismatch. We are building for $OPENJDK_TARGET_CPU but CL is for "$COMPILER_CPU_TEST"; expected "x64".])
1051       fi
1052     fi
1053   fi
1054 
1055   if test "x$TOOLCHAIN_TYPE" = xgcc; then
1056     # If this is a --hash-style=gnu system, use --hash-style=both, why?
1057     HAS_GNU_HASH=`$CC -dumpspecs 2>/dev/null | $GREP 'hash-style=gnu'`
1058     # This is later checked when setting flags.
1059   fi
1060 
1061   if test "x$TOOLCHAIN_TYPE" = xgcc || test "x$TOOLCHAIN_TYPE" = xclang; then
1062     # Check if linker has -z noexecstack.




 163     :
 164     ARG_IF_AT_LEAST
 165   else
 166     :
 167     ARG_IF_OLDER_THAN
 168   fi
 169 ])
 170 
 171 # Setup a number of variables describing how native output files are
 172 # named on this platform/toolchain.
 173 AC_DEFUN([TOOLCHAIN_SETUP_FILENAME_PATTERNS],
 174 [
 175   # Define filename patterns
 176   if test "x$OPENJDK_TARGET_OS" = xwindows; then
 177     LIBRARY_PREFIX=
 178     SHARED_LIBRARY_SUFFIX='.dll'
 179     STATIC_LIBRARY_SUFFIX='.lib'
 180     SHARED_LIBRARY='[$]1.dll'
 181     STATIC_LIBRARY='[$]1.lib'
 182     OBJ_SUFFIX='.obj'
 183     EXE_SUFFIX='.exe'
 184   else
 185     LIBRARY_PREFIX=lib
 186     SHARED_LIBRARY_SUFFIX='.so'
 187     STATIC_LIBRARY_SUFFIX='.a'
 188     SHARED_LIBRARY='lib[$]1.so'
 189     STATIC_LIBRARY='lib[$]1.a'
 190     OBJ_SUFFIX='.o'
 191     EXE_SUFFIX=''
 192     if test "x$OPENJDK_TARGET_OS" = xmacosx; then
 193       # For full static builds, we're overloading the SHARED_LIBRARY
 194       # variables in order to limit the amount of changes required.
 195       # It would be better to remove SHARED and just use LIBRARY and
 196       # LIBRARY_SUFFIX for libraries that can be built either
 197       # shared or static and use STATIC_* for libraries that are
 198       # always built statically.
 199       if test "x$STATIC_BUILD" = xtrue; then
 200         SHARED_LIBRARY='lib[$]1.a'
 201         SHARED_LIBRARY_SUFFIX='.a'
 202       else
 203         SHARED_LIBRARY='lib[$]1.dylib'
 204         SHARED_LIBRARY_SUFFIX='.dylib'
 205       fi
 206     fi
 207   fi
 208 
 209   AC_SUBST(LIBRARY_PREFIX)
 210   AC_SUBST(SHARED_LIBRARY_SUFFIX)
 211   AC_SUBST(STATIC_LIBRARY_SUFFIX)
 212   AC_SUBST(SHARED_LIBRARY)
 213   AC_SUBST(STATIC_LIBRARY)
 214   AC_SUBST(OBJ_SUFFIX)
 215   AC_SUBST(EXE_SUFFIX)
 216 ])
 217 
 218 # Determine which toolchain type to use, and make sure it is valid for this
 219 # platform. Setup various information about the selected toolchain.
 220 AC_DEFUN_ONCE([TOOLCHAIN_DETERMINE_TOOLCHAIN_TYPE],
 221 [
 222   AC_ARG_WITH(toolchain-type, [AS_HELP_STRING([--with-toolchain-type],
 223       [the toolchain type (or family) to use, use '--help' to show possible values @<:@platform dependent@:>@])])
 224 
 225   # Use indirect variable referencing
 226   toolchain_var_name=VALID_TOOLCHAINS_$OPENJDK_BUILD_OS
 227   VALID_TOOLCHAINS=${!toolchain_var_name}
 228 
 229   if test "x$OPENJDK_TARGET_OS" = xmacosx; then
 230     if test -n "$XCODEBUILD"; then
 231       # On Mac OS X, default toolchain to clang after Xcode 5
 232       XCODE_VERSION_OUTPUT=`"$XCODEBUILD" -version 2>&1 | $HEAD -n 1`
 233       $ECHO "$XCODE_VERSION_OUTPUT" | $GREP "Xcode " > /dev/null
 234       if test $? -ne 0; then
 235         AC_MSG_NOTICE([xcodebuild output: $XCODE_VERSION_OUTPUT])


 262       toolchain_var_name=TOOLCHAIN_DESCRIPTION_$toolchain
 263       TOOLCHAIN_DESCRIPTION=${!toolchain_var_name}
 264       $PRINTF "  %-10s  %s\n" $toolchain "$TOOLCHAIN_DESCRIPTION"
 265     done
 266 
 267     exit 0
 268   elif test "x$with_toolchain_type" != x; then
 269     # User override; check that it is valid
 270     if test "x${VALID_TOOLCHAINS/$with_toolchain_type/}" = "x${VALID_TOOLCHAINS}"; then
 271       AC_MSG_NOTICE([Toolchain type $with_toolchain_type is not valid on this platform.])
 272       AC_MSG_NOTICE([Valid toolchains: $VALID_TOOLCHAINS.])
 273       AC_MSG_ERROR([Cannot continue.])
 274     fi
 275     TOOLCHAIN_TYPE=$with_toolchain_type
 276   else
 277     # No flag given, use default
 278     TOOLCHAIN_TYPE=$DEFAULT_TOOLCHAIN
 279   fi
 280   AC_SUBST(TOOLCHAIN_TYPE)
 281 














 282   TOOLCHAIN_CC_BINARY_clang="clang"
 283   TOOLCHAIN_CC_BINARY_gcc="gcc"
 284   TOOLCHAIN_CC_BINARY_microsoft="cl"
 285   TOOLCHAIN_CC_BINARY_solstudio="cc"
 286   TOOLCHAIN_CC_BINARY_xlc="xlc_r"
 287 
 288   TOOLCHAIN_CXX_BINARY_clang="clang++"
 289   TOOLCHAIN_CXX_BINARY_gcc="g++"
 290   TOOLCHAIN_CXX_BINARY_microsoft="cl"
 291   TOOLCHAIN_CXX_BINARY_solstudio="CC"
 292   TOOLCHAIN_CXX_BINARY_xlc="xlC_r"
 293 








 294   # Use indirect variable referencing
 295   toolchain_var_name=TOOLCHAIN_DESCRIPTION_$TOOLCHAIN_TYPE
 296   TOOLCHAIN_DESCRIPTION=${!toolchain_var_name}
 297   toolchain_var_name=TOOLCHAIN_MINIMUM_VERSION_$TOOLCHAIN_TYPE
 298   TOOLCHAIN_MINIMUM_VERSION=${!toolchain_var_name}
 299   toolchain_var_name=TOOLCHAIN_MINIMUM_LD_VERSION_$TOOLCHAIN_TYPE
 300   TOOLCHAIN_MINIMUM_LD_VERSION=${!toolchain_var_name}
 301   toolchain_var_name=TOOLCHAIN_CC_BINARY_$TOOLCHAIN_TYPE
 302   TOOLCHAIN_CC_BINARY=${!toolchain_var_name}
 303   toolchain_var_name=TOOLCHAIN_CXX_BINARY_$TOOLCHAIN_TYPE
 304   TOOLCHAIN_CXX_BINARY=${!toolchain_var_name}
 305 
 306   TOOLCHAIN_SETUP_FILENAME_PATTERNS
 307 
 308   if test "x$TOOLCHAIN_TYPE" = "x$DEFAULT_TOOLCHAIN"; then
 309     AC_MSG_NOTICE([Using default toolchain $TOOLCHAIN_TYPE ($TOOLCHAIN_DESCRIPTION)])
 310   else
 311     AC_MSG_NOTICE([Using user selected toolchain $TOOLCHAIN_TYPE ($TOOLCHAIN_DESCRIPTION). Default toolchain is $DEFAULT_TOOLCHAIN.])
 312   fi
 313 ])


 316 # special setup, e.g. additional paths etc.
 317 AC_DEFUN_ONCE([TOOLCHAIN_PRE_DETECTION],
 318 [
 319   # FIXME: Is this needed?
 320   AC_LANG(C++)
 321 
 322   # Store the CFLAGS etc passed to the configure script.
 323   ORG_CFLAGS="$CFLAGS"
 324   ORG_CXXFLAGS="$CXXFLAGS"
 325 
 326   # autoconf magic only relies on PATH, so update it if tools dir is specified
 327   OLD_PATH="$PATH"
 328 
 329   # On Windows, we need to detect the visual studio installation first.
 330   # This will change the PATH, but we need to keep that new PATH even
 331   # after toolchain detection is done, since the compiler (on x86) uses
 332   # it for DLL resolution in runtime.
 333   if test "x$OPENJDK_BUILD_OS" = "xwindows" \
 334       && test "x$TOOLCHAIN_TYPE" = "xmicrosoft"; then
 335     TOOLCHAIN_SETUP_VISUAL_STUDIO_ENV
 336     # Reset path to VS_PATH. It will include everything that was on PATH at the time we
 337     # ran TOOLCHAIN_SETUP_VISUAL_STUDIO_ENV.
 338     PATH="$VS_PATH"








 339     # The microsoft toolchain also requires INCLUDE and LIB to be set.
 340     export INCLUDE="$VS_INCLUDE"
 341     export LIB="$VS_LIB"
 342   else
 343     if test "x$XCODE_VERSION_OUTPUT" != x; then
 344       # For Xcode, we set the Xcode version as TOOLCHAIN_VERSION
 345       TOOLCHAIN_VERSION=`$ECHO $XCODE_VERSION_OUTPUT | $CUT -f 2 -d ' '`
 346       TOOLCHAIN_DESCRIPTION="$TOOLCHAIN_DESCRIPTION from Xcode $TOOLCHAIN_VERSION"
 347     else
 348       # Currently we do not define this for other toolchains. This might change as the need arise.
 349       TOOLCHAIN_VERSION=
 350     fi
 351   fi
 352   AC_SUBST(TOOLCHAIN_VERSION)
 353 
 354   # Finally add TOOLCHAIN_PATH at the beginning, to allow --with-tools-dir to
 355   # override all other locations.
 356   if test "x$TOOLCHAIN_PATH" != x; then
 357     PATH=$TOOLCHAIN_PATH:$PATH
 358   fi


 413     #     IBM XL C/C++ for AIX, V11.1 (5724-X13)
 414     #     Version: 11.01.0000.0015
 415     COMPILER_VERSION_OUTPUT=`$COMPILER -qversion 2>&1`
 416     # Check that this is likely to be the IBM XL C compiler.
 417     $ECHO "$COMPILER_VERSION_OUTPUT" | $GREP "IBM XL C" > /dev/null
 418     if test $? -ne 0; then
 419       ALT_VERSION_OUTPUT=`$COMPILER --version 2>&1`
 420       AC_MSG_NOTICE([The $COMPILER_NAME compiler (located as $COMPILER) does not seem to be the required $TOOLCHAIN_TYPE compiler.])
 421       AC_MSG_NOTICE([The result from running with -qversion was: "$COMPILER_VERSION_OUTPUT"])
 422       AC_MSG_NOTICE([The result from running with --version was: "$ALT_VERSION_OUTPUT"])
 423       AC_MSG_ERROR([A $TOOLCHAIN_TYPE compiler is required. Try setting --with-tools-dir.])
 424     fi
 425     # Collapse compiler output into a single line
 426     COMPILER_VERSION_STRING=`$ECHO $COMPILER_VERSION_OUTPUT`
 427     COMPILER_VERSION_NUMBER=`$ECHO $COMPILER_VERSION_OUTPUT | \
 428         $SED -e 's/^.*, V\(@<:@1-9@:>@@<:@0-9.@:>@*\).*$/\1/'`
 429   elif test  "x$TOOLCHAIN_TYPE" = xmicrosoft; then
 430     # There is no specific version flag, but all output starts with a version string.
 431     # First line typically looks something like:
 432     # Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.40219.01 for 80x86
 433     COMPILER_VERSION_OUTPUT=`$COMPILER 2>&1 | $HEAD -n 1 | $TR -d '\r'`
 434     # Check that this is likely to be Microsoft CL.EXE.
 435     $ECHO "$COMPILER_VERSION_OUTPUT" | $GREP "Microsoft.*Compiler" > /dev/null
 436     if test $? -ne 0; then
 437       AC_MSG_NOTICE([The $COMPILER_NAME compiler (located as $COMPILER) does not seem to be the required $TOOLCHAIN_TYPE compiler.])
 438       AC_MSG_NOTICE([The result from running it was: "$COMPILER_VERSION_OUTPUT"])
 439       AC_MSG_ERROR([A $TOOLCHAIN_TYPE compiler is required. Try setting --with-tools-dir.])
 440     fi
 441     # Collapse compiler output into a single line
 442     COMPILER_VERSION_STRING=`$ECHO $COMPILER_VERSION_OUTPUT`
 443     COMPILER_VERSION_NUMBER=`$ECHO $COMPILER_VERSION_OUTPUT | \
 444         $SED -e 's/^.*ersion.\(@<:@1-9@:>@@<:@0-9.@:>@*\) .*$/\1/'`
 445   elif test  "x$TOOLCHAIN_TYPE" = xgcc; then
 446     # gcc --version output typically looks like
 447     #     gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
 448     #     Copyright (C) 2013 Free Software Foundation, Inc.
 449     #     This is free software; see the source for copying conditions.  There is NO
 450     #     warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 451     COMPILER_VERSION_OUTPUT=`$COMPILER --version 2>&1`
 452     # Check that this is likely to be GCC.
 453     $ECHO "$COMPILER_VERSION_OUTPUT" | $GREP "Free Software Foundation" > /dev/null


 573     # using ccache. Instead ccache usage must be controlled by a configure option.
 574     COMPILER_BASENAME=`$BASENAME "$SYMLINK_ORIGINAL"`
 575     if test "x$COMPILER_BASENAME" = "xccache"; then
 576       AC_MSG_NOTICE([Please use --enable-ccache instead of providing a wrapped compiler.])
 577       AC_MSG_ERROR([$TEST_COMPILER is a symbolic link to ccache. This is not supported.])
 578     fi
 579   fi
 580 
 581   TOOLCHAIN_EXTRACT_COMPILER_VERSION([$1], [$COMPILER_NAME])
 582 ])
 583 
 584 # Retrieve the linker version number and store it in LD_VERSION_NUMBER
 585 # (as a dotted number), and
 586 # the full version string in LD_VERSION_STRING.
 587 #
 588 # $1 = linker to test (LD or BUILD_LD)
 589 # $2 = human readable name of linker (Linker or BuildLinker)
 590 AC_DEFUN([TOOLCHAIN_EXTRACT_LD_VERSION],
 591 [
 592   LINKER=[$]$1
 593   LINKER_NAME=$2
 594 
 595   if test "x$TOOLCHAIN_TYPE" = xsolstudio; then
 596     # cc -Wl,-V output typically looks like
 597     #   ld: Software Generation Utilities - Solaris Link Editors: 5.11-1.2329
 598 
 599     # solstudio cc requires us to have an existing file to pass as argument,
 600     # but it need not be a syntactically correct C file, so just use
 601     # ourself. :) The intermediate 'cat' is needed to stop ld from leaving
 602     # a lingering a.out (!).
 603     LINKER_VERSION_STRING=`$LD -Wl,-V $TOPDIR/configure 2>&1 | $CAT | $HEAD -n 1 | $SED -e 's/ld: //'`
 604     # Extract version number
 605     [ LINKER_VERSION_NUMBER=`$ECHO $LINKER_VERSION_STRING | \
 606         $SED -e 's/.* \([0-9][0-9]*\.[0-9][0-9]*\)-\([0-9][0-9]*\.[0-9][0-9]*\)/\1.\2/'` ]
 607   elif test  "x$TOOLCHAIN_TYPE" = xxlc; then
 608     LINKER_VERSION_STRING="Unknown"
 609     LINKER_VERSION_NUMBER="0.0"
 610   elif test  "x$TOOLCHAIN_TYPE" = xmicrosoft; then
 611     # There is no specific version flag, but all output starts with a version string.
 612     # First line typically looks something like:
 613     #   Microsoft (R) Incremental Linker Version 12.00.31101.0
 614     LINKER_VERSION_STRING=`$LD 2>&1 | $HEAD -n 1 | $TR -d '\r'`
 615     # Extract version number
 616     [ LINKER_VERSION_NUMBER=`$ECHO $LINKER_VERSION_STRING | \
 617         $SED -e 's/.* \([0-9][0-9]*\(\.[0-9][0-9]*\)*\).*/\1/'` ]
 618   elif test  "x$TOOLCHAIN_TYPE" = xgcc; then
 619     # gcc -Wl,-version output typically looks like
 620     #   GNU ld (GNU Binutils for Ubuntu) 2.26.1
 621     #   Copyright (C) 2015 Free Software Foundation, Inc.
 622     #   This program is free software; [...]
 623     LINKER_VERSION_STRING=`$LD -Wl,-version 2>&1 | $HEAD -n 1`


 624     # Extract version number
 625     [ LINKER_VERSION_NUMBER=`$ECHO $LINKER_VERSION_STRING | \
 626         $SED -e 's/.* \([0-9][0-9]*\(\.[0-9][0-9]*\)*\).*/\1/'` ]





 627   elif test  "x$TOOLCHAIN_TYPE" = xclang; then
 628     # clang -Wl,-v output typically looks like
 629     #   @(#)PROGRAM:ld  PROJECT:ld64-305
 630     #   configured to support archs: armv6 armv7 armv7s arm64 i386 x86_64 x86_64h armv6m armv7k armv7m armv7em (tvOS)
 631     #   Library search paths: [...]
 632     # or
 633     #   GNU ld (GNU Binutils for Ubuntu) 2.26.1
 634 
 635     LINKER_VERSION_STRING=`$LD -Wl,-v 2>&1 | $HEAD -n 1`
 636     # Check if we're using the GNU ld
 637     $ECHO "$LINKER_VERSION_STRING" | $GREP "GNU" > /dev/null
 638     if test $? -eq 0; then
 639       # Extract version number
 640       [ LINKER_VERSION_NUMBER=`$ECHO $LINKER_VERSION_STRING | \
 641           $SED -e 's/.* \([0-9][0-9]*\(\.[0-9][0-9]*\)*\).*/\1/'` ]
 642     else
 643       # Extract version number
 644       [ LINKER_VERSION_NUMBER=`$ECHO $LINKER_VERSION_STRING | \
 645           $SED -e 's/.*-\([0-9][0-9]*\)/\1/'` ]
 646     fi


 681           AC_MSG_WARN([You are using $TOOLCHAIN_TYPE older than $TOOLCHAIN_MINIMUM_VERSION. This is not a supported configuration.])
 682         ]
 683     )
 684   fi
 685 
 686   #
 687   # Setup the preprocessor (CPP and CXXCPP)
 688   #
 689   AC_PROG_CPP
 690   BASIC_FIXUP_EXECUTABLE(CPP)
 691   AC_PROG_CXXCPP
 692   BASIC_FIXUP_EXECUTABLE(CXXCPP)
 693 
 694   #
 695   # Setup the linker (LD)
 696   #
 697   if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
 698     # In the Microsoft toolchain we have a separate LD command "link".
 699     # Make sure we reject /usr/bin/link (as determined in CYGWIN_LINK), which is
 700     # a cygwin program for something completely different.
 701     AC_CHECK_PROG([LD], [link],[link],,, [$CYGWIN_LINK])
 702     BASIC_FIXUP_EXECUTABLE(LD)
 703     # Verify that we indeed succeeded with this trick.
 704     AC_MSG_CHECKING([if the found link.exe is actually the Visual Studio linker])
 705     "$LD" --version > /dev/null
 706     if test $? -eq 0 ; then
 707       AC_MSG_RESULT([no])
 708       AC_MSG_ERROR([This is the Cygwin link tool. Please check your PATH and rerun configure.])
 709     else
 710       AC_MSG_RESULT([yes])
 711     fi
 712     LDCXX="$LD"


 713   else
 714     # All other toolchains use the compiler to link.
 715     LD="$CC"
 716     LDCXX="$CXX"



 717   fi
 718   AC_SUBST(LD)

 719   # FIXME: it should be CXXLD, according to standard (cf CXXCPP)
 720   AC_SUBST(LDCXX)
 721 
 722   TOOLCHAIN_EXTRACT_LD_VERSION([LD], [linker])
 723   TOOLCHAIN_PREPARE_FOR_LD_VERSION_COMPARISONS
 724 
 725   if test "x$TOOLCHAIN_MINIMUM_LD_VERSION" != x; then
 726     TOOLCHAIN_CHECK_LINKER_VERSION(VERSION: $TOOLCHAIN_MINIMUM_LD_VERSION,
 727         IF_OLDER_THAN: [
 728           AC_MSG_WARN([You are using a linker older than $TOOLCHAIN_MINIMUM_LD_VERSION. This is not a supported configuration.])
 729         ]
 730     )
 731   fi
 732 
 733   #
 734   # Setup the assembler (AS)
 735   #
 736   if test "x$OPENJDK_TARGET_OS" = xsolaris; then
 737     BASIC_PATH_PROGS(AS, as)
 738     BASIC_FIXUP_EXECUTABLE(AS)
 739     if test "x$AS" = x; then
 740       AC_MSG_ERROR([Solaris assembler (as) is required. Please install via "pkg install pkg:/developer/assembler".])
 741     fi
 742   else
 743     # FIXME: is this correct for microsoft?
 744     AS="$CC -c"
 745   fi
 746   AC_SUBST(AS)
 747 
 748   #
 749   # Setup the archiver (AR)
 750   #
 751   if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
 752     # The corresponding ar tool is lib.exe (used to create static libraries)
 753     AC_CHECK_PROG([AR], [lib],[lib],,,)
 754   elif test "x$TOOLCHAIN_TYPE" = xgcc; then
 755     BASIC_CHECK_TOOLS(AR, ar gcc-ar)
 756   else
 757     BASIC_CHECK_TOOLS(AR, ar)
 758   fi
 759   BASIC_FIXUP_EXECUTABLE(AR)
 760 ])
 761 
 762 # Setup additional tools that is considered a part of the toolchain, but not the
 763 # core part. Many of these are highly platform-specific and do not exist,
 764 # and/or are not needed on all platforms.
 765 AC_DEFUN_ONCE([TOOLCHAIN_DETECT_TOOLCHAIN_EXTRA],
 766 [
 767   if test "x$OPENJDK_TARGET_OS" = "xmacosx"; then
 768     BASIC_PATH_PROGS(LIPO, lipo)
 769     BASIC_FIXUP_EXECUTABLE(LIPO)
 770     BASIC_REQUIRE_PROGS(OTOOL, otool)
 771     BASIC_FIXUP_EXECUTABLE(OTOOL)
 772     BASIC_REQUIRE_PROGS(INSTALL_NAME_TOOL, install_name_tool)
 773     BASIC_FIXUP_EXECUTABLE(INSTALL_NAME_TOOL)
 774   fi
 775 
 776   if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
 777     AC_CHECK_PROG([MT], [mt], [mt],,, [/usr/bin/mt])
 778     BASIC_FIXUP_EXECUTABLE(MT)
 779     # Setup the resource compiler (RC)
 780     AC_CHECK_PROG([RC], [rc], [rc],,, [/usr/bin/rc])
 781     BASIC_FIXUP_EXECUTABLE(RC)
 782     AC_CHECK_PROG([DUMPBIN], [dumpbin], [dumpbin],,,)
 783     BASIC_FIXUP_EXECUTABLE(DUMPBIN)
 784     # We need to check for 'msbuild.exe' because at the place where we expect to
 785     # find 'msbuild.exe' there's also a directory called 'msbuild' and configure
 786     # won't find the 'msbuild.exe' executable in that case (and the
 787     # 'ac_executable_extensions' is unusable due to performance reasons).
 788     # Notice that we intentionally don't fix up the path to MSBUILD because we
 789     # will call it in a DOS shell during freetype detection on Windows (see
 790     # 'LIB_SETUP_FREETYPE' in "libraries.m4"
 791     AC_CHECK_PROG([MSBUILD], [msbuild.exe], [msbuild.exe],,,)
 792   fi
 793 
 794   if test "x$OPENJDK_TARGET_OS" = xsolaris; then
 795     BASIC_PATH_PROGS(STRIP, strip)
 796     BASIC_FIXUP_EXECUTABLE(STRIP)
 797     BASIC_PATH_PROGS(NM, nm)
 798     BASIC_FIXUP_EXECUTABLE(NM)
 799     BASIC_PATH_PROGS(GNM, gnm)
 800     BASIC_FIXUP_EXECUTABLE(GNM)
 801   elif test "x$OPENJDK_TARGET_OS" != xwindows; then
 802     # FIXME: we should unify this with the solaris case above.
 803     BASIC_CHECK_TOOLS(STRIP, strip)
 804     BASIC_FIXUP_EXECUTABLE(STRIP)
 805     if test "x$TOOLCHAIN_TYPE" = xgcc; then
 806       BASIC_CHECK_TOOLS(NM, nm gcc-nm)
 807     else
 808       BASIC_CHECK_TOOLS(NM, nm)
 809     fi
 810     BASIC_FIXUP_EXECUTABLE(NM)
 811     GNM="$NM"


 982 
 983     TOOLCHAIN_PREPARE_FOR_VERSION_COMPARISONS([], [OPENJDK_BUILD_])
 984     TOOLCHAIN_PREPARE_FOR_LD_VERSION_COMPARISONS([BUILD_], [OPENJDK_BUILD_])
 985   fi
 986 
 987   AC_SUBST(BUILD_CC)
 988   AC_SUBST(BUILD_CXX)
 989   AC_SUBST(BUILD_LD)
 990   AC_SUBST(BUILD_LDCXX)
 991   AC_SUBST(BUILD_NM)
 992   AC_SUBST(BUILD_AS)
 993   AC_SUBST(BUILD_AR)
 994 ])
 995 
 996 # Do some additional checks on the detected tools.
 997 AC_DEFUN_ONCE([TOOLCHAIN_MISC_CHECKS],
 998 [
 999   # Check for extra potential brokenness.
1000   if test  "x$TOOLCHAIN_TYPE" = xmicrosoft; then
1001     # On Windows, double-check that we got the right compiler.
1002     CC_VERSION_OUTPUT=`$CC 2>&1 | $HEAD -n 1 | $TR -d '\r'`
1003     COMPILER_CPU_TEST=`$ECHO $CC_VERSION_OUTPUT | $SED -n "s/^.* \(.*\)$/\1/p"`
1004     if test "x$OPENJDK_TARGET_CPU" = "xx86"; then
1005       if test "x$COMPILER_CPU_TEST" != "x80x86" -a "x$COMPILER_CPU_TEST" != "xx86"; then
1006         AC_MSG_ERROR([Target CPU mismatch. We are building for $OPENJDK_TARGET_CPU but CL is for "$COMPILER_CPU_TEST"; expected "80x86" or "x86".])
1007       fi
1008     elif test "x$OPENJDK_TARGET_CPU" = "xx86_64"; then
1009       if test "x$COMPILER_CPU_TEST" != "xx64"; then
1010         AC_MSG_ERROR([Target CPU mismatch. We are building for $OPENJDK_TARGET_CPU but CL is for "$COMPILER_CPU_TEST"; expected "x64".])
1011       fi
1012     fi
1013   fi
1014 
1015   if test "x$TOOLCHAIN_TYPE" = xgcc; then
1016     # If this is a --hash-style=gnu system, use --hash-style=both, why?
1017     HAS_GNU_HASH=`$CC -dumpspecs 2>/dev/null | $GREP 'hash-style=gnu'`
1018     # This is later checked when setting flags.
1019   fi
1020 
1021   if test "x$TOOLCHAIN_TYPE" = xgcc || test "x$TOOLCHAIN_TYPE" = xclang; then
1022     # Check if linker has -z noexecstack.


< prev index next >