blob: 9b16574848fd32e6b5ae0d6356f058bd9efc074d [file] [log] [blame]
Erik Joelsson34570ba2012-07-05 18:27:07 -07001#
Magnus Ihse Bursie0bedc5f2014-02-24 12:16:58 +01002# Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
Erik Joelsson34570ba2012-07-05 18:27:07 -07003# 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
Magnus Ihse Bursie0bedc5f2014-02-24 12:16:58 +010026########################################################################
Mike Duigou7b2f1d22014-06-12 16:33:32 -070027# This file is responsible for detecting, verifying and setting up the
28# toolchain, i.e. the compiler, linker and related utilities. It will setup
Magnus Ihse Bursie0bedc5f2014-02-24 12:16:58 +010029# proper paths to the binaries, but it will not setup any flags.
30#
Mike Duigou7b2f1d22014-06-12 16:33:32 -070031# The binaries used is determined by the toolchain type, which is the family of
Magnus Ihse Bursie0bedc5f2014-02-24 12:16:58 +010032# compilers and related tools that are used.
33########################################################################
34
35
36# All valid toolchains, regardless of platform (used by help.m4)
37VALID_TOOLCHAINS_all="gcc clang solstudio xlc microsoft"
38
39# These toolchains are valid on different platforms
40VALID_TOOLCHAINS_linux="gcc clang"
41VALID_TOOLCHAINS_solaris="solstudio"
42VALID_TOOLCHAINS_macosx="gcc clang"
43VALID_TOOLCHAINS_aix="xlc"
44VALID_TOOLCHAINS_windows="microsoft"
45
46# Toolchain descriptions
47TOOLCHAIN_DESCRIPTION_clang="clang/LLVM"
48TOOLCHAIN_DESCRIPTION_gcc="GNU Compiler Collection"
49TOOLCHAIN_DESCRIPTION_microsoft="Microsoft Visual Studio"
50TOOLCHAIN_DESCRIPTION_solstudio="Oracle Solaris Studio"
51TOOLCHAIN_DESCRIPTION_xlc="IBM XL C/C++"
52
53# Setup a number of variables describing how native output files are
54# named on this platform/toolchain.
55AC_DEFUN([TOOLCHAIN_SETUP_FILENAME_PATTERNS],
56[
57 # Define filename patterns
58 if test "x$OPENJDK_TARGET_OS" = xwindows; then
59 LIBRARY_PREFIX=
60 SHARED_LIBRARY_SUFFIX='.dll'
61 STATIC_LIBRARY_SUFFIX='.lib'
62 SHARED_LIBRARY='[$]1.dll'
63 STATIC_LIBRARY='[$]1.lib'
64 OBJ_SUFFIX='.obj'
65 EXE_SUFFIX='.exe'
66 else
67 LIBRARY_PREFIX=lib
68 SHARED_LIBRARY_SUFFIX='.so'
69 STATIC_LIBRARY_SUFFIX='.a'
70 SHARED_LIBRARY='lib[$]1.so'
71 STATIC_LIBRARY='lib[$]1.a'
72 OBJ_SUFFIX='.o'
73 EXE_SUFFIX=''
74 if test "x$OPENJDK_TARGET_OS" = xmacosx; then
75 SHARED_LIBRARY='lib[$]1.dylib'
76 SHARED_LIBRARY_SUFFIX='.dylib'
77 fi
78 fi
79
80 AC_SUBST(LIBRARY_PREFIX)
81 AC_SUBST(SHARED_LIBRARY_SUFFIX)
82 AC_SUBST(STATIC_LIBRARY_SUFFIX)
83 AC_SUBST(SHARED_LIBRARY)
84 AC_SUBST(STATIC_LIBRARY)
85 AC_SUBST(OBJ_SUFFIX)
Mike Duigou7b2f1d22014-06-12 16:33:32 -070086 AC_SUBST(EXE_SUFFIX)
Magnus Ihse Bursie0bedc5f2014-02-24 12:16:58 +010087])
88
89# Determine which toolchain type to use, and make sure it is valid for this
90# platform. Setup various information about the selected toolchain.
91AC_DEFUN_ONCE([TOOLCHAIN_DETERMINE_TOOLCHAIN_TYPE],
92[
93 AC_ARG_WITH(toolchain-type, [AS_HELP_STRING([--with-toolchain-type],
94 [the toolchain type (or family) to use, use '--help' to show possible values @<:@platform dependent@:>@])])
95
96 # Use indirect variable referencing
97 toolchain_var_name=VALID_TOOLCHAINS_$OPENJDK_BUILD_OS
98 VALID_TOOLCHAINS=${!toolchain_var_name}
Henry Jen97a80c52014-02-25 23:38:52 -080099
100 if test "x$OPENJDK_TARGET_OS" = xmacosx; then
David Dehaven9110c162014-06-18 12:52:13 -0700101 if test -n "$XCODEBUILD"; then
102 # On Mac OS X, default toolchain to clang after Xcode 5
103 XCODE_VERSION_OUTPUT=`"$XCODEBUILD" -version 2>&1 | $HEAD -n 1`
104 $ECHO "$XCODE_VERSION_OUTPUT" | $GREP "Xcode " > /dev/null
105 if test $? -ne 0; then
106 AC_MSG_ERROR([Failed to determine Xcode version.])
107 fi
108 XCODE_MAJOR_VERSION=`$ECHO $XCODE_VERSION_OUTPUT | \
109 $SED -e 's/^Xcode \(@<:@1-9@:>@@<:@0-9.@:>@*\)/\1/' | \
110 $CUT -f 1 -d .`
111 AC_MSG_NOTICE([Xcode major version: $XCODE_MAJOR_VERSION])
112 if test $XCODE_MAJOR_VERSION -ge 5; then
113 DEFAULT_TOOLCHAIN="clang"
114 else
115 DEFAULT_TOOLCHAIN="gcc"
116 fi
Henry Jen97a80c52014-02-25 23:38:52 -0800117 else
David Dehaven9110c162014-06-18 12:52:13 -0700118 # If Xcode is not installed, but the command line tools are
119 # then we can't run xcodebuild. On these systems we should
120 # default to clang
121 DEFAULT_TOOLCHAIN="clang"
Henry Jen97a80c52014-02-25 23:38:52 -0800122 fi
123 else
124 # First toolchain type in the list is the default
125 DEFAULT_TOOLCHAIN=${VALID_TOOLCHAINS%% *}
126 fi
Mike Duigou7b2f1d22014-06-12 16:33:32 -0700127
Magnus Ihse Bursie0bedc5f2014-02-24 12:16:58 +0100128 if test "x$with_toolchain_type" = xlist; then
129 # List all toolchains
130 AC_MSG_NOTICE([The following toolchains are valid on this platform:])
131 for toolchain in $VALID_TOOLCHAINS; do
132 toolchain_var_name=TOOLCHAIN_DESCRIPTION_$toolchain
133 TOOLCHAIN_DESCRIPTION=${!toolchain_var_name}
134 $PRINTF " %-10s %s\n" $toolchain "$TOOLCHAIN_DESCRIPTION"
135 done
Mike Duigou7b2f1d22014-06-12 16:33:32 -0700136
Magnus Ihse Bursie0bedc5f2014-02-24 12:16:58 +0100137 exit 0
138 elif test "x$with_toolchain_type" != x; then
139 # User override; check that it is valid
140 if test "x${VALID_TOOLCHAINS/$with_toolchain_type/}" = "x${VALID_TOOLCHAINS}"; then
141 AC_MSG_NOTICE([Toolchain type $with_toolchain_type is not valid on this platform.])
142 AC_MSG_NOTICE([Valid toolchains: $VALID_TOOLCHAINS.])
143 AC_MSG_ERROR([Cannot continue.])
144 fi
145 TOOLCHAIN_TYPE=$with_toolchain_type
146 else
147 # No flag given, use default
148 TOOLCHAIN_TYPE=$DEFAULT_TOOLCHAIN
149 fi
150 AC_SUBST(TOOLCHAIN_TYPE)
151
152 TOOLCHAIN_CC_BINARY_clang="clang"
153 TOOLCHAIN_CC_BINARY_gcc="gcc"
154 TOOLCHAIN_CC_BINARY_microsoft="cl"
155 TOOLCHAIN_CC_BINARY_solstudio="cc"
156 TOOLCHAIN_CC_BINARY_xlc="xlc_r"
157
158 TOOLCHAIN_CXX_BINARY_clang="clang++"
159 TOOLCHAIN_CXX_BINARY_gcc="g++"
160 TOOLCHAIN_CXX_BINARY_microsoft="cl"
161 TOOLCHAIN_CXX_BINARY_solstudio="CC"
162 TOOLCHAIN_CXX_BINARY_xlc="xlC_r"
163
164 # Use indirect variable referencing
165 toolchain_var_name=TOOLCHAIN_DESCRIPTION_$TOOLCHAIN_TYPE
166 TOOLCHAIN_DESCRIPTION=${!toolchain_var_name}
167 toolchain_var_name=TOOLCHAIN_CC_BINARY_$TOOLCHAIN_TYPE
168 TOOLCHAIN_CC_BINARY=${!toolchain_var_name}
169 toolchain_var_name=TOOLCHAIN_CXX_BINARY_$TOOLCHAIN_TYPE
170 TOOLCHAIN_CXX_BINARY=${!toolchain_var_name}
171
172 TOOLCHAIN_SETUP_FILENAME_PATTERNS
173
174 if test "x$TOOLCHAIN_TYPE" = "x$DEFAULT_TOOLCHAIN"; then
175 AC_MSG_NOTICE([Using default toolchain $TOOLCHAIN_TYPE ($TOOLCHAIN_DESCRIPTION)])
176 else
177 AC_MSG_NOTICE([Using user selected toolchain $TOOLCHAIN_TYPE ($TOOLCHAIN_DESCRIPTION). Default toolchain is $DEFAULT_TOOLCHAIN.])
Mike Duigou7b2f1d22014-06-12 16:33:32 -0700178 fi
Magnus Ihse Bursie0bedc5f2014-02-24 12:16:58 +0100179])
180
Mike Duigou7b2f1d22014-06-12 16:33:32 -0700181# Before we start detecting the toolchain executables, we might need some
Magnus Ihse Bursie0bedc5f2014-02-24 12:16:58 +0100182# special setup, e.g. additional paths etc.
183AC_DEFUN_ONCE([TOOLCHAIN_PRE_DETECTION],
184[
185 # FIXME: Is this needed?
186 AC_LANG(C++)
187
188 # Store the CFLAGS etc passed to the configure script.
189 ORG_CFLAGS="$CFLAGS"
190 ORG_CXXFLAGS="$CXXFLAGS"
191 ORG_OBJCFLAGS="$OBJCFLAGS"
192
Magnus Ihse Bursiee7066f32014-02-25 15:19:32 +0100193 # On Windows, we need to detect the visual studio installation first.
Mike Duigou7b2f1d22014-06-12 16:33:32 -0700194 # This will change the PATH, but we need to keep that new PATH even
Magnus Ihse Bursiee7066f32014-02-25 15:19:32 +0100195 # after toolchain detection is done, since the compiler (on x86) uses
196 # it for DLL resolution in runtime.
197 if test "x$OPENJDK_BUILD_OS" = "xwindows" && test "x$TOOLCHAIN_TYPE" = "xmicrosoft"; then
198 TOOLCHAIN_SETUP_VISUAL_STUDIO_ENV
Magnus Ihse Bursie268191c2014-03-31 22:30:11 +0200199 # Reset path to VS_PATH. It will include everything that was on PATH at the time we
200 # ran TOOLCHAIN_SETUP_VISUAL_STUDIO_ENV.
201 PATH="$VS_PATH"
202 # The microsoft toolchain also requires INCLUDE and LIB to be set.
203 export INCLUDE="$VS_INCLUDE"
204 export LIB="$VS_LIB"
Magnus Ihse Bursiee7066f32014-02-25 15:19:32 +0100205 fi
206
Magnus Ihse Bursie0bedc5f2014-02-24 12:16:58 +0100207 # autoconf magic only relies on PATH, so update it if tools dir is specified
208 OLD_PATH="$PATH"
209
210 # For solaris we really need solaris tools, and not the GNU equivalent.
211 # The build tools on Solaris reside in /usr/ccs (C Compilation System),
212 # so add that to path before starting to probe.
213 # FIXME: This was originally only done for AS,NM,GNM,STRIP,MCS,OBJCOPY,OBJDUMP.
214 if test "x$OPENJDK_BUILD_OS" = xsolaris; then
215 PATH="/usr/ccs/bin:$PATH"
216 fi
217
Mike Duigou7b2f1d22014-06-12 16:33:32 -0700218 # Finally add TOOLCHAIN_PATH at the beginning, to allow --with-tools-dir to
Magnus Ihse Bursie0bedc5f2014-02-24 12:16:58 +0100219 # override all other locations.
Erik Joelsson4cbd0142014-03-28 14:59:56 +0100220 if test "x$TOOLCHAIN_PATH" != x; then
221 PATH=$TOOLCHAIN_PATH:$PATH
Magnus Ihse Bursie0bedc5f2014-02-24 12:16:58 +0100222 fi
Magnus Ihse Bursie0bedc5f2014-02-24 12:16:58 +0100223])
224
225# Restore path, etc
226AC_DEFUN_ONCE([TOOLCHAIN_POST_DETECTION],
227[
228 # Restore old path.
229 PATH="$OLD_PATH"
230
231 # Restore the flags to the user specified values.
232 # This is necessary since AC_PROG_CC defaults CFLAGS to "-g -O2"
233 CFLAGS="$ORG_CFLAGS"
234 CXXFLAGS="$ORG_CXXFLAGS"
235 OBJCFLAGS="$ORG_OBJCFLAGS"
236])
237
238# Check if a compiler is of the toolchain type we expect, and save the version
239# information from it. If the compiler does not match the expected type,
240# this function will abort using AC_MSG_ERROR. If it matches, the version will
241# be stored in CC_VERSION_NUMBER/CXX_VERSION_NUMBER (as a dotted number), and
242# the full version string in CC_VERSION_STRING/CXX_VERSION_STRING.
243#
Kelly O'Hairf9c6f4b2012-10-26 14:29:57 -0700244# $1 = compiler to test (CC or CXX)
245# $2 = human readable name of compiler (C or C++)
246AC_DEFUN([TOOLCHAIN_CHECK_COMPILER_VERSION],
Erik Joelsson34570ba2012-07-05 18:27:07 -0700247[
Kelly O'Hairf9c6f4b2012-10-26 14:29:57 -0700248 COMPILER=[$]$1
249 COMPILER_NAME=$2
Erik Joelsson34570ba2012-07-05 18:27:07 -0700250
Magnus Ihse Bursie0bedc5f2014-02-24 12:16:58 +0100251 if test "x$TOOLCHAIN_TYPE" = xsolstudio; then
252 # cc -V output typically looks like
253 # cc: Sun C 5.12 Linux_i386 2011/11/16
254 COMPILER_VERSION_OUTPUT=`$COMPILER -V 2>&1`
255 # Check that this is likely to be the Solaris Studio cc.
256 $ECHO "$COMPILER_VERSION_OUTPUT" | $GREP "^.*: Sun $COMPILER_NAME" > /dev/null
Kelly O'Hairf9c6f4b2012-10-26 14:29:57 -0700257 if test $? -ne 0; then
Magnus Ihse Bursie0bedc5f2014-02-24 12:16:58 +0100258 ALT_VERSION_OUTPUT=`$COMPILER --version 2>&1`
259 AC_MSG_NOTICE([The $COMPILER_NAME compiler (located as $COMPILER) does not seem to be the required $TOOLCHAIN_TYPE compiler.])
260 AC_MSG_NOTICE([The result from running with -V was: "$COMPILER_VERSION_OUTPUT"])
261 AC_MSG_NOTICE([The result from running with --version was: "$ALT_VERSION_OUTPUT"])
262 AC_MSG_ERROR([A $TOOLCHAIN_TYPE compiler is required. Try setting --with-tools-dir.])
Kelly O'Hairf9c6f4b2012-10-26 14:29:57 -0700263 fi
Mike Duigou7b2f1d22014-06-12 16:33:32 -0700264 # Remove usage instructions (if present), and
Magnus Ihse Bursie0bedc5f2014-02-24 12:16:58 +0100265 # collapse compiler output into a single line
266 COMPILER_VERSION_STRING=`$ECHO $COMPILER_VERSION_OUTPUT | \
267 $SED -e 's/ *@<:@Uu@:>@sage:.*//'`
268 COMPILER_VERSION_NUMBER=`$ECHO $COMPILER_VERSION_OUTPUT | \
269 $SED -e "s/^.*@<:@ ,\t@:>@$COMPILER_NAME@<:@ ,\t@:>@\(@<:@1-9@:>@\.@<:@0-9@:>@@<:@0-9@:>@*\).*/\1/"`
270 elif test "x$TOOLCHAIN_TYPE" = xxlc; then
271 # xlc -qversion output typically looks like
272 # IBM XL C/C++ for AIX, V11.1 (5724-X13)
273 # Version: 11.01.0000.0015
274 COMPILER_VERSION_OUTPUT=`$COMPILER -qversion 2>&1`
275 # Check that this is likely to be the IBM XL C compiler.
276 $ECHO "$COMPILER_VERSION_OUTPUT" | $GREP "IBM XL C" > /dev/null
277 if test $? -ne 0; then
278 ALT_VERSION_OUTPUT=`$COMPILER --version 2>&1`
279 AC_MSG_NOTICE([The $COMPILER_NAME compiler (located as $COMPILER) does not seem to be the required $TOOLCHAIN_TYPE compiler.])
280 AC_MSG_NOTICE([The result from running with -qversion was: "$COMPILER_VERSION_OUTPUT"])
281 AC_MSG_NOTICE([The result from running with --version was: "$ALT_VERSION_OUTPUT"])
282 AC_MSG_ERROR([A $TOOLCHAIN_TYPE compiler is required. Try setting --with-tools-dir.])
283 fi
284 # Collapse compiler output into a single line
285 COMPILER_VERSION_STRING=`$ECHO $COMPILER_VERSION_OUTPUT`
286 COMPILER_VERSION_NUMBER=`$ECHO $COMPILER_VERSION_OUTPUT | \
287 $SED -e 's/^.*, V\(@<:@1-9@:>@@<:@0-9.@:>@*\).*$/\1/'`
288 elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
289 # There is no specific version flag, but all output starts with a version string.
Kelly O'Hairf9c6f4b2012-10-26 14:29:57 -0700290 # First line typically looks something like:
Tim Bell3cb6eed2013-10-09 18:51:32 -0700291 # Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.40219.01 for 80x86
Mike Duigou7b2f1d22014-06-12 16:33:32 -0700292 COMPILER_VERSION_OUTPUT=`$COMPILER 2>&1 | $HEAD -n 1 | $TR -d '\r'`
Magnus Ihse Bursie0bedc5f2014-02-24 12:16:58 +0100293 # Check that this is likely to be Microsoft CL.EXE.
294 $ECHO "$COMPILER_VERSION_OUTPUT" | $GREP "Microsoft.*Compiler" > /dev/null
Kelly O'Hairf9c6f4b2012-10-26 14:29:57 -0700295 if test $? -ne 0; then
Magnus Ihse Bursie0bedc5f2014-02-24 12:16:58 +0100296 AC_MSG_NOTICE([The $COMPILER_NAME compiler (located as $COMPILER) does not seem to be the required $TOOLCHAIN_TYPE compiler.])
297 AC_MSG_NOTICE([The result from running it was: "$COMPILER_VERSION_OUTPUT"])
298 AC_MSG_ERROR([A $TOOLCHAIN_TYPE compiler is required. Try setting --with-tools-dir.])
Kelly O'Hair228c2162012-09-18 11:29:16 -0700299 fi
Magnus Ihse Bursie0bedc5f2014-02-24 12:16:58 +0100300 # Collapse compiler output into a single line
301 COMPILER_VERSION_STRING=`$ECHO $COMPILER_VERSION_OUTPUT`
302 COMPILER_VERSION_NUMBER=`$ECHO $COMPILER_VERSION_OUTPUT | \
303 $SED -e 's/^.*ersion.\(@<:@1-9@:>@@<:@0-9.@:>@*\) .*$/\1/'`
304 elif test "x$TOOLCHAIN_TYPE" = xgcc; then
305 # gcc --version output typically looks like
306 # gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
307 # Copyright (C) 2013 Free Software Foundation, Inc.
308 # This is free software; see the source for copying conditions. There is NO
309 # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
310 COMPILER_VERSION_OUTPUT=`$COMPILER --version 2>&1`
311 # Check that this is likely to be GCC.
312 $ECHO "$COMPILER_VERSION_OUTPUT" | $GREP "Free Software Foundation" > /dev/null
313 if test $? -ne 0; then
314 AC_MSG_NOTICE([The $COMPILER_NAME compiler (located as $COMPILER) does not seem to be the required $TOOLCHAIN_TYPE compiler.])
315 AC_MSG_NOTICE([The result from running with --version was: "$COMPILER_VERSION"])
316 AC_MSG_ERROR([A $TOOLCHAIN_TYPE compiler is required. Try setting --with-tools-dir.])
317 fi
318 # Remove Copyright and legalese from version string, and
319 # collapse into a single line
320 COMPILER_VERSION_STRING=`$ECHO $COMPILER_VERSION_OUTPUT | \
321 $SED -e 's/ *Copyright .*//'`
322 COMPILER_VERSION_NUMBER=`$ECHO $COMPILER_VERSION_OUTPUT | \
323 $SED -e 's/^.* \(@<:@1-9@:>@\.@<:@0-9.@:>@*\) .*$/\1/'`
324 elif test "x$TOOLCHAIN_TYPE" = xclang; then
325 # clang --version output typically looks like
326 # Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn)
327 # clang version 3.3 (tags/RELEASE_33/final)
328 # or
329 # Debian clang version 3.2-7ubuntu1 (tags/RELEASE_32/final) (based on LLVM 3.2)
330 # Target: x86_64-pc-linux-gnu
331 # Thread model: posix
332 COMPILER_VERSION_OUTPUT=`$COMPILER --version 2>&1`
333 # Check that this is likely to be clang
334 $ECHO "$COMPILER_VERSION_OUTPUT" | $GREP "clang" > /dev/null
335 if test $? -ne 0; then
336 AC_MSG_NOTICE([The $COMPILER_NAME compiler (located as $COMPILER) does not seem to be the required $TOOLCHAIN_TYPE compiler.])
337 AC_MSG_NOTICE([The result from running with --version was: "$COMPILER_VERSION_OUTPUT"])
338 AC_MSG_ERROR([A $TOOLCHAIN_TYPE compiler is required. Try setting --with-tools-dir.])
339 fi
340 # Collapse compiler output into a single line
341 COMPILER_VERSION_STRING=`$ECHO $COMPILER_VERSION_OUTPUT`
342 COMPILER_VERSION_NUMBER=`$ECHO $COMPILER_VERSION_OUTPUT | \
343 $SED -e 's/^.*clang version \(@<:@1-9@:>@@<:@0-9.@:>@*\).*$/\1/'`
344 else
345 AC_MSG_ERROR([Unknown toolchain type $TOOLCHAIN_TYPE.])
Kelly O'Hairf9c6f4b2012-10-26 14:29:57 -0700346 fi
Magnus Ihse Bursie0bedc5f2014-02-24 12:16:58 +0100347 # This sets CC_VERSION_NUMBER or CXX_VERSION_NUMBER. (This comment is a grep marker)
348 $1_VERSION_NUMBER="$COMPILER_VERSION_NUMBER"
349 # This sets CC_VERSION_STRING or CXX_VERSION_STRING. (This comment is a grep marker)
350 $1_VERSION_STRING="$COMPILER_VERSION_STRING"
Erik Joelsson34570ba2012-07-05 18:27:07 -0700351
Magnus Ihse Bursie0bedc5f2014-02-24 12:16:58 +0100352 AC_MSG_NOTICE([Using $TOOLCHAIN_TYPE $COMPILER_NAME compiler version $COMPILER_VERSION_NUMBER @<:@$COMPILER_VERSION_STRING@:>@])
Erik Joelsson34570ba2012-07-05 18:27:07 -0700353])
354
Magnus Ihse Bursie0bedc5f2014-02-24 12:16:58 +0100355# Try to locate the given C or C++ compiler in the path, or otherwise.
356#
Kelly O'Hairf9c6f4b2012-10-26 14:29:57 -0700357# $1 = compiler to test (CC or CXX)
358# $2 = human readable name of compiler (C or C++)
359# $3 = list of compiler names to search for
360AC_DEFUN([TOOLCHAIN_FIND_COMPILER],
Erik Joelsson34570ba2012-07-05 18:27:07 -0700361[
Kelly O'Hairf9c6f4b2012-10-26 14:29:57 -0700362 COMPILER_NAME=$2
Magnus Ihse Bursie4d64b2e2014-01-28 14:47:22 +0100363 SEARCH_LIST="$3"
Kelly O'Hairf9c6f4b2012-10-26 14:29:57 -0700364
Magnus Ihse Bursie4d64b2e2014-01-28 14:47:22 +0100365 if test "x[$]$1" != x; then
366 # User has supplied compiler name already, always let that override.
367 AC_MSG_NOTICE([Will use user supplied compiler $1=[$]$1])
368 if test "x`basename [$]$1`" = "x[$]$1"; then
369 # A command without a complete path is provided, search $PATH.
Mike Duigou7b2f1d22014-06-12 16:33:32 -0700370
Magnus Ihse Bursie4d64b2e2014-01-28 14:47:22 +0100371 AC_PATH_PROGS(POTENTIAL_$1, [$]$1)
372 if test "x$POTENTIAL_$1" != x; then
373 $1=$POTENTIAL_$1
374 else
375 AC_MSG_ERROR([User supplied compiler $1=[$]$1 could not be found])
376 fi
377 else
378 # Otherwise it might already be a complete path
379 if test ! -x "[$]$1"; then
380 AC_MSG_ERROR([User supplied compiler $1=[$]$1 does not exist])
381 fi
382 fi
383 else
Magnus Ihse Bursie0bedc5f2014-02-24 12:16:58 +0100384 # No user supplied value. Locate compiler ourselves.
Mike Duigou7b2f1d22014-06-12 16:33:32 -0700385
Magnus Ihse Bursie0bedc5f2014-02-24 12:16:58 +0100386 # If we are cross compiling, assume cross compilation tools follows the
387 # cross compilation standard where they are prefixed with the autoconf
Mike Duigou7b2f1d22014-06-12 16:33:32 -0700388 # standard name for the target. For example the binary
Magnus Ihse Bursie0bedc5f2014-02-24 12:16:58 +0100389 # i686-sun-solaris2.10-gcc will cross compile for i686-sun-solaris2.10.
Mike Duigou7b2f1d22014-06-12 16:33:32 -0700390 # If we are not cross compiling, then the default compiler name will be
Magnus Ihse Bursie0bedc5f2014-02-24 12:16:58 +0100391 # used.
392
Magnus Ihse Bursie4d64b2e2014-01-28 14:47:22 +0100393 $1=
Erik Joelsson4cbd0142014-03-28 14:59:56 +0100394 # If TOOLCHAIN_PATH is set, check for all compiler names in there first
Magnus Ihse Bursie4d64b2e2014-01-28 14:47:22 +0100395 # before checking the rest of the PATH.
Magnus Ihse Bursie0bedc5f2014-02-24 12:16:58 +0100396 # FIXME: Now that we prefix the TOOLS_DIR to the PATH in the PRE_DETECTION
397 # step, this should not be necessary.
Erik Joelsson4cbd0142014-03-28 14:59:56 +0100398 if test -n "$TOOLCHAIN_PATH"; then
Magnus Ihse Bursie4d64b2e2014-01-28 14:47:22 +0100399 PATH_save="$PATH"
Erik Joelsson4cbd0142014-03-28 14:59:56 +0100400 PATH="$TOOLCHAIN_PATH"
401 AC_PATH_PROGS(TOOLCHAIN_PATH_$1, $SEARCH_LIST)
402 $1=$TOOLCHAIN_PATH_$1
Magnus Ihse Bursie4d64b2e2014-01-28 14:47:22 +0100403 PATH="$PATH_save"
404 fi
405
406 # AC_PATH_PROGS can't be run multiple times with the same variable,
407 # so create a new name for this run.
408 if test "x[$]$1" = x; then
409 AC_PATH_PROGS(POTENTIAL_$1, $SEARCH_LIST)
410 $1=$POTENTIAL_$1
411 fi
412
413 if test "x[$]$1" = x; then
414 HELP_MSG_MISSING_DEPENDENCY([devkit])
415 AC_MSG_ERROR([Could not find a $COMPILER_NAME compiler. $HELP_MSG])
416 fi
Erik Joelssonf5fc8bc2012-12-11 11:29:58 +0100417 fi
418
Magnus Ihse Bursie4d64b2e2014-01-28 14:47:22 +0100419 # Now we have a compiler binary in $1. Make sure it's okay.
Kelly O'Hairf9c6f4b2012-10-26 14:29:57 -0700420 BASIC_FIXUP_EXECUTABLE($1)
Kelly O'Hairf9c6f4b2012-10-26 14:29:57 -0700421 TEST_COMPILER="[$]$1"
Volker Simonis988aff42013-09-12 12:29:17 -0700422 # Don't remove symbolic links on AIX because 'xlc_r' and 'xlC_r' may all be links
423 # to 'xlc' but it is crucial that we invoke the compiler with the right name!
424 if test "x$OPENJDK_BUILD_OS" != xaix; then
Magnus Ihse Bursie0bedc5f2014-02-24 12:16:58 +0100425 # FIXME: This test should not be needed anymore; we don't do that for any platform.
Volker Simonis988aff42013-09-12 12:29:17 -0700426 AC_MSG_CHECKING([resolved symbolic links for $1])
427 BASIC_REMOVE_SYMBOLIC_LINKS(TEST_COMPILER)
428 AC_MSG_RESULT([$TEST_COMPILER])
429 fi
Kelly O'Hairf9c6f4b2012-10-26 14:29:57 -0700430 AC_MSG_CHECKING([if $1 is disguised ccache])
Mike Duigou22dc46d2013-06-04 10:36:00 +0200431
Kelly O'Hairf9c6f4b2012-10-26 14:29:57 -0700432 COMPILER_BASENAME=`$BASENAME "$TEST_COMPILER"`
433 if test "x$COMPILER_BASENAME" = "xccache"; then
434 AC_MSG_RESULT([yes, trying to find proper $COMPILER_NAME compiler])
435 # We /usr/lib/ccache in the path, so cc is a symlink to /usr/bin/ccache.
436 # We want to control ccache invocation ourselves, so ignore this cc and try
437 # searching again.
438
439 # Remove the path to the fake ccache cc from the PATH
440 RETRY_COMPILER_SAVED_PATH="$PATH"
441 COMPILER_DIRNAME=`$DIRNAME [$]$1`
442 PATH="`$ECHO $PATH | $SED -e "s,$COMPILER_DIRNAME,,g" -e "s,::,:,g" -e "s,^:,,g"`"
443
444 # Try again looking for our compiler
445 AC_CHECK_TOOLS(PROPER_COMPILER_$1, $3)
446 BASIC_FIXUP_EXECUTABLE(PROPER_COMPILER_$1)
447 PATH="$RETRY_COMPILER_SAVED_PATH"
448
449 AC_MSG_CHECKING([for resolved symbolic links for $1])
450 BASIC_REMOVE_SYMBOLIC_LINKS(PROPER_COMPILER_$1)
451 AC_MSG_RESULT([$PROPER_COMPILER_$1])
452 $1="$PROPER_COMPILER_$1"
453 else
454 AC_MSG_RESULT([no, keeping $1])
Kelly O'Hairf9c6f4b2012-10-26 14:29:57 -0700455 fi
Mike Duigou35219b02014-01-14 10:25:22 -0800456
Kelly O'Hairf9c6f4b2012-10-26 14:29:57 -0700457 TOOLCHAIN_CHECK_COMPILER_VERSION([$1], [$COMPILER_NAME])
458])
459
Mike Duigou7b2f1d22014-06-12 16:33:32 -0700460# Detect the core components of the toolchain, i.e. the compilers (CC and CXX),
461# preprocessor (CPP and CXXCPP), the linker (LD), the assembler (AS) and the
462# archiver (AR). Verify that the compilers are correct according to the
Magnus Ihse Bursie0bedc5f2014-02-24 12:16:58 +0100463# toolchain type.
464AC_DEFUN_ONCE([TOOLCHAIN_DETECT_TOOLCHAIN_CORE],
Kelly O'Hairf9c6f4b2012-10-26 14:29:57 -0700465[
Magnus Ihse Bursie0bedc5f2014-02-24 12:16:58 +0100466 #
467 # Setup the compilers (CC and CXX)
468 #
469 TOOLCHAIN_FIND_COMPILER([CC], [C], $TOOLCHAIN_CC_BINARY)
Magnus Ihse Bursie952d9ce2013-10-10 14:58:19 +0200470 # Now that we have resolved CC ourself, let autoconf have its go at it
471 AC_PROG_CC([$CC])
Kelly O'Hairf9c6f4b2012-10-26 14:29:57 -0700472
Magnus Ihse Bursie0bedc5f2014-02-24 12:16:58 +0100473 TOOLCHAIN_FIND_COMPILER([CXX], [C++], $TOOLCHAIN_CXX_BINARY)
Magnus Ihse Bursie952d9ce2013-10-10 14:58:19 +0200474 # Now that we have resolved CXX ourself, let autoconf have its go at it
475 AC_PROG_CXX([$CXX])
Kelly O'Hairf9c6f4b2012-10-26 14:29:57 -0700476
Magnus Ihse Bursie0bedc5f2014-02-24 12:16:58 +0100477 #
478 # Setup the preprocessor (CPP and CXXCPP)
479 #
480 AC_PROG_CPP
481 BASIC_FIXUP_EXECUTABLE(CPP)
482 AC_PROG_CXXCPP
483 BASIC_FIXUP_EXECUTABLE(CXXCPP)
Kelly O'Hairf9c6f4b2012-10-26 14:29:57 -0700484
Magnus Ihse Bursie0bedc5f2014-02-24 12:16:58 +0100485 #
486 # Setup the linker (LD)
487 #
488 if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
489 # In the Microsoft toolchain we have a separate LD command "link".
490 # Make sure we reject /usr/bin/link (as determined in CYGWIN_LINK), which is
491 # a cygwin program for something completely different.
492 AC_CHECK_PROG([LD], [link],[link],,, [$CYGWIN_LINK])
493 BASIC_FIXUP_EXECUTABLE(LD)
494 # Verify that we indeed succeeded with this trick.
Kelly O'Hair228c2162012-09-18 11:29:16 -0700495 AC_MSG_CHECKING([if the found link.exe is actually the Visual Studio linker])
Magnus Ihse Bursie0bedc5f2014-02-24 12:16:58 +0100496 "$LD" --version > /dev/null
Kelly O'Hair228c2162012-09-18 11:29:16 -0700497 if test $? -eq 0 ; then
498 AC_MSG_RESULT([no])
499 AC_MSG_ERROR([This is the Cygwin link tool. Please check your PATH and rerun configure.])
500 else
501 AC_MSG_RESULT([yes])
502 fi
Magnus Ihse Bursie0bedc5f2014-02-24 12:16:58 +0100503 LDCXX="$LD"
504 else
505 # All other toolchains use the compiler to link.
506 LD="$CC"
507 LDCXX="$CXX"
Magnus Ihse Bursie952d9ce2013-10-10 14:58:19 +0200508 fi
Magnus Ihse Bursie0bedc5f2014-02-24 12:16:58 +0100509 AC_SUBST(LD)
510 # FIXME: it should be CXXLD, according to standard (cf CXXCPP)
511 AC_SUBST(LDCXX)
Erik Joelsson34570ba2012-07-05 18:27:07 -0700512
Magnus Ihse Bursie952d9ce2013-10-10 14:58:19 +0200513 #
Magnus Ihse Bursie0bedc5f2014-02-24 12:16:58 +0100514 # Setup the assembler (AS)
515 #
Magnus Ihse Bursie952d9ce2013-10-10 14:58:19 +0200516 if test "x$OPENJDK_TARGET_OS" = xsolaris; then
Magnus Ihse Bursie0bedc5f2014-02-24 12:16:58 +0100517 # FIXME: should this really be solaris, or solstudio?
Magnus Ihse Bursie57fe89a2014-01-29 11:21:54 +0100518 BASIC_PATH_PROGS(AS, as)
Kelly O'Hairf9c6f4b2012-10-26 14:29:57 -0700519 BASIC_FIXUP_EXECUTABLE(AS)
Magnus Ihse Bursie952d9ce2013-10-10 14:58:19 +0200520 else
Magnus Ihse Bursie0bedc5f2014-02-24 12:16:58 +0100521 # FIXME: is this correct for microsoft?
Erik Joelsson34570ba2012-07-05 18:27:07 -0700522 AS="$CC -c"
Magnus Ihse Bursie952d9ce2013-10-10 14:58:19 +0200523 fi
524 AC_SUBST(AS)
Erik Joelsson34570ba2012-07-05 18:27:07 -0700525
Magnus Ihse Bursie0bedc5f2014-02-24 12:16:58 +0100526 #
527 # Setup the archiver (AR)
528 #
529 if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
530 # The corresponding ar tool is lib.exe (used to create static libraries)
531 AC_CHECK_PROG([AR], [lib],[lib],,,)
532 else
533 BASIC_CHECK_TOOLS(AR, ar)
534 fi
535 BASIC_FIXUP_EXECUTABLE(AR)
536])
537
538# Setup additional tools that is considered a part of the toolchain, but not the
Mike Duigou7b2f1d22014-06-12 16:33:32 -0700539# core part. Many of these are highly platform-specific and do not exist,
Magnus Ihse Bursie0bedc5f2014-02-24 12:16:58 +0100540# and/or are not needed on all platforms.
541AC_DEFUN_ONCE([TOOLCHAIN_DETECT_TOOLCHAIN_EXTRA],
542[
543 if test "x$OPENJDK_TARGET_OS" = "xmacosx"; then
544 AC_PROG_OBJC
545 BASIC_FIXUP_EXECUTABLE(OBJC)
546 BASIC_PATH_PROGS(LIPO, lipo)
547 BASIC_FIXUP_EXECUTABLE(LIPO)
548 else
549 OBJC=
550 fi
551
552 if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
553 AC_CHECK_PROG([MT], [mt], [mt],,, [/usr/bin/mt])
554 BASIC_FIXUP_EXECUTABLE(MT)
555 # Setup the resource compiler (RC)
556 AC_CHECK_PROG([RC], [rc], [rc],,, [/usr/bin/rc])
557 BASIC_FIXUP_EXECUTABLE(RC)
558 AC_CHECK_PROG([DUMPBIN], [dumpbin], [dumpbin],,,)
559 BASIC_FIXUP_EXECUTABLE(DUMPBIN)
Volker Simoniscdb4a8c2014-09-09 17:42:07 +0100560 # We need to check for 'msbuild.exe' because at the place where we expect to
561 # find 'msbuild.exe' there's also a directory called 'msbuild' and configure
562 # won't find the 'msbuild.exe' executable in that case (and the
563 # 'ac_executable_extensions' is unusable due to performance reasons).
564 # Notice that we intentionally don't fix up the path to MSBUILD because we
565 # will call it in a DOS shell during freetype detection on Windows (see
566 # 'LIB_SETUP_FREETYPE' in "libraries.m4"
567 AC_CHECK_PROG([MSBUILD], [msbuild.exe], [msbuild.exe],,,)
Magnus Ihse Bursie0bedc5f2014-02-24 12:16:58 +0100568 fi
Mike Duigou7b2f1d22014-06-12 16:33:32 -0700569
Magnus Ihse Bursie952d9ce2013-10-10 14:58:19 +0200570 if test "x$OPENJDK_TARGET_OS" = xsolaris; then
Magnus Ihse Bursie0bedc5f2014-02-24 12:16:58 +0100571 BASIC_PATH_PROGS(STRIP, strip)
572 BASIC_FIXUP_EXECUTABLE(STRIP)
Magnus Ihse Bursie57fe89a2014-01-29 11:21:54 +0100573 BASIC_PATH_PROGS(NM, nm)
Kelly O'Hairf9c6f4b2012-10-26 14:29:57 -0700574 BASIC_FIXUP_EXECUTABLE(NM)
Magnus Ihse Bursie57fe89a2014-01-29 11:21:54 +0100575 BASIC_PATH_PROGS(GNM, gnm)
Erik Joelsson21711142013-04-09 09:42:20 +0200576 BASIC_FIXUP_EXECUTABLE(GNM)
Mike Duigou7b2f1d22014-06-12 16:33:32 -0700577
Magnus Ihse Bursie57fe89a2014-01-29 11:21:54 +0100578 BASIC_PATH_PROGS(MCS, mcs)
Kelly O'Hairf9c6f4b2012-10-26 14:29:57 -0700579 BASIC_FIXUP_EXECUTABLE(MCS)
Magnus Ihse Bursie952d9ce2013-10-10 14:58:19 +0200580 elif test "x$OPENJDK_TARGET_OS" != xwindows; then
Magnus Ihse Bursie0bedc5f2014-02-24 12:16:58 +0100581 # FIXME: we should unify this with the solaris case above.
582 BASIC_CHECK_TOOLS(STRIP, strip)
583 BASIC_FIXUP_EXECUTABLE(STRIP)
Magnus Ihse Bursie57fe89a2014-01-29 11:21:54 +0100584 BASIC_CHECK_TOOLS(NM, nm)
Kelly O'Hairf9c6f4b2012-10-26 14:29:57 -0700585 BASIC_FIXUP_EXECUTABLE(NM)
Erik Joelsson21711142013-04-09 09:42:20 +0200586 GNM="$NM"
587 AC_SUBST(GNM)
Magnus Ihse Bursie952d9ce2013-10-10 14:58:19 +0200588 fi
Erik Joelsson34570ba2012-07-05 18:27:07 -0700589
Magnus Ihse Bursie952d9ce2013-10-10 14:58:19 +0200590 # objcopy is used for moving debug symbols to separate files when
591 # full debug symbols are enabled.
592 if test "x$OPENJDK_TARGET_OS" = xsolaris || test "x$OPENJDK_TARGET_OS" = xlinux; then
Magnus Ihse Bursie57fe89a2014-01-29 11:21:54 +0100593 BASIC_CHECK_TOOLS(OBJCOPY, [gobjcopy objcopy])
Erik Joelsson4850bec2012-11-19 14:06:30 -0800594 # Only call fixup if objcopy was found.
595 if test -n "$OBJCOPY"; then
Magnus Ihse Bursie952d9ce2013-10-10 14:58:19 +0200596 BASIC_FIXUP_EXECUTABLE(OBJCOPY)
Erik Joelsson4850bec2012-11-19 14:06:30 -0800597 fi
Magnus Ihse Bursie952d9ce2013-10-10 14:58:19 +0200598 fi
Kelly O'Hairf9c6f4b2012-10-26 14:29:57 -0700599
Magnus Ihse Bursie57fe89a2014-01-29 11:21:54 +0100600 BASIC_CHECK_TOOLS(OBJDUMP, [gobjdump objdump])
Magnus Ihse Bursie952d9ce2013-10-10 14:58:19 +0200601 if test "x$OBJDUMP" != x; then
Magnus Ihse Bursie0bedc5f2014-02-24 12:16:58 +0100602 # Only used for compare.sh; we can live without it. BASIC_FIXUP_EXECUTABLE
603 # bails if argument is missing.
Magnus Ihse Bursie952d9ce2013-10-10 14:58:19 +0200604 BASIC_FIXUP_EXECUTABLE(OBJDUMP)
605 fi
Erik Joelsson34570ba2012-07-05 18:27:07 -0700606])
607
Magnus Ihse Bursie0bedc5f2014-02-24 12:16:58 +0100608# Setup the build tools (i.e, the compiler and linker used to build programs
609# that should be run on the build platform, not the target platform, as a build
Mike Duigou7b2f1d22014-06-12 16:33:32 -0700610# helper). Since the non-cross-compile case uses the normal, target compilers
Magnus Ihse Bursie0bedc5f2014-02-24 12:16:58 +0100611# for this, we can only do this after these have been setup.
612AC_DEFUN_ONCE([TOOLCHAIN_SETUP_BUILD_COMPILERS],
Mike Duigou7b2f1d22014-06-12 16:33:32 -0700613[
Magnus Ihse Bursie0bedc5f2014-02-24 12:16:58 +0100614 if test "x$COMPILE_TYPE" = "xcross"; then
615 # Now we need to find a C/C++ compiler that can build executables for the
616 # build platform. We can't use the AC_PROG_CC macro, since it can only be
617 # used once. Also, we need to do this without adding a tools dir to the
618 # path, otherwise we might pick up cross-compilers which don't use standard
619 # naming.
Mike Duigou7b2f1d22014-06-12 16:33:32 -0700620
Magnus Ihse Bursie0bedc5f2014-02-24 12:16:58 +0100621 # FIXME: we should list the discovered compilers as an exclude pattern!
622 # If we do that, we can do this detection before POST_DETECTION, and still
623 # find the build compilers in the tools dir, if needed.
624 BASIC_PATH_PROGS(BUILD_CC, [cl cc gcc])
625 BASIC_FIXUP_EXECUTABLE(BUILD_CC)
626 BASIC_PATH_PROGS(BUILD_CXX, [cl CC g++])
627 BASIC_FIXUP_EXECUTABLE(BUILD_CXX)
628 BASIC_PATH_PROGS(BUILD_LD, ld)
629 BASIC_FIXUP_EXECUTABLE(BUILD_LD)
Magnus Ihse Bursie952d9ce2013-10-10 14:58:19 +0200630 else
Magnus Ihse Bursie0bedc5f2014-02-24 12:16:58 +0100631 # If we are not cross compiling, use the normal target compilers for
632 # building the build platform executables.
633 BUILD_CC="$CC"
634 BUILD_CXX="$CXX"
635 BUILD_LD="$LD"
Magnus Ihse Bursie952d9ce2013-10-10 14:58:19 +0200636 fi
Erik Joelsson34570ba2012-07-05 18:27:07 -0700637
Magnus Ihse Bursie0bedc5f2014-02-24 12:16:58 +0100638 AC_SUBST(BUILD_CC)
639 AC_SUBST(BUILD_CXX)
640 AC_SUBST(BUILD_LD)
Erik Joelsson34570ba2012-07-05 18:27:07 -0700641])
642
Magnus Ihse Bursie0bedc5f2014-02-24 12:16:58 +0100643# Setup legacy variables that are still needed as alternative ways to refer to
644# parts of the toolchain.
645AC_DEFUN_ONCE([TOOLCHAIN_SETUP_LEGACY],
Erik Joelsson34570ba2012-07-05 18:27:07 -0700646[
Magnus Ihse Bursie0bedc5f2014-02-24 12:16:58 +0100647 if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
648 # For hotspot, we need these in Windows mixed path,
649 # so rewrite them all. Need added .exe suffix.
650 HOTSPOT_CXX="$CXX.exe"
651 HOTSPOT_LD="$LD.exe"
652 HOTSPOT_MT="$MT.exe"
653 HOTSPOT_RC="$RC.exe"
654 BASIC_WINDOWS_REWRITE_AS_WINDOWS_MIXED_PATH(HOTSPOT_CXX)
655 BASIC_WINDOWS_REWRITE_AS_WINDOWS_MIXED_PATH(HOTSPOT_LD)
656 BASIC_WINDOWS_REWRITE_AS_WINDOWS_MIXED_PATH(HOTSPOT_MT)
657 BASIC_WINDOWS_REWRITE_AS_WINDOWS_MIXED_PATH(HOTSPOT_RC)
658 AC_SUBST(HOTSPOT_MT)
659 AC_SUBST(HOTSPOT_RC)
660 else
661 HOTSPOT_CXX="$CXX"
662 HOTSPOT_LD="$LD"
Magnus Ihse Bursie952d9ce2013-10-10 14:58:19 +0200663 fi
Magnus Ihse Bursie0bedc5f2014-02-24 12:16:58 +0100664 AC_SUBST(HOTSPOT_CXX)
665 AC_SUBST(HOTSPOT_LD)
Kelly O'Hair228c2162012-09-18 11:29:16 -0700666
Magnus Ihse Bursie0bedc5f2014-02-24 12:16:58 +0100667 if test "x$TOOLCHAIN_TYPE" = xclang; then
668 USE_CLANG=true
Magnus Ihse Bursie952d9ce2013-10-10 14:58:19 +0200669 fi
Magnus Ihse Bursie0bedc5f2014-02-24 12:16:58 +0100670 AC_SUBST(USE_CLANG)
Erik Joelsson34570ba2012-07-05 18:27:07 -0700671
Magnus Ihse Bursie0bedc5f2014-02-24 12:16:58 +0100672 # LDEXE is the linker to use, when creating executables. Not really used.
673 # FIXME: These should just be removed!
674 LDEXE="$LD"
675 LDEXECXX="$LDCXX"
676 AC_SUBST(LDEXE)
677 AC_SUBST(LDEXECXX)
Erik Joelsson34570ba2012-07-05 18:27:07 -0700678])
679
Magnus Ihse Bursie0bedc5f2014-02-24 12:16:58 +0100680# Do some additional checks on the detected tools.
681AC_DEFUN_ONCE([TOOLCHAIN_MISC_CHECKS],
Erik Joelsson34570ba2012-07-05 18:27:07 -0700682[
Magnus Ihse Bursie952d9ce2013-10-10 14:58:19 +0200683 # The package path is used only on macosx?
Magnus Ihse Bursie0bedc5f2014-02-24 12:16:58 +0100684 # FIXME: clean this up, and/or move it elsewhere.
Magnus Ihse Bursie952d9ce2013-10-10 14:58:19 +0200685 PACKAGE_PATH=/opt/local
686 AC_SUBST(PACKAGE_PATH)
Erik Joelsson34570ba2012-07-05 18:27:07 -0700687
Magnus Ihse Bursie0bedc5f2014-02-24 12:16:58 +0100688 # Check for extra potential brokenness.
689 if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
690 # On Windows, double-check that we got the right compiler.
Magnus Ihse Bursiee7066f32014-02-25 15:19:32 +0100691 CC_VERSION_OUTPUT=`$CC 2>&1 | $HEAD -n 1 | $TR -d '\r'`
Magnus Ihse Bursie0bedc5f2014-02-24 12:16:58 +0100692 COMPILER_CPU_TEST=`$ECHO $CC_VERSION_OUTPUT | $SED -n "s/^.* \(.*\)$/\1/p"`
693 if test "x$OPENJDK_TARGET_CPU" = "xx86"; then
694 if test "x$COMPILER_CPU_TEST" != "x80x86"; then
695 AC_MSG_ERROR([Target CPU mismatch. We are building for $OPENJDK_TARGET_CPU but CL is for "$COMPILER_CPU_TEST"; expected "80x86".])
Magnus Ihse Bursie952d9ce2013-10-10 14:58:19 +0200696 fi
Magnus Ihse Bursie0bedc5f2014-02-24 12:16:58 +0100697 elif test "x$OPENJDK_TARGET_CPU" = "xx86_64"; then
698 if test "x$COMPILER_CPU_TEST" != "xx64"; then
699 AC_MSG_ERROR([Target CPU mismatch. We are building for $OPENJDK_TARGET_CPU but CL is for "$COMPILER_CPU_TEST"; expected "x64".])
Magnus Ihse Bursie952d9ce2013-10-10 14:58:19 +0200700 fi
Erik Joelsson34570ba2012-07-05 18:27:07 -0700701 fi
Magnus Ihse Bursie952d9ce2013-10-10 14:58:19 +0200702 fi
Erik Joelsson34570ba2012-07-05 18:27:07 -0700703
Magnus Ihse Bursie0bedc5f2014-02-24 12:16:58 +0100704 if test "x$TOOLCHAIN_TYPE" = xgcc; then
705 # If this is a --hash-style=gnu system, use --hash-style=both, why?
706 HAS_GNU_HASH=`$CC -dumpspecs 2>/dev/null | $GREP 'hash-style=gnu'`
707 # This is later checked when setting flags.
Mike Duigou7b2f1d22014-06-12 16:33:32 -0700708
709 # "-Og" suppported for GCC 4.8 and later
710 CFLAG_OPTIMIZE_DEBUG_FLAG="-Og"
711 FLAGS_COMPILER_CHECK_ARGUMENTS([$CFLAG_OPTIMIZE_DEBUG_FLAG],
712 [HAS_CFLAG_OPTIMIZE_DEBUG=true],
713 [HAS_CFLAG_OPTIMIZE_DEBUG=false])
714
Mike Duigou7b2f1d22014-06-12 16:33:32 -0700715 # "-z relro" supported in GNU binutils 2.17 and later
716 LINKER_RELRO_FLAG="-Xlinker -z -Xlinker relro"
717 FLAGS_LINKER_CHECK_ARGUMENTS([$LINKER_RELRO_FLAG],
718 [HAS_LINKER_RELRO=true],
719 [HAS_LINKER_RELRO=false])
720
721 # "-z now" supported in GNU binutils 2.11 and later
722 LINKER_NOW_FLAG="-Xlinker -z -Xlinker now"
723 FLAGS_LINKER_CHECK_ARGUMENTS([$LINKER_NOW_FLAG],
724 [HAS_LINKER_NOW=true],
725 [HAS_LINKER_NOW=false])
Erik Joelssone44f5ce2013-05-02 15:46:38 +0200726 fi
Erik Joelssone44f5ce2013-05-02 15:46:38 +0200727
Mike Duigou7b2f1d22014-06-12 16:33:32 -0700728 # Check for broken SuSE 'ld' for which 'Only anonymous version tag is allowed
Magnus Ihse Bursie0bedc5f2014-02-24 12:16:58 +0100729 # in executable.'
Volker Simonis23040362013-07-02 17:38:10 -0700730 USING_BROKEN_SUSE_LD=no
Magnus Ihse Bursie0bedc5f2014-02-24 12:16:58 +0100731 if test "x$OPENJDK_TARGET_OS" = xlinux && test "x$TOOLCHAIN_TYPE" = xgcc; then
Volker Simonis23040362013-07-02 17:38:10 -0700732 AC_MSG_CHECKING([for broken SuSE 'ld' which only understands anonymous version tags in executables])
Mike Duigou7b2f1d22014-06-12 16:33:32 -0700733 $ECHO "SUNWprivate_1.1 { local: *; };" > version-script.map
734 $ECHO "int main() { }" > main.c
Volker Simonis23040362013-07-02 17:38:10 -0700735 if $CXX -Xlinker -version-script=version-script.map main.c 2>&AS_MESSAGE_LOG_FD >&AS_MESSAGE_LOG_FD; then
736 AC_MSG_RESULT(no)
737 USING_BROKEN_SUSE_LD=no
738 else
739 AC_MSG_RESULT(yes)
740 USING_BROKEN_SUSE_LD=yes
741 fi
Erik Joelsson7331f032014-02-11 10:44:23 +0100742 rm -rf version-script.map main.c a.out
Volker Simonis23040362013-07-02 17:38:10 -0700743 fi
744 AC_SUBST(USING_BROKEN_SUSE_LD)
Erik Joelssone44f5ce2013-05-02 15:46:38 +0200745])
Erik Joelssone0285412013-05-28 08:50:52 +0200746
Magnus Ihse Bursie0bedc5f2014-02-24 12:16:58 +0100747# Setup the JTReg Regression Test Harness.
Mike Duigou22dc46d2013-06-04 10:36:00 +0200748AC_DEFUN_ONCE([TOOLCHAIN_SETUP_JTREG],
749[
750 AC_ARG_WITH(jtreg, [AS_HELP_STRING([--with-jtreg],
Magnus Ihse Bursie952d9ce2013-10-10 14:58:19 +0200751 [Regression Test Harness @<:@probed@:>@])],
752 [],
753 [with_jtreg=no])
Mike Duigou22dc46d2013-06-04 10:36:00 +0200754
755 if test "x$with_jtreg" = xno; then
756 # jtreg disabled
757 AC_MSG_CHECKING([for jtreg])
Erik Joelssone0285412013-05-28 08:50:52 +0200758 AC_MSG_RESULT(no)
Mike Duigou22dc46d2013-06-04 10:36:00 +0200759 else
760 if test "x$with_jtreg" != xyes; then
761 # with path specified.
762 JT_HOME="$with_jtreg"
763 fi
764
765 if test "x$JT_HOME" != x; then
766 AC_MSG_CHECKING([for jtreg])
767
768 # use JT_HOME enviroment var.
769 BASIC_FIXUP_PATH([JT_HOME])
770
771 # jtreg win32 script works for everybody
772 JTREGEXE="$JT_HOME/win32/bin/jtreg"
773
774 if test ! -f "$JTREGEXE"; then
775 AC_MSG_ERROR([JTReg executable does not exist: $JTREGEXE])
776 fi
777
778 AC_MSG_RESULT($JTREGEXE)
779 else
780 # try to find jtreg on path
Magnus Ihse Bursie57fe89a2014-01-29 11:21:54 +0100781 BASIC_REQUIRE_PROGS(JTREGEXE, jtreg)
Mike Duigou22dc46d2013-06-04 10:36:00 +0200782 JT_HOME="`$DIRNAME $JTREGEXE`"
783 fi
784 fi
785
786 AC_SUBST(JT_HOME)
787 AC_SUBST(JTREGEXE)
Erik Joelssone0285412013-05-28 08:50:52 +0200788])