Move definition to the build system

0 #
1 # Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
2 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3 #
4 # This code is free software; you can redistribute it and/or modify it
5 # under the terms of the GNU General Public License version 2 only, as
6 # published by the Free Software Foundation.  Oracle designates this
7 # particular file as subject to the "Classpath" exception as provided
8 # by Oracle in the LICENSE file that accompanied this code.
9 #
10 # This code is distributed in the hope that it will be useful, but WITHOUT
11 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 # FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
13 # version 2 for more details (a copy is included in the LICENSE file that
14 # accompanied this code).
15 #
16 # You should have received a copy of the GNU General Public License version
17 # 2 along with this work; if not, write to the Free Software Foundation,
18 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19 #
20 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21 # or visit www.oracle.com if you need additional information or have any
22 # questions.
23 #
24 
25 ################################################################################
26 #
27 # Setup ABI profile (for arm)
28 #
29 AC_DEFUN([FLAGS_SETUP_ABI_PROFILE],
30 [
31   AC_ARG_WITH(abi-profile, [AS_HELP_STRING([--with-abi-profile],
32       [specify ABI profile for ARM builds (arm-vfp-sflt,arm-vfp-hflt,arm-sflt, armv5-vfp-sflt,armv6-vfp-hflt,arm64,aarch64)
33 
34   if test "x$with_abi_profile" != x; then
35     if test "x$OPENJDK_TARGET_CPU" != xarm && \
36         test "x$OPENJDK_TARGET_CPU" != xaarch64; then
37       AC_MSG_ERROR([--with-abi-profile only available on arm/aarch64])
38     fi
39 
40     OPENJDK_TARGET_ABI_PROFILE=$with_abi_profile
41     AC_MSG_CHECKING([for ABI profle])
42     AC_MSG_RESULT([$OPENJDK_TARGET_ABI_PROFILE])
43 
44     if test "x$OPENJDK_TARGET_ABI_PROFILE" = xarm-vfp-sflt; then
45       ARM_FLOAT_TYPE=vfp-sflt
46       ARM_ARCH_TYPE_FLAGS='-march=armv7-a -mthumb'
47     elif test "x$OPENJDK_TARGET_ABI_PROFILE" = xarm-vfp-hflt; then
48       ARM_FLOAT_TYPE=vfp-hflt
49       ARM_ARCH_TYPE_FLAGS='-march=armv7-a -mthumb'
50     elif test "x$OPENJDK_TARGET_ABI_PROFILE" = xarm-sflt; then
51       ARM_FLOAT_TYPE=sflt
52       ARM_ARCH_TYPE_FLAGS='-march=armv5t -marm'
53     elif test "x$OPENJDK_TARGET_ABI_PROFILE" = xarmv5-vfp-sflt; then
54       ARM_FLOAT_TYPE=vfp-sflt
55       ARM_ARCH_TYPE_FLAGS='-march=armv5t -marm'
56     elif test "x$OPENJDK_TARGET_ABI_PROFILE" = xarmv6-vfp-hflt; then
57       ARM_FLOAT_TYPE=vfp-hflt
58       ARM_ARCH_TYPE_FLAGS='-march=armv6 -marm'
59     elif test "x$OPENJDK_TARGET_ABI_PROFILE" = xarm64; then
60       # No special flags, just need to trigger setting JDK_ARCH_ABI_PROP_NAME
61       ARM_FLOAT_TYPE=
62       ARM_ARCH_TYPE_FLAGS=
63     elif test "x$OPENJDK_TARGET_ABI_PROFILE" = xaarch64; then
64       # No special flags, just need to trigger setting JDK_ARCH_ABI_PROP_NAME
65       ARM_FLOAT_TYPE=
66       ARM_ARCH_TYPE_FLAGS=
67     else
68       AC_MSG_ERROR([Invalid ABI profile: "$OPENJDK_TARGET_ABI_PROFILE"])
69     fi
70 
71     if test "x$ARM_FLOAT_TYPE" = xvfp-sflt; then
72       ARM_FLOAT_TYPE_FLAGS='-mfloat-abi=softfp -mfpu=vfp -DFLOAT_ARCH=-vfp-sflt'
73     elif test "x$ARM_FLOAT_TYPE" = xvfp-hflt; then
74       ARM_FLOAT_TYPE_FLAGS='-mfloat-abi=hard -mfpu=vfp -DFLOAT_ARCH=-vfp-hflt'
75     elif test "x$ARM_FLOAT_TYPE" = xsflt; then
76       ARM_FLOAT_TYPE_FLAGS='-msoft-float -mfpu=vfp'
77     fi
78     AC_MSG_CHECKING([for $ARM_FLOAT_TYPE floating point flags])
79     AC_MSG_RESULT([$ARM_FLOAT_TYPE_FLAGS])
80 
81     AC_MSG_CHECKING([for arch type flags])
82     AC_MSG_RESULT([$ARM_ARCH_TYPE_FLAGS])
83 
84     # Now set JDK_ARCH_ABI_PROP_NAME. This is equivalent to the last part of the
85     # autoconf target triplet.
86     [ JDK_ARCH_ABI_PROP_NAME=`$ECHO $OPENJDK_TARGET_AUTOCONF_NAME | $SED -e 's/.*-\([^-]*\)$/\1/'` ]
87     # Sanity check that it is a known ABI.
88     if test "x$JDK_ARCH_ABI_PROP_NAME" != xgnu && \
89         test "x$JDK_ARCH_ABI_PROP_NAME" != xgnueabi  && \
90         test "x$JDK_ARCH_ABI_PROP_NAME" != xgnueabihf; then
91           AC_MSG_WARN([Unknown autoconf target triplet ABI: "$JDK_ARCH_ABI_PROP_NAME"])
92     fi
93     AC_MSG_CHECKING([for ABI property name])
94     AC_MSG_RESULT([$JDK_ARCH_ABI_PROP_NAME])
95     AC_SUBST(JDK_ARCH_ABI_PROP_NAME)
96 
97     # Pass these on to the open part of configure as if they were set using
98     # --with-extra-c[xx]flags.
99     EXTRA_CFLAGS="$EXTRA_CFLAGS $ARM_ARCH_TYPE_FLAGS $ARM_FLOAT_TYPE_FLAGS"
100     EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS $ARM_ARCH_TYPE_FLAGS $ARM_FLOAT_TYPE_FLAGS"
101     # Get rid of annoying "note: the mangling of 'va_list' has changed in GCC 4.4"
102     # FIXME: This should not really be set using extra_cflags.
103     if test "x$OPENJDK_TARGET_CPU" = xarm; then
104         EXTRA_CFLAGS="$EXTRA_CFLAGS -Wno-psabi"
105         EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS -Wno-psabi"
106     fi
107     # Also add JDK_ARCH_ABI_PROP_NAME define, but only to CFLAGS.
108     EXTRA_CFLAGS="$EXTRA_CFLAGS -DJDK_ARCH_ABI_PROP_NAME='\"\$(JDK_ARCH_ABI_PROP_NAME)\"'"
109     # And pass the architecture flags to the linker as well
110     EXTRA_LDFLAGS="$EXTRA_LDFLAGS $ARM_ARCH_TYPE_FLAGS $ARM_FLOAT_TYPE_FLAGS"
111   fi
112 
113   # When building with an abi profile, the name of that profile is appended on the
114   # bundle platform, which is used in bundle names.
115   if test "x$OPENJDK_TARGET_ABI_PROFILE" != x; then
116     OPENJDK_TARGET_BUNDLE_PLATFORM="$OPENJDK_TARGET_OS_BUNDLE-$OPENJDK_TARGET_ABI_PROFILE"
117   fi
118 ])
119 
120 # Reset the global CFLAGS/LDFLAGS variables and initialize them with the
121 # corresponding configure arguments instead
122 AC_DEFUN_ONCE([FLAGS_SETUP_USER_SUPPLIED_FLAGS],
123 [
124   if test "x$CFLAGS" != "x${ADDED_CFLAGS}"; then
125     AC_MSG_WARN([Ignoring CFLAGS($CFLAGS) found in environment. Use --with-extra-cflags])
126   fi
127 
128   if test "x$CXXFLAGS" != "x${ADDED_CXXFLAGS}"; then
129     AC_MSG_WARN([Ignoring CXXFLAGS($CXXFLAGS) found in environment. Use --with-extra-cxxflags])
130   fi
131 
132   if test "x$LDFLAGS" != "x${ADDED_LDFLAGS}"; then
133     AC_MSG_WARN([Ignoring LDFLAGS($LDFLAGS) found in environment. Use --with-extra-ldflags])
134   fi
135 
136   AC_ARG_WITH(extra-cflags, [AS_HELP_STRING([--with-extra-cflags],
137       [extra flags to be used when compiling jdk c-files])])
138 
139   AC_ARG_WITH(extra-cxxflags, [AS_HELP_STRING([--with-extra-cxxflags],
140       [extra flags to be used when compiling jdk c++-files])])
141 
142   AC_ARG_WITH(extra-ldflags, [AS_HELP_STRING([--with-extra-ldflags],
143       [extra flags to be used when linking jdk])])
144 
145   EXTRA_CFLAGS="$with_extra_cflags"
146   EXTRA_CXXFLAGS="$with_extra_cxxflags"
147   EXTRA_LDFLAGS="$with_extra_ldflags"
148 
149   AC_SUBST(EXTRA_CFLAGS)
150   AC_SUBST(EXTRA_CXXFLAGS)
151   AC_SUBST(EXTRA_LDFLAGS)
152 
153   # The global CFLAGS and LDLAGS variables are used by configure tests and
154   # should include the extra parameters
155   CFLAGS="$EXTRA_CFLAGS"
156   CXXFLAGS="$EXTRA_CXXFLAGS"
157   LDFLAGS="$EXTRA_LDFLAGS"
158   CPPFLAGS=""
159 ])
160 
161 # Setup the sysroot flags and add them to global CFLAGS and LDFLAGS so
162 # that configure can use them while detecting compilers.
163 # TOOLCHAIN_TYPE is available here.
164 # Param 1 - Optional prefix to all variables. (e.g BUILD_)
165 AC_DEFUN([FLAGS_SETUP_SYSROOT_FLAGS],
166 [
167   if test "x[$]$1SYSROOT" != "x"; then
168     if test "x$TOOLCHAIN_TYPE" = xsolstudio; then
169       if test "x$OPENJDK_TARGET_OS" = xsolaris; then
170         # Solaris Studio does not have a concept of sysroot. Instead we must
171         # make sure the default include and lib dirs are appended to each
172         # compile and link command line. Must also add -I-xbuiltin to enable
173         # inlining of system functions and intrinsics.
174         $1SYSROOT_CFLAGS="-I-xbuiltin -I[$]$1SYSROOT/usr/include"
175         $1SYSROOT_LDFLAGS="-L[$]$1SYSROOT/usr/lib$OPENJDK_TARGET_CPU_ISADIR \
176             -L[$]$1SYSROOT/lib$OPENJDK_TARGET_CPU_ISADIR"
177         # If the devkit contains the ld linker, make sure we use it.
178         AC_PATH_PROG(SOLARIS_LD, ld, , $DEVKIT_TOOLCHAIN_PATH:$DEVKIT_EXTRA_PATH)
179         # Make sure this ld is runnable.
180         if test -f "$SOLARIS_LD"; then
181           if "$SOLARIS_LD" -V > /dev/null 2> /dev/null; then
182             $1SYSROOT_LDFLAGS="[$]$1SYSROOT_LDFLAGS -Yl,$(dirname $SOLARIS_LD)"
183           else
184             AC_MSG_WARN([Could not run $SOLARIS_LD found in devkit, reverting to system ld])
185           fi
186         fi
187       fi
188     elif test "x$TOOLCHAIN_TYPE" = xgcc; then
189       $1SYSROOT_CFLAGS="--sysroot=[$]$1SYSROOT"
190       $1SYSROOT_LDFLAGS="--sysroot=[$]$1SYSROOT"
191     elif test "x$TOOLCHAIN_TYPE" = xclang; then
192       $1SYSROOT_CFLAGS="-isysroot [$]$1SYSROOT"
193       $1SYSROOT_LDFLAGS="-isysroot [$]$1SYSROOT"
194     fi
195     # The global CFLAGS and LDFLAGS variables need these for configure to function
196     $1CFLAGS="[$]$1CFLAGS [$]$1SYSROOT_CFLAGS"
197     $1CPPFLAGS="[$]$1CPPFLAGS [$]$1SYSROOT_CFLAGS"
198     $1CXXFLAGS="[$]$1CXXFLAGS [$]$1SYSROOT_CFLAGS"
199     $1LDFLAGS="[$]$1LDFLAGS [$]$1SYSROOT_LDFLAGS"
200   fi
201 
202   if test "x$OPENJDK_TARGET_OS" = xmacosx; then
203     # We also need -iframework<path>/System/Library/Frameworks
204     $1SYSROOT_CFLAGS="[$]$1SYSROOT_CFLAGS -iframework [$]$1SYSROOT/System/Library/Frameworks"
205     $1SYSROOT_LDFLAGS="[$]$1SYSROOT_LDFLAGS -iframework [$]$1SYSROOT/System/Library/Frameworks"
206     # These always need to be set, or we can't find the frameworks embedded in JavaVM.framework
207     # set this here so it doesn't have to be peppered throughout the forest
208     $1SYSROOT_CFLAGS="[$]$1SYSROOT_CFLAGS -F [$]$1SYSROOT/System/Library/Frameworks/JavaVM.framework/Frameworks"
209     $1SYSROOT_LDFLAGS="[$]$1SYSROOT_LDFLAGS -F [$]$1SYSROOT/System/Library/Frameworks/JavaVM.framework/Frameworks"
210   fi
211 
212   AC_SUBST($1SYSROOT_CFLAGS)
213   AC_SUBST($1SYSROOT_LDFLAGS)
214 ])
215 
216 AC_DEFUN_ONCE([FLAGS_SETUP_INIT_FLAGS],
217 [
218   # COMPILER_TARGET_BITS_FLAG  : option for selecting 32- or 64-bit output
219   # COMPILER_COMMAND_FILE_FLAG : option for passing a command file to the compiler
220   # COMPILER_BINDCMD_FILE_FLAG : option for specifying a file which saves the binder
221   #                              commands produced by the link step (currently AIX only)
222   if test "x$TOOLCHAIN_TYPE" = xxlc; then
223     COMPILER_TARGET_BITS_FLAG="-q"
224     COMPILER_COMMAND_FILE_FLAG="-f"
225     COMPILER_BINDCMD_FILE_FLAG="-bloadmap:"
226   else
227     COMPILER_TARGET_BITS_FLAG="-m"
228     COMPILER_COMMAND_FILE_FLAG="@"
229     COMPILER_BINDCMD_FILE_FLAG=""
230 
231     # The solstudio linker does not support @-files.
232     if test "x$TOOLCHAIN_TYPE" = xsolstudio; then
233       COMPILER_COMMAND_FILE_FLAG=
234     fi
235 
236     # Check if @file is supported by gcc
237     if test "x$TOOLCHAIN_TYPE" = xgcc; then
238       AC_MSG_CHECKING([if @file is supported by gcc])
239       # Extra emtpy "" to prevent ECHO from interpreting '--version' as argument
240       $ECHO "" "--version" > command.file
241       if $CXX @command.file 2>&AS_MESSAGE_LOG_FD >&AS_MESSAGE_LOG_FD; then
242         AC_MSG_RESULT(yes)
243         COMPILER_COMMAND_FILE_FLAG="@"
244       else
245         AC_MSG_RESULT(no)
246         COMPILER_COMMAND_FILE_FLAG=
247       fi
248       $RM command.file
249     fi
250   fi
251   AC_SUBST(COMPILER_TARGET_BITS_FLAG)
252   AC_SUBST(COMPILER_COMMAND_FILE_FLAG)
253   AC_SUBST(COMPILER_BINDCMD_FILE_FLAG)
254 
255   # FIXME: figure out if we should select AR flags depending on OS or toolchain.
256   if test "x$OPENJDK_TARGET_OS" = xmacosx; then
257     ARFLAGS="-r"
258   elif test "x$OPENJDK_TARGET_OS" = xaix; then
259     ARFLAGS="-X64"
260   elif test "x$OPENJDK_TARGET_OS" = xwindows; then
261     # lib.exe is used as AR to create static libraries.
262     ARFLAGS="-nologo -NODEFAULTLIB:MSVCRT"
263   else
264     ARFLAGS=""
265   fi
266   AC_SUBST(ARFLAGS)
267 
268   ## Setup strip.
269   # FIXME: should this really be per platform, or should it be per toolchain type?
270   # strip is not provided by clang or solstudio; so guessing platform makes most sense.
271   # FIXME: we should really only export STRIPFLAGS from here, not POST_STRIP_CMD.
272   if test "x$OPENJDK_TARGET_OS" = xlinux; then
273     STRIPFLAGS="-g"
274   elif test "x$OPENJDK_TARGET_OS" = xsolaris; then
275     STRIPFLAGS="-x"
276   elif test "x$OPENJDK_TARGET_OS" = xmacosx; then
277     STRIPFLAGS="-S"
278   elif test "x$OPENJDK_TARGET_OS" = xaix; then
279     STRIPFLAGS="-X32_64"
280   fi
281 
282   AC_SUBST(STRIPFLAGS)
283 
284   if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
285     CC_OUT_OPTION=-Fo
286     EXE_OUT_OPTION=-out:
287     LD_OUT_OPTION=-out:
288     AR_OUT_OPTION=-out:
289   else
290     # The option used to specify the target .o,.a or .so file.
291     # When compiling, how to specify the to be created object file.
292     CC_OUT_OPTION='-o$(SPACE)'
293     # When linking, how to specify the to be created executable.
294     EXE_OUT_OPTION='-o$(SPACE)'
295     # When linking, how to specify the to be created dynamically linkable library.
296     LD_OUT_OPTION='-o$(SPACE)'
297     # When archiving, how to specify the to be create static archive for object files.
298     AR_OUT_OPTION='rcs$(SPACE)'
299   fi
300   AC_SUBST(CC_OUT_OPTION)
301   AC_SUBST(EXE_OUT_OPTION)
302   AC_SUBST(LD_OUT_OPTION)
303   AC_SUBST(AR_OUT_OPTION)
304 
305   # On Windows, we need to set RC flags.
306   if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
307     RC_FLAGS="-nologo -l0x409"
308     JVM_RCFLAGS="-nologo"
309     if test "x$DEBUG_LEVEL" = xrelease; then
310       RC_FLAGS="$RC_FLAGS -DNDEBUG"
311       JVM_RCFLAGS="$JVM_RCFLAGS -DNDEBUG"
312     fi
313 
314     # The version variables used to create RC_FLAGS may be overridden
315     # in a custom configure script, or possibly the command line.
316     # Let those variables be expanded at make time in spec.gmk.
317     # The \$ are escaped to the shell, and the $(...) variables
318     # are evaluated by make.
319     RC_FLAGS="$RC_FLAGS \
320         -D\"JDK_VERSION_STRING=\$(VERSION_STRING)\" \
321         -D\"JDK_COMPANY=\$(COMPANY_NAME)\" \
322         -D\"JDK_COMPONENT=\$(PRODUCT_NAME) \$(JDK_RC_PLATFORM_NAME) binary\" \
323         -D\"JDK_VER=\$(VERSION_NUMBER)\" \
324         -D\"JDK_COPYRIGHT=Copyright \xA9 $COPYRIGHT_YEAR\" \
325         -D\"JDK_NAME=\$(PRODUCT_NAME) \$(JDK_RC_PLATFORM_NAME) \$(VERSION_FEATURE)\" \
326         -D\"JDK_FVER=\$(subst .,\$(COMMA),\$(VERSION_NUMBER_FOUR_POSITIONS))\""
327 
328     JVM_RCFLAGS="$JVM_RCFLAGS \
329         -D\"HS_BUILD_ID=\$(VERSION_STRING)\" \
330         -D\"HS_COMPANY=\$(COMPANY_NAME)\" \
331         -D\"JDK_DOTVER=\$(VERSION_NUMBER_FOUR_POSITIONS)\" \
332         -D\"HS_COPYRIGHT=Copyright $COPYRIGHT_YEAR\" \
333         -D\"HS_NAME=\$(PRODUCT_NAME) \$(VERSION_SHORT)\" \
334         -D\"JDK_VER=\$(subst .,\$(COMMA),\$(VERSION_NUMBER_FOUR_POSITIONS))\" \
335         -D\"HS_FNAME=jvm.dll\" \
336         -D\"HS_INTERNAL_NAME=jvm\""
337   fi
338   AC_SUBST(RC_FLAGS)
339   AC_SUBST(JVM_RCFLAGS)
340 
341   if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
342     # silence copyright notice and other headers.
343     COMMON_CCXXFLAGS="$COMMON_CCXXFLAGS -nologo"
344   fi
345 ])
346 
347 AC_DEFUN([FLAGS_SETUP_COMPILER_FLAGS_FOR_LIBS],
348 [
349   ###############################################################################
350   #
351   # How to compile shared libraries.
352   #
353 
354   if test "x$TOOLCHAIN_TYPE" = xgcc; then
355     PICFLAG="-fPIC"
356     C_FLAG_REORDER=''
357     CXX_FLAG_REORDER=''
358 
359     if test "x$OPENJDK_TARGET_OS" = xmacosx; then
360       # Linking is different on MacOSX
361       if test "x$STATIC_BUILD" = xtrue; then
362         SHARED_LIBRARY_FLAGS ='-undefined dynamic_lookup'
363       else
364         SHARED_LIBRARY_FLAGS="-dynamiclib -compatibility_version 1.0.0 -current_version 1.0.0 $PICFLAG"
365         JVM_CFLAGS="$JVM_CFLAGS $PICFLAG"
366       fi
367       SET_EXECUTABLE_ORIGIN='-Wl,-rpath,@loader_path$(or [$]1,/.)'
368       SET_SHARED_LIBRARY_ORIGIN="$SET_EXECUTABLE_ORIGIN"
369       SET_SHARED_LIBRARY_NAME='-Wl,-install_name,@rpath/[$]1'
370       SET_SHARED_LIBRARY_MAPFILE='-Wl,-exported_symbols_list,[$]1'
371     else
372       # Default works for linux, might work on other platforms as well.
373       SHARED_LIBRARY_FLAGS='-shared'
374       SET_EXECUTABLE_ORIGIN='-Wl,-rpath,\$$ORIGIN[$]1'
375       SET_SHARED_LIBRARY_ORIGIN="-Wl,-z,origin $SET_EXECUTABLE_ORIGIN"
376       SET_SHARED_LIBRARY_NAME='-Wl,-soname=[$]1'
377       SET_SHARED_LIBRARY_MAPFILE='-Wl,-version-script=[$]1'
378     fi
379   elif test "x$TOOLCHAIN_TYPE" = xclang; then
380     C_FLAG_REORDER=''
381     CXX_FLAG_REORDER=''
382 
383     if test "x$OPENJDK_TARGET_OS" = xmacosx; then
384       # Linking is different on MacOSX
385       PICFLAG=''
386       SHARED_LIBRARY_FLAGS="-dynamiclib -compatibility_version 1.0.0 -current_version 1.0.0 $PICFLAG"
387       SET_EXECUTABLE_ORIGIN='-Wl,-rpath,@loader_path$(or [$]1,/.)'
388       SET_SHARED_LIBRARY_ORIGIN="$SET_EXECUTABLE_ORIGIN"
389       SET_SHARED_LIBRARY_NAME='-Wl,-install_name,@rpath/[$]1'
390       SET_SHARED_LIBRARY_MAPFILE='-Wl,-exported_symbols_list,[$]1'
391 
392       if test "x$STATIC_BUILD" = xfalse; then
393         JVM_CFLAGS="$JVM_CFLAGS -fPIC"
394       fi
395     else
396       # Default works for linux, might work on other platforms as well.
397       PICFLAG='-fPIC'
398       SHARED_LIBRARY_FLAGS='-shared'
399       SET_EXECUTABLE_ORIGIN='-Wl,-rpath,\$$ORIGIN[$]1'
400       SET_SHARED_LIBRARY_NAME='-Wl,-soname=[$]1'
401       SET_SHARED_LIBRARY_MAPFILE='-Wl,-version-script=[$]1'
402 
403       # arm specific settings
404       if test "x$OPENJDK_TARGET_CPU" = "xarm"; then
405         # '-Wl,-z,origin' isn't used on arm.
406         SET_SHARED_LIBRARY_ORIGIN='-Wl,-rpath,\$$$$ORIGIN[$]1'
407       else
408         SET_SHARED_LIBRARY_ORIGIN="-Wl,-z,origin $SET_EXECUTABLE_ORIGIN"
409       fi
410 
411     fi
412   elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
413     if test "x$OPENJDK_TARGET_CPU" = xsparcv9; then
414       PICFLAG="-xcode=pic32"
415     else
416       PICFLAG="-KPIC"
417     fi
418     C_FLAG_REORDER='-xF'
419     CXX_FLAG_REORDER='-xF'
420     SHARED_LIBRARY_FLAGS="-G"
421     SET_EXECUTABLE_ORIGIN='-R\$$ORIGIN[$]1'
422     SET_SHARED_LIBRARY_ORIGIN="$SET_EXECUTABLE_ORIGIN"
423     SET_SHARED_LIBRARY_NAME='-h [$]1'
424     SET_SHARED_LIBRARY_MAPFILE='-M[$]1'
425   elif test "x$TOOLCHAIN_TYPE" = xxlc; then
426     # '-qpic' defaults to 'qpic=small'. This means that the compiler generates only
427     # one instruction for accessing the TOC. If the TOC grows larger than 64K, the linker
428     # will have to patch this single instruction with a call to some out-of-order code which
429     # does the load from the TOC. This is of course slow. But in that case we also would have
430     # to use '-bbigtoc' for linking anyway so we could also change the PICFLAG to 'qpic=large'.
431     # With 'qpic=large' the compiler will by default generate a two-instruction sequence which
432     # can be patched directly by the linker and does not require a jump to out-of-order code.
433     # Another alternative instead of using 'qpic=large -bbigtoc' may be to use '-qminimaltoc'
434     # instead. This creates a distinct TOC for every compilation unit (and thus requires two
435     # loads for accessing a global variable). But there are rumors that this may be seen as a
436     # 'performance feature' because of improved code locality of the symbols used in a
437     # compilation unit.
438     PICFLAG="-qpic"
439     JVM_CFLAGS="$JVM_CFLAGS $PICFLAG"
440     C_FLAG_REORDER=''
441     CXX_FLAG_REORDER=''
442     SHARED_LIBRARY_FLAGS="-qmkshrobj -bM:SRE -bnoentry"
443     SET_EXECUTABLE_ORIGIN=""
444     SET_SHARED_LIBRARY_ORIGIN=''
445     SET_SHARED_LIBRARY_NAME=''
446     SET_SHARED_LIBRARY_MAPFILE=''
447   elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
448     PICFLAG=""
449     C_FLAG_REORDER=''
450     CXX_FLAG_REORDER=''
451     SHARED_LIBRARY_FLAGS="-dll"
452     SET_EXECUTABLE_ORIGIN=''
453     SET_SHARED_LIBRARY_ORIGIN=''
454     SET_SHARED_LIBRARY_NAME=''
455     SET_SHARED_LIBRARY_MAPFILE='-def:[$]1'
456   fi
457 
458   AC_SUBST(C_FLAG_REORDER)
459   AC_SUBST(CXX_FLAG_REORDER)
460   AC_SUBST(SET_EXECUTABLE_ORIGIN)
461   AC_SUBST(SET_SHARED_LIBRARY_ORIGIN)
462   AC_SUBST(SET_SHARED_LIBRARY_NAME)
463   AC_SUBST(SET_SHARED_LIBRARY_MAPFILE)
464   AC_SUBST(SHARED_LIBRARY_FLAGS)
465 
466   # The (cross) compiler is now configured, we can now test capabilities
467   # of the target platform.
468 ])
469 
470 # Documentation on common flags used for solstudio in HIGHEST.
471 #
472 # WARNING: Use of OPTIMIZATION_LEVEL=HIGHEST in your Makefile needs to be
473 #          done with care, there are some assumptions below that need to
474 #          be understood about the use of pointers, and IEEE behavior.
475 #
476 # -fns: Use non-standard floating point mode (not IEEE 754)
477 # -fsimple: Do some simplification of floating point arithmetic (not IEEE 754)
478 # -fsingle: Use single precision floating point with 'float'
479 # -xalias_level=basic: Assume memory references via basic pointer types do not alias
480 #   (Source with excessing pointer casting and data access with mixed
481 #    pointer types are not recommended)
482 # -xbuiltin=%all: Use intrinsic or inline versions for math/std functions
483 #   (If you expect perfect errno behavior, do not use this)
484 # -xdepend: Loop data dependency optimizations (need -xO3 or higher)
485 # -xrestrict: Pointer parameters to functions do not overlap
486 #   (Similar to -xalias_level=basic usage, but less obvious sometimes.
487 #    If you pass in multiple pointers to the same data, do not use this)
488 # -xlibmil: Inline some library routines
489 #   (If you expect perfect errno behavior, do not use this)
490 # -xlibmopt: Use optimized math routines (CURRENTLY DISABLED)
491 #   (If you expect perfect errno behavior, do not use this)
492 #  Can cause undefined external on Solaris 8 X86 on __sincos, removing for now
493 
494     # FIXME: this will never happen since sparc != sparcv9, ie 32 bit, which we don't build anymore.
495     # Bug?
496     #if test "x$OPENJDK_TARGET_CPU" = xsparc; then
497     #  CFLAGS_JDK="${CFLAGS_JDK} -xmemalign=4s"
498     #  CXXFLAGS_JDK="${CXXFLAGS_JDK} -xmemalign=4s"
499     #fi
500 
501 AC_DEFUN_ONCE([FLAGS_SETUP_COMPILER_FLAGS_FOR_OPTIMIZATION],
502 [
503 
504   ###############################################################################
505   #
506   # Setup the opt flags for different compilers
507   # and different operating systems.
508   #
509 
510   # FIXME: this was indirectly the old default, but just inherited.
511   # if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
512   #   C_FLAG_DEPS="-MMD -MF"
513   # fi
514 
515   # Generate make dependency files
516   if test "x$TOOLCHAIN_TYPE" = xgcc; then
517     C_FLAG_DEPS="-MMD -MF"
518   elif test "x$TOOLCHAIN_TYPE" = xclang; then
519     C_FLAG_DEPS="-MMD -MF"
520   elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
521     C_FLAG_DEPS="-xMMD -xMF"
522   elif test "x$TOOLCHAIN_TYPE" = xxlc; then
523     C_FLAG_DEPS="-qmakedep=gcc -MF"
524   fi
525   CXX_FLAG_DEPS="$C_FLAG_DEPS"
526   AC_SUBST(C_FLAG_DEPS)
527   AC_SUBST(CXX_FLAG_DEPS)
528 
529   # Debug symbols
530   if test "x$TOOLCHAIN_TYPE" = xgcc; then
531     if test "x$OPENJDK_TARGET_CPU_BITS" = "x64" && test "x$DEBUG_LEVEL" = "xfastdebug"; then
532       # reduce from default "-g2" option to save space
533       CFLAGS_DEBUG_SYMBOLS="-g1"
534       CXXFLAGS_DEBUG_SYMBOLS="-g1"
535     else
536       CFLAGS_DEBUG_SYMBOLS="-g"
537       CXXFLAGS_DEBUG_SYMBOLS="-g"
538     fi
539   elif test "x$TOOLCHAIN_TYPE" = xclang; then
540     CFLAGS_DEBUG_SYMBOLS="-g"
541     CXXFLAGS_DEBUG_SYMBOLS="-g"
542   elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
543     CFLAGS_DEBUG_SYMBOLS="-g -xs"
544     # -g0 enables debug symbols without disabling inlining.
545     CXXFLAGS_DEBUG_SYMBOLS="-g0 -xs"
546   elif test "x$TOOLCHAIN_TYPE" = xxlc; then
547     CFLAGS_DEBUG_SYMBOLS="-g"
548     CXXFLAGS_DEBUG_SYMBOLS="-g"
549   elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
550     CFLAGS_DEBUG_SYMBOLS="-Zi"
551     CXXFLAGS_DEBUG_SYMBOLS="-Zi"
552   fi
553   AC_SUBST(CFLAGS_DEBUG_SYMBOLS)
554   AC_SUBST(CXXFLAGS_DEBUG_SYMBOLS)
555 
556   # Debug symbols for JVM_CFLAGS
557   if test "x$TOOLCHAIN_TYPE" = xsolstudio; then
558     JVM_CFLAGS_SYMBOLS="$JVM_CFLAGS_SYMBOLS -xs"
559     if test "x$DEBUG_LEVEL" = xslowdebug; then
560       JVM_CFLAGS_SYMBOLS="$JVM_CFLAGS_SYMBOLS -g"
561     else
562       # -g0 does not disable inlining, which -g does.
563       JVM_CFLAGS_SYMBOLS="$JVM_CFLAGS_SYMBOLS -g0"
564     fi
565   elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
566     JVM_CFLAGS_SYMBOLS="$JVM_CFLAGS_SYMBOLS -Z7 -d2Zi+"
567   else
568     JVM_CFLAGS_SYMBOLS="$JVM_CFLAGS_SYMBOLS -g"
569   fi
570   AC_SUBST(JVM_CFLAGS_SYMBOLS)
571 
572   # bounds, memory and behavior checking options
573   if test "x$TOOLCHAIN_TYPE" = xgcc; then
574     case $DEBUG_LEVEL in
575     release )
576       # no adjustment
577       ;;
578     fastdebug )
579       # no adjustment
580       ;;
581     slowdebug )
582       # FIXME: By adding this to C(XX)FLAGS_DEBUG_OPTIONS/JVM_CFLAGS_SYMBOLS it
583       # get's added conditionally on whether we produce debug symbols or not.
584       # This is most likely not really correct.
585 
586       # Add runtime stack smashing and undefined behavior checks.
587       # Not all versions of gcc support -fstack-protector
588       STACK_PROTECTOR_CFLAG="-fstack-protector-all"
589       FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [$STACK_PROTECTOR_CFLAG -Werror], IF_FALSE: [STACK_PROTECTOR_CFLAG=""])
590 
591       CFLAGS_DEBUG_OPTIONS="$STACK_PROTECTOR_CFLAG --param ssp-buffer-size=1"
592       CXXFLAGS_DEBUG_OPTIONS="$STACK_PROTECTOR_CFLAG --param ssp-buffer-size=1"
593       if test "x$STACK_PROTECTOR_CFLAG" != x; then
594         JVM_CFLAGS_SYMBOLS="$JVM_CFLAGS_SYMBOLS $STACK_PROTECTOR_CFLAG --param ssp-buffer-size=1"
595       fi
596       ;;
597     esac
598   fi
599 
600   if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
601     if test "x$DEBUG_LEVEL" != xrelease; then
602       if test "x$OPENJDK_TARGET_CPU" = xx86_64; then
603         JVM_CFLAGS="$JVM_CFLAGS -homeparams"
604       fi
605     fi
606   fi
607 
608   # Optimization levels
609   if test "x$TOOLCHAIN_TYPE" = xsolstudio; then
610     CC_HIGHEST="$CC_HIGHEST -fns -fsimple -fsingle -xbuiltin=%all -xdepend -xrestrict -xlibmil"
611 
612     if test "x$OPENJDK_TARGET_CPU_ARCH" = "xx86"; then
613       # FIXME: seems we always set -xregs=no%frameptr; put it elsewhere more global?
614       C_O_FLAG_HIGHEST_JVM="-xO4"
615       C_O_FLAG_HIGHEST="-xO4 -Wu,-O4~yz $CC_HIGHEST -xalias_level=basic -xregs=no%frameptr"
616       C_O_FLAG_HI="-xO4 -Wu,-O4~yz -xregs=no%frameptr"
617       C_O_FLAG_NORM="-xO2 -Wu,-O2~yz -xregs=no%frameptr"
618       C_O_FLAG_DEBUG="-xregs=no%frameptr"
619       C_O_FLAG_DEBUG_JVM=""
620       C_O_FLAG_NONE="-xregs=no%frameptr"
621       CXX_O_FLAG_HIGHEST_JVM="-xO4"
622       CXX_O_FLAG_HIGHEST="-xO4 -Qoption ube -O4~yz $CC_HIGHEST -xregs=no%frameptr"
623       CXX_O_FLAG_HI="-xO4 -Qoption ube -O4~yz -xregs=no%frameptr"
624       CXX_O_FLAG_NORM="-xO2 -Qoption ube -O2~yz -xregs=no%frameptr"
625       CXX_O_FLAG_DEBUG="-xregs=no%frameptr"
626       CXX_O_FLAG_DEBUG_JVM=""
627       CXX_O_FLAG_NONE="-xregs=no%frameptr"
628       if test "x$OPENJDK_TARGET_CPU_BITS" = "x32"; then
629         C_O_FLAG_HIGHEST="$C_O_FLAG_HIGHEST -xchip=pentium"
630         CXX_O_FLAG_HIGHEST="$CXX_O_FLAG_HIGHEST -xchip=pentium"
631       fi
632     elif test "x$OPENJDK_TARGET_CPU_ARCH" = "xsparc"; then
633       C_O_FLAG_HIGHEST_JVM="-xO4"
634       C_O_FLAG_HIGHEST="-xO4 -Wc,-Qrm-s -Wc,-Qiselect-T0 $CC_HIGHEST -xalias_level=basic -xprefetch=auto,explicit -xchip=ul
635       C_O_FLAG_HI="-xO4 -Wc,-Qrm-s -Wc,-Qiselect-T0"
636       C_O_FLAG_NORM="-xO2 -Wc,-Qrm-s -Wc,-Qiselect-T0"
637       C_O_FLAG_DEBUG=""
638       C_O_FLAG_DEBUG_JVM=""
639       C_O_FLAG_NONE=""
640       CXX_O_FLAG_HIGHEST_JVM="-xO4"
641       CXX_O_FLAG_HIGHEST="-xO4 -Qoption cg -Qrm-s -Qoption cg -Qiselect-T0 $CC_HIGHEST -xprefetch=auto,explicit -xchip=ultr
642       CXX_O_FLAG_HI="-xO4 -Qoption cg -Qrm-s -Qoption cg -Qiselect-T0"
643       CXX_O_FLAG_NORM="-xO2 -Qoption cg -Qrm-s -Qoption cg -Qiselect-T0"
644       CXX_O_FLAG_DEBUG=""
645       CXX_O_FLAG_DEBUG_JVM=""
646       CXX_O_FLAG_NONE=""
647     fi
648   else
649     # The remaining toolchains share opt flags between CC and CXX;
650     # setup for C and duplicate afterwards.
651     if test "x$TOOLCHAIN_TYPE" = xgcc; then
652       if test "x$OPENJDK_TARGET_OS" = xmacosx; then
653         # On MacOSX we optimize for size, something
654         # we should do for all platforms?
655         C_O_FLAG_HIGHEST_JVM="-Os"
656         C_O_FLAG_HIGHEST="-Os"
657         C_O_FLAG_HI="-Os"
658         C_O_FLAG_NORM="-Os"
659         C_O_FLAG_SIZE="-Os"
660       else
661         C_O_FLAG_HIGHEST_JVM="-O3"
662         C_O_FLAG_HIGHEST="-O3"
663         C_O_FLAG_HI="-O3"
664         C_O_FLAG_NORM="-O2"
665         C_O_FLAG_SIZE="-Os"
666       fi
667       C_O_FLAG_DEBUG="-O0"
668       if test "x$OPENJDK_TARGET_OS" = xmacosx; then
669         C_O_FLAG_DEBUG_JVM=""
670       elif test "x$OPENJDK_TARGET_OS" = xlinux; then
671         C_O_FLAG_DEBUG_JVM="-O0"
672       fi
673       C_O_FLAG_NONE="-O0"
674     elif test "x$TOOLCHAIN_TYPE" = xclang; then
675       if test "x$OPENJDK_TARGET_OS" = xmacosx; then
676         # On MacOSX we optimize for size, something
677         # we should do for all platforms?
678         C_O_FLAG_HIGHEST_JVM="-Os"
679         C_O_FLAG_HIGHEST="-Os"
680         C_O_FLAG_HI="-Os"
681         C_O_FLAG_NORM="-Os"
682         C_O_FLAG_SIZE="-Os"
683       else
684         C_O_FLAG_HIGHEST_JVM="-O3"
685         C_O_FLAG_HIGHEST="-O3"
686         C_O_FLAG_HI="-O3"
687         C_O_FLAG_NORM="-O2"
688         C_O_FLAG_SIZE="-Os"
689       fi
690       C_O_FLAG_DEBUG="-O0"
691       if test "x$OPENJDK_TARGET_OS" = xmacosx; then
692         C_O_FLAG_DEBUG_JVM=""
693       elif test "x$OPENJDK_TARGET_OS" = xlinux; then
694         C_O_FLAG_DEBUG_JVM="-O0"
695       fi
696       C_O_FLAG_NONE="-O0"
697     elif test "x$TOOLCHAIN_TYPE" = xxlc; then
698       C_O_FLAG_HIGHEST_JVM="-O3 -qhot=level=1 -qinline -qinlglue"
699       C_O_FLAG_HIGHEST="-O3 -qhot=level=1 -qinline -qinlglue"
700       C_O_FLAG_HI="-O3 -qinline -qinlglue"
701       C_O_FLAG_NORM="-O2"
702       C_O_FLAG_DEBUG="-qnoopt"
703       # FIXME: Value below not verified.
704       C_O_FLAG_DEBUG_JVM=""
705       C_O_FLAG_NONE="-qnoopt"
706     elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
707       C_O_FLAG_HIGHEST_JVM="-O2 -Oy-"
708       C_O_FLAG_HIGHEST="-O2"
709       C_O_FLAG_HI="-O1"
710       C_O_FLAG_NORM="-O1"
711       C_O_FLAG_DEBUG="-Od"
712       C_O_FLAG_DEBUG_JVM=""
713       C_O_FLAG_NONE="-Od"
714       C_O_FLAG_SIZE="-Os"
715     fi
716     CXX_O_FLAG_HIGHEST_JVM="$C_O_FLAG_HIGHEST_JVM"
717     CXX_O_FLAG_HIGHEST="$C_O_FLAG_HIGHEST"
718     CXX_O_FLAG_HI="$C_O_FLAG_HI"
719     CXX_O_FLAG_NORM="$C_O_FLAG_NORM"
720     CXX_O_FLAG_DEBUG="$C_O_FLAG_DEBUG"
721     CXX_O_FLAG_DEBUG_JVM="$C_O_FLAG_DEBUG_JVM"
722     CXX_O_FLAG_NONE="$C_O_FLAG_NONE"
723     CXX_O_FLAG_SIZE="$C_O_FLAG_SIZE"
724   fi
725 
726   # Adjust optimization flags according to debug level.
727   case $DEBUG_LEVEL in
728     release )
729       # no adjustment
730       ;;
731     fastdebug )
732       # Not quite so much optimization
733       C_O_FLAG_HI="$C_O_FLAG_NORM"
734       CXX_O_FLAG_HI="$CXX_O_FLAG_NORM"
735       ;;
736     slowdebug )
737       # Disable optimization
738       C_O_FLAG_HIGHEST_JVM="$C_O_FLAG_DEBUG_JVM"
739       C_O_FLAG_HIGHEST="$C_O_FLAG_DEBUG"
740       C_O_FLAG_HI="$C_O_FLAG_DEBUG"
741       C_O_FLAG_NORM="$C_O_FLAG_DEBUG"
742       C_O_FLAG_SIZE="$C_O_FLAG_DEBUG"
743       CXX_O_FLAG_HIGHEST_JVM="$CXX_O_FLAG_DEBUG_JVM"
744       CXX_O_FLAG_HIGHEST="$CXX_O_FLAG_DEBUG"
745       CXX_O_FLAG_HI="$CXX_O_FLAG_DEBUG"
746       CXX_O_FLAG_NORM="$CXX_O_FLAG_DEBUG"
747       CXX_O_FLAG_SIZE="$CXX_O_FLAG_DEBUG"
748       ;;
749   esac
750 
751   AC_SUBST(C_O_FLAG_HIGHEST_JVM)
752   AC_SUBST(C_O_FLAG_HIGHEST)
753   AC_SUBST(C_O_FLAG_HI)
754   AC_SUBST(C_O_FLAG_NORM)
755   AC_SUBST(C_O_FLAG_DEBUG)
756   AC_SUBST(C_O_FLAG_NONE)
757   AC_SUBST(C_O_FLAG_SIZE)
758   AC_SUBST(CXX_O_FLAG_HIGHEST_JVM)
759   AC_SUBST(CXX_O_FLAG_HIGHEST)
760   AC_SUBST(CXX_O_FLAG_HI)
761   AC_SUBST(CXX_O_FLAG_NORM)
762   AC_SUBST(CXX_O_FLAG_DEBUG)
763   AC_SUBST(CXX_O_FLAG_NONE)
764   AC_SUBST(CXX_O_FLAG_SIZE)
765 ])
766 
767 
768 AC_DEFUN([FLAGS_SETUP_COMPILER_FLAGS_FOR_JDK],
769 [
770 
771   FLAGS_SETUP_ABI_PROFILE
772 
773   # Optional POSIX functionality needed by the JVM
774   #
775   # Check if clock_gettime is available and in which library. This indicates
776   # availability of CLOCK_MONOTONIC for hotspot. But we don't need to link, so
777   # don't let it update LIBS.
778   save_LIBS="$LIBS"
779   AC_SEARCH_LIBS(clock_gettime, rt, [HAS_CLOCK_GETTIME=true], [])
780   if test "x$LIBS" = "x-lrt "; then
781     CLOCK_GETTIME_IN_LIBRT=true
782   fi
783   LIBS="$save_LIBS"
784 
785   FLAGS_SETUP_COMPILER_FLAGS_FOR_JDK_HELPER([TARGET])
786   FLAGS_SETUP_COMPILER_FLAGS_FOR_JDK_HELPER([BUILD], [OPENJDK_BUILD_])
787 
788   # Tests are only ever compiled for TARGET
789   # Flags for compiling test libraries
790   CFLAGS_TESTLIB="$COMMON_CCXXFLAGS_JDK $CFLAGS_JDK $PICFLAG $CFLAGS_JDKLIB_EXTRA"
791   CXXFLAGS_TESTLIB="$COMMON_CCXXFLAGS_JDK $CXXFLAGS_JDK $PICFLAG $CXXFLAGS_JDKLIB_EXTRA"
792 
793   # Flags for compiling test executables
794   CFLAGS_TESTEXE="$COMMON_CCXXFLAGS_JDK $CFLAGS_JDK"
795   CXXFLAGS_TESTEXE="$COMMON_CCXXFLAGS_JDK $CXXFLAGS_JDK"
796 
797   AC_SUBST(CFLAGS_TESTLIB)
798   AC_SUBST(CFLAGS_TESTEXE)
799   AC_SUBST(CXXFLAGS_TESTLIB)
800   AC_SUBST(CXXFLAGS_TESTEXE)
801 
802   LDFLAGS_TESTLIB="$LDFLAGS_JDKLIB"
803   LDFLAGS_TESTEXE="$LDFLAGS_JDKEXE $JAVA_BASE_LDFLAGS"
804 
805   AC_SUBST(LDFLAGS_TESTLIB)
806   AC_SUBST(LDFLAGS_TESTEXE)
807 
808 ])
809 
810 ################################################################################
811 # $1 - Either BUILD or TARGET to pick the correct OS/CPU variables to check
812 #      conditionals against.
813 # $2 - Optional prefix for each variable defined.
814 AC_DEFUN([FLAGS_SETUP_COMPILER_FLAGS_FOR_JDK_HELPER],
815 [
816   # Special extras...
817   if test "x$TOOLCHAIN_TYPE" = xsolstudio; then
818     if test "x$OPENJDK_$1_CPU_ARCH" = "xsparc"; then
819       $2CFLAGS_JDKLIB_EXTRA="${$2CFLAGS_JDKLIB_EXTRA} -xregs=no%appl"
820       $2CXXFLAGS_JDKLIB_EXTRA="${$2CXXFLAGS_JDKLIB_EXTRA} -xregs=no%appl"
821     fi
822     $2CFLAGS_JDKLIB_EXTRA="${$2CFLAGS_JDKLIB_EXTRA} -errtags=yes -errfmt"
823     $2CXXFLAGS_JDKLIB_EXTRA="${$2CXXFLAGS_JDKLIB_EXTRA} -errtags=yes -errfmt"
824   elif test "x$TOOLCHAIN_TYPE" = xxlc; then
825     $2CFLAGS_JDK="${$2CFLAGS_JDK} -qchars=signed -qfullpath -qsaveopt"
826     $2CXXFLAGS_JDK="${$2CXXFLAGS_JDK} -qchars=signed -qfullpath -qsaveopt"
827   elif test "x$TOOLCHAIN_TYPE" = xgcc; then
828     $2CXXSTD_CXXFLAG="-std=gnu++98"
829     FLAGS_CXX_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [[$]$2CXXSTD_CXXFLAG -Werror],
830                                                  IF_FALSE: [$2CXXSTD_CXXFLAG=""])
831     $2CXXFLAGS_JDK="${$2CXXFLAGS_JDK} ${$2CXXSTD_CXXFLAG}"
832     $2JVM_CFLAGS="${$2JVM_CFLAGS} ${$2CXXSTD_CXXFLAG}"
833     AC_SUBST($2CXXSTD_CXXFLAG)
834   fi
835   if test "x$OPENJDK_TARGET_OS" = xsolaris; then
836     $2CFLAGS_JDK="${$2CFLAGS_JDK} -D__solaris__"
837     $2CXXFLAGS_JDK="${$2CXXFLAGS_JDK} -D__solaris__"
838   fi
839 
840   $2CFLAGS_JDK="${$2CFLAGS_JDK} ${$2EXTRA_CFLAGS}"
841   $2CXXFLAGS_JDK="${$2CXXFLAGS_JDK} ${$2EXTRA_CXXFLAGS}"
842   $2LDFLAGS_JDK="${$2LDFLAGS_JDK} ${$2EXTRA_LDFLAGS}"
843 
844   ###############################################################################
845   #
846   # Now setup the CFLAGS and LDFLAGS for the JDK build.
847   # Later we will also have CFLAGS and LDFLAGS for the hotspot subrepo build.
848   #
849 
850   # Setup compiler/platform specific flags into
851   #    $2CFLAGS_JDK    - C Compiler flags
852   #    $2CXXFLAGS_JDK  - C++ Compiler flags
853   #    $2COMMON_CCXXFLAGS_JDK - common to C and C++
854   if test "x$TOOLCHAIN_TYPE" = xgcc; then
855     $2JVM_CFLAGS="[$]$2JVM_CFLAGS -D_GNU_SOURCE"
856     $2JVM_CFLAGS="[$]$2JVM_CFLAGS -D_REENTRANT"
857     $2JVM_CFLAGS="[$]$2JVM_CFLAGS -fcheck-new"
858     if test "x$OPENJDK_$1_CPU" = xx86; then
859       # Force compatibility with i586 on 32 bit intel platforms.
860       $2COMMON_CCXXFLAGS="${$2COMMON_CCXXFLAGS} -march=i586"
861       $2JVM_CFLAGS="[$]$2JVM_CFLAGS -march=i586"
862     fi
863     $2COMMON_CCXXFLAGS_JDK="[$]$2COMMON_CCXXFLAGS [$]$2COMMON_CCXXFLAGS_JDK -Wall -Wextra -Wno-unused -Wno-unused-parameter
864         -pipe -D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE"
865     case $OPENJDK_$1_CPU_ARCH in
866       arm )
867         # on arm we don't prevent gcc to omit frame pointer but do prevent strict aliasing
868         $2CFLAGS_JDK="${$2CFLAGS_JDK} -fno-strict-aliasing"
869         $2COMMON_CCXXFLAGS_JDK="${$2COMMON_CCXXFLAGS_JDK} -fsigned-char"
870         ;;
871       ppc )
872         # on ppc we don't prevent gcc to omit frame pointer but do prevent strict aliasing
873         $2CFLAGS_JDK="${$2CFLAGS_JDK} -fno-strict-aliasing"
874         ;;
875       s390 )
876         $2COMMON_CCXXFLAGS_JDK="[$]$2COMMON_CCXXFLAGS_JDK -fno-omit-frame-pointer -mbackchain -march=z10"
877         $2CFLAGS_JDK="${$2CFLAGS_JDK} -fno-strict-aliasing"
878         ;;
879       * )
880         $2COMMON_CCXXFLAGS_JDK="[$]$2COMMON_CCXXFLAGS_JDK -fno-omit-frame-pointer"
881         $2CFLAGS_JDK="${$2CFLAGS_JDK} -fno-strict-aliasing"
882         ;;
883     esac
884     TOOLCHAIN_CHECK_COMPILER_VERSION(VERSION: 6, PREFIX: $2, IF_AT_LEAST: FLAGS_SETUP_GCC6_COMPILER_FLAGS($2))
885   elif test "x$TOOLCHAIN_TYPE" = xclang; then
886     $2JVM_CFLAGS="[$]$2JVM_CFLAGS -D_GNU_SOURCE"
887 
888     # Restrict the debug information created by Clang to avoid
889     # too big object files and speed the build up a little bit
890     # (see http://llvm.org/bugs/show_bug.cgi?id=7554)
891     $2JVM_CFLAGS="[$]$2JVM_CFLAGS -flimit-debug-info"
892     if test "x$OPENJDK_$1_OS" = xlinux; then
893       if test "x$OPENJDK_$1_CPU" = xx86; then
894         # Force compatibility with i586 on 32 bit intel platforms.
895         $2COMMON_CCXXFLAGS="${$2COMMON_CCXXFLAGS} -march=i586"
896         $2JVM_CFLAGS="[$]$2JVM_CFLAGS -march=i586"
897       fi
898       $2JVM_CFLAGS="[$]$2JVM_CFLAGS -Wno-sometimes-uninitialized"
899       $2COMMON_CCXXFLAGS_JDK="[$]$2COMMON_CCXXFLAGS [$]$2COMMON_CCXXFLAGS_JDK -Wall -Wextra -Wno-unused -Wno-unused-paramet
900           -pipe -D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE"
901       case $OPENJDK_$1_CPU_ARCH in
902         ppc )
903           # on ppc we don't prevent gcc to omit frame pointer but do prevent strict aliasing
904           $2CFLAGS_JDK="${$2CFLAGS_JDK} -fno-strict-aliasing"
905           ;;
906         * )
907           $2COMMON_CCXXFLAGS_JDK="[$]$2COMMON_CCXXFLAGS_JDK -fno-omit-frame-pointer"
908           $2CFLAGS_JDK="${$2CFLAGS_JDK} -fno-strict-aliasing"
909           ;;
910       esac
911     fi
912   elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
913     $2JVM_CFLAGS="[$]$2JVM_CFLAGS -DSPARC_WORKS"
914     $2COMMON_CCXXFLAGS_JDK="[$]$2COMMON_CCXXFLAGS [$]$2COMMON_CCXXFLAGS_JDK -DTRACING -DMACRO_MEMSYS_OPS -DBREAKPTS"
915     if test "x$OPENJDK_$1_CPU_ARCH" = xx86; then
916       $2COMMON_CCXXFLAGS_JDK="[$]$2COMMON_CCXXFLAGS_JDK -DcpuIntel -Di586 -D$OPENJDK_$1_CPU_LEGACY_LIB"
917     fi
918 
919     $2CFLAGS_JDK="[$]$2CFLAGS_JDK -xc99=%none -xCC -errshort=tags -Xa -v -mt -W0,-noglobal"
920     $2CXXFLAGS_JDK="[$]$2CXXFLAGS_JDK -errtags=yes +w -mt -features=no%except -DCC_NOEX -norunpath -xnolib"
921   elif test "x$TOOLCHAIN_TYPE" = xxlc; then
922     $2JVM_CFLAGS="[$]$2JVM_CFLAGS -D_REENTRANT"
923     $2CFLAGS_JDK="[$]$2CFLAGS_JDK -D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE -DSTDC"
924     $2CXXFLAGS_JDK="[$]$2CXXFLAGS_JDK -D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE -DSTDC"
925   elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
926     $2COMMON_CCXXFLAGS_JDK="[$]$2COMMON_CCXXFLAGS [$]$2COMMON_CCXXFLAGS_JDK \
927         -MD -Zc:wchar_t- -W3 -wd4800 \
928         -DWIN32_LEAN_AND_MEAN \
929         -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE \
930         -DWIN32 -DIAL"
931     $2JVM_CFLAGS="[$]$2JVM_CFLAGS -DWIN32_LEAN_AND_MEAN"
932     if test "x$OPENJDK_$1_CPU" = xx86_64; then
933       $2COMMON_CCXXFLAGS_JDK="[$]$2COMMON_CCXXFLAGS_JDK -D_AMD64_ -Damd64"
934     else
935       $2COMMON_CCXXFLAGS_JDK="[$]$2COMMON_CCXXFLAGS_JDK -D_X86_ -Dx86"
936     fi
937     # If building with Visual Studio 2010, we can still use _STATIC_CPPLIB to
938     # avoid bundling msvcpNNN.dll. Doesn't work with newer versions of visual
939     # studio.
940     if test "x$TOOLCHAIN_VERSION" = "x2010"; then
941       STATIC_CPPLIB_FLAGS="-D_STATIC_CPPLIB -D_DISABLE_DEPRECATE_STATIC_CPPLIB"
942       $2COMMON_CCXXFLAGS_JDK="[$]$2COMMON_CCXXFLAGS_JDK $STATIC_CPPLIB_FLAGS"
943       $2JVM_CFLAGS="[$]$2JVM_CFLAGS $STATIC_CPPLIB_FLAGS"
944     fi
945   fi
946 
947   ###############################################################################
948 
949   # Adjust flags according to debug level.
950   case $DEBUG_LEVEL in
951     fastdebug | slowdebug )
952       $2CFLAGS_JDK="[$]$2CFLAGS_JDK $CFLAGS_DEBUG_SYMBOLS $CFLAGS_DEBUG_OPTIONS"
953       $2CXXFLAGS_JDK="[$]$2CXXFLAGS_JDK $CXXFLAGS_DEBUG_SYMBOLS $CXXFLAGS_DEBUG_OPTIONS"
954       ;;
955     release )
956       ;;
957     * )
958       AC_MSG_ERROR([Unrecognized \$DEBUG_LEVEL: $DEBUG_LEVEL])
959       ;;
960   esac
961 
962   # Set some common defines. These works for all compilers, but assume
963   # -D is universally accepted.
964 
965   # Setup endianness
966   if test "x$OPENJDK_$1_CPU_ENDIAN" = xlittle; then
967     # The macro _LITTLE_ENDIAN needs to be defined the same to avoid the
968     #   Sun C compiler warning message: warning: macro redefined: _LITTLE_ENDIAN
969     #   (The Solaris X86 system defines this in file /usr/include/sys/isa_defs.h).
970     #   Note: -Dmacro         is the same as    #define macro 1
971     #         -Dmacro=        is the same as    #define macro
972     if test "x$OPENJDK_$1_OS" = xsolaris; then
973       $2COMMON_CCXXFLAGS_JDK="[$]$2COMMON_CCXXFLAGS_JDK -D_LITTLE_ENDIAN="
974     else
975       $2COMMON_CCXXFLAGS_JDK="[$]$2COMMON_CCXXFLAGS_JDK -D_LITTLE_ENDIAN"
976     fi
977   else
978     # Same goes for _BIG_ENDIAN. Do we really need to set *ENDIAN on Solaris if they
979     # are defined in the system?
980     if test "x$OPENJDK_$1_OS" = xsolaris; then
981       $2COMMON_CCXXFLAGS_JDK="[$]$2COMMON_CCXXFLAGS_JDK -D_BIG_ENDIAN="
982     else
983       $2COMMON_CCXXFLAGS_JDK="[$]$2COMMON_CCXXFLAGS_JDK -D_BIG_ENDIAN"
984     fi
985   fi
986 
987   # Always enable optional macros for VM.
988   $2JVM_CFLAGS="[$]$2JVM_CFLAGS -D__STDC_FORMAT_MACROS"
989   $2JVM_CFLAGS="[$]$2JVM_CFLAGS -D__STDC_LIMIT_MACROS"
990   $2JVM_CFLAGS="[$]$2JVM_CFLAGS -D__STDC_CONSTANT_MACROS"
991 
992   # Setup target OS define. Use OS target name but in upper case.
993   OPENJDK_$1_OS_UPPERCASE=`$ECHO $OPENJDK_$1_OS | $TR 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
994   $2COMMON_CCXXFLAGS_JDK="[$]$2COMMON_CCXXFLAGS_JDK -D$OPENJDK_$1_OS_UPPERCASE"
995 
996   # Setup target CPU
997   $2COMMON_CCXXFLAGS_JDK="[$]$2COMMON_CCXXFLAGS_JDK \
998       $OPENJDK_$1_ADD_LP64 \
999       -DARCH='\"$OPENJDK_$1_CPU_LEGACY\"' -D$OPENJDK_$1_CPU_LEGACY"
1000 
1001   # Setup debug/release defines
1002   if test "x$DEBUG_LEVEL" = xrelease; then
1003     $2COMMON_CCXXFLAGS_JDK="[$]$2COMMON_CCXXFLAGS_JDK -DNDEBUG"
1004     if test "x$OPENJDK_$1_OS" = xsolaris; then
1005       $2COMMON_CCXXFLAGS_JDK="[$]$2COMMON_CCXXFLAGS_JDK -DTRIMMED"
1006     fi
1007   else
1008     $2COMMON_CCXXFLAGS_JDK="[$]$2COMMON_CCXXFLAGS_JDK -DDEBUG"
1009   fi
1010 
1011   # Optional POSIX functionality needed by the VM
1012 
1013   if test "x$HAS_CLOCK_GETTIME" = "xtrue"; then
1014     $2JVM_CFLAGS="[$]$2JVM_CFLAGS -DSUPPORTS_CLOCK_MONOTONIC"
1015     if test "x$CLOCK_GETTIME_IN_LIBRT" = "xtrue"; then
1016       $2JVM_CFLAGS="[$]$2JVM_CFLAGS -DNEEDS_LIBRT"
1017     fi
1018   fi
1019 
1020 
1021   # Set some additional per-OS defines.
1022   if test "x$OPENJDK_$1_OS" = xlinux; then
1023     $2JVM_CFLAGS="[$]$2JVM_CFLAGS -DLINUX"
1024     $2JVM_CFLAGS="[$]$2JVM_CFLAGS -pipe $PICFLAG -fno-rtti -fno-exceptions \
1025         -fvisibility=hidden -fno-strict-aliasing -fno-omit-frame-pointer"
1026   elif test "x$OPENJDK_$1_OS" = xsolaris; then
1027     $2JVM_CFLAGS="[$]$2JVM_CFLAGS -DSOLARIS"
1028     $2JVM_CFLAGS="[$]$2JVM_CFLAGS -template=no%extdef -features=no%split_init \
1029         -D_Crun_inline_placement -library=stlport4 $PICFLAG -mt -features=no%except"
1030   elif test "x$OPENJDK_$1_OS" = xmacosx; then
1031     $2COMMON_CCXXFLAGS_JDK="[$]$2COMMON_CCXXFLAGS_JDK -D_ALLBSD_SOURCE -D_DARWIN_UNLIMITED_SELECT"
1032     $2JVM_CFLAGS="[$]$2JVM_CFLAGS -D_ALLBSD_SOURCE"
1033     $2JVM_CFLAGS="[$]$2JVM_CFLAGS -D_DARWIN_C_SOURCE -D_XOPEN_SOURCE"
1034     $2JVM_CFLAGS="[$]$2JVM_CFLAGS -fno-rtti -fno-exceptions -fvisibility=hidden \
1035         -mno-omit-leaf-frame-pointer -mstack-alignment=16 -pipe -fno-strict-aliasing \
1036         -fno-omit-frame-pointer"
1037   elif test "x$OPENJDK_$1_OS" = xaix; then
1038     $2JVM_CFLAGS="[$]$2JVM_CFLAGS -DAIX"
1039     $2JVM_CFLAGS="[$]$2JVM_CFLAGS -qtune=balanced \
1040         -qalias=noansi -qstrict -qtls=default -qlanglvl=c99vla \
1041         -qlanglvl=noredefmac -qnortti -qnoeh -qignerrno"
1042     # We need '-qminimaltoc' or '-qpic=large -bbigtoc' if the TOC overflows.
1043     # Hotspot now overflows its 64K TOC (currently only for debug),
1044     # so for debug we build with '-qpic=large -bbigtoc'.
1045     if test "x$DEBUG_LEVEL" = xslowdebug || test "x$DEBUG_LEVEL" = xfastdebug; then
1046       $2JVM_CFLAGS="[$]$2JVM_CFLAGS -qpic=large"
1047     fi
1048   elif test "x$OPENJDK_$1_OS" = xbsd; then
1049     $2COMMON_CCXXFLAGS_JDK="[$]$2COMMON_CCXXFLAGS_JDK -D_ALLBSD_SOURCE"
1050   elif test "x$OPENJDK_$1_OS" = xwindows; then
1051     $2JVM_CFLAGS="[$]$2JVM_CFLAGS -D_WINDOWS -DWIN32 -D_JNI_IMPLEMENTATION_"
1052     $2JVM_CFLAGS="[$]$2JVM_CFLAGS -nologo -W3 -MD -MP"
1053   fi
1054 
1055   # Set some additional per-CPU defines.
1056   if test "x$OPENJDK_$1_OS-$OPENJDK_$1_CPU" = xwindows-x86; then
1057     $2JVM_CFLAGS="[$]$2JVM_CFLAGS -arch:IA32"
1058   elif test "x$OPENJDK_$1_OS-$OPENJDK_$1_CPU" = xsolaris-sparcv9; then
1059     $2JVM_CFLAGS="[$]$2JVM_CFLAGS -xarch=sparc"
1060   elif test "x$OPENJDK_$1_CPU" = xppc64; then
1061     if test "x$OPENJDK_$1_OS" = xlinux; then
1062       $2JVM_CFLAGS="[$]$2JVM_CFLAGS -minsert-sched-nops=regroup_exact -mno-multiple -mno-string"
1063       # fixes `relocation truncated to fit' error for gcc 4.1.
1064       $2JVM_CFLAGS="[$]$2JVM_CFLAGS -mminimal-toc"
1065       # Use ppc64 instructions, but schedule for power5
1066       $2JVM_CFLAGS="[$]$2JVM_CFLAGS -mcpu=powerpc64 -mtune=power5"
1067     elif test "x$OPENJDK_$1_OS" = xaix; then
1068       $2JVM_CFLAGS="[$]$2JVM_CFLAGS -qarch=ppc64"
1069     fi
1070   elif test "x$OPENJDK_$1_CPU" = xppc64le; then
1071     if test "x$OPENJDK_$1_OS" = xlinux; then
1072       $2JVM_CFLAGS="[$]$2JVM_CFLAGS -minsert-sched-nops=regroup_exact -mno-multiple -mno-string"
1073       # Little endian machine uses ELFv2 ABI.
1074       $2JVM_CFLAGS="[$]$2JVM_CFLAGS -DABI_ELFv2"
1075       # Use Power8, this is the first CPU to support PPC64 LE with ELFv2 ABI.
1076       $2JVM_CFLAGS="[$]$2JVM_CFLAGS -mcpu=power8 -mtune=power8"
1077     fi
1078   elif test "x$OPENJDK_$1_CPU" = xs390x; then
1079     if test "x$OPENJDK_$1_OS" = xlinux; then
1080       $2JVM_CFLAGS="[$]$2JVM_CFLAGS -mbackchain -march=z10"
1081     fi
1082   fi
1083 
1084   if test "x$OPENJDK_$1_CPU_ENDIAN" = xlittle; then
1085     $2JVM_CFLAGS="[$]$2JVM_CFLAGS -DVM_LITTLE_ENDIAN"
1086   fi
1087 
1088   if test "x$OPENJDK_$1_CPU_BITS" = x64; then
1089     if test "x$OPENJDK_$1_OS" != xsolaris && test "x$OPENJDK_$1_OS" != xaix; then
1090       # Solaris does not have _LP64=1 in the old build.
1091       # xlc on AIX defines _LP64=1 by default and issues a warning if we redefine it.
1092       $2JVM_CFLAGS="[$]$2JVM_CFLAGS -D_LP64=1"
1093     fi
1094   fi
1095 
1096   # Set $2JVM_CFLAGS warning handling
1097   if test "x$OPENJDK_$1_OS" = xlinux; then
1098     $2JVM_CFLAGS="[$]$2JVM_CFLAGS -Wpointer-arith -Wsign-compare -Wunused-function \
1099         -Wunused-value -Woverloaded-virtual"
1100 
1101     if test "x$TOOLCHAIN_TYPE" = xgcc; then
1102       TOOLCHAIN_CHECK_COMPILER_VERSION(VERSION: [4.8], PREFIX: $2,
1103           IF_AT_LEAST: [
1104             # These flags either do not work or give spurious warnings prior to gcc 4.8.
1105             $2JVM_CFLAGS="[$]$2JVM_CFLAGS -Wno-format-zero-length -Wtype-limits -Wuninitialized"
1106           ]
1107       )
1108     fi
1109     if ! HOTSPOT_CHECK_JVM_VARIANT(zero); then
1110       # Non-zero builds have stricter warnings
1111       $2JVM_CFLAGS="[$]$2JVM_CFLAGS -Wreturn-type -Wundef -Wformat=2"
1112     else
1113       if test "x$TOOLCHAIN_TYPE" = xclang; then
1114         # Some versions of llvm do not like -Wundef
1115         $2JVM_CFLAGS="[$]$2JVM_CFLAGS -Wno-undef"
1116       fi
1117     fi
1118   elif test "x$OPENJDK_$1_OS" = xmacosx; then
1119     $2JVM_CFLAGS="[$]$2JVM_CFLAGS -Wno-deprecated -Wpointer-arith \
1120         -Wsign-compare -Wundef -Wunused-function -Wformat=2"
1121   fi
1122 
1123   # Additional macosx handling
1124   if test "x$OPENJDK_$1_OS" = xmacosx; then
1125     # MACOSX_VERSION_MIN specifies the lowest version of Macosx that the built
1126     # binaries should be compatible with, even if compiled on a newer version
1127     # of the OS. It currently has a hard coded value. Setting this also limits
1128     # exposure to API changes in header files. Bumping this is likely to
1129     # require code changes to build.
1130     MACOSX_VERSION_MIN=10.7.0
1131     AC_SUBST(MACOSX_VERSION_MIN)
1132 
1133     # Setting --with-macosx-version-max=<version> makes it an error to build or
1134     # link to macosx APIs that are newer than the given OS version. The expected
1135     # format for <version> is either nn.n.n or nn.nn.nn. See /usr/include/AvailabilityMacros.h.
1136     AC_ARG_WITH([macosx-version-max], [AS_HELP_STRING([--with-macosx-version-max],
1137         [error on use of newer functionality. @<:@macosx@:>@])],
1138         [
1139           if echo "$with_macosx_version_max" | $GREP -q "^[[0-9]][[0-9]]\.[[0-9]]\.[[0-9]]\$"; then
1140               MACOSX_VERSION_MAX=$with_macosx_version_max
1141           elif echo "$with_macosx_version_max" | $GREP -q "^[[0-9]][[0-9]]\.[[0-9]][[0-9]]\.[[0-9]][[0-9]]\$"; then
1142               MACOSX_VERSION_MAX=$with_macosx_version_max
1143           elif test "x$with_macosx_version_max" = "xno"; then
1144               # Use build system default
1145               MACOSX_VERSION_MAX=
1146           else
1147               AC_MSG_ERROR([osx version format must be nn.n.n or nn.nn.nn])
1148           fi
1149         ],
1150         [MACOSX_VERSION_MAX=]
1151     )
1152     AC_SUBST(MACOSX_VERSION_MAX)
1153 
1154     # Let the flags variables get resolved in make for easier override on make
1155     # command line. AvailabilityMacros.h versions have no dots, ex: 1070.
1156     $2COMMON_CCXXFLAGS_JDK="[$]$2COMMON_CCXXFLAGS_JDK \
1157         -DMAC_OS_X_VERSION_MIN_REQUIRED=\$(subst .,,\$(MACOSX_VERSION_MIN)) \
1158         -mmacosx-version-min=\$(MACOSX_VERSION_MIN)"
1159     $2LDFLAGS_JDK="[$]$2LDFLAGS_JDK -mmacosx-version-min=\$(MACOSX_VERSION_MIN)"
1160     $2JVM_CFLAGS="[$]$2JVM_CFLAGS \
1161         -DMAC_OS_X_VERSION_MIN_REQUIRED=\$(subst .,,\$(MACOSX_VERSION_MIN)) \
1162         -mmacosx-version-min=\$(MACOSX_VERSION_MIN)"
1163     $2ARFLAGS="$2$ARFLAGS -mmacosx-version-min=\$(MACOSX_VERSION_MIN)"
1164 
1165     if test -n "$MACOSX_VERSION_MAX"; then
1166         $2COMMON_CCXXFLAGS_JDK="[$]$2COMMON_CCXXFLAGS_JDK \
1167             -DMAC_OS_X_VERSION_MAX_ALLOWED=\$(subst .,,\$(MACOSX_VERSION_MAX))"
1168         $2JVM_CFLAGS="[$]$2JVM_CFLAGS \
1169             -DMAC_OS_X_VERSION_MAX_ALLOWED=\$(subst .,,\$(MACOSX_VERSION_MAX))"
1170     fi
1171   fi
1172 
1173   # Setup some hard coded includes
1174   $2COMMON_CCXXFLAGS_JDK="[$]$2COMMON_CCXXFLAGS_JDK \
1175       -I\$(SUPPORT_OUTPUTDIR)/modules_include/java.base \
1176       -I\$(SUPPORT_OUTPUTDIR)/modules_include/java.base/\$(OPENJDK_TARGET_OS_INCLUDE_SUBDIR) \
1177       -I${TOPDIR}/src/java.base/share/native/libjava \
1178       -I${TOPDIR}/src/java.base/$OPENJDK_$1_OS_TYPE/native/libjava \
1179       -I${TOPDIR}/src/hotspot/share/include \
1180       -I${TOPDIR}/src/hotspot/os/${HOTSPOT_$1_OS_TYPE}/include"
1181 
1182   # The shared libraries are compiled using the picflag.
1183   $2CFLAGS_JDKLIB="[$]$2COMMON_CCXXFLAGS_JDK \
1184       [$]$2CFLAGS_JDK [$]$2EXTRA_CFLAGS_JDK $PICFLAG [$]$2CFLAGS_JDKLIB_EXTRA"
1185   $2CXXFLAGS_JDKLIB="[$]$2COMMON_CCXXFLAGS_JDK \
1186       [$]$2CXXFLAGS_JDK [$]$2EXTRA_CXXFLAGS_JDK $PICFLAG [$]$2CXXFLAGS_JDKLIB_EXTRA"
1187 
1188   # Executable flags
1189   $2CFLAGS_JDKEXE="[$]$2COMMON_CCXXFLAGS_JDK [$]$2CFLAGS_JDK [$]$2EXTRA_CFLAGS_JDK"
1190   $2CXXFLAGS_JDKEXE="[$]$2COMMON_CCXXFLAGS_JDK [$]$2CXXFLAGS_JDK [$]$2EXTRA_CXXFLAGS_JDK"
1191 
1192   AC_SUBST($2CFLAGS_JDKLIB)
1193   AC_SUBST($2CFLAGS_JDKEXE)
1194   AC_SUBST($2CXXFLAGS_JDKLIB)
1195   AC_SUBST($2CXXFLAGS_JDKEXE)
1196 
1197   # Setup LDFLAGS et al.
1198   #
1199 
1200   if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
1201     LDFLAGS_MICROSOFT="-nologo -opt:ref"
1202     $2LDFLAGS_JDK="[$]$2LDFLAGS_JDK $LDFLAGS_MICROSOFT -incremental:no"
1203     $2JVM_LDFLAGS="[$]$2JVM_LDFLAGS $LDFLAGS_MICROSOFT -opt:icf,8 -subsystem:windows -base:0x8000000 -ignore:4281"
1204     if test "x$OPENJDK_$1_CPU_BITS" = "x32"; then
1205       LDFLAGS_SAFESH="-safeseh"
1206       $2LDFLAGS_JDK="[$]$2LDFLAGS_JDK $LDFLAGS_SAFESH"
1207       $2JVM_LDFLAGS="[$]$2JVM_LDFLAGS $LDFLAGS_SAFESH"
1208       # NOTE: Old build added -machine. Probably not needed.
1209       $2JVM_LDFLAGS="[$]$2JVM_LDFLAGS -machine:I386"
1210     else
1211       $2JVM_LDFLAGS="[$]$2JVM_LDFLAGS -machine:AMD64"
1212     fi
1213   elif test "x$TOOLCHAIN_TYPE" = xclang; then
1214       $2JVM_LDFLAGS="[$]$2JVM_LDFLAGS -mno-omit-leaf-frame-pointer -mstack-alignment=16 -stdlib=libstdc++ -fPIC"
1215       if test "x$OPENJDK_$1_OS" = xmacosx; then
1216         # FIXME: We should really generalize SET_SHARED_LIBRARY_ORIGIN instead.
1217         $2JVM_LDFLAGS="[$]$2JVM_LDFLAGS -Wl,-rpath,@loader_path/. -Wl,-rpath,@loader_path/.."
1218     fi
1219   elif test "x$TOOLCHAIN_TYPE" = xgcc; then
1220     # If this is a --hash-style=gnu system, use --hash-style=both, why?
1221     # We have previously set HAS_GNU_HASH if this is the case
1222     if test -n "$HAS_GNU_HASH"; then
1223       $2LDFLAGS_HASH_STYLE="-Wl,--hash-style=both"
1224       $2LDFLAGS_JDK="${$2LDFLAGS_JDK} [$]$2LDFLAGS_HASH_STYLE"
1225       $2JVM_LDFLAGS="[$]$2JVM_LDFLAGS [$]$2LDFLAGS_HASH_STYLE"
1226     fi
1227       if test "x$OPENJDK_$1_OS" = xmacosx; then
1228         $2JVM_LDFLAGS="[$]$2JVM_LDFLAGS -Wl,-rpath,@loader_path/. -Wl,-rpath,@loader_path/.."
1229     fi
1230     if test "x$OPENJDK_$1_OS" = xlinux; then
1231       # And since we now know that the linker is gnu, then add -z defs, to forbid
1232       # undefined symbols in object files.
1233       LDFLAGS_NO_UNDEF_SYM="-Wl,-z,defs"
1234       $2LDFLAGS_JDK="${$2LDFLAGS_JDK} $LDFLAGS_NO_UNDEF_SYM"
1235       $2JVM_LDFLAGS="[$]$2JVM_LDFLAGS  $LDFLAGS_NO_UNDEF_SYM"
1236       LDFLAGS_NO_EXEC_STACK="-Wl,-z,noexecstack"
1237       $2JVM_LDFLAGS="[$]$2JVM_LDFLAGS $LDFLAGS_NO_EXEC_STACK"
1238       if test "x$OPENJDK_$1_CPU" = xx86; then
1239         $2JVM_LDFLAGS="[$]$2JVM_LDFLAGS -march=i586"
1240       fi
1241       case $DEBUG_LEVEL in
1242         release )
1243           # tell linker to optimize libraries.
1244           # Should this be supplied to the OSS linker as well?
1245           LDFLAGS_DEBUGLEVEL_release="-Wl,-O1"
1246           $2LDFLAGS_JDK="${$2LDFLAGS_JDK} $LDFLAGS_DEBUGLEVEL_release"
1247           $2JVM_LDFLAGS="[$]$2JVM_LDFLAGS $LDFLAGS_DEBUGLEVEL_release"
1248           if test "x$HAS_LINKER_RELRO" = "xtrue"; then
1249             $2JVM_LDFLAGS="[$]$2JVM_LDFLAGS $LINKER_RELRO_FLAG"
1250           fi
1251           ;;
1252         slowdebug )
1253           # Hotspot always let the linker optimize
1254           $2JVM_LDFLAGS="[$]$2JVM_LDFLAGS -Wl,-O1"
1255           if test "x$HAS_LINKER_NOW" = "xtrue"; then
1256             # do relocations at load
1257             $2LDFLAGS_JDK="[$]$2LDFLAGS_JDK $LINKER_NOW_FLAG"
1258             $2LDFLAGS_CXX_JDK="[$]$2LDFLAGS_CXX_JDK $LINKER_NOW_FLAG"
1259             $2JVM_LDFLAGS="[$]$2JVM_LDFLAGS $LINKER_NOW_FLAG"
1260           fi
1261           if test "x$HAS_LINKER_RELRO" = "xtrue"; then
1262             # mark relocations read only
1263             $2LDFLAGS_JDK="[$]$2LDFLAGS_JDK $LINKER_RELRO_FLAG"
1264             $2LDFLAGS_CXX_JDK="[$]$2LDFLAGS_CXX_JDK $LINKER_RELRO_FLAG"
1265             $2JVM_LDFLAGS="[$]$2JVM_LDFLAGS $LINKER_RELRO_FLAG"
1266           fi
1267           ;;
1268         fastdebug )
1269           # Hotspot always let the linker optimize
1270           $2JVM_LDFLAGS="[$]$2JVM_LDFLAGS -Wl,-O1"
1271           if test "x$HAS_LINKER_RELRO" = "xtrue"; then
1272             # mark relocations read only
1273             $2LDFLAGS_JDK="[$]$2LDFLAGS_JDK $LINKER_RELRO_FLAG"
1274             $2LDFLAGS_CXX_JDK="[$]$2LDFLAGS_CXX_JDK $LINKER_RELRO_FLAG"
1275             $2JVM_LDFLAGS="[$]$2JVM_LDFLAGS $LINKER_RELRO_FLAG"
1276           fi
1277           ;;
1278         * )
1279           AC_MSG_ERROR([Unrecognized \$DEBUG_LEVEL: $DEBUG_LEVEL])
1280           ;;
1281         esac
1282     fi
1283   elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
1284     LDFLAGS_SOLSTUDIO="-Wl,-z,defs"
1285     $2LDFLAGS_JDK="[$]$2LDFLAGS_JDK $LDFLAGS_SOLSTUDIO -ztext"
1286     LDFLAGS_CXX_SOLSTUDIO="-norunpath"
1287     $2LDFLAGS_CXX_JDK="[$]$2LDFLAGS_CXX_JDK $LDFLAGS_CXX_SOLSTUDIO -xnolib"
1288     $2JVM_LDFLAGS="[$]$2JVM_LDFLAGS $LDFLAGS_SOLSTUDIO -library=%none -mt $LDFLAGS_CXX_SOLSTUDIO -z noversion"
1289     if test "x$OPENJDK_$1_CPU_ARCH" = "xsparc"; then
1290       $2JVM_LDFLAGS="[$]$2JVM_LDFLAGS -xarch=sparc"
1291     fi
1292   elif test "x$TOOLCHAIN_TYPE" = xxlc; then
1293     LDFLAGS_XLC="-b64 -brtl -bnolibpath -bexpall -bernotok -btextpsize:64K -bdatapsize:64K -bstackpsize:64K"
1294     $2LDFLAGS_JDK="${$2LDFLAGS_JDK} $LDFLAGS_XLC"
1295     $2JVM_LDFLAGS="[$]$2JVM_LDFLAGS $LDFLAGS_XLC"
1296     # We need '-qminimaltoc' or '-qpic=large -bbigtoc' if the TOC overflows.
1297     # Hotspot now overflows its 64K TOC (currently only for debug),
1298     # so we build with '-qpic=large -bbigtoc'.
1299     if test "x$DEBUG_LEVEL" = xslowdebug || test "x$DEBUG_LEVEL" = xfastdebug; then
1300       $2JVM_LDFLAGS="[$]$2JVM_LDFLAGS -bbigtoc"
1301     fi
1302   fi
1303 
1304   # Customize LDFLAGS for executables
1305 
1306   $2LDFLAGS_JDKEXE="${$2LDFLAGS_JDK}"
1307 
1308   if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
1309     if test "x$OPENJDK_$1_CPU_BITS" = "x64"; then
1310       LDFLAGS_STACK_SIZE=1048576
1311     else
1312       LDFLAGS_STACK_SIZE=327680
1313     fi
1314     $2LDFLAGS_JDKEXE="${$2LDFLAGS_JDKEXE} /STACK:$LDFLAGS_STACK_SIZE"
1315   elif test "x$OPENJDK_$1_OS" = xlinux; then
1316     $2LDFLAGS_JDKEXE="[$]$2LDFLAGS_JDKEXE -Wl,--allow-shlib-undefined"
1317   fi
1318 
1319   $2LDFLAGS_JDKEXE="${$2LDFLAGS_JDKEXE} ${$2EXTRA_LDFLAGS_JDK}"
1320 
1321   # Customize LDFLAGS for libs
1322   $2LDFLAGS_JDKLIB="${$2LDFLAGS_JDK}"
1323 
1324   $2LDFLAGS_JDKLIB="${$2LDFLAGS_JDKLIB} ${SHARED_LIBRARY_FLAGS}"
1325   $2LDFLAGS_JDKLIB="${$2LDFLAGS_JDKLIB} ${LDFLAGS_NO_EXEC_STACK}"
1326   if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
1327     $2JAVA_BASE_LDFLAGS="${$2JAVA_BASE_LDFLAGS} \
1328         -libpath:${OUTPUTDIR}/support/modules_libs/java.base"
1329     $2JDKLIB_LIBS=""
1330   else
1331     $2JAVA_BASE_LDFLAGS="${$2JAVA_BASE_LDFLAGS} \
1332         -L\$(SUPPORT_OUTPUTDIR)/modules_libs/java.base"
1333 
1334     if test "x$1" = "xTARGET"; then
1335       # On some platforms (mac) the linker warns about non existing -L dirs.
1336       # For any of the variants server, client or minimal, the dir matches the
1337       # variant name. The "main" variant should be used for linking. For the
1338       # rest, the dir is just server.
1339       if HOTSPOT_CHECK_JVM_VARIANT(server) || HOTSPOT_CHECK_JVM_VARIANT(client) \
1340           || HOTSPOT_CHECK_JVM_VARIANT(minimal); then
1341         $2JAVA_BASE_LDFLAGS="${$2JAVA_BASE_LDFLAGS} \
1342             -L\$(SUPPORT_OUTPUTDIR)/modules_libs/java.base/$JVM_VARIANT_MAIN"
1343       else
1344         $2JAVA_BASE_LDFLAGS="${$2JAVA_BASE_LDFLAGS} \
1345             -L\$(SUPPORT_OUTPUTDIR)/modules_libs/java.base/server"
1346       fi
1347     elif test "x$1" = "xBUILD"; then
1348       # When building a buildjdk, it's always only the server variant
1349       $2JAVA_BASE_LDFLAGS="${$2JAVA_BASE_LDFLAGS} \
1350           -L\$(SUPPORT_OUTPUTDIR)/modules_libs/java.base/server"
1351     fi
1352 
1353     $2JDKLIB_LIBS="-ljava -ljvm"
1354     if test "x$TOOLCHAIN_TYPE" = xsolstudio; then
1355       $2JDKLIB_LIBS="[$]$2JDKLIB_LIBS -lc"
1356     fi
1357 
1358   fi
1359 
1360 $2LDFLAGS_JDKLIB="${$2LDFLAGS_JDKLIB} ${$2JAVA_BASE_LDFLAGS}"
1361 
1362   # Set $2JVM_LIBS (per os)
1363   if test "x$OPENJDK_$1_OS" = xlinux; then
1364     $2JVM_LIBS="[$]$2JVM_LIBS -lm -ldl -lpthread"
1365   elif test "x$OPENJDK_$1_OS" = xsolaris; then
1366     # FIXME: This hard-coded path is not really proper.
1367     if test "x$OPENJDK_$1_CPU" = xx86_64; then
1368       $2SOLARIS_LIBM_LIBS="/usr/lib/amd64/libm.so.1"
1369     elif test "x$OPENJDK_$1_CPU" = xsparcv9; then
1370       $2SOLARIS_LIBM_LIBS="/usr/lib/sparcv9/libm.so.1"
1371     fi
1372     $2JVM_LIBS="[$]$2JVM_LIBS -lsocket -lsched -ldl $SOLARIS_LIBM_LIBS -lCrun \
1373         -lthread -ldoor -lc -ldemangle -lnsl -lrt"
1374   elif test "x$OPENJDK_$1_OS" = xmacosx; then
1375     $2JVM_LIBS="[$]$2JVM_LIBS -lm"
1376   elif test "x$OPENJDK_$1_OS" = xaix; then
1377     $2JVM_LIBS="[$]$2JVM_LIBS -Wl,-lC_r -lm -ldl -lpthread"
1378   elif test "x$OPENJDK_$1_OS" = xbsd; then
1379     $2JVM_LIBS="[$]$2JVM_LIBS -lm"
1380   elif test "x$OPENJDK_$1_OS" = xwindows; then
1381     $2JVM_LIBS="[$]$2JVM_LIBS kernel32.lib user32.lib gdi32.lib winspool.lib \
1382         comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib \
1383         wsock32.lib winmm.lib version.lib psapi.lib"
1384     fi
1385 
1386   # Set $2JVM_ASFLAGS
1387   if test "x$OPENJDK_$1_OS" = xlinux; then
1388     if test "x$OPENJDK_$1_CPU" = xx86; then
1389       $2JVM_ASFLAGS="[$]$2JVM_ASFLAGS -march=i586"
1390     fi
1391   elif test "x$OPENJDK_$1_OS" = xmacosx; then
1392     $2JVM_ASFLAGS="[$]$2JVM_ASFLAGS -x assembler-with-cpp -mno-omit-leaf-frame-pointer -mstack-alignment=16"
1393   fi
1394 
1395   $2LDFLAGS_JDKLIB="${$2LDFLAGS_JDKLIB} ${$2EXTRA_LDFLAGS_JDK}"
1396 
1397   AC_SUBST($2LDFLAGS_JDKLIB)
1398   AC_SUBST($2LDFLAGS_JDKEXE)
1399   AC_SUBST($2JDKLIB_LIBS)
1400   AC_SUBST($2JDKEXE_LIBS)
1401   AC_SUBST($2LDFLAGS_CXX_JDK)
1402   AC_SUBST($2LDFLAGS_HASH_STYLE)
1403   AC_SUBST($2LDFLAGS_NO_EXEC_STACK)
1404 
1405   AC_SUBST($2JVM_CFLAGS)
1406   AC_SUBST($2JVM_LDFLAGS)
1407   AC_SUBST($2JVM_ASFLAGS)
1408   AC_SUBST($2JVM_LIBS)
1409 
1410 ])
1411 
1412 # FLAGS_C_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [ARGUMENT], IF_TRUE: [RUN-IF-TRUE],
1413 #                                  IF_FALSE: [RUN-IF-FALSE])
1414 # ------------------------------------------------------------
1415 # Check that the C compiler supports an argument
1416 BASIC_DEFUN_NAMED([FLAGS_C_COMPILER_CHECK_ARGUMENTS],
1417     [*ARGUMENT IF_TRUE IF_FALSE], [$@],
1418 [
1419   AC_MSG_CHECKING([if the C compiler supports "ARG_ARGUMENT"])
1420   supports=yes
1421 
1422   saved_cflags="$CFLAGS"
1423   CFLAGS="$CFLAGS ARG_ARGUMENT"
1424   AC_LANG_PUSH([C])
1425   AC_COMPILE_IFELSE([AC_LANG_SOURCE([[int i;]])], [],
1426       [supports=no])
1427   AC_LANG_POP([C])
1428   CFLAGS="$saved_cflags"
1429 
1430   AC_MSG_RESULT([$supports])
1431   if test "x$supports" = "xyes" ; then
1432     :
1433     ARG_IF_TRUE
1434   else
1435     :
1436     ARG_IF_FALSE
1437   fi
1438 ])
1439 
1440 # FLAGS_CXX_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [ARGUMENT], IF_TRUE: [RUN-IF-TRUE],
1441 #                                    IF_FALSE: [RUN-IF-FALSE])
1442 # ------------------------------------------------------------
1443 # Check that the C++ compiler supports an argument
1444 BASIC_DEFUN_NAMED([FLAGS_CXX_COMPILER_CHECK_ARGUMENTS],
1445     [*ARGUMENT IF_TRUE IF_FALSE], [$@],
1446 [
1447   AC_MSG_CHECKING([if the C++ compiler supports "ARG_ARGUMENT"])
1448   supports=yes
1449 
1450   saved_cxxflags="$CXXFLAGS"
1451   CXXFLAGS="$CXXFLAG ARG_ARGUMENT"
1452   AC_LANG_PUSH([C++])
1453   AC_COMPILE_IFELSE([AC_LANG_SOURCE([[int i;]])], [],
1454       [supports=no])
1455   AC_LANG_POP([C++])
1456   CXXFLAGS="$saved_cxxflags"
1457 
1458   AC_MSG_RESULT([$supports])
1459   if test "x$supports" = "xyes" ; then
1460     :
1461     ARG_IF_TRUE
1462   else
1463     :
1464     ARG_IF_FALSE
1465   fi
1466 ])
1467 
1468 # FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [ARGUMENT], IF_TRUE: [RUN-IF-TRUE],
1469 #                                IF_FALSE: [RUN-IF-FALSE])
1470 # ------------------------------------------------------------
1471 # Check that the C and C++ compilers support an argument
1472 BASIC_DEFUN_NAMED([FLAGS_COMPILER_CHECK_ARGUMENTS],
1473     [*ARGUMENT IF_TRUE IF_FALSE], [$@],
1474 [
1475   FLAGS_C_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [ARG_ARGUMENT],
1476                                              IF_TRUE: [C_COMP_SUPPORTS="yes"],
1477                                              IF_FALSE: [C_COMP_SUPPORTS="no"])
1478   FLAGS_CXX_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [ARG_ARGUMENT],
1479                                                IF_TRUE: [CXX_COMP_SUPPORTS="yes"],
1480                                                IF_FALSE: [CXX_COMP_SUPPORTS="no"])
1481 
1482   AC_MSG_CHECKING([if both compilers support "ARG_ARGUMENT"])
1483   supports=no
1484   if test "x$C_COMP_SUPPORTS" = "xyes" -a "x$CXX_COMP_SUPPORTS" = "xyes"; then supports=yes; fi
1485 
1486   AC_MSG_RESULT([$supports])
1487   if test "x$supports" = "xyes" ; then
1488     :
1489     ARG_IF_TRUE
1490   else
1491     :
1492     ARG_IF_FALSE
1493   fi
1494 ])
1495 
1496 # FLAGS_LINKER_CHECK_ARGUMENTS(ARGUMENT: [ARGUMENT], IF_TRUE: [RUN-IF-TRUE],
1497 #                                   IF_FALSE: [RUN-IF-FALSE])
1498 # ------------------------------------------------------------
1499 # Check that the linker support an argument
1500 BASIC_DEFUN_NAMED([FLAGS_LINKER_CHECK_ARGUMENTS],
1501     [*ARGUMENT IF_TRUE IF_FALSE], [$@],
1502 [
1503   AC_MSG_CHECKING([if linker supports "ARG_ARGUMENT"])
1504   supports=yes
1505 
1506   saved_ldflags="$LDFLAGS"
1507   LDFLAGS="$LDFLAGS ARG_ARGUMENT"
1508   AC_LANG_PUSH([C])
1509   AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[]])],
1510       [], [supports=no])
1511   AC_LANG_POP([C])
1512   LDFLAGS="$saved_ldflags"
1513 
1514   AC_MSG_RESULT([$supports])
1515   if test "x$supports" = "xyes" ; then
1516     :
1517     ARG_IF_TRUE
1518   else
1519     :
1520     ARG_IF_FALSE
1521   fi
1522 ])
1523 
1524 AC_DEFUN_ONCE([FLAGS_SETUP_COMPILER_FLAGS_MISC],
1525 [
1526   # Check that the compiler supports -mX (or -qX on AIX) flags
1527   # Set COMPILER_SUPPORTS_TARGET_BITS_FLAG to 'true' if it does
1528   FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [${COMPILER_TARGET_BITS_FLAG}${OPENJDK_TARGET_CPU_BITS}],
1529       IF_TRUE: [COMPILER_SUPPORTS_TARGET_BITS_FLAG=true],
1530       IF_FALSE: [COMPILER_SUPPORTS_TARGET_BITS_FLAG=false])
1531   AC_SUBST(COMPILER_SUPPORTS_TARGET_BITS_FLAG)
1532 
1533   AC_ARG_ENABLE([warnings-as-errors], [AS_HELP_STRING([--disable-warnings-as-errors],
1534       [do not consider native warnings to be an error @<:@enabled@:>@])])
1535 
1536   AC_MSG_CHECKING([if native warnings are errors])
1537   if test "x$enable_warnings_as_errors" = "xyes"; then
1538     AC_MSG_RESULT([yes (explicitly set)])
1539     WARNINGS_AS_ERRORS=true
1540   elif test "x$enable_warnings_as_errors" = "xno"; then
1541     AC_MSG_RESULT([no])
1542     WARNINGS_AS_ERRORS=false
1543   elif test "x$enable_warnings_as_errors" = "x"; then
1544     AC_MSG_RESULT([yes (default)])
1545     WARNINGS_AS_ERRORS=true
1546   else
1547     AC_MSG_ERROR([--enable-warnings-as-errors accepts no argument])
1548   fi
1549 
1550   AC_SUBST(WARNINGS_AS_ERRORS)
1551 
1552   case "${TOOLCHAIN_TYPE}" in
1553     microsoft)
1554       DISABLE_WARNING_PREFIX="-wd"
1555       CFLAGS_WARNINGS_ARE_ERRORS="-WX"
1556       ;;
1557     solstudio)
1558       DISABLE_WARNING_PREFIX="-erroff="
1559       CFLAGS_WARNINGS_ARE_ERRORS="-errtags -errwarn=%all"
1560       ;;
1561     gcc)
1562       # Prior to gcc 4.4, a -Wno-X where X is unknown for that version of gcc will cause an error
1563       FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [-Wno-this-is-a-warning-that-do-not-exist],
1564           IF_TRUE: [GCC_CAN_DISABLE_WARNINGS=true],
1565           IF_FALSE: [GCC_CAN_DISABLE_WARNINGS=false]
1566       )
1567       if test "x$GCC_CAN_DISABLE_WARNINGS" = "xtrue"; then
1568         DISABLE_WARNING_PREFIX="-Wno-"
1569       else
1570         DISABLE_WARNING_PREFIX=
1571       fi
1572       CFLAGS_WARNINGS_ARE_ERRORS="-Werror"
1573       # Repeate the check for the BUILD_CC and BUILD_CXX. Need to also reset
1574       # CFLAGS since any target specific flags will likely not work with the
1575       # build compiler
1576       CC_OLD="$CC"
1577       CXX_OLD="$CXX"
1578       CC="$BUILD_CC"
1579       CXX="$BUILD_CXX"
1580       CFLAGS_OLD="$CFLAGS"
1581       CFLAGS=""
1582       FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [-Wno-this-is-a-warning-that-do-not-exist],
1583           IF_TRUE: [BUILD_CC_CAN_DISABLE_WARNINGS=true],
1584           IF_FALSE: [BUILD_CC_CAN_DISABLE_WARNINGS=false]
1585       )
1586       if test "x$BUILD_CC_CAN_DISABLE_WARNINGS" = "xtrue"; then
1587         BUILD_CC_DISABLE_WARNING_PREFIX="-Wno-"
1588       else
1589         BUILD_CC_DISABLE_WARNING_PREFIX=
1590       fi
1591       CC="$CC_OLD"
1592       CXX="$CXX_OLD"
1593       CFLAGS="$CFLAGS_OLD"
1594       ;;
1595     clang)
1596       DISABLE_WARNING_PREFIX="-Wno-"
1597       CFLAGS_WARNINGS_ARE_ERRORS="-Werror"
1598       ;;
1599     xlc)
1600       DISABLE_WARNING_PREFIX="-qsuppress="
1601       CFLAGS_WARNINGS_ARE_ERRORS="-qhalt=w"
1602       ;;
1603   esac
1604   AC_SUBST(DISABLE_WARNING_PREFIX)
1605   AC_SUBST(BUILD_CC_DISABLE_WARNING_PREFIX)
1606   AC_SUBST(CFLAGS_WARNINGS_ARE_ERRORS)
1607 ])
1608 
1609 # FLAGS_SETUP_GCC6_COMPILER_FLAGS([PREFIX])
1610 # Arguments:
1611 # $1 - Optional prefix for each variable defined.
1612 AC_DEFUN([FLAGS_SETUP_GCC6_COMPILER_FLAGS],
1613 [
1614   # These flags are required for GCC 6 builds as undefined behaviour in OpenJDK code
1615   # runs afoul of the more aggressive versions of these optimisations.
1616   # Notably, value range propagation now assumes that the this pointer of C++
1617   # member functions is non-null.
1618   NO_DELETE_NULL_POINTER_CHECKS_CFLAG="-fno-delete-null-pointer-checks"
1619   dnl Argument check is disabled until FLAGS_COMPILER_CHECK_ARGUMENTS handles cross-compilation
1620   dnl FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [$NO_DELETE_NULL_POINTER_CHECKS_CFLAG -Werror],
1621   dnl                                        IF_FALSE: [NO_DELETE_NULL_POINTER_CHECKS_CFLAG=""])
1622   NO_LIFETIME_DSE_CFLAG="-fno-lifetime-dse"
1623   dnl Argument check is disabled until FLAGS_COMPILER_CHECK_ARGUMENTS handles cross-compilation
1624   dnl FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [$NO_LIFETIME_DSE_CFLAG -Werror],
1625   dnl                                        IF_FALSE: [NO_LIFETIME_DSE_CFLAG=""])
1626   AC_MSG_NOTICE([GCC >= 6 detected; adding ${NO_DELETE_NULL_POINTER_CHECKS_CFLAG} and ${NO_LIFETIME_DSE_CFLAG}])
1627   $1CFLAGS_JDK="[$]$1CFLAGS_JDK ${NO_DELETE_NULL_POINTER_CHECKS_CFLAG} ${NO_LIFETIME_DSE_CFLAG}"
1628   $1JVM_CFLAGS="[$]$1JVM_CFLAGS ${NO_DELETE_NULL_POINTER_CHECKS_CFLAG} ${NO_LIFETIME_DSE_CFLAG}"
1629 ])
--- EOF ---