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