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