Thu, 04 Oct 2018 02:46:08 -0700
Added tag jdk8u181-b37 for changeset 6be7467c0f3b
1 #
2 # Copyright (c) 2011, 2018, 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 #
26 # Prepare the system so that TOOLCHAIN_CHECK_COMPILER_VERSION can be called.
27 # Must have CC_VERSION_NUMBER and CXX_VERSION_NUMBER.
28 AC_DEFUN([TOOLCHAIN_PREPARE_FOR_VERSION_COMPARISONS],
29 [
30 if test "x$CC_VERSION" != "x$CXX_VERSION"; then
31 AC_MSG_WARN([C and C++ compiler has different version numbers, $CC_VERSION vs $CXX_VERSION.])
32 AC_MSG_WARN([This typically indicates a broken setup, and is not supported])
33 fi
35 # We only check CC_VERSION since we assume CXX_VERSION is equal.
36 if [ [[ "$CC_VERSION" =~ (.*\.){3} ]] ]; then
37 AC_MSG_WARN([C compiler version number has more than three parts (X.Y.Z): $CC_VERSION. Comparisons might be wrong.])
38 fi
40 if [ [[ "$CC_VERSION" =~ [0-9]{6} ]] ]; then
41 AC_MSG_WARN([C compiler version number has a part larger than 99999: $CC_VERSION. Comparisons might be wrong.])
42 fi
44 COMPARABLE_ACTUAL_VERSION=`$AWK -F. '{ printf("%05d%05d%05d\n", [$]1, [$]2, [$]3) }' <<< "$CC_VERSION"`
45 ])
47 # Check if the configured compiler (C and C++) is of a specific version or
48 # newer. TOOLCHAIN_PREPARE_FOR_VERSION_COMPARISONS must have been called before.
49 #
50 # Arguments:
51 # $1: The version string to check against the found version
52 # $2: block to run if the compiler is at least this version (>=)
53 # $3: block to run if the compiler is older than this version (<)
54 AC_DEFUN([TOOLCHAIN_CHECK_COMPILER_VERSION],
55 [
56 REFERENCE_VERSION=$1
58 if [ [[ "$REFERENCE_VERSION" =~ (.*\.){3} ]] ]; then
59 AC_MSG_ERROR([Internal error: Cannot compare to $REFERENCE_VERSION, only three parts (X.Y.Z) is supported])
60 fi
62 if [ [[ "$REFERENCE_VERSION" =~ [0-9]{6} ]] ]; then
63 AC_MSG_ERROR([Internal error: Cannot compare to $REFERENCE_VERSION, only parts < 99999 is supported])
64 fi
66 # Version comparison method inspired by http://stackoverflow.com/a/24067243
67 COMPARABLE_REFERENCE_VERSION=`$AWK -F. '{ printf("%05d%05d%05d\n", [$]1, [$]2, [$]3) }' <<< "$REFERENCE_VERSION"`
69 if test $COMPARABLE_ACTUAL_VERSION -ge $COMPARABLE_REFERENCE_VERSION ; then
70 m4_ifval([$2], [$2], [:])
71 else
72 m4_ifval([$3], [$3], [:])
73 fi
74 ])
76 # $1 = compiler to test (CC or CXX)
77 # $2 = human readable name of compiler (C or C++)
78 AC_DEFUN([TOOLCHAIN_EXTRACT_COMPILER_VERSION],
79 [
80 COMPILER=[$]$1
81 COMPILER_NAME=$2
83 if test "x$OPENJDK_TARGET_OS" = xsolaris; then
84 # Make sure we use the Sun Studio compiler and not gcc on Solaris, which won't work
85 COMPILER_VERSION_TEST=`$COMPILER -V 2>&1 | $HEAD -n 1`
86 $ECHO $COMPILER_VERSION_TEST | $GREP "^.*: Sun $COMPILER_NAME" > /dev/null
87 if test $? -ne 0; then
88 GCC_VERSION_TEST=`$COMPILER --version 2>&1 | $HEAD -n 1`
90 AC_MSG_NOTICE([The $COMPILER_NAME compiler (located as $COMPILER) does not seem to be the required Sun Studio compiler.])
91 AC_MSG_NOTICE([The result from running with -V was: "$COMPILER_VERSION_TEST" and with --version: "$GCC_VERSION_TEST"])
92 AC_MSG_ERROR([Sun Studio compiler is required. Try setting --with-tools-dir.])
93 else
94 COMPILER_VERSION=`$ECHO $COMPILER_VERSION_TEST | $SED -n "s/^.*@<:@ ,\t@:>@$COMPILER_NAME@<:@ ,\t@:>@\(@<:@1-9@:>@\.@<:@0-9@:>@@<:@0-9@:>@*\).*/\1/p"`
95 COMPILER_VENDOR="Sun Studio"
96 fi
97 elif test "x$OPENJDK_TARGET_OS" = xaix; then
98 COMPILER_VERSION_TEST=`$COMPILER -qversion 2>&1 | $TAIL -n 1`
99 $ECHO $COMPILER_VERSION_TEST | $GREP "^Version: " > /dev/null
100 if test $? -ne 0; then
101 AC_MSG_ERROR([Failed to detect the compiler version of $COMPILER ....])
102 else
103 COMPILER_VERSION=`$ECHO $COMPILER_VERSION_TEST | $SED -n 's/Version: \([0-9][0-9]\.[0-9][0-9]*\).*/\1/p'`
104 COMPILER_VENDOR='IBM'
105 fi
106 elif test "x$OPENJDK_TARGET_OS" = xwindows; then
107 # First line typically looks something like:
108 # Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.40219.01 for 80x86
109 COMPILER_VERSION_TEST=`$COMPILER 2>&1 | $HEAD -n 1 | $TR -d '\r'`
110 COMPILER_VERSION=`$ECHO $COMPILER_VERSION_TEST | $SED -n "s/^.*Version \(@<:@1-9@:>@@<:@0-9.@:>@*\) .*/\1/p"`
111 COMPILER_VENDOR="Microsoft CL.EXE"
112 COMPILER_CPU_TEST=`$ECHO $COMPILER_VERSION_TEST | $SED -n "s/^.* for \(.*\)$/\1/p"`
113 if test "x$OPENJDK_TARGET_CPU" = "xx86"; then
114 if test "x$COMPILER_CPU_TEST" != "x80x86"; then
115 AC_MSG_ERROR([Target CPU mismatch. We are building for $OPENJDK_TARGET_CPU but CL is for "$COMPILER_CPU_TEST"; expected "80x86".])
116 fi
117 elif test "x$OPENJDK_TARGET_CPU" = "xx86_64"; then
118 if test "x$COMPILER_CPU_TEST" != "xx64"; then
119 AC_MSG_ERROR([Target CPU mismatch. We are building for $OPENJDK_TARGET_CPU but CL is for "$COMPILER_CPU_TEST"; expected "x64".])
120 fi
121 fi
122 else
123 COMPILER_VERSION_TEST=`$COMPILER --version 2>&1 | $HEAD -n 1`
124 # Check that this is likely to be GCC.
125 $COMPILER --version 2>&1 | $GREP "Free Software Foundation" > /dev/null
126 if test $? -ne 0; then
127 AC_MSG_NOTICE([The $COMPILER_NAME compiler (located as $COMPILER) does not seem to be the required GCC compiler.])
128 AC_MSG_NOTICE([The result from running with --version was: "$COMPILER_VERSION_TEST"])
129 AC_MSG_ERROR([GCC compiler is required. Try setting --with-tools-dir.])
130 fi
132 # First line typically looks something like:
133 # gcc (Ubuntu/Linaro 4.5.2-8ubuntu4) 4.5.2
134 COMPILER_VERSION=`$ECHO $COMPILER_VERSION_TEST | \
135 $SED -e 's/^.* \(@<:@1-9@:>@\.@<:@0-9.@:>@*\)@<:@^0-9.@:>@.*$/\1/'`
136 COMPILER_VENDOR=`$ECHO $COMPILER_VERSION_TEST | $SED -n "s/^\(.*\) @<:@1-9@:>@@<:@0-9.@:>@*/\1/p"`
137 fi
138 # This sets CC_VERSION or CXX_VERSION. (This comment is a grep marker)
139 $1_VERSION="$COMPILER_VERSION"
140 # This sets CC_VENDOR or CXX_VENDOR. (This comment is a grep marker)
141 $1_VENDOR="$COMPILER_VENDOR"
143 AC_MSG_NOTICE([Using $COMPILER_VENDOR $COMPILER_NAME compiler version $COMPILER_VERSION (located at $COMPILER)])
144 ])
147 AC_DEFUN_ONCE([TOOLCHAIN_SETUP_SYSROOT_AND_OUT_OPTIONS],
148 [
149 ###############################################################################
150 #
151 # Configure the development tool paths and potential sysroot.
152 #
153 AC_LANG(C++)
155 # The option used to specify the target .o,.a or .so file.
156 # When compiling, how to specify the to be created object file.
157 CC_OUT_OPTION='-o$(SPACE)'
158 # When linking, how to specify the to be created executable.
159 EXE_OUT_OPTION='-o$(SPACE)'
160 # When linking, how to specify the to be created dynamically linkable library.
161 LD_OUT_OPTION='-o$(SPACE)'
162 # When archiving, how to specify the to be create static archive for object files.
163 AR_OUT_OPTION='rcs$(SPACE)'
164 AC_SUBST(CC_OUT_OPTION)
165 AC_SUBST(EXE_OUT_OPTION)
166 AC_SUBST(LD_OUT_OPTION)
167 AC_SUBST(AR_OUT_OPTION)
168 ])
170 # $1 = compiler to test (CC or CXX)
171 # $2 = human readable name of compiler (C or C++)
172 # $3 = list of compiler names to search for
173 AC_DEFUN([TOOLCHAIN_FIND_COMPILER],
174 [
175 COMPILER_NAME=$2
177 $1=
178 # If TOOLS_DIR is set, check for all compiler names in there first
179 # before checking the rest of the PATH.
180 if test -n "$TOOLS_DIR"; then
181 PATH_save="$PATH"
182 PATH="$TOOLS_DIR"
183 AC_PATH_PROGS(TOOLS_DIR_$1, $3)
184 $1=$TOOLS_DIR_$1
185 PATH="$PATH_save"
186 fi
188 # AC_PATH_PROGS can't be run multiple times with the same variable,
189 # so create a new name for this run.
190 if test "x[$]$1" = x; then
191 AC_PATH_PROGS(POTENTIAL_$1, $3)
192 $1=$POTENTIAL_$1
193 fi
195 if test "x[$]$1" = x; then
196 HELP_MSG_MISSING_DEPENDENCY([devkit])
197 AC_MSG_ERROR([Could not find a $COMPILER_NAME compiler. $HELP_MSG])
198 fi
199 BASIC_FIXUP_EXECUTABLE($1)
200 TEST_COMPILER="[$]$1"
201 # Don't remove symbolic links on AIX because 'xlc_r' and 'xlC_r' may all be links
202 # to 'xlc' but it is crucial that we invoke the compiler with the right name!
203 if test "x$OPENJDK_BUILD_OS" != xaix; then
204 AC_MSG_CHECKING([resolved symbolic links for $1])
205 BASIC_REMOVE_SYMBOLIC_LINKS(TEST_COMPILER)
206 AC_MSG_RESULT([$TEST_COMPILER])
207 fi
208 AC_MSG_CHECKING([if $1 is disguised ccache])
210 COMPILER_BASENAME=`$BASENAME "$TEST_COMPILER"`
211 if test "x$COMPILER_BASENAME" = "xccache"; then
212 AC_MSG_RESULT([yes, trying to find proper $COMPILER_NAME compiler])
213 # We /usr/lib/ccache in the path, so cc is a symlink to /usr/bin/ccache.
214 # We want to control ccache invocation ourselves, so ignore this cc and try
215 # searching again.
217 # Remove the path to the fake ccache cc from the PATH
218 RETRY_COMPILER_SAVED_PATH="$PATH"
219 COMPILER_DIRNAME=`$DIRNAME [$]$1`
220 PATH="`$ECHO $PATH | $SED -e "s,$COMPILER_DIRNAME,,g" -e "s,::,:,g" -e "s,^:,,g"`"
222 # Try again looking for our compiler
223 AC_CHECK_TOOLS(PROPER_COMPILER_$1, $3)
224 BASIC_FIXUP_EXECUTABLE(PROPER_COMPILER_$1)
225 PATH="$RETRY_COMPILER_SAVED_PATH"
227 AC_MSG_CHECKING([for resolved symbolic links for $1])
228 BASIC_REMOVE_SYMBOLIC_LINKS(PROPER_COMPILER_$1)
229 AC_MSG_RESULT([$PROPER_COMPILER_$1])
230 $1="$PROPER_COMPILER_$1"
231 else
232 AC_MSG_RESULT([no, keeping $1])
233 $1="$TEST_COMPILER"
234 fi
235 TOOLCHAIN_EXTRACT_COMPILER_VERSION([$1], [$COMPILER_NAME])
236 ])
239 AC_DEFUN([TOOLCHAIN_SETUP_PATHS],
240 [
241 if test "x$OPENJDK_TARGET_OS" = "xwindows"; then
242 TOOLCHAIN_SETUP_VISUAL_STUDIO_ENV
243 TOOLCHAIN_SETUP_MSVCR_DLL
244 BASIC_DEPRECATED_ARG_WITH([dxsdk])
245 BASIC_DEPRECATED_ARG_WITH([dxsdk-lib])
246 BASIC_DEPRECATED_ARG_WITH([dxsdk-include])
247 fi
249 AC_SUBST(MSVCR_DLL)
251 # If --build AND --host is set, then the configure script will find any
252 # cross compilation tools in the PATH. Cross compilation tools
253 # follows the cross compilation standard where they are prefixed with ${host}.
254 # For example the binary i686-sun-solaris2.10-gcc
255 # will cross compile for i686-sun-solaris2.10
256 # If neither of build and host is not set, then build=host and the
257 # default compiler found in the path will be used.
258 # Setting only --host, does not seem to be really supported.
259 # Please set both --build and --host if you want to cross compile.
261 if test "x$COMPILE_TYPE" = "xcross"; then
262 # Now we to find a C/C++ compiler that can build executables for the build
263 # platform. We can't use the AC_PROG_CC macro, since it can only be used
264 # once. Also, we need to do this before adding a tools dir to the path,
265 # otherwise we might pick up cross-compilers which don't use standard naming.
266 # Otherwise, we'll set the BUILD_tools to the native tools, but that'll have
267 # to wait until they are properly discovered.
268 AC_PATH_PROGS(BUILD_CC, [cl cc gcc])
269 BASIC_FIXUP_EXECUTABLE(BUILD_CC)
270 AC_PATH_PROGS(BUILD_CXX, [cl CC g++])
271 BASIC_FIXUP_EXECUTABLE(BUILD_CXX)
272 AC_PATH_PROG(BUILD_LD, ld)
273 BASIC_FIXUP_EXECUTABLE(BUILD_LD)
274 fi
275 AC_SUBST(BUILD_CC)
276 AC_SUBST(BUILD_CXX)
277 AC_SUBST(BUILD_LD)
279 # If a devkit is found on the builddeps server, then prepend its path to the
280 # PATH variable. If there are cross compilers available in the devkit, these
281 # will be found by AC_PROG_CC et al.
282 DEVKIT=
283 BDEPS_CHECK_MODULE(DEVKIT, devkit, xxx,
284 [
285 # Found devkit
286 PATH="$DEVKIT/bin:$PATH"
287 SYS_ROOT="$DEVKIT/${rewritten_target}/sys-root"
288 if test "x$x_includes" = "xNONE"; then
289 x_includes="$SYS_ROOT/usr/include/X11"
290 fi
291 if test "x$x_libraries" = "xNONE"; then
292 x_libraries="$SYS_ROOT/usr/lib"
293 fi
294 ],
295 [])
297 # Store the CFLAGS etal passed to the configure script.
298 ORG_CFLAGS="$CFLAGS"
299 ORG_CXXFLAGS="$CXXFLAGS"
300 ORG_OBJCFLAGS="$OBJCFLAGS"
302 # autoconf magic only relies on PATH, so update it if tools dir is specified
303 OLD_PATH="$PATH"
304 if test "x$TOOLS_DIR" != x; then
305 PATH=$TOOLS_DIR:$PATH
306 fi
308 # Before we locate the compilers, we need to sanitize the Xcode build environment
309 if test "x$OPENJDK_TARGET_OS" = "xmacosx"; then
310 # determine path to Xcode developer directory
311 # can be empty in which case all the tools will rely on a sane Xcode 4 installation
312 SET_DEVELOPER_DIR=
314 if test -n "$XCODE_PATH"; then
315 DEVELOPER_DIR="$XCODE_PATH"/Contents/Developer
316 fi
318 # DEVELOPER_DIR could also be provided directly
319 AC_MSG_CHECKING([Determining if we need to set DEVELOPER_DIR])
320 if test -n "$DEVELOPER_DIR"; then
321 if test ! -d "$DEVELOPER_DIR"; then
322 AC_MSG_ERROR([Xcode Developer path does not exist: $DEVELOPER_DIR, please provide a path to the Xcode 4 application bundle using --with-xcode-path])
323 fi
324 if test ! -f "$DEVELOPER_DIR"/usr/bin/xcodebuild; then
325 AC_MSG_ERROR([Xcode Developer path is not valid: $DEVELOPER_DIR, it must point to Contents/Developer inside an Xcode application bundle])
326 fi
327 # make it visible to all the tools immediately
328 export DEVELOPER_DIR
329 SET_DEVELOPER_DIR="export DEVELOPER_DIR := $DEVELOPER_DIR"
330 AC_MSG_RESULT([yes ($DEVELOPER_DIR)])
331 else
332 AC_MSG_RESULT([no])
333 fi
334 AC_SUBST(SET_DEVELOPER_DIR)
336 AC_PATH_PROG(XCODEBUILD, xcodebuild)
337 if test -z "$XCODEBUILD"; then
338 AC_MSG_ERROR([The xcodebuild tool was not found, the Xcode command line tools are required to build on Mac OS X])
339 fi
341 # Fail-fast: verify we're building on Xcode 4, we cannot build with Xcode 5 or later
342 XCODE_VERSION=`$XCODEBUILD -version | grep '^Xcode ' | sed 's/Xcode //'`
343 XC_VERSION_PARTS=( ${XCODE_VERSION//./ } )
344 if test ! "${XC_VERSION_PARTS[[0]]}" = "4"; then
345 AC_MSG_ERROR([Xcode 4 is required to build JDK 8, the version found was $XCODE_VERSION. Use --with-xcode-path to specify the location of Xcode 4 or make Xcode 4 active by using xcode-select.])
346 fi
348 # Some versions of Xcode 5 command line tools install gcc and g++ as symlinks to
349 # clang and clang++, which will break the build. So handle that here if we need to.
350 if test -L "/usr/bin/gcc" -o -L "/usr/bin/g++"; then
351 # use xcrun to find the real gcc and add it's directory to PATH
352 # then autoconf magic will find it
353 AC_MSG_NOTICE([Found gcc symlinks to clang in /usr/bin, adding path to real gcc to PATH])
354 XCODE_BIN_PATH=$(dirname `xcrun -find gcc`)
355 PATH="$XCODE_BIN_PATH":$PATH
356 fi
358 # Determine appropriate SDKPATH, don't use SDKROOT as it interferes with the stub tools
359 AC_MSG_CHECKING([Determining Xcode SDK path])
360 # allow SDKNAME to be set to override the default SDK selection
361 SDKPATH=`"$XCODEBUILD" -sdk ${SDKNAME:-macosx} -version | grep '^Path: ' | sed 's/Path: //'`
362 if test -n "$SDKPATH"; then
363 AC_MSG_RESULT([$SDKPATH])
364 else
365 AC_MSG_RESULT([(none, will use system headers and frameworks)])
366 fi
367 AC_SUBST(SDKPATH)
369 # Perform a basic sanity test
370 if test ! -f "$SDKPATH/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h"; then
371 AC_MSG_ERROR([Unable to find required framework headers, provide a valid path to Xcode 4 using --with-xcode-path])
372 fi
374 # if SDKPATH is non-empty then we need to add -isysroot and -iframework for gcc and g++
375 if test -n "$SDKPATH"; then
376 # We need -isysroot <path> and -iframework<path>/System/Library/Frameworks
377 CFLAGS_JDK="${CFLAGS_JDK} -isysroot \"$SDKPATH\" -iframework\"$SDKPATH/System/Library/Frameworks\""
378 CXXFLAGS_JDK="${CXXFLAGS_JDK} -isysroot \"$SDKPATH\" -iframework\"$SDKPATH/System/Library/Frameworks\""
379 LDFLAGS_JDK="${LDFLAGS_JDK} -isysroot \"$SDKPATH\" -iframework\"$SDKPATH/System/Library/Frameworks\""
380 fi
382 # These always need to be set, or we can't find the frameworks embedded in JavaVM.framework
383 # setting this here means it doesn't have to be peppered throughout the forest
384 CFLAGS_JDK="$CFLAGS_JDK -F\"$SDKPATH/System/Library/Frameworks/JavaVM.framework/Frameworks\""
385 CXXFLAGS_JDK="$CXXFLAGS_JDK -F\"$SDKPATH/System/Library/Frameworks/JavaVM.framework/Frameworks\""
386 LDFLAGS_JDK="$LDFLAGS_JDK -F\"$SDKPATH/System/Library/Frameworks/JavaVM.framework/Frameworks\""
387 fi
389 ### Locate C compiler (CC)
391 # On windows, only cl.exe is supported.
392 # On Solaris, cc is preferred to gcc.
393 # Elsewhere, gcc is preferred to cc.
395 if test "x$CC" != x; then
396 COMPILER_CHECK_LIST="$CC"
397 elif test "x$OPENJDK_TARGET_OS" = "xwindows"; then
398 COMPILER_CHECK_LIST="cl"
399 elif test "x$OPENJDK_TARGET_OS" = "xsolaris"; then
400 COMPILER_CHECK_LIST="cc gcc"
401 elif test "x$OPENJDK_TARGET_OS" = "xaix"; then
402 # Do not probe for cc on AIX.
403 COMPILER_CHECK_LIST="xlc_r"
404 else
405 COMPILER_CHECK_LIST="gcc cc"
406 fi
408 TOOLCHAIN_FIND_COMPILER([CC],[C],[$COMPILER_CHECK_LIST])
409 # Now that we have resolved CC ourself, let autoconf have its go at it
410 AC_PROG_CC([$CC])
412 # Option used to tell the compiler whether to create 32- or 64-bit executables
413 # Notice that CC contains the full compiler path at this point.
414 case $CC in
415 *xlc_r) COMPILER_TARGET_BITS_FLAG="-q";;
416 *) COMPILER_TARGET_BITS_FLAG="-m";;
417 esac
418 AC_SUBST(COMPILER_TARGET_BITS_FLAG)
420 ### Locate C++ compiler (CXX)
422 if test "x$CXX" != x; then
423 COMPILER_CHECK_LIST="$CXX"
424 elif test "x$OPENJDK_TARGET_OS" = "xwindows"; then
425 COMPILER_CHECK_LIST="cl"
426 elif test "x$OPENJDK_TARGET_OS" = "xsolaris"; then
427 COMPILER_CHECK_LIST="CC g++"
428 elif test "x$OPENJDK_TARGET_OS" = "xaix"; then
429 # Do not probe for CC on AIX .
430 COMPILER_CHECK_LIST="xlC_r"
431 else
432 COMPILER_CHECK_LIST="g++ CC"
433 fi
435 TOOLCHAIN_FIND_COMPILER([CXX],[C++],[$COMPILER_CHECK_LIST])
436 # Now that we have resolved CXX ourself, let autoconf have its go at it
437 AC_PROG_CXX([$CXX])
439 # This is the compiler version number on the form X.Y[.Z]
440 AC_SUBST(CC_VERSION)
441 AC_SUBST(CXX_VERSION)
443 TOOLCHAIN_PREPARE_FOR_VERSION_COMPARISONS
445 ### Locate other tools
447 if test "x$OPENJDK_TARGET_OS" = xmacosx; then
448 AC_PROG_OBJC
449 BASIC_FIXUP_EXECUTABLE(OBJC)
450 else
451 OBJC=
452 fi
454 # Restore the flags to the user specified values.
455 # This is necessary since AC_PROG_CC defaults CFLAGS to "-g -O2"
456 CFLAGS="$ORG_CFLAGS"
457 CXXFLAGS="$ORG_CXXFLAGS"
458 OBJCFLAGS="$ORG_OBJCFLAGS"
460 LD="$CC"
461 LDEXE="$CC"
462 LDCXX="$CXX"
463 LDEXECXX="$CXX"
464 AC_SUBST(LD)
465 # LDEXE is the linker to use, when creating executables.
466 AC_SUBST(LDEXE)
467 # Linking C++ libraries.
468 AC_SUBST(LDCXX)
469 # Linking C++ executables.
470 AC_SUBST(LDEXECXX)
472 if test "x$OPENJDK_TARGET_OS" != xwindows; then
473 AC_CHECK_TOOL(AR, ar)
474 BASIC_FIXUP_EXECUTABLE(AR)
475 fi
476 if test "x$OPENJDK_TARGET_OS" = xmacosx; then
477 ARFLAGS="-r"
478 elif test "x$OPENJDK_TARGET_OS" = xaix; then
479 ARFLAGS="-X64"
480 else
481 ARFLAGS=""
482 fi
483 AC_SUBST(ARFLAGS)
485 # For hotspot, we need these in Windows mixed path; other platforms keep them the same
486 HOTSPOT_CXX="$CXX"
487 HOTSPOT_LD="$LD"
488 AC_SUBST(HOTSPOT_CXX)
489 AC_SUBST(HOTSPOT_LD)
491 COMPILER_NAME=gcc
492 COMPILER_TYPE=CC
493 AS_IF([test "x$OPENJDK_TARGET_OS" = xwindows], [
494 # For now, assume that we are always compiling using cl.exe.
495 CC_OUT_OPTION=-Fo
496 EXE_OUT_OPTION=-out:
497 LD_OUT_OPTION=-out:
498 AR_OUT_OPTION=-out:
499 # On Windows, reject /usr/bin/link (as determined in CYGWIN_LINK), which is a cygwin
500 # program for something completely different.
501 AC_CHECK_PROG([WINLD], [link],[link],,, [$CYGWIN_LINK])
502 # Since we must ignore the first found link, WINLD will contain
503 # the full path to the link.exe program.
504 BASIC_FIXUP_EXECUTABLE(WINLD)
505 printf "Windows linker was found at $WINLD\n"
506 AC_MSG_CHECKING([if the found link.exe is actually the Visual Studio linker])
507 "$WINLD" --version > /dev/null
508 if test $? -eq 0 ; then
509 AC_MSG_RESULT([no])
510 AC_MSG_ERROR([This is the Cygwin link tool. Please check your PATH and rerun configure.])
511 else
512 AC_MSG_RESULT([yes])
513 fi
514 LD="$WINLD"
515 LDEXE="$WINLD"
516 LDCXX="$WINLD"
517 LDEXECXX="$WINLD"
519 AC_CHECK_PROG([MT], [mt], [mt],,, [/usr/bin/mt])
520 BASIC_FIXUP_EXECUTABLE(MT)
521 # The resource compiler
522 AC_CHECK_PROG([RC], [rc], [rc],,, [/usr/bin/rc])
523 BASIC_FIXUP_EXECUTABLE(RC)
525 # For hotspot, we need these in Windows mixed path,
526 # so rewrite them all. Need added .exe suffix.
527 HOTSPOT_CXX="$CXX.exe"
528 HOTSPOT_LD="$LD.exe"
529 HOTSPOT_MT="$MT.exe"
530 HOTSPOT_RC="$RC.exe"
531 BASIC_WINDOWS_REWRITE_AS_WINDOWS_MIXED_PATH(HOTSPOT_CXX)
532 BASIC_WINDOWS_REWRITE_AS_WINDOWS_MIXED_PATH(HOTSPOT_LD)
533 BASIC_WINDOWS_REWRITE_AS_WINDOWS_MIXED_PATH(HOTSPOT_MT)
534 BASIC_WINDOWS_REWRITE_AS_WINDOWS_MIXED_PATH(HOTSPOT_RC)
535 AC_SUBST(HOTSPOT_MT)
536 AC_SUBST(HOTSPOT_RC)
538 RC_FLAGS="-nologo -l 0x409 -r"
539 AS_IF([test "x$VARIANT" = xOPT], [
540 RC_FLAGS="$RC_FLAGS -d NDEBUG"
541 ])
543 # The version variables used to create RC_FLAGS may be overridden
544 # in a custom configure script, or possibly the command line.
545 # Let those variables be expanded at make time in spec.gmk.
546 # The \$ are escaped to the shell, and the $(...) variables
547 # are evaluated by make.
548 RC_FLAGS="$RC_FLAGS \
549 -d \"JDK_BUILD_ID=\$(FULL_VERSION)\" \
550 -d \"JDK_COMPANY=\$(COMPANY_NAME)\" \
551 -d \"JDK_COMPONENT=\$(PRODUCT_NAME) \$(JDK_RC_PLATFORM_NAME) binary\" \
552 -d \"JDK_VER=\$(JDK_MINOR_VERSION).\$(JDK_MICRO_VERSION).\$(COOKED_JDK_UPDATE_VERSION).\$(COOKED_BUILD_NUMBER)\" \
553 -d \"JDK_COPYRIGHT=Copyright \xA9 $COPYRIGHT_YEAR\" \
554 -d \"JDK_NAME=\$(PRODUCT_NAME) \$(JDK_RC_PLATFORM_NAME) \$(JDK_MINOR_VERSION) \$(JDK_UPDATE_META_TAG)\" \
555 -d \"JDK_FVER=\$(JDK_MINOR_VERSION),\$(JDK_MICRO_VERSION),\$(COOKED_JDK_UPDATE_VERSION),\$(COOKED_BUILD_NUMBER)\""
557 # lib.exe is used to create static libraries.
558 AC_CHECK_PROG([WINAR], [lib],[lib],,,)
559 BASIC_FIXUP_EXECUTABLE(WINAR)
560 AR="$WINAR"
561 ARFLAGS="-nologo -NODEFAULTLIB:MSVCRT"
563 AC_CHECK_PROG([DUMPBIN], [dumpbin], [dumpbin],,,)
564 BASIC_FIXUP_EXECUTABLE(DUMPBIN)
566 COMPILER_TYPE=CL
567 # silence copyright notice and other headers.
568 COMMON_CCXXFLAGS="$COMMON_CCXXFLAGS -nologo"
569 ])
570 AC_SUBST(RC_FLAGS)
571 AC_SUBST(COMPILER_TYPE)
573 AC_PROG_CPP
574 BASIC_FIXUP_EXECUTABLE(CPP)
576 AC_PROG_CXXCPP
577 BASIC_FIXUP_EXECUTABLE(CXXCPP)
579 if test "x$COMPILE_TYPE" != "xcross"; then
580 # If we are not cross compiling, use the same compilers for
581 # building the build platform executables. The cross-compilation
582 # case needed to be done earlier, but this can only be done after
583 # the native tools have been localized.
584 BUILD_CC="$CC"
585 BUILD_CXX="$CXX"
586 BUILD_LD="$LD"
587 fi
589 # for solaris we really need solaris tools, and not gnu equivalent
590 # these seems to normally reside in /usr/ccs/bin so add that to path before
591 # starting to probe
592 #
593 # NOTE: I add this /usr/ccs/bin after TOOLS but before OLD_PATH
594 # so that it can be overriden --with-tools-dir
595 if test "x$OPENJDK_BUILD_OS" = xsolaris; then
596 PATH="${TOOLS_DIR}:/usr/ccs/bin:${OLD_PATH}"
597 fi
599 # Find the right assembler.
600 if test "x$OPENJDK_TARGET_OS" = xsolaris; then
601 AC_PATH_PROG(AS, as)
602 BASIC_FIXUP_EXECUTABLE(AS)
603 else
604 AS="$CC -c"
605 fi
606 AC_SUBST(AS)
608 if test "x$OPENJDK_TARGET_OS" = xsolaris; then
609 AC_PATH_PROG(NM, nm)
610 BASIC_FIXUP_EXECUTABLE(NM)
611 AC_PATH_PROG(GNM, gnm)
612 BASIC_FIXUP_EXECUTABLE(GNM)
613 AC_PATH_PROG(STRIP, strip)
614 BASIC_FIXUP_EXECUTABLE(STRIP)
615 AC_PATH_PROG(MCS, mcs)
616 BASIC_FIXUP_EXECUTABLE(MCS)
617 elif test "x$OPENJDK_TARGET_OS" != xwindows; then
618 AC_PATH_PROG(OTOOL, otool)
619 if test "x$OTOOL" = "x"; then
620 OTOOL="true"
621 fi
622 AC_CHECK_TOOL(NM, nm)
623 BASIC_FIXUP_EXECUTABLE(NM)
624 GNM="$NM"
625 AC_SUBST(GNM)
626 AC_CHECK_TOOL(STRIP, strip)
627 BASIC_FIXUP_EXECUTABLE(STRIP)
628 fi
630 # objcopy is used for moving debug symbols to separate files when
631 # full debug symbols are enabled.
632 if test "x$OPENJDK_TARGET_OS" = xsolaris || test "x$OPENJDK_TARGET_OS" = xlinux; then
633 AC_CHECK_TOOLS(OBJCOPY, [gobjcopy objcopy])
634 # Only call fixup if objcopy was found.
635 if test -n "$OBJCOPY"; then
636 BASIC_FIXUP_EXECUTABLE(OBJCOPY)
637 fi
638 fi
640 AC_CHECK_TOOLS(OBJDUMP, [gobjdump objdump])
641 if test "x$OBJDUMP" != x; then
642 # Only used for compare.sh; we can live without it. BASIC_FIXUP_EXECUTABLE bails if argument is missing.
643 BASIC_FIXUP_EXECUTABLE(OBJDUMP)
644 fi
646 TOOLCHAIN_SETUP_JTREG
648 # Restore old path without tools dir
649 PATH="$OLD_PATH"
650 ])
653 AC_DEFUN_ONCE([TOOLCHAIN_SETUP_COMPILER_FLAGS_FOR_LIBS],
654 [
656 ###############################################################################
657 #
658 # How to compile shared libraries.
659 #
661 if test "x$GCC" = xyes; then
662 COMPILER_NAME=gcc
663 PICFLAG="-fPIC"
664 LIBRARY_PREFIX=lib
665 SHARED_LIBRARY='lib[$]1.so'
666 STATIC_LIBRARY='lib[$]1.a'
667 SHARED_LIBRARY_FLAGS="-shared"
668 SHARED_LIBRARY_SUFFIX='.so'
669 STATIC_LIBRARY_SUFFIX='.a'
670 OBJ_SUFFIX='.o'
671 EXE_SUFFIX=''
672 SET_SHARED_LIBRARY_NAME='-Xlinker -soname=[$]1'
673 SET_SHARED_LIBRARY_MAPFILE='-Xlinker -version-script=[$]1'
674 C_FLAG_REORDER=''
675 CXX_FLAG_REORDER=''
676 SET_SHARED_LIBRARY_ORIGIN='-Xlinker -z -Xlinker origin -Xlinker -rpath -Xlinker \$$$$ORIGIN[$]1'
677 SET_EXECUTABLE_ORIGIN='-Xlinker -rpath -Xlinker \$$$$ORIGIN[$]1'
678 LD="$CC"
679 LDEXE="$CC"
680 LDCXX="$CXX"
681 LDEXECXX="$CXX"
682 POST_STRIP_CMD="$STRIP -g"
684 # Linking is different on MacOSX
685 if test "x$OPENJDK_TARGET_OS" = xmacosx; then
686 # Might change in the future to clang.
687 COMPILER_NAME=gcc
688 SHARED_LIBRARY='lib[$]1.dylib'
689 SHARED_LIBRARY_FLAGS="-dynamiclib -compatibility_version 1.0.0 -current_version 1.0.0 $PICFLAG"
690 SHARED_LIBRARY_SUFFIX='.dylib'
691 EXE_SUFFIX=''
692 SET_SHARED_LIBRARY_NAME='-Xlinker -install_name -Xlinker @rpath/[$]1'
693 SET_SHARED_LIBRARY_MAPFILE=''
694 SET_SHARED_LIBRARY_ORIGIN='-Xlinker -rpath -Xlinker @loader_path/.'
695 SET_EXECUTABLE_ORIGIN="$SET_SHARED_LIBRARY_ORIGIN"
696 POST_STRIP_CMD="$STRIP -S"
697 fi
698 else
699 if test "x$OPENJDK_TARGET_OS" = xsolaris; then
700 # If it is not gcc, then assume it is the Oracle Solaris Studio Compiler
701 COMPILER_NAME=ossc
702 PICFLAG="-KPIC"
703 LIBRARY_PREFIX=lib
704 SHARED_LIBRARY='lib[$]1.so'
705 STATIC_LIBRARY='lib[$]1.a'
706 SHARED_LIBRARY_FLAGS="-G"
707 SHARED_LIBRARY_SUFFIX='.so'
708 STATIC_LIBRARY_SUFFIX='.a'
709 OBJ_SUFFIX='.o'
710 EXE_SUFFIX=''
711 SET_SHARED_LIBRARY_NAME=''
712 SET_SHARED_LIBRARY_MAPFILE='-M[$]1'
713 C_FLAG_REORDER='-xF'
714 CXX_FLAG_REORDER='-xF'
715 SET_SHARED_LIBRARY_ORIGIN='-R\$$$$ORIGIN[$]1'
716 SET_EXECUTABLE_ORIGIN="$SET_SHARED_LIBRARY_ORIGIN"
717 CFLAGS_JDK="${CFLAGS_JDK} -D__solaris__"
718 CXXFLAGS_JDK="${CXXFLAGS_JDK} -D__solaris__"
719 CFLAGS_JDKLIB_EXTRA='-xstrconst'
720 POST_STRIP_CMD="$STRIP -x"
721 POST_MCS_CMD="$MCS -d -a \"JDK $FULL_VERSION\""
722 fi
723 if test "x$OPENJDK_TARGET_OS" = xaix; then
724 COMPILER_NAME=xlc
725 PICFLAG="-qpic=large"
726 LIBRARY_PREFIX=lib
727 SHARED_LIBRARY='lib[$]1.so'
728 STATIC_LIBRARY='lib[$]1.a'
729 SHARED_LIBRARY_FLAGS="-qmkshrobj"
730 SHARED_LIBRARY_SUFFIX='.so'
731 STATIC_LIBRARY_SUFFIX='.a'
732 OBJ_SUFFIX='.o'
733 EXE_SUFFIX=''
734 SET_SHARED_LIBRARY_NAME=''
735 SET_SHARED_LIBRARY_MAPFILE=''
736 C_FLAG_REORDER=''
737 CXX_FLAG_REORDER=''
738 SET_SHARED_LIBRARY_ORIGIN=''
739 SET_EXECUTABLE_ORIGIN=""
740 CFLAGS_JDK=""
741 CXXFLAGS_JDK=""
742 CFLAGS_JDKLIB_EXTRA=''
743 POST_STRIP_CMD="$STRIP -X32_64"
744 POST_MCS_CMD=""
745 fi
746 if test "x$OPENJDK_TARGET_OS" = xwindows; then
747 # If it is not gcc, then assume it is the MS Visual Studio compiler
748 COMPILER_NAME=cl
749 PICFLAG=""
750 LIBRARY_PREFIX=
751 SHARED_LIBRARY='[$]1.dll'
752 STATIC_LIBRARY='[$]1.lib'
753 SHARED_LIBRARY_FLAGS="-LD"
754 SHARED_LIBRARY_SUFFIX='.dll'
755 STATIC_LIBRARY_SUFFIX='.lib'
756 OBJ_SUFFIX='.obj'
757 EXE_SUFFIX='.exe'
758 SET_SHARED_LIBRARY_NAME=''
759 SET_SHARED_LIBRARY_MAPFILE=''
760 SET_SHARED_LIBRARY_ORIGIN=''
761 SET_EXECUTABLE_ORIGIN=''
762 fi
763 fi
765 AC_SUBST(COMPILER_NAME)
766 AC_SUBST(OBJ_SUFFIX)
767 AC_SUBST(SHARED_LIBRARY)
768 AC_SUBST(STATIC_LIBRARY)
769 AC_SUBST(LIBRARY_PREFIX)
770 AC_SUBST(SHARED_LIBRARY_SUFFIX)
771 AC_SUBST(STATIC_LIBRARY_SUFFIX)
772 AC_SUBST(EXE_SUFFIX)
773 AC_SUBST(SHARED_LIBRARY_FLAGS)
774 AC_SUBST(SET_SHARED_LIBRARY_NAME)
775 AC_SUBST(SET_SHARED_LIBRARY_MAPFILE)
776 AC_SUBST(C_FLAG_REORDER)
777 AC_SUBST(CXX_FLAG_REORDER)
778 AC_SUBST(SET_SHARED_LIBRARY_ORIGIN)
779 AC_SUBST(SET_EXECUTABLE_ORIGIN)
780 AC_SUBST(POST_STRIP_CMD)
781 AC_SUBST(POST_MCS_CMD)
783 # The (cross) compiler is now configured, we can now test capabilities
784 # of the target platform.
785 ])
787 AC_DEFUN_ONCE([TOOLCHAIN_SETUP_COMPILER_FLAGS_FOR_OPTIMIZATION],
788 [
790 ###############################################################################
791 #
792 # Setup the opt flags for different compilers
793 # and different operating systems.
794 #
796 #
797 # NOTE: check for -mstackrealign needs to be below potential addition of -m32
798 #
799 if test "x$OPENJDK_TARGET_CPU_BITS" = x32 && test "x$OPENJDK_TARGET_OS" = xmacosx; then
800 # On 32-bit MacOSX the OS requires C-entry points to be 16 byte aligned.
801 # While waiting for a better solution, the current workaround is to use -mstackrealign.
802 CFLAGS="$CFLAGS -mstackrealign"
803 AC_MSG_CHECKING([if 32-bit compiler supports -mstackrealign])
804 AC_LINK_IFELSE([AC_LANG_SOURCE([[int main() { return 0; }]])],
805 [
806 AC_MSG_RESULT([yes])
807 ],
808 [
809 AC_MSG_RESULT([no])
810 AC_MSG_ERROR([The selected compiler $CXX does not support -mstackrealign! Try to put another compiler in the path.])
811 ]
812 )
813 fi
815 C_FLAG_DEPS="-MMD -MF"
816 CXX_FLAG_DEPS="-MMD -MF"
818 case $COMPILER_TYPE in
819 CC )
820 case $COMPILER_NAME in
821 gcc )
822 case $OPENJDK_TARGET_OS in
823 macosx )
824 # On MacOSX we optimize for size, something
825 # we should do for all platforms?
826 C_O_FLAG_HI="-Os"
827 C_O_FLAG_NORM="-Os"
828 C_O_FLAG_NONE=""
829 ;;
830 *)
831 C_O_FLAG_HI="-O3"
832 C_O_FLAG_NORM="-O2"
833 C_O_FLAG_NONE="-O0"
834 ;;
835 esac
836 CXX_O_FLAG_HI="$C_O_FLAG_HI"
837 CXX_O_FLAG_NORM="$C_O_FLAG_NORM"
838 CXX_O_FLAG_NONE="$C_O_FLAG_NONE"
839 CFLAGS_DEBUG_SYMBOLS="-g"
840 CXXFLAGS_DEBUG_SYMBOLS="-g"
841 if test "x$OPENJDK_TARGET_CPU_BITS" = "x64" && test "x$DEBUG_LEVEL" = "xfastdebug"; then
842 CFLAGS_DEBUG_SYMBOLS="-g1"
843 CXXFLAGS_DEBUG_SYMBOLS="-g1"
844 fi
845 ;;
846 ossc )
847 #
848 # Forte has different names for this with their C++ compiler...
849 #
850 C_FLAG_DEPS="-xMMD -xMF"
851 CXX_FLAG_DEPS="-xMMD -xMF"
853 # Extra options used with HIGHEST
854 #
855 # WARNING: Use of OPTIMIZATION_LEVEL=HIGHEST in your Makefile needs to be
856 # done with care, there are some assumptions below that need to
857 # be understood about the use of pointers, and IEEE behavior.
858 #
859 # Use non-standard floating point mode (not IEEE 754)
860 CC_HIGHEST="$CC_HIGHEST -fns"
861 # Do some simplification of floating point arithmetic (not IEEE 754)
862 CC_HIGHEST="$CC_HIGHEST -fsimple"
863 # Use single precision floating point with 'float'
864 CC_HIGHEST="$CC_HIGHEST -fsingle"
865 # Assume memory references via basic pointer types do not alias
866 # (Source with excessing pointer casting and data access with mixed
867 # pointer types are not recommended)
868 CC_HIGHEST="$CC_HIGHEST -xalias_level=basic"
869 # Use intrinsic or inline versions for math/std functions
870 # (If you expect perfect errno behavior, do not use this)
871 CC_HIGHEST="$CC_HIGHEST -xbuiltin=%all"
872 # Loop data dependency optimizations (need -xO3 or higher)
873 CC_HIGHEST="$CC_HIGHEST -xdepend"
874 # Pointer parameters to functions do not overlap
875 # (Similar to -xalias_level=basic usage, but less obvious sometimes.
876 # If you pass in multiple pointers to the same data, do not use this)
877 CC_HIGHEST="$CC_HIGHEST -xrestrict"
878 # Inline some library routines
879 # (If you expect perfect errno behavior, do not use this)
880 CC_HIGHEST="$CC_HIGHEST -xlibmil"
881 # Use optimized math routines
882 # (If you expect perfect errno behavior, do not use this)
883 # Can cause undefined external on Solaris 8 X86 on __sincos, removing for now
884 #CC_HIGHEST="$CC_HIGHEST -xlibmopt"
886 if test "x$OPENJDK_TARGET_CPU" = xsparc; then
887 CFLAGS_JDK="${CFLAGS_JDK} -xmemalign=4s"
888 CXXFLAGS_JDK="${CXXFLAGS_JDK} -xmemalign=4s"
889 fi
891 case $OPENJDK_TARGET_CPU_ARCH in
892 x86)
893 C_O_FLAG_HIGHEST="-xO4 -Wu,-O4~yz $CC_HIGHEST -xregs=no%frameptr"
894 C_O_FLAG_HI="-xO4 -Wu,-O4~yz -xregs=no%frameptr"
895 C_O_FLAG_NORM="-xO2 -Wu,-O2~yz -xregs=no%frameptr"
896 C_O_FLAG_NONE="-xregs=no%frameptr"
897 CXX_O_FLAG_HIGHEST="-xO4 -Qoption ube -O4~yz $CC_HIGHEST -xregs=no%frameptr"
898 CXX_O_FLAG_HI="-xO4 -Qoption ube -O4~yz -xregs=no%frameptr"
899 CXX_O_FLAG_NORM="-xO2 -Qoption ube -O2~yz -xregs=no%frameptr"
900 CXX_O_FLAG_NONE="-xregs=no%frameptr"
901 if test "x$OPENJDK_TARGET_CPU" = xx86; then
902 C_O_FLAG_HIGHEST="$C_O_FLAG_HIGHEST -xchip=pentium"
903 CXX_O_FLAG_HIGHEST="$CXX_O_FLAG_HIGHEST -xchip=pentium"
904 fi
905 ;;
906 sparc)
907 CFLAGS_JDKLIB_EXTRA="${CFLAGS_JDKLIB_EXTRA} -xregs=no%appl"
908 CXXFLAGS_JDKLIB_EXTRA="${CXXFLAGS_JDKLIB_EXTRA} -xregs=no%appl"
909 C_O_FLAG_HIGHEST="-xO4 -Wc,-Qrm-s -Wc,-Qiselect-T0 $CC_HIGHEST -xprefetch=auto,explicit -xchip=ultra"
910 C_O_FLAG_HI="-xO4 -Wc,-Qrm-s -Wc,-Qiselect-T0"
911 C_O_FLAG_NORM="-xO2 -Wc,-Qrm-s -Wc,-Qiselect-T0"
912 C_O_FLAG_NONE=""
913 CXX_O_FLAG_HIGHEST="-xO4 -Qoption cg -Qrm-s -Qoption cg -Qiselect-T0 $CC_HIGHEST -xprefetch=auto,explicit -xchip=ultra"
914 CXX_O_FLAG_HI="-xO4 -Qoption cg -Qrm-s -Qoption cg -Qiselect-T0"
915 CXX_O_FLAG_NORM="-xO2 -Qoption cg -Qrm-s -Qoption cg -Qiselect-T0"
916 CXX_O_FLAG_NONE=""
917 ;;
918 esac
920 CFLAGS_DEBUG_SYMBOLS="-g -xs"
921 CXXFLAGS_DEBUG_SYMBOLS="-g0 -xs"
922 ;;
923 xlc )
924 C_FLAG_DEPS="-qmakedep=gcc -MF"
925 CXX_FLAG_DEPS="-qmakedep=gcc -MF"
926 C_O_FLAG_HIGHEST="-O3"
927 C_O_FLAG_HI="-O3 -qstrict"
928 C_O_FLAG_NORM="-O2"
929 C_O_FLAG_NONE=""
930 CXX_O_FLAG_HIGHEST="-O3"
931 CXX_O_FLAG_HI="-O3 -qstrict"
932 CXX_O_FLAG_NORM="-O2"
933 CXX_O_FLAG_NONE=""
934 CFLAGS_DEBUG_SYMBOLS="-g"
935 CXXFLAGS_DEBUG_SYMBOLS="-g"
936 LDFLAGS_JDK="${LDFLAGS_JDK} -q64 -brtl -bnolibpath -liconv -bexpall"
937 CFLAGS_JDK="${CFLAGS_JDK} -qchars=signed -q64 -qfullpath -qsaveopt"
938 CXXFLAGS_JDK="${CXXFLAGS_JDK} -qchars=signed -q64 -qfullpath -qsaveopt"
939 ;;
940 esac
941 ;;
942 CL )
943 C_O_FLAG_HIGHEST="-O2"
944 C_O_FLAG_HI="-O1"
945 C_O_FLAG_NORM="-O1"
946 C_O_FLAG_NONE="-Od"
947 CXX_O_FLAG_HIGHEST="$C_O_FLAG_HIGHEST"
948 CXX_O_FLAG_HI="$C_O_FLAG_HI"
949 CXX_O_FLAG_NORM="$C_O_FLAG_NORM"
950 CXX_O_FLAG_NONE="$C_O_FLAG_NONE"
951 ;;
952 esac
954 if test -z "$C_O_FLAG_HIGHEST"; then
955 C_O_FLAG_HIGHEST="$C_O_FLAG_HI"
956 fi
958 if test -z "$CXX_O_FLAG_HIGHEST"; then
959 CXX_O_FLAG_HIGHEST="$CXX_O_FLAG_HI"
960 fi
962 AC_SUBST(C_O_FLAG_HIGHEST)
963 AC_SUBST(C_O_FLAG_HI)
964 AC_SUBST(C_O_FLAG_NORM)
965 AC_SUBST(C_O_FLAG_NONE)
966 AC_SUBST(CXX_O_FLAG_HIGHEST)
967 AC_SUBST(CXX_O_FLAG_HI)
968 AC_SUBST(CXX_O_FLAG_NORM)
969 AC_SUBST(CXX_O_FLAG_NONE)
970 AC_SUBST(C_FLAG_DEPS)
971 AC_SUBST(CXX_FLAG_DEPS)
972 ])
974 AC_DEFUN_ONCE([TOOLCHAIN_SETUP_COMPILER_FLAGS_FOR_JDK],
975 [
977 if test "x$CFLAGS" != "x${ADDED_CFLAGS}"; then
978 AC_MSG_WARN([Ignoring CFLAGS($CFLAGS) found in environment. Use --with-extra-cflags])
979 fi
981 if test "x$CXXFLAGS" != "x${ADDED_CXXFLAGS}"; then
982 AC_MSG_WARN([Ignoring CXXFLAGS($CXXFLAGS) found in environment. Use --with-extra-cxxflags])
983 fi
985 if test "x$LDFLAGS" != "x${ADDED_LDFLAGS}"; then
986 AC_MSG_WARN([Ignoring LDFLAGS($LDFLAGS) found in environment. Use --with-extra-ldflags])
987 fi
989 AC_ARG_WITH(extra-cflags, [AS_HELP_STRING([--with-extra-cflags],
990 [extra flags to be used when compiling jdk c-files])])
992 AC_ARG_WITH(extra-cxxflags, [AS_HELP_STRING([--with-extra-cxxflags],
993 [extra flags to be used when compiling jdk c++-files])])
995 AC_ARG_WITH(extra-ldflags, [AS_HELP_STRING([--with-extra-ldflags],
996 [extra flags to be used when linking jdk])])
998 CFLAGS_JDK="${CFLAGS_JDK} $with_extra_cflags"
999 CXXFLAGS_JDK="${CXXFLAGS_JDK} $with_extra_cxxflags"
1000 LDFLAGS_JDK="${LDFLAGS_JDK} $with_extra_ldflags"
1002 # Hotspot needs these set in their legacy form
1003 LEGACY_EXTRA_CFLAGS=$with_extra_cflags
1004 LEGACY_EXTRA_CXXFLAGS=$with_extra_cxxflags
1005 LEGACY_EXTRA_LDFLAGS=$with_extra_ldflags
1007 AC_SUBST(LEGACY_EXTRA_CFLAGS)
1008 AC_SUBST(LEGACY_EXTRA_CXXFLAGS)
1009 AC_SUBST(LEGACY_EXTRA_LDFLAGS)
1011 ###############################################################################
1012 #
1013 # Now setup the CFLAGS and LDFLAGS for the JDK build.
1014 # Later we will also have CFLAGS and LDFLAGS for the hotspot subrepo build.
1015 # CFLAGS_JDK - C Compiler flags
1016 # CXXFLAGS_JDK - C++ Compiler flags
1017 # COMMON_CCXXFLAGS_JDK - common to C and C++
1018 #
1019 case $COMPILER_NAME in
1020 gcc )
1021 COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS $COMMON_CCXXFLAGS_JDK -W -Wall -Wno-unused -Wno-parentheses \
1022 -pipe \
1023 -D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE"
1024 CXXSTD_CXXFLAG="-std=gnu++98"
1025 TOOLCHAIN_CXX_COMPILER_CHECK_ARGUMENTS([$CXXSTD_CXXFLAG $CFLAGS_WARNINGS_ARE_ERRORS],
1026 [], [CXXSTD_CXXFLAG=""])
1027 CXXFLAGS_JDK="${CXXFLAGS_JDK} ${CXXSTD_CXXFLAG}"
1028 AC_SUBST([CXXSTD_CXXFLAG])
1029 case $OPENJDK_TARGET_CPU_ARCH in
1030 arm )
1031 # on arm we don't prevent gcc to omit frame pointer but do prevent strict aliasing
1032 CFLAGS_JDK="${CFLAGS_JDK} -fno-strict-aliasing"
1033 ;;
1034 ppc )
1035 # on ppc we don't prevent gcc to omit frame pointer nor strict-aliasing
1036 ;;
1037 * )
1038 COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -fno-omit-frame-pointer"
1039 CFLAGS_JDK="${CFLAGS_JDK} -fno-strict-aliasing"
1040 ;;
1041 esac
1042 TOOLCHAIN_CHECK_COMPILER_VERSION(6, TOOLCHAIN_SETUP_GCC6_COMPILER_FLAGS)
1043 ;;
1044 ossc )
1045 COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS $COMMON_CCXXFLAGS_JDK -DTRACING -DMACRO_MEMSYS_OPS -DBREAKPTS"
1046 case $OPENJDK_TARGET_CPU_ARCH in
1047 x86 )
1048 COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DcpuIntel -Di586 -D$OPENJDK_TARGET_CPU_LEGACY_LIB"
1049 CFLAGS_JDK="$CFLAGS_JDK -erroff=E_BAD_PRAGMA_PACK_VALUE"
1050 ;;
1051 esac
1053 CFLAGS_JDK="$CFLAGS_JDK -xc99=%none -xCC -errshort=tags -Xa -v -mt -W0,-noglobal"
1054 CXXFLAGS_JDK="$CXXFLAGS_JDK -errtags=yes +w -mt -features=no%except -DCC_NOEX -norunpath -xnolib"
1056 LDFLAGS_JDK="$LDFLAGS_JDK -z defs -xildoff -ztext"
1057 LDFLAGS_CXX_JDK="$LDFLAGS_CXX_JDK -norunpath -xnolib"
1058 ;;
1059 xlc )
1060 CFLAGS_JDK="$CFLAGS_JDK -D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE -DSTDC"
1061 CXXFLAGS_JDK="$CXXFLAGS_JDK -D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE -DSTDC"
1063 LDFLAGS_JDK="$LDFLAGS_JDK"
1064 LDFLAGS_CXX_JDK="$LDFLAGS_CXX_JDK"
1065 ;;
1066 cl )
1067 COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS $COMMON_CCXXFLAGS_JDK -Zi -MD -Zc:wchar_t- -W3 -wd4800 \
1068 -D_STATIC_CPPLIB -D_DISABLE_DEPRECATE_STATIC_CPPLIB -DWIN32_LEAN_AND_MEAN \
1069 -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE \
1070 -DWIN32 -DIAL"
1071 case $OPENJDK_TARGET_CPU in
1072 x86 )
1073 COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D_X86_ -Dx86"
1074 ;;
1075 x86_64 )
1076 COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D_AMD64_ -Damd64"
1077 ;;
1078 esac
1079 ;;
1080 esac
1082 ###############################################################################
1084 # Adjust flags according to debug level.
1085 case $DEBUG_LEVEL in
1086 fastdebug )
1087 CFLAGS_JDK="$CFLAGS_JDK $CFLAGS_DEBUG_SYMBOLS"
1088 CXXFLAGS_JDK="$CXXFLAGS_JDK $CXXFLAGS_DEBUG_SYMBOLS"
1089 C_O_FLAG_HI="$C_O_FLAG_NORM"
1090 C_O_FLAG_NORM="$C_O_FLAG_NORM"
1091 CXX_O_FLAG_HI="$CXX_O_FLAG_NORM"
1092 CXX_O_FLAG_NORM="$CXX_O_FLAG_NORM"
1093 JAVAC_FLAGS="$JAVAC_FLAGS -g"
1094 ;;
1095 slowdebug )
1096 CFLAGS_JDK="$CFLAGS_JDK $CFLAGS_DEBUG_SYMBOLS"
1097 CXXFLAGS_JDK="$CXXFLAGS_JDK $CXXFLAGS_DEBUG_SYMBOLS"
1098 C_O_FLAG_HI="$C_O_FLAG_NONE"
1099 C_O_FLAG_NORM="$C_O_FLAG_NONE"
1100 CXX_O_FLAG_HI="$CXX_O_FLAG_NONE"
1101 CXX_O_FLAG_NORM="$CXX_O_FLAG_NONE"
1102 JAVAC_FLAGS="$JAVAC_FLAGS -g"
1103 ;;
1104 esac
1106 COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK $ADD_LP64"
1108 # The package path is used only on macosx?
1109 PACKAGE_PATH=/opt/local
1110 AC_SUBST(PACKAGE_PATH)
1112 if test "x$OPENJDK_TARGET_CPU_ENDIAN" = xlittle; then
1113 # The macro _LITTLE_ENDIAN needs to be defined the same to avoid the
1114 # Sun C compiler warning message: warning: macro redefined: _LITTLE_ENDIAN
1115 # (The Solaris X86 system defines this in file /usr/include/sys/isa_defs.h).
1116 # Note: -Dmacro is the same as #define macro 1
1117 # -Dmacro= is the same as #define macro
1118 if test "x$OPENJDK_TARGET_OS" = xsolaris; then
1119 COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D_LITTLE_ENDIAN="
1120 else
1121 COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D_LITTLE_ENDIAN"
1122 fi
1123 else
1124 COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D_BIG_ENDIAN"
1125 fi
1126 if test "x$OPENJDK_TARGET_OS" = xlinux; then
1127 COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DLINUX"
1128 fi
1129 if test "x$OPENJDK_TARGET_OS" = xwindows; then
1130 COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DWINDOWS"
1131 fi
1132 if test "x$OPENJDK_TARGET_OS" = xsolaris; then
1133 COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DSOLARIS"
1134 fi
1135 if test "x$OPENJDK_TARGET_OS" = xaix; then
1136 COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DAIX -DPPC64"
1137 fi
1138 if test "x$OPENJDK_TARGET_OS" = xmacosx; then
1139 COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DMACOSX -D_ALLBSD_SOURCE -D_DARWIN_UNLIMITED_SELECT"
1140 # Setting these parameters makes it an error to link to macosx APIs that are
1141 # newer than the given OS version and makes the linked binaries compatible even
1142 # if built on a newer version of the OS.
1143 # The expected format is X.Y.Z
1144 MACOSX_VERSION_MIN=10.7.0
1145 AC_SUBST(MACOSX_VERSION_MIN)
1146 # The macro takes the version with no dots, ex: 1070
1147 # Let the flags variables get resolved in make for easier override on make
1148 # command line.
1149 COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DMAC_OS_X_VERSION_MAX_ALLOWED=\$(subst .,,\$(MACOSX_VERSION_MIN)) -mmacosx-version-min=\$(MACOSX_VERSION_MIN)"
1150 LDFLAGS_JDK="$LDFLAGS_JDK -mmacosx-version-min=\$(MACOSX_VERSION_MIN)"
1151 fi
1152 if test "x$OPENJDK_TARGET_OS" = xbsd; then
1153 COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DBSD -D_ALLBSD_SOURCE"
1154 fi
1155 if test "x$DEBUG_LEVEL" = xrelease; then
1156 COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DNDEBUG"
1157 if test "x$OPENJDK_TARGET_OS" = xsolaris; then
1158 COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DTRIMMED"
1159 fi
1160 else
1161 COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DDEBUG"
1162 fi
1164 COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DARCH='\"$OPENJDK_TARGET_CPU_LEGACY\"' -D$OPENJDK_TARGET_CPU_LEGACY"
1165 COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DRELEASE='\"\$(RELEASE)\"'"
1167 COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK \
1168 -I${JDK_OUTPUTDIR}/include \
1169 -I${JDK_OUTPUTDIR}/include/$OPENJDK_TARGET_OS \
1170 -I${JDK_TOPDIR}/src/share/javavm/export \
1171 -I${JDK_TOPDIR}/src/$OPENJDK_TARGET_OS_EXPORT_DIR/javavm/export \
1172 -I${JDK_TOPDIR}/src/share/native/common \
1173 -I${JDK_TOPDIR}/src/$OPENJDK_TARGET_OS_API_DIR/native/common"
1175 # The shared libraries are compiled using the picflag.
1176 CFLAGS_JDKLIB="$COMMON_CCXXFLAGS_JDK $CFLAGS_JDK $PICFLAG $CFLAGS_JDKLIB_EXTRA"
1177 CXXFLAGS_JDKLIB="$COMMON_CCXXFLAGS_JDK $CXXFLAGS_JDK $PICFLAG $CXXFLAGS_JDKLIB_EXTRA "
1179 # Executable flags
1180 CFLAGS_JDKEXE="$COMMON_CCXXFLAGS_JDK $CFLAGS_JDK"
1181 CXXFLAGS_JDKEXE="$COMMON_CCXXFLAGS_JDK $CXXFLAGS_JDK"
1183 # Now this is odd. The JDK native libraries have to link against libjvm.so
1184 # On 32-bit machines there is normally two distinct libjvm.so:s, client and server.
1185 # Which should we link to? Are we lucky enough that the binary api to the libjvm.so library
1186 # is identical for client and server? Yes. Which is picked at runtime (client or server)?
1187 # Neither, since the chosen libjvm.so has already been loaded by the launcher, all the following
1188 # libraries will link to whatever is in memory. Yuck.
1189 #
1190 # Thus we offer the compiler to find libjvm.so first in server then in client. It works. Ugh.
1191 if test "x$COMPILER_NAME" = xcl; then
1192 LDFLAGS_JDK="$LDFLAGS_JDK -nologo -opt:ref -incremental:no"
1193 if test "x$OPENJDK_TARGET_CPU" = xx86; then
1194 LDFLAGS_JDK="$LDFLAGS_JDK -safeseh"
1195 fi
1196 # TODO: make -debug optional "--disable-full-debug-symbols"
1197 LDFLAGS_JDK="$LDFLAGS_JDK -debug"
1198 LDFLAGS_JDKLIB="${LDFLAGS_JDK} -dll -libpath:${JDK_OUTPUTDIR}/lib"
1199 LDFLAGS_JDKLIB_SUFFIX=""
1200 if test "x$OPENJDK_TARGET_CPU_BITS" = "x64"; then
1201 LDFLAGS_STACK_SIZE=1048576
1202 else
1203 LDFLAGS_STACK_SIZE=327680
1204 fi
1205 LDFLAGS_JDKEXE="${LDFLAGS_JDK} /STACK:$LDFLAGS_STACK_SIZE"
1206 else
1207 if test "x$COMPILER_NAME" = xgcc; then
1208 # If this is a --hash-style=gnu system, use --hash-style=both, why?
1209 HAS_GNU_HASH=`$CC -dumpspecs 2>/dev/null | $GREP 'hash-style=gnu'`
1210 if test -n "$HAS_GNU_HASH"; then
1211 LDFLAGS_JDK="${LDFLAGS_JDK} -Xlinker --hash-style=both "
1212 fi
1213 if test "x$OPENJDK_TARGET_OS" = xlinux; then
1214 # And since we now know that the linker is gnu, then add:
1215 # -z defs, to forbid undefined symbols in object files
1216 # -z noexecstack, to mark stack regions as non-executable
1217 LDFLAGS_JDK="${LDFLAGS_JDK} -Xlinker -z -Xlinker defs -Xlinker -z -Xlinker noexecstack"
1218 if test "x$DEBUG_LEVEL" = "xrelease"; then
1219 # When building release libraries, tell the linker optimize them.
1220 # Should this be supplied to the OSS linker as well?
1221 LDFLAGS_JDK="${LDFLAGS_JDK} -Xlinker -O1"
1222 fi
1223 fi
1224 fi
1225 LDFLAGS_JDKLIB="${LDFLAGS_JDK} $SHARED_LIBRARY_FLAGS \
1226 -L${JDK_OUTPUTDIR}/lib${OPENJDK_TARGET_CPU_LIBDIR}"
1228 # On some platforms (mac) the linker warns about non existing -L dirs.
1229 # Add server first if available. Linking aginst client does not always produce the same results.
1230 # Only add client dir if client is being built. Add minimal (note not minimal1) if only building minimal1.
1231 # Default to server for other variants.
1232 if test "x$JVM_VARIANT_SERVER" = xtrue; then
1233 LDFLAGS_JDKLIB="${LDFLAGS_JDKLIB} -L${JDK_OUTPUTDIR}/lib${OPENJDK_TARGET_CPU_LIBDIR}/server"
1234 elif test "x$JVM_VARIANT_CLIENT" = xtrue; then
1235 LDFLAGS_JDKLIB="${LDFLAGS_JDKLIB} -L${JDK_OUTPUTDIR}/lib${OPENJDK_TARGET_CPU_LIBDIR}/client"
1236 elif test "x$JVM_VARIANT_MINIMAL1" = xtrue; then
1237 LDFLAGS_JDKLIB="${LDFLAGS_JDKLIB} -L${JDK_OUTPUTDIR}/lib${OPENJDK_TARGET_CPU_LIBDIR}/minimal"
1238 else
1239 LDFLAGS_JDKLIB="${LDFLAGS_JDKLIB} -L${JDK_OUTPUTDIR}/lib${OPENJDK_TARGET_CPU_LIBDIR}/server"
1240 fi
1242 LDFLAGS_JDKLIB_SUFFIX="-ljava -ljvm"
1243 if test "x$COMPILER_NAME" = xossc; then
1244 LDFLAGS_JDKLIB_SUFFIX="$LDFLAGS_JDKLIB_SUFFIX -lc"
1245 fi
1247 LDFLAGS_JDKEXE="${LDFLAGS_JDK}"
1248 if test "x$OPENJDK_TARGET_OS" = xlinux; then
1249 LDFLAGS_JDKEXE="$LDFLAGS_JDKEXE -Xlinker --allow-shlib-undefined"
1250 fi
1251 fi
1253 AC_SUBST(CFLAGS_JDKLIB)
1254 AC_SUBST(CFLAGS_JDKEXE)
1256 AC_SUBST(CXXFLAGS_JDKLIB)
1257 AC_SUBST(CXXFLAGS_JDKEXE)
1259 AC_SUBST(LDFLAGS_JDKLIB)
1260 AC_SUBST(LDFLAGS_JDKEXE)
1261 AC_SUBST(LDFLAGS_JDKLIB_SUFFIX)
1262 AC_SUBST(LDFLAGS_JDKEXE_SUFFIX)
1263 AC_SUBST(LDFLAGS_CXX_JDK)
1264 ])
1267 # TOOLCHAIN_C_COMPILER_CHECK_ARGUMENTS([ARGUMENT], [RUN-IF-TRUE],
1268 # [RUN-IF-FALSE])
1269 # ------------------------------------------------------------
1270 # Check that the C compiler supports an argument
1271 AC_DEFUN([TOOLCHAIN_C_COMPILER_CHECK_ARGUMENTS],
1272 [
1273 AC_MSG_CHECKING([if the C compiler supports "$1"])
1274 supports=yes
1276 saved_cflags="$CFLAGS"
1277 CFLAGS="$CFLAGS $1"
1278 AC_LANG_PUSH([C])
1279 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[int i;]])], [],
1280 [supports=no])
1281 AC_LANG_POP([C])
1282 CFLAGS="$saved_cflags"
1284 AC_MSG_RESULT([$supports])
1285 if test "x$supports" = "xyes" ; then
1286 m4_ifval([$2], [$2], [:])
1287 else
1288 m4_ifval([$3], [$3], [:])
1289 fi
1290 ])
1292 # TOOLCHAIN_CXX_COMPILER_CHECK_ARGUMENTS([ARGUMENT], [RUN-IF-TRUE],
1293 # [RUN-IF-FALSE])
1294 # ------------------------------------------------------------
1295 # Check that the C++ compiler supports an argument
1296 AC_DEFUN([TOOLCHAIN_CXX_COMPILER_CHECK_ARGUMENTS],
1297 [
1298 AC_MSG_CHECKING([if the C++ compiler supports "$1"])
1299 supports=yes
1301 saved_cxxflags="$CXXFLAGS"
1302 CXXFLAGS="$CXXFLAG $1"
1303 AC_LANG_PUSH([C++])
1304 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[int i;]])], [],
1305 [supports=no])
1306 AC_LANG_POP([C++])
1307 CXXFLAGS="$saved_cxxflags"
1309 AC_MSG_RESULT([$supports])
1310 if test "x$supports" = "xyes" ; then
1311 m4_ifval([$2], [$2], [:])
1312 else
1313 m4_ifval([$3], [$3], [:])
1314 fi
1315 ])
1317 # TOOLCHAIN_COMPILER_CHECK_ARGUMENTS([ARGUMENT], [RUN-IF-TRUE],
1318 # [RUN-IF-FALSE])
1319 # ------------------------------------------------------------
1320 # Check that the C and C++ compilers support an argument
1321 AC_DEFUN([TOOLCHAIN_COMPILER_CHECK_ARGUMENTS],
1322 [
1323 TOOLCHAIN_C_COMPILER_CHECK_ARGUMENTS([$1],
1324 [C_COMP_SUPPORTS="yes"],
1325 [C_COMP_SUPPORTS="no"])
1326 TOOLCHAIN_CXX_COMPILER_CHECK_ARGUMENTS([$1],
1327 [CXX_COMP_SUPPORTS="yes"],
1328 [CXX_COMP_SUPPORTS="no"])
1330 AC_MSG_CHECKING([if both compilers support "$1"])
1331 supports=no
1332 if test "x$C_COMP_SUPPORTS" = "xyes" -a "x$CXX_COMP_SUPPORTS" = "xyes"; then supports=yes; fi
1334 AC_MSG_RESULT([$supports])
1335 if test "x$supports" = "xyes" ; then
1336 m4_ifval([$2], [$2], [:])
1337 else
1338 m4_ifval([$3], [$3], [:])
1339 fi
1340 ])
1342 AC_DEFUN_ONCE([TOOLCHAIN_SETUP_COMPILER_FLAGS_MISC],
1343 [
1344 # Some Zero and Shark settings.
1345 # ZERO_ARCHFLAG tells the compiler which mode to build for
1346 case "${OPENJDK_TARGET_CPU}" in
1347 s390)
1348 ZERO_ARCHFLAG="${COMPILER_TARGET_BITS_FLAG}31"
1349 ;;
1350 *)
1351 ZERO_ARCHFLAG="${COMPILER_TARGET_BITS_FLAG}${OPENJDK_TARGET_CPU_BITS}"
1352 esac
1353 TOOLCHAIN_COMPILER_CHECK_ARGUMENTS([$ZERO_ARCHFLAG], [], [ZERO_ARCHFLAG=""])
1354 AC_SUBST(ZERO_ARCHFLAG)
1356 # Check that the compiler supports -mX (or -qX on AIX) flags
1357 # Set COMPILER_SUPPORTS_TARGET_BITS_FLAG to 'true' if it does
1358 TOOLCHAIN_COMPILER_CHECK_ARGUMENTS([${COMPILER_TARGET_BITS_FLAG}${OPENJDK_TARGET_CPU_BITS}],
1359 [COMPILER_SUPPORTS_TARGET_BITS_FLAG=true],
1360 [COMPILER_SUPPORTS_TARGET_BITS_FLAG=false])
1361 AC_SUBST(COMPILER_SUPPORTS_TARGET_BITS_FLAG)
1364 # Check for broken SuSE 'ld' for which 'Only anonymous version tag is allowed in executable.'
1365 USING_BROKEN_SUSE_LD=no
1366 if test "x$OPENJDK_TARGET_OS" = xlinux && test "x$GCC" = xyes; then
1367 AC_MSG_CHECKING([for broken SuSE 'ld' which only understands anonymous version tags in executables])
1368 echo "SUNWprivate_1.1 { local: *; };" > version-script.map
1369 echo "int main() { }" > main.c
1370 if $CXX -Xlinker -version-script=version-script.map main.c 2>&AS_MESSAGE_LOG_FD >&AS_MESSAGE_LOG_FD; then
1371 AC_MSG_RESULT(no)
1372 USING_BROKEN_SUSE_LD=no
1373 else
1374 AC_MSG_RESULT(yes)
1375 USING_BROKEN_SUSE_LD=yes
1376 fi
1377 rm -rf version-script.map main.c
1378 fi
1379 AC_SUBST(USING_BROKEN_SUSE_LD)
1380 ])
1382 # Setup the JTREG paths
1383 AC_DEFUN_ONCE([TOOLCHAIN_SETUP_JTREG],
1384 [
1385 AC_ARG_WITH(jtreg, [AS_HELP_STRING([--with-jtreg],
1386 [Regression Test Harness @<:@probed@:>@])],
1387 [],
1388 [with_jtreg=no])
1390 if test "x$with_jtreg" = xno; then
1391 # jtreg disabled
1392 AC_MSG_CHECKING([for jtreg])
1393 AC_MSG_RESULT(no)
1394 else
1395 if test "x$with_jtreg" != xyes; then
1396 # with path specified.
1397 JT_HOME="$with_jtreg"
1398 fi
1400 if test "x$JT_HOME" != x; then
1401 AC_MSG_CHECKING([for jtreg])
1403 # use JT_HOME enviroment var.
1404 BASIC_FIXUP_PATH([JT_HOME])
1406 # jtreg win32 script works for everybody
1407 JTREGEXE="$JT_HOME/bin/jtreg"
1409 if test ! -f "$JTREGEXE"; then
1410 AC_MSG_ERROR([JTReg executable does not exist: $JTREGEXE])
1411 fi
1413 AC_MSG_RESULT($JTREGEXE)
1414 else
1415 # try to find jtreg on path
1416 BASIC_REQUIRE_PROG(JTREGEXE, jtreg)
1417 JT_HOME="`$DIRNAME $JTREGEXE`"
1418 fi
1419 fi
1421 AC_SUBST(JT_HOME)
1422 AC_SUBST(JTREGEXE)
1423 ])
1425 AC_DEFUN_ONCE([TOOLCHAIN_SETUP_GCC6_COMPILER_FLAGS],
1426 [
1427 # These flags are required for GCC 6 builds as undefined behaviour in OpenJDK code
1428 # runs afoul of the more aggressive versions of these optimisations.
1429 # Notably, value range propagation now assumes that the this pointer of C++
1430 # member functions is non-null.
1431 NO_DELETE_NULL_POINTER_CHECKS_CFLAG="-fno-delete-null-pointer-checks"
1432 TOOLCHAIN_COMPILER_CHECK_ARGUMENTS([$NO_DELETE_NULL_POINTER_CHECKS_CFLAG -Werror],
1433 [], [NO_DELETE_NULL_POINTER_CHECKS_CFLAG=""])
1434 AC_SUBST([NO_DELETE_NULL_POINTER_CHECKS_CFLAG])
1435 NO_LIFETIME_DSE_CFLAG="-fno-lifetime-dse"
1436 TOOLCHAIN_COMPILER_CHECK_ARGUMENTS([$NO_LIFETIME_DSE_CFLAG -Werror],
1437 [], [NO_LIFETIME_DSE_CFLAG=""])
1438 CFLAGS_JDK="${CFLAGS_JDK} ${NO_DELETE_NULL_POINTER_CHECKS_CFLAG} ${NO_LIFETIME_DSE_CFLAG}"
1439 AC_SUBST([NO_LIFETIME_DSE_CFLAG])
1440 ])