Magellan Linux

Annotation of /trunk/java8-openjdk/patches/java8-openjdk-8.3.4.0-gcc6.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2941 - (hide annotations) (download)
Mon Jun 12 11:28:21 2017 UTC (7 years ago) by niro
File size: 42128 byte(s)
-added java8 patches
1 niro 2941 # HG changeset patch
2     # User andrew
3     # Date 1468209748 -3600
4     # Mon Jul 11 05:02:28 2016 +0100
5     # Node ID 7eb66a95dbd58d26ed271477076e0ab72e8c9ebf
6     # Parent 817d9fb584baecae7c989dfd7009a7f0ac7c6360
7     8151841: Build needs additional flags to compile with GCC 6 [plus parts of 8149647 & 8032045]
8     Summary: C++ standard needs to be explicitly set and some optimisations turned off to build on GCC 6
9     Reviewed-by: erikj, dholmes, kbarrett
10    
11     diff --git a/common/autoconf/generated-configure.sh b/common/autoconf/generated-configure.sh
12     --- a/common/autoconf/generated-configure.sh
13     +++ b/common/autoconf/generated-configure.sh
14     @@ -679,6 +679,9 @@
15     CFLAGS_JDKLIB
16     MACOSX_VERSION_MIN
17     PACKAGE_PATH
18     +NO_LIFETIME_DSE_CFLAG
19     +NO_DELETE_NULL_POINTER_CHECKS_CFLAG
20     +CXXSTD_CXXFLAG
21     LEGACY_EXTRA_LDFLAGS
22     LEGACY_EXTRA_CXXFLAGS
23     LEGACY_EXTRA_CFLAGS
24     @@ -743,6 +746,8 @@
25     ac_ct_OBJC
26     OBJCFLAGS
27     OBJC
28     +CXX_VERSION
29     +CC_VERSION
30     ac_ct_CXX
31     CXXFLAGS
32     CXX
33     @@ -3672,7 +3677,7 @@
34    
35    
36     #
37     -# Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
38     +# Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
39     # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
40     #
41     # This code is free software; you can redistribute it and/or modify it
42     @@ -3795,6 +3800,19 @@
43     # questions.
44     #
45    
46     +# Prepare the system so that TOOLCHAIN_CHECK_COMPILER_VERSION can be called.
47     +# Must have CC_VERSION_NUMBER and CXX_VERSION_NUMBER.
48     +
49     +
50     +# Check if the configured compiler (C and C++) is of a specific version or
51     +# newer. TOOLCHAIN_PREPARE_FOR_VERSION_COMPARISONS must have been called before.
52     +#
53     +# Arguments:
54     +# $1: The version string to check against the found version
55     +# $2: block to run if the compiler is at least this version (>=)
56     +# $3: block to run if the compiler is older than this version (<)
57     +
58     +
59     # $1 = compiler to test (CC or CXX)
60     # $2 = human readable name of compiler (C or C++)
61    
62     @@ -3818,10 +3836,22 @@
63    
64    
65    
66     +# TOOLCHAIN_C_COMPILER_CHECK_ARGUMENTS([ARGUMENT], [RUN-IF-TRUE],
67     +# [RUN-IF-FALSE])
68     +# ------------------------------------------------------------
69     +# Check that the C compiler supports an argument
70     +
71     +
72     +# TOOLCHAIN_CXX_COMPILER_CHECK_ARGUMENTS([ARGUMENT], [RUN-IF-TRUE],
73     +# [RUN-IF-FALSE])
74     +# ------------------------------------------------------------
75     +# Check that the C++ compiler supports an argument
76     +
77     +
78     # TOOLCHAIN_COMPILER_CHECK_ARGUMENTS([ARGUMENT], [RUN-IF-TRUE],
79     -# [RUN-IF-FALSE])
80     +# [RUN-IF-FALSE])
81     # ------------------------------------------------------------
82     -# Check that the c and c++ compilers support an argument
83     +# Check that the C and C++ compilers support an argument
84    
85    
86    
87     @@ -3829,6 +3859,8 @@
88     # Setup the JTREG paths
89    
90    
91     +
92     +
93     #
94     # Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
95     # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
96     @@ -3880,7 +3912,7 @@
97     #CUSTOM_AUTOCONF_INCLUDE
98    
99     # Do not change or remove the following line, it is needed for consistency checks:
100     -DATE_WHEN_GENERATED=1449096260
101     +DATE_WHEN_GENERATED=1468207795
102    
103     ###############################################################################
104     #
105     @@ -20368,7 +20400,8 @@
106    
107     # First line typically looks something like:
108     # gcc (Ubuntu/Linaro 4.5.2-8ubuntu4) 4.5.2
109     - COMPILER_VERSION=`$ECHO $COMPILER_VERSION_TEST | $SED -n "s/^.* \([1-9][0-9.]*\)/\1/p"`
110     + COMPILER_VERSION=`$ECHO $COMPILER_VERSION_TEST | \
111     + $SED -e 's/^.* \([1-9]\.[0-9.]*\)[^0-9.].*$/\1/'`
112     COMPILER_VENDOR=`$ECHO $COMPILER_VERSION_TEST | $SED -n "s/^\(.*\) [1-9][0-9.]*/\1/p"`
113     fi
114     # This sets CC_VERSION or CXX_VERSION. (This comment is a grep marker)
115     @@ -21969,7 +22002,8 @@
116    
117     # First line typically looks something like:
118     # gcc (Ubuntu/Linaro 4.5.2-8ubuntu4) 4.5.2
119     - COMPILER_VERSION=`$ECHO $COMPILER_VERSION_TEST | $SED -n "s/^.* \([1-9][0-9.]*\)/\1/p"`
120     + COMPILER_VERSION=`$ECHO $COMPILER_VERSION_TEST | \
121     + $SED -e 's/^.* \([1-9]\.[0-9.]*\)[^0-9.].*$/\1/'`
122     COMPILER_VENDOR=`$ECHO $COMPILER_VERSION_TEST | $SED -n "s/^\(.*\) [1-9][0-9.]*/\1/p"`
123     fi
124     # This sets CC_VERSION or CXX_VERSION. (This comment is a grep marker)
125     @@ -22240,6 +22274,32 @@
126     ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
127    
128    
129     + # This is the compiler version number on the form X.Y[.Z]
130     +
131     +
132     +
133     +
134     + if test "x$CC_VERSION" != "x$CXX_VERSION"; then
135     + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: C and C++ compiler has different version numbers, $CC_VERSION vs $CXX_VERSION." >&5
136     +$as_echo "$as_me: WARNING: C and C++ compiler has different version numbers, $CC_VERSION vs $CXX_VERSION." >&2;}
137     + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: This typically indicates a broken setup, and is not supported" >&5
138     +$as_echo "$as_me: WARNING: This typically indicates a broken setup, and is not supported" >&2;}
139     + fi
140     +
141     + # We only check CC_VERSION since we assume CXX_VERSION is equal.
142     + if [[ "$CC_VERSION" =~ (.*\.){3} ]] ; then
143     + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: C compiler version number has more than three parts (X.Y.Z): $CC_VERSION. Comparisons might be wrong." >&5
144     +$as_echo "$as_me: WARNING: C compiler version number has more than three parts (X.Y.Z): $CC_VERSION. Comparisons might be wrong." >&2;}
145     + fi
146     +
147     + if [[ "$CC_VERSION" =~ [0-9]{6} ]] ; then
148     + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: C compiler version number has a part larger than 99999: $CC_VERSION. Comparisons might be wrong." >&5
149     +$as_echo "$as_me: WARNING: C compiler version number has a part larger than 99999: $CC_VERSION. Comparisons might be wrong." >&2;}
150     + fi
151     +
152     + COMPARABLE_ACTUAL_VERSION=`$AWK -F. '{ printf("%05d%05d%05d\n", $1, $2, $3) }' <<< "$CC_VERSION"`
153     +
154     +
155     ### Locate other tools
156    
157     if test "x$OPENJDK_TARGET_OS" = xmacosx; then
158     @@ -24831,7 +24891,8 @@
159    
160    
161     COMPILER_TYPE=CL
162     - CCXXFLAGS="$CCXXFLAGS -nologo"
163     + # silence copyright notice and other headers.
164     + COMMON_CCXXFLAGS="$COMMON_CCXXFLAGS -nologo"
165    
166     fi
167    
168     @@ -29664,12 +29725,57 @@
169     #
170     # Now setup the CFLAGS and LDFLAGS for the JDK build.
171     # Later we will also have CFLAGS and LDFLAGS for the hotspot subrepo build.
172     + # CFLAGS_JDK - C Compiler flags
173     + # CXXFLAGS_JDK - C++ Compiler flags
174     + # COMMON_CCXXFLAGS_JDK - common to C and C++
175     #
176     case $COMPILER_NAME in
177     gcc )
178     - CCXXFLAGS_JDK="$CCXXFLAGS $CCXXFLAGS_JDK -W -Wall -Wno-unused -Wno-parentheses \
179     + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS $COMMON_CCXXFLAGS_JDK -W -Wall -Wno-unused -Wno-parentheses \
180     -pipe \
181     -D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE"
182     + CXXSTD_CXXFLAG="-std=gnu++98"
183     +
184     + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if the C++ compiler supports \"$CXXSTD_CXXFLAG $CFLAGS_WARNINGS_ARE_ERRORS\"" >&5
185     +$as_echo_n "checking if the C++ compiler supports \"$CXXSTD_CXXFLAG $CFLAGS_WARNINGS_ARE_ERRORS\"... " >&6; }
186     + supports=yes
187     +
188     + saved_cxxflags="$CXXFLAGS"
189     + CXXFLAGS="$CXXFLAG $CXXSTD_CXXFLAG $CFLAGS_WARNINGS_ARE_ERRORS"
190     + ac_ext=cpp
191     +ac_cpp='$CXXCPP $CPPFLAGS'
192     +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
193     +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
194     +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
195     +
196     + cat confdefs.h - <<_ACEOF >conftest.$ac_ext
197     +/* end confdefs.h. */
198     +int i;
199     +_ACEOF
200     +if ac_fn_cxx_try_compile "$LINENO"; then :
201     +
202     +else
203     + supports=no
204     +fi
205     +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
206     + ac_ext=cpp
207     +ac_cpp='$CXXCPP $CPPFLAGS'
208     +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
209     +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
210     +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
211     +
212     + CXXFLAGS="$saved_cxxflags"
213     +
214     + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $supports" >&5
215     +$as_echo "$supports" >&6; }
216     + if test "x$supports" = "xyes" ; then
217     + :
218     + else
219     + CXXSTD_CXXFLAG=""
220     + fi
221     +
222     + CXXFLAGS_JDK="${CXXFLAGS_JDK} ${CXXSTD_CXXFLAG}"
223     +
224     case $OPENJDK_TARGET_CPU_ARCH in
225     arm )
226     # on arm we don't prevent gcc to omit frame pointer but do prevent strict aliasing
227     @@ -29679,16 +29785,234 @@
228     # on ppc we don't prevent gcc to omit frame pointer nor strict-aliasing
229     ;;
230     * )
231     - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -fno-omit-frame-pointer"
232     + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -fno-omit-frame-pointer"
233     CFLAGS_JDK="${CFLAGS_JDK} -fno-strict-aliasing"
234     ;;
235     esac
236     +
237     + REFERENCE_VERSION=6
238     +
239     + if [[ "$REFERENCE_VERSION" =~ (.*\.){3} ]] ; then
240     + as_fn_error $? "Internal error: Cannot compare to $REFERENCE_VERSION, only three parts (X.Y.Z) is supported" "$LINENO" 5
241     + fi
242     +
243     + if [[ "$REFERENCE_VERSION" =~ [0-9]{6} ]] ; then
244     + as_fn_error $? "Internal error: Cannot compare to $REFERENCE_VERSION, only parts < 99999 is supported" "$LINENO" 5
245     + fi
246     +
247     + # Version comparison method inspired by http://stackoverflow.com/a/24067243
248     + COMPARABLE_REFERENCE_VERSION=`$AWK -F. '{ printf("%05d%05d%05d\n", $1, $2, $3) }' <<< "$REFERENCE_VERSION"`
249     +
250     + if test $COMPARABLE_ACTUAL_VERSION -ge $COMPARABLE_REFERENCE_VERSION ; then
251     +
252     + # These flags are required for GCC 6 builds as undefined behaviour in OpenJDK code
253     + # runs afoul of the more aggressive versions of these optimisations.
254     + # Notably, value range propagation now assumes that the this pointer of C++
255     + # member functions is non-null.
256     + NO_DELETE_NULL_POINTER_CHECKS_CFLAG="-fno-delete-null-pointer-checks"
257     +
258     +
259     + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if the C compiler supports \"$NO_DELETE_NULL_POINTER_CHECKS_CFLAG -Werror\"" >&5
260     +$as_echo_n "checking if the C compiler supports \"$NO_DELETE_NULL_POINTER_CHECKS_CFLAG -Werror\"... " >&6; }
261     + supports=yes
262     +
263     + saved_cflags="$CFLAGS"
264     + CFLAGS="$CFLAGS $NO_DELETE_NULL_POINTER_CHECKS_CFLAG -Werror"
265     + ac_ext=c
266     +ac_cpp='$CPP $CPPFLAGS'
267     +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
268     +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
269     +ac_compiler_gnu=$ac_cv_c_compiler_gnu
270     +
271     +
272     +cat confdefs.h - <<_ACEOF >conftest.$ac_ext
273     +/* end confdefs.h. */
274     +int i;
275     +_ACEOF
276     +if ac_fn_c_try_compile "$LINENO"; then :
277     +
278     +else
279     + supports=no
280     +fi
281     +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
282     + ac_ext=cpp
283     +ac_cpp='$CXXCPP $CPPFLAGS'
284     +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
285     +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
286     +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
287     +
288     + CFLAGS="$saved_cflags"
289     +
290     + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $supports" >&5
291     +$as_echo "$supports" >&6; }
292     + if test "x$supports" = "xyes" ; then
293     + C_COMP_SUPPORTS="yes"
294     + else
295     + C_COMP_SUPPORTS="no"
296     + fi
297     +
298     +
299     + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if the C++ compiler supports \"$NO_DELETE_NULL_POINTER_CHECKS_CFLAG -Werror\"" >&5
300     +$as_echo_n "checking if the C++ compiler supports \"$NO_DELETE_NULL_POINTER_CHECKS_CFLAG -Werror\"... " >&6; }
301     + supports=yes
302     +
303     + saved_cxxflags="$CXXFLAGS"
304     + CXXFLAGS="$CXXFLAG $NO_DELETE_NULL_POINTER_CHECKS_CFLAG -Werror"
305     + ac_ext=cpp
306     +ac_cpp='$CXXCPP $CPPFLAGS'
307     +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
308     +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
309     +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
310     +
311     + cat confdefs.h - <<_ACEOF >conftest.$ac_ext
312     +/* end confdefs.h. */
313     +int i;
314     +_ACEOF
315     +if ac_fn_cxx_try_compile "$LINENO"; then :
316     +
317     +else
318     + supports=no
319     +fi
320     +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
321     + ac_ext=cpp
322     +ac_cpp='$CXXCPP $CPPFLAGS'
323     +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
324     +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
325     +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
326     +
327     + CXXFLAGS="$saved_cxxflags"
328     +
329     + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $supports" >&5
330     +$as_echo "$supports" >&6; }
331     + if test "x$supports" = "xyes" ; then
332     + CXX_COMP_SUPPORTS="yes"
333     + else
334     + CXX_COMP_SUPPORTS="no"
335     + fi
336     +
337     +
338     + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if both compilers support \"$NO_DELETE_NULL_POINTER_CHECKS_CFLAG -Werror\"" >&5
339     +$as_echo_n "checking if both compilers support \"$NO_DELETE_NULL_POINTER_CHECKS_CFLAG -Werror\"... " >&6; }
340     + supports=no
341     + if test "x$C_COMP_SUPPORTS" = "xyes" -a "x$CXX_COMP_SUPPORTS" = "xyes"; then supports=yes; fi
342     +
343     + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $supports" >&5
344     +$as_echo "$supports" >&6; }
345     + if test "x$supports" = "xyes" ; then
346     + :
347     + else
348     + NO_DELETE_NULL_POINTER_CHECKS_CFLAG=""
349     + fi
350     +
351     +
352     + NO_LIFETIME_DSE_CFLAG="-fno-lifetime-dse"
353     +
354     +
355     + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if the C compiler supports \"$NO_LIFETIME_DSE_CFLAG -Werror\"" >&5
356     +$as_echo_n "checking if the C compiler supports \"$NO_LIFETIME_DSE_CFLAG -Werror\"... " >&6; }
357     + supports=yes
358     +
359     + saved_cflags="$CFLAGS"
360     + CFLAGS="$CFLAGS $NO_LIFETIME_DSE_CFLAG -Werror"
361     + ac_ext=c
362     +ac_cpp='$CPP $CPPFLAGS'
363     +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
364     +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
365     +ac_compiler_gnu=$ac_cv_c_compiler_gnu
366     +
367     + cat confdefs.h - <<_ACEOF >conftest.$ac_ext
368     +/* end confdefs.h. */
369     +int i;
370     +_ACEOF
371     +if ac_fn_c_try_compile "$LINENO"; then :
372     +
373     +else
374     + supports=no
375     +fi
376     +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
377     + ac_ext=cpp
378     +ac_cpp='$CXXCPP $CPPFLAGS'
379     +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
380     +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
381     +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
382     +
383     + CFLAGS="$saved_cflags"
384     +
385     + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $supports" >&5
386     +$as_echo "$supports" >&6; }
387     + if test "x$supports" = "xyes" ; then
388     + C_COMP_SUPPORTS="yes"
389     + else
390     + C_COMP_SUPPORTS="no"
391     + fi
392     +
393     +
394     + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if the C++ compiler supports \"$NO_LIFETIME_DSE_CFLAG -Werror\"" >&5
395     +$as_echo_n "checking if the C++ compiler supports \"$NO_LIFETIME_DSE_CFLAG -Werror\"... " >&6; }
396     + supports=yes
397     +
398     + saved_cxxflags="$CXXFLAGS"
399     + CXXFLAGS="$CXXFLAG $NO_LIFETIME_DSE_CFLAG -Werror"
400     + ac_ext=cpp
401     +ac_cpp='$CXXCPP $CPPFLAGS'
402     +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
403     +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
404     +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
405     +
406     + cat confdefs.h - <<_ACEOF >conftest.$ac_ext
407     +/* end confdefs.h. */
408     +int i;
409     +_ACEOF
410     +if ac_fn_cxx_try_compile "$LINENO"; then :
411     +
412     +else
413     + supports=no
414     +fi
415     +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
416     + ac_ext=cpp
417     +ac_cpp='$CXXCPP $CPPFLAGS'
418     +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
419     +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
420     +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
421     +
422     + CXXFLAGS="$saved_cxxflags"
423     +
424     + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $supports" >&5
425     +$as_echo "$supports" >&6; }
426     + if test "x$supports" = "xyes" ; then
427     + CXX_COMP_SUPPORTS="yes"
428     + else
429     + CXX_COMP_SUPPORTS="no"
430     + fi
431     +
432     +
433     + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if both compilers support \"$NO_LIFETIME_DSE_CFLAG -Werror\"" >&5
434     +$as_echo_n "checking if both compilers support \"$NO_LIFETIME_DSE_CFLAG -Werror\"... " >&6; }
435     + supports=no
436     + if test "x$C_COMP_SUPPORTS" = "xyes" -a "x$CXX_COMP_SUPPORTS" = "xyes"; then supports=yes; fi
437     +
438     + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $supports" >&5
439     +$as_echo "$supports" >&6; }
440     + if test "x$supports" = "xyes" ; then
441     + :
442     + else
443     + NO_LIFETIME_DSE_CFLAG=""
444     + fi
445     +
446     + CFLAGS_JDK="${CFLAGS_JDK} ${NO_DELETE_NULL_POINTER_CHECKS_CFLAG} ${NO_LIFETIME_DSE_CFLAG}"
447     +
448     +
449     +
450     + else
451     + :
452     + fi
453     +
454     ;;
455     ossc )
456     - CCXXFLAGS_JDK="$CCXXFLAGS $CCXXFLAGS_JDK -DTRACING -DMACRO_MEMSYS_OPS -DBREAKPTS"
457     + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS $COMMON_CCXXFLAGS_JDK -DTRACING -DMACRO_MEMSYS_OPS -DBREAKPTS"
458     case $OPENJDK_TARGET_CPU_ARCH in
459     x86 )
460     - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DcpuIntel -Di586 -D$OPENJDK_TARGET_CPU_LEGACY_LIB"
461     + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DcpuIntel -Di586 -D$OPENJDK_TARGET_CPU_LEGACY_LIB"
462     CFLAGS_JDK="$CFLAGS_JDK -erroff=E_BAD_PRAGMA_PACK_VALUE"
463     ;;
464     esac
465     @@ -29707,16 +30031,16 @@
466     LDFLAGS_CXX_JDK="$LDFLAGS_CXX_JDK"
467     ;;
468     cl )
469     - CCXXFLAGS_JDK="$CCXXFLAGS $CCXXFLAGS_JDK -Zi -MD -Zc:wchar_t- -W3 -wd4800 \
470     + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS $COMMON_CCXXFLAGS_JDK -Zi -MD -Zc:wchar_t- -W3 -wd4800 \
471     -D_STATIC_CPPLIB -D_DISABLE_DEPRECATE_STATIC_CPPLIB -DWIN32_LEAN_AND_MEAN \
472     -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE \
473     -DWIN32 -DIAL"
474     case $OPENJDK_TARGET_CPU in
475     x86 )
476     - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_X86_ -Dx86"
477     + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D_X86_ -Dx86"
478     ;;
479     x86_64 )
480     - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_AMD64_ -Damd64"
481     + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D_AMD64_ -Damd64"
482     ;;
483     esac
484     ;;
485     @@ -29746,7 +30070,7 @@
486     ;;
487     esac
488    
489     - CCXXFLAGS_JDK="$CCXXFLAGS_JDK $ADD_LP64"
490     + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK $ADD_LP64"
491    
492     # The package path is used only on macosx?
493     PACKAGE_PATH=/opt/local
494     @@ -29759,27 +30083,27 @@
495     # Note: -Dmacro is the same as #define macro 1
496     # -Dmacro= is the same as #define macro
497     if test "x$OPENJDK_TARGET_OS" = xsolaris; then
498     - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_LITTLE_ENDIAN="
499     - else
500     - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_LITTLE_ENDIAN"
501     - fi
502     - else
503     - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_BIG_ENDIAN"
504     + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D_LITTLE_ENDIAN="
505     + else
506     + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D_LITTLE_ENDIAN"
507     + fi
508     + else
509     + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D_BIG_ENDIAN"
510     fi
511     if test "x$OPENJDK_TARGET_OS" = xlinux; then
512     - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DLINUX"
513     + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DLINUX"
514     fi
515     if test "x$OPENJDK_TARGET_OS" = xwindows; then
516     - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DWINDOWS"
517     + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DWINDOWS"
518     fi
519     if test "x$OPENJDK_TARGET_OS" = xsolaris; then
520     - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DSOLARIS"
521     + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DSOLARIS"
522     fi
523     if test "x$OPENJDK_TARGET_OS" = xaix; then
524     - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DAIX -DPPC64"
525     + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DAIX -DPPC64"
526     fi
527     if test "x$OPENJDK_TARGET_OS" = xmacosx; then
528     - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DMACOSX -D_ALLBSD_SOURCE -D_DARWIN_UNLIMITED_SELECT"
529     + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DMACOSX -D_ALLBSD_SOURCE -D_DARWIN_UNLIMITED_SELECT"
530     # Setting these parameters makes it an error to link to macosx APIs that are
531     # newer than the given OS version and makes the linked binaries compatible even
532     # if built on a newer version of the OS.
533     @@ -29789,25 +30113,25 @@
534     # The macro takes the version with no dots, ex: 1070
535     # Let the flags variables get resolved in make for easier override on make
536     # command line.
537     - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DMAC_OS_X_VERSION_MAX_ALLOWED=\$(subst .,,\$(MACOSX_VERSION_MIN)) -mmacosx-version-min=\$(MACOSX_VERSION_MIN)"
538     + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DMAC_OS_X_VERSION_MAX_ALLOWED=\$(subst .,,\$(MACOSX_VERSION_MIN)) -mmacosx-version-min=\$(MACOSX_VERSION_MIN)"
539     LDFLAGS_JDK="$LDFLAGS_JDK -mmacosx-version-min=\$(MACOSX_VERSION_MIN)"
540     fi
541     if test "x$OPENJDK_TARGET_OS" = xbsd; then
542     - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DBSD -D_ALLBSD_SOURCE"
543     + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DBSD -D_ALLBSD_SOURCE"
544     fi
545     if test "x$DEBUG_LEVEL" = xrelease; then
546     - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DNDEBUG"
547     + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DNDEBUG"
548     if test "x$OPENJDK_TARGET_OS" = xsolaris; then
549     - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DTRIMMED"
550     - fi
551     - else
552     - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DDEBUG"
553     - fi
554     -
555     - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DARCH='\"$OPENJDK_TARGET_CPU_LEGACY\"' -D$OPENJDK_TARGET_CPU_LEGACY"
556     - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DRELEASE='\"\$(RELEASE)\"'"
557     -
558     - CCXXFLAGS_JDK="$CCXXFLAGS_JDK \
559     + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DTRIMMED"
560     + fi
561     + else
562     + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DDEBUG"
563     + fi
564     +
565     + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DARCH='\"$OPENJDK_TARGET_CPU_LEGACY\"' -D$OPENJDK_TARGET_CPU_LEGACY"
566     + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DRELEASE='\"\$(RELEASE)\"'"
567     +
568     + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK \
569     -I${JDK_OUTPUTDIR}/include \
570     -I${JDK_OUTPUTDIR}/include/$OPENJDK_TARGET_OS \
571     -I${JDK_TOPDIR}/src/share/javavm/export \
572     @@ -29816,12 +30140,12 @@
573     -I${JDK_TOPDIR}/src/$OPENJDK_TARGET_OS_API_DIR/native/common"
574    
575     # The shared libraries are compiled using the picflag.
576     - CFLAGS_JDKLIB="$CCXXFLAGS_JDK $CFLAGS_JDK $PICFLAG $CFLAGS_JDKLIB_EXTRA"
577     - CXXFLAGS_JDKLIB="$CCXXFLAGS_JDK $CXXFLAGS_JDK $PICFLAG $CXXFLAGS_JDKLIB_EXTRA "
578     + CFLAGS_JDKLIB="$COMMON_CCXXFLAGS_JDK $CFLAGS_JDK $PICFLAG $CFLAGS_JDKLIB_EXTRA"
579     + CXXFLAGS_JDKLIB="$COMMON_CCXXFLAGS_JDK $CXXFLAGS_JDK $PICFLAG $CXXFLAGS_JDKLIB_EXTRA "
580    
581     # Executable flags
582     - CFLAGS_JDKEXE="$CCXXFLAGS_JDK $CFLAGS_JDK"
583     - CXXFLAGS_JDKEXE="$CCXXFLAGS_JDK $CXXFLAGS_JDK"
584     + CFLAGS_JDKEXE="$COMMON_CCXXFLAGS_JDK $CFLAGS_JDK"
585     + CXXFLAGS_JDKEXE="$COMMON_CCXXFLAGS_JDK $CXXFLAGS_JDK"
586    
587     # Now this is odd. The JDK native libraries have to link against libjvm.so
588     # On 32-bit machines there is normally two distinct libjvm.so:s, client and server.
589     @@ -29905,7 +30229,6 @@
590    
591    
592    
593     -
594     # Some Zero and Shark settings.
595     # ZERO_ARCHFLAG tells the compiler which mode to build for
596     case "${OPENJDK_TARGET_CPU}" in
597     @@ -29916,8 +30239,9 @@
598     ZERO_ARCHFLAG="${COMPILER_TARGET_BITS_FLAG}${OPENJDK_TARGET_CPU_BITS}"
599     esac
600    
601     - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if compiler supports \"$ZERO_ARCHFLAG\"" >&5
602     -$as_echo_n "checking if compiler supports \"$ZERO_ARCHFLAG\"... " >&6; }
603     +
604     + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if the C compiler supports \"$ZERO_ARCHFLAG\"" >&5
605     +$as_echo_n "checking if the C compiler supports \"$ZERO_ARCHFLAG\"... " >&6; }
606     supports=yes
607    
608     saved_cflags="$CFLAGS"
609     @@ -29946,6 +30270,19 @@
610    
611     CFLAGS="$saved_cflags"
612    
613     + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $supports" >&5
614     +$as_echo "$supports" >&6; }
615     + if test "x$supports" = "xyes" ; then
616     + C_COMP_SUPPORTS="yes"
617     + else
618     + C_COMP_SUPPORTS="no"
619     + fi
620     +
621     +
622     + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if the C++ compiler supports \"$ZERO_ARCHFLAG\"" >&5
623     +$as_echo_n "checking if the C++ compiler supports \"$ZERO_ARCHFLAG\"... " >&6; }
624     + supports=yes
625     +
626     saved_cxxflags="$CXXFLAGS"
627     CXXFLAGS="$CXXFLAG $ZERO_ARCHFLAG"
628     ac_ext=cpp
629     @@ -29975,6 +30312,20 @@
630     { $as_echo "$as_me:${as_lineno-$LINENO}: result: $supports" >&5
631     $as_echo "$supports" >&6; }
632     if test "x$supports" = "xyes" ; then
633     + CXX_COMP_SUPPORTS="yes"
634     + else
635     + CXX_COMP_SUPPORTS="no"
636     + fi
637     +
638     +
639     + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if both compilers support \"$ZERO_ARCHFLAG\"" >&5
640     +$as_echo_n "checking if both compilers support \"$ZERO_ARCHFLAG\"... " >&6; }
641     + supports=no
642     + if test "x$C_COMP_SUPPORTS" = "xyes" -a "x$CXX_COMP_SUPPORTS" = "xyes"; then supports=yes; fi
643     +
644     + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $supports" >&5
645     +$as_echo "$supports" >&6; }
646     + if test "x$supports" = "xyes" ; then
647     :
648     else
649     ZERO_ARCHFLAG=""
650     @@ -29985,8 +30336,9 @@
651     # Check that the compiler supports -mX (or -qX on AIX) flags
652     # Set COMPILER_SUPPORTS_TARGET_BITS_FLAG to 'true' if it does
653    
654     - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if compiler supports \"${COMPILER_TARGET_BITS_FLAG}${OPENJDK_TARGET_CPU_BITS}\"" >&5
655     -$as_echo_n "checking if compiler supports \"${COMPILER_TARGET_BITS_FLAG}${OPENJDK_TARGET_CPU_BITS}\"... " >&6; }
656     +
657     + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if the C compiler supports \"${COMPILER_TARGET_BITS_FLAG}${OPENJDK_TARGET_CPU_BITS}\"" >&5
658     +$as_echo_n "checking if the C compiler supports \"${COMPILER_TARGET_BITS_FLAG}${OPENJDK_TARGET_CPU_BITS}\"... " >&6; }
659     supports=yes
660    
661     saved_cflags="$CFLAGS"
662     @@ -30015,6 +30367,19 @@
663    
664     CFLAGS="$saved_cflags"
665    
666     + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $supports" >&5
667     +$as_echo "$supports" >&6; }
668     + if test "x$supports" = "xyes" ; then
669     + C_COMP_SUPPORTS="yes"
670     + else
671     + C_COMP_SUPPORTS="no"
672     + fi
673     +
674     +
675     + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if the C++ compiler supports \"${COMPILER_TARGET_BITS_FLAG}${OPENJDK_TARGET_CPU_BITS}\"" >&5
676     +$as_echo_n "checking if the C++ compiler supports \"${COMPILER_TARGET_BITS_FLAG}${OPENJDK_TARGET_CPU_BITS}\"... " >&6; }
677     + supports=yes
678     +
679     saved_cxxflags="$CXXFLAGS"
680     CXXFLAGS="$CXXFLAG ${COMPILER_TARGET_BITS_FLAG}${OPENJDK_TARGET_CPU_BITS}"
681     ac_ext=cpp
682     @@ -30044,6 +30409,20 @@
683     { $as_echo "$as_me:${as_lineno-$LINENO}: result: $supports" >&5
684     $as_echo "$supports" >&6; }
685     if test "x$supports" = "xyes" ; then
686     + CXX_COMP_SUPPORTS="yes"
687     + else
688     + CXX_COMP_SUPPORTS="no"
689     + fi
690     +
691     +
692     + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if both compilers support \"${COMPILER_TARGET_BITS_FLAG}${OPENJDK_TARGET_CPU_BITS}\"" >&5
693     +$as_echo_n "checking if both compilers support \"${COMPILER_TARGET_BITS_FLAG}${OPENJDK_TARGET_CPU_BITS}\"... " >&6; }
694     + supports=no
695     + if test "x$C_COMP_SUPPORTS" = "xyes" -a "x$CXX_COMP_SUPPORTS" = "xyes"; then supports=yes; fi
696     +
697     + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $supports" >&5
698     +$as_echo "$supports" >&6; }
699     + if test "x$supports" = "xyes" ; then
700     COMPILER_SUPPORTS_TARGET_BITS_FLAG=true
701     else
702     COMPILER_SUPPORTS_TARGET_BITS_FLAG=false
703     diff --git a/common/autoconf/hotspot-spec.gmk.in b/common/autoconf/hotspot-spec.gmk.in
704     --- a/common/autoconf/hotspot-spec.gmk.in
705     +++ b/common/autoconf/hotspot-spec.gmk.in
706     @@ -1,5 +1,5 @@
707     #
708     -# Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
709     +# Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
710     # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
711     #
712     # This code is free software; you can redistribute it and/or modify it
713     @@ -109,7 +109,8 @@
714     MT:=@HOTSPOT_MT@
715     RC:=@HOTSPOT_RC@
716    
717     -EXTRA_CFLAGS=@LEGACY_EXTRA_CFLAGS@
718     +EXTRA_CFLAGS=@LEGACY_EXTRA_CFLAGS@ $(NO_DELETE_NULL_POINTER_CHECKS_CFLAG) \
719     + $(NO_LIFETIME_DSE_CFLAG) $(CXXSTD_CXXFLAG)
720     EXTRA_CXXFLAGS=@LEGACY_EXTRA_CXXFLAGS@
721     EXTRA_LDFLAGS=@LEGACY_EXTRA_LDFLAGS@
722    
723     diff --git a/common/autoconf/spec.gmk.in b/common/autoconf/spec.gmk.in
724     --- a/common/autoconf/spec.gmk.in
725     +++ b/common/autoconf/spec.gmk.in
726     @@ -331,6 +331,10 @@
727     CFLAGS_JDKEXE:=@CFLAGS_JDKEXE@
728     CXXFLAGS_JDKEXE:=@CXXFLAGS_JDKEXE@
729    
730     +NO_DELETE_NULL_POINTER_CHECKS_CFLAG=@NO_DELETE_NULL_POINTER_CHECKS_CFLAG@
731     +NO_LIFETIME_DSE_CFLAG=@NO_LIFETIME_DSE_CFLAG@
732     +CXXSTD_CXXFLAG=@CXXSTD_CXXFLAG@
733     +
734     CXX:=@FIXPATH@ @CCACHE@ @CXX@
735     #CXXFLAGS:=@CXXFLAGS@
736    
737     diff --git a/common/autoconf/toolchain.m4 b/common/autoconf/toolchain.m4
738     --- a/common/autoconf/toolchain.m4
739     +++ b/common/autoconf/toolchain.m4
740     @@ -23,9 +23,59 @@
741     # questions.
742     #
743    
744     +# Prepare the system so that TOOLCHAIN_CHECK_COMPILER_VERSION can be called.
745     +# Must have CC_VERSION_NUMBER and CXX_VERSION_NUMBER.
746     +AC_DEFUN([TOOLCHAIN_PREPARE_FOR_VERSION_COMPARISONS],
747     +[
748     + if test "x$CC_VERSION" != "x$CXX_VERSION"; then
749     + AC_MSG_WARN([C and C++ compiler has different version numbers, $CC_VERSION vs $CXX_VERSION.])
750     + AC_MSG_WARN([This typically indicates a broken setup, and is not supported])
751     + fi
752     +
753     + # We only check CC_VERSION since we assume CXX_VERSION is equal.
754     + if [ [[ "$CC_VERSION" =~ (.*\.){3} ]] ]; then
755     + AC_MSG_WARN([C compiler version number has more than three parts (X.Y.Z): $CC_VERSION. Comparisons might be wrong.])
756     + fi
757     +
758     + if [ [[ "$CC_VERSION" =~ [0-9]{6} ]] ]; then
759     + AC_MSG_WARN([C compiler version number has a part larger than 99999: $CC_VERSION. Comparisons might be wrong.])
760     + fi
761     +
762     + COMPARABLE_ACTUAL_VERSION=`$AWK -F. '{ printf("%05d%05d%05d\n", [$]1, [$]2, [$]3) }' <<< "$CC_VERSION"`
763     +])
764     +
765     +# Check if the configured compiler (C and C++) is of a specific version or
766     +# newer. TOOLCHAIN_PREPARE_FOR_VERSION_COMPARISONS must have been called before.
767     +#
768     +# Arguments:
769     +# $1: The version string to check against the found version
770     +# $2: block to run if the compiler is at least this version (>=)
771     +# $3: block to run if the compiler is older than this version (<)
772     +AC_DEFUN([TOOLCHAIN_CHECK_COMPILER_VERSION],
773     +[
774     + REFERENCE_VERSION=$1
775     +
776     + if [ [[ "$REFERENCE_VERSION" =~ (.*\.){3} ]] ]; then
777     + AC_MSG_ERROR([Internal error: Cannot compare to $REFERENCE_VERSION, only three parts (X.Y.Z) is supported])
778     + fi
779     +
780     + if [ [[ "$REFERENCE_VERSION" =~ [0-9]{6} ]] ]; then
781     + AC_MSG_ERROR([Internal error: Cannot compare to $REFERENCE_VERSION, only parts < 99999 is supported])
782     + fi
783     +
784     + # Version comparison method inspired by http://stackoverflow.com/a/24067243
785     + COMPARABLE_REFERENCE_VERSION=`$AWK -F. '{ printf("%05d%05d%05d\n", [$]1, [$]2, [$]3) }' <<< "$REFERENCE_VERSION"`
786     +
787     + if test $COMPARABLE_ACTUAL_VERSION -ge $COMPARABLE_REFERENCE_VERSION ; then
788     + m4_ifval([$2], [$2], [:])
789     + else
790     + m4_ifval([$3], [$3], [:])
791     + fi
792     +])
793     +
794     # $1 = compiler to test (CC or CXX)
795     # $2 = human readable name of compiler (C or C++)
796     -AC_DEFUN([TOOLCHAIN_CHECK_COMPILER_VERSION],
797     +AC_DEFUN([TOOLCHAIN_EXTRACT_COMPILER_VERSION],
798     [
799     COMPILER=[$]$1
800     COMPILER_NAME=$2
801     @@ -81,7 +131,8 @@
802    
803     # First line typically looks something like:
804     # gcc (Ubuntu/Linaro 4.5.2-8ubuntu4) 4.5.2
805     - COMPILER_VERSION=`$ECHO $COMPILER_VERSION_TEST | $SED -n "s/^.* \(@<:@1-9@:>@@<:@0-9.@:>@*\)/\1/p"`
806     + COMPILER_VERSION=`$ECHO $COMPILER_VERSION_TEST | \
807     + $SED -e 's/^.* \(@<:@1-9@:>@\.@<:@0-9.@:>@*\)@<:@^0-9.@:>@.*$/\1/'`
808     COMPILER_VENDOR=`$ECHO $COMPILER_VERSION_TEST | $SED -n "s/^\(.*\) @<:@1-9@:>@@<:@0-9.@:>@*/\1/p"`
809     fi
810     # This sets CC_VERSION or CXX_VERSION. (This comment is a grep marker)
811     @@ -181,7 +232,7 @@
812     AC_MSG_RESULT([no, keeping $1])
813     $1="$TEST_COMPILER"
814     fi
815     - TOOLCHAIN_CHECK_COMPILER_VERSION([$1], [$COMPILER_NAME])
816     + TOOLCHAIN_EXTRACT_COMPILER_VERSION([$1], [$COMPILER_NAME])
817     ])
818    
819    
820     @@ -385,6 +436,12 @@
821     # Now that we have resolved CXX ourself, let autoconf have its go at it
822     AC_PROG_CXX([$CXX])
823    
824     + # This is the compiler version number on the form X.Y[.Z]
825     + AC_SUBST(CC_VERSION)
826     + AC_SUBST(CXX_VERSION)
827     +
828     + TOOLCHAIN_PREPARE_FOR_VERSION_COMPARISONS
829     +
830     ### Locate other tools
831    
832     if test "x$OPENJDK_TARGET_OS" = xmacosx; then
833     @@ -507,7 +564,8 @@
834     BASIC_FIXUP_EXECUTABLE(DUMPBIN)
835    
836     COMPILER_TYPE=CL
837     - CCXXFLAGS="$CCXXFLAGS -nologo"
838     + # silence copyright notice and other headers.
839     + COMMON_CCXXFLAGS="$COMMON_CCXXFLAGS -nologo"
840     ])
841     AC_SUBST(RC_FLAGS)
842     AC_SUBST(COMPILER_TYPE)
843     @@ -954,12 +1012,20 @@
844     #
845     # Now setup the CFLAGS and LDFLAGS for the JDK build.
846     # Later we will also have CFLAGS and LDFLAGS for the hotspot subrepo build.
847     + # CFLAGS_JDK - C Compiler flags
848     + # CXXFLAGS_JDK - C++ Compiler flags
849     + # COMMON_CCXXFLAGS_JDK - common to C and C++
850     #
851     case $COMPILER_NAME in
852     gcc )
853     - CCXXFLAGS_JDK="$CCXXFLAGS $CCXXFLAGS_JDK -W -Wall -Wno-unused -Wno-parentheses \
854     + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS $COMMON_CCXXFLAGS_JDK -W -Wall -Wno-unused -Wno-parentheses \
855     -pipe \
856     -D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE"
857     + CXXSTD_CXXFLAG="-std=gnu++98"
858     + TOOLCHAIN_CXX_COMPILER_CHECK_ARGUMENTS([$CXXSTD_CXXFLAG $CFLAGS_WARNINGS_ARE_ERRORS],
859     + [], [CXXSTD_CXXFLAG=""])
860     + CXXFLAGS_JDK="${CXXFLAGS_JDK} ${CXXSTD_CXXFLAG}"
861     + AC_SUBST([CXXSTD_CXXFLAG])
862     case $OPENJDK_TARGET_CPU_ARCH in
863     arm )
864     # on arm we don't prevent gcc to omit frame pointer but do prevent strict aliasing
865     @@ -969,16 +1035,17 @@
866     # on ppc we don't prevent gcc to omit frame pointer nor strict-aliasing
867     ;;
868     * )
869     - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -fno-omit-frame-pointer"
870     + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -fno-omit-frame-pointer"
871     CFLAGS_JDK="${CFLAGS_JDK} -fno-strict-aliasing"
872     ;;
873     esac
874     + TOOLCHAIN_CHECK_COMPILER_VERSION(6, TOOLCHAIN_SETUP_GCC6_COMPILER_FLAGS)
875     ;;
876     ossc )
877     - CCXXFLAGS_JDK="$CCXXFLAGS $CCXXFLAGS_JDK -DTRACING -DMACRO_MEMSYS_OPS -DBREAKPTS"
878     + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS $COMMON_CCXXFLAGS_JDK -DTRACING -DMACRO_MEMSYS_OPS -DBREAKPTS"
879     case $OPENJDK_TARGET_CPU_ARCH in
880     x86 )
881     - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DcpuIntel -Di586 -D$OPENJDK_TARGET_CPU_LEGACY_LIB"
882     + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DcpuIntel -Di586 -D$OPENJDK_TARGET_CPU_LEGACY_LIB"
883     CFLAGS_JDK="$CFLAGS_JDK -erroff=E_BAD_PRAGMA_PACK_VALUE"
884     ;;
885     esac
886     @@ -997,16 +1064,16 @@
887     LDFLAGS_CXX_JDK="$LDFLAGS_CXX_JDK"
888     ;;
889     cl )
890     - CCXXFLAGS_JDK="$CCXXFLAGS $CCXXFLAGS_JDK -Zi -MD -Zc:wchar_t- -W3 -wd4800 \
891     + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS $COMMON_CCXXFLAGS_JDK -Zi -MD -Zc:wchar_t- -W3 -wd4800 \
892     -D_STATIC_CPPLIB -D_DISABLE_DEPRECATE_STATIC_CPPLIB -DWIN32_LEAN_AND_MEAN \
893     -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE \
894     -DWIN32 -DIAL"
895     case $OPENJDK_TARGET_CPU in
896     x86 )
897     - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_X86_ -Dx86"
898     + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D_X86_ -Dx86"
899     ;;
900     x86_64 )
901     - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_AMD64_ -Damd64"
902     + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D_AMD64_ -Damd64"
903     ;;
904     esac
905     ;;
906     @@ -1036,7 +1103,7 @@
907     ;;
908     esac
909    
910     - CCXXFLAGS_JDK="$CCXXFLAGS_JDK $ADD_LP64"
911     + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK $ADD_LP64"
912    
913     # The package path is used only on macosx?
914     PACKAGE_PATH=/opt/local
915     @@ -1049,27 +1116,27 @@
916     # Note: -Dmacro is the same as #define macro 1
917     # -Dmacro= is the same as #define macro
918     if test "x$OPENJDK_TARGET_OS" = xsolaris; then
919     - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_LITTLE_ENDIAN="
920     + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D_LITTLE_ENDIAN="
921     else
922     - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_LITTLE_ENDIAN"
923     + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D_LITTLE_ENDIAN"
924     fi
925     else
926     - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_BIG_ENDIAN"
927     + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D_BIG_ENDIAN"
928     fi
929     if test "x$OPENJDK_TARGET_OS" = xlinux; then
930     - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DLINUX"
931     + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DLINUX"
932     fi
933     if test "x$OPENJDK_TARGET_OS" = xwindows; then
934     - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DWINDOWS"
935     + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DWINDOWS"
936     fi
937     if test "x$OPENJDK_TARGET_OS" = xsolaris; then
938     - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DSOLARIS"
939     + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DSOLARIS"
940     fi
941     if test "x$OPENJDK_TARGET_OS" = xaix; then
942     - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DAIX -DPPC64"
943     + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DAIX -DPPC64"
944     fi
945     if test "x$OPENJDK_TARGET_OS" = xmacosx; then
946     - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DMACOSX -D_ALLBSD_SOURCE -D_DARWIN_UNLIMITED_SELECT"
947     + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DMACOSX -D_ALLBSD_SOURCE -D_DARWIN_UNLIMITED_SELECT"
948     # Setting these parameters makes it an error to link to macosx APIs that are
949     # newer than the given OS version and makes the linked binaries compatible even
950     # if built on a newer version of the OS.
951     @@ -1079,25 +1146,25 @@
952     # The macro takes the version with no dots, ex: 1070
953     # Let the flags variables get resolved in make for easier override on make
954     # command line.
955     - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DMAC_OS_X_VERSION_MAX_ALLOWED=\$(subst .,,\$(MACOSX_VERSION_MIN)) -mmacosx-version-min=\$(MACOSX_VERSION_MIN)"
956     + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DMAC_OS_X_VERSION_MAX_ALLOWED=\$(subst .,,\$(MACOSX_VERSION_MIN)) -mmacosx-version-min=\$(MACOSX_VERSION_MIN)"
957     LDFLAGS_JDK="$LDFLAGS_JDK -mmacosx-version-min=\$(MACOSX_VERSION_MIN)"
958     fi
959     if test "x$OPENJDK_TARGET_OS" = xbsd; then
960     - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DBSD -D_ALLBSD_SOURCE"
961     + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DBSD -D_ALLBSD_SOURCE"
962     fi
963     if test "x$DEBUG_LEVEL" = xrelease; then
964     - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DNDEBUG"
965     + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DNDEBUG"
966     if test "x$OPENJDK_TARGET_OS" = xsolaris; then
967     - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DTRIMMED"
968     + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DTRIMMED"
969     fi
970     else
971     - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DDEBUG"
972     + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DDEBUG"
973     fi
974    
975     - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DARCH='\"$OPENJDK_TARGET_CPU_LEGACY\"' -D$OPENJDK_TARGET_CPU_LEGACY"
976     - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DRELEASE='\"\$(RELEASE)\"'"
977     + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DARCH='\"$OPENJDK_TARGET_CPU_LEGACY\"' -D$OPENJDK_TARGET_CPU_LEGACY"
978     + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DRELEASE='\"\$(RELEASE)\"'"
979    
980     - CCXXFLAGS_JDK="$CCXXFLAGS_JDK \
981     + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK \
982     -I${JDK_OUTPUTDIR}/include \
983     -I${JDK_OUTPUTDIR}/include/$OPENJDK_TARGET_OS \
984     -I${JDK_TOPDIR}/src/share/javavm/export \
985     @@ -1106,12 +1173,12 @@
986     -I${JDK_TOPDIR}/src/$OPENJDK_TARGET_OS_API_DIR/native/common"
987    
988     # The shared libraries are compiled using the picflag.
989     - CFLAGS_JDKLIB="$CCXXFLAGS_JDK $CFLAGS_JDK $PICFLAG $CFLAGS_JDKLIB_EXTRA"
990     - CXXFLAGS_JDKLIB="$CCXXFLAGS_JDK $CXXFLAGS_JDK $PICFLAG $CXXFLAGS_JDKLIB_EXTRA "
991     + CFLAGS_JDKLIB="$COMMON_CCXXFLAGS_JDK $CFLAGS_JDK $PICFLAG $CFLAGS_JDKLIB_EXTRA"
992     + CXXFLAGS_JDKLIB="$COMMON_CCXXFLAGS_JDK $CXXFLAGS_JDK $PICFLAG $CXXFLAGS_JDKLIB_EXTRA "
993    
994     # Executable flags
995     - CFLAGS_JDKEXE="$CCXXFLAGS_JDK $CFLAGS_JDK"
996     - CXXFLAGS_JDKEXE="$CCXXFLAGS_JDK $CXXFLAGS_JDK"
997     + CFLAGS_JDKEXE="$COMMON_CCXXFLAGS_JDK $CFLAGS_JDK"
998     + CXXFLAGS_JDKEXE="$COMMON_CCXXFLAGS_JDK $CXXFLAGS_JDK"
999    
1000     # Now this is odd. The JDK native libraries have to link against libjvm.so
1001     # On 32-bit machines there is normally two distinct libjvm.so:s, client and server.
1002     @@ -1196,13 +1263,13 @@
1003     ])
1004    
1005    
1006     -# TOOLCHAIN_COMPILER_CHECK_ARGUMENTS([ARGUMENT], [RUN-IF-TRUE],
1007     -# [RUN-IF-FALSE])
1008     +# TOOLCHAIN_C_COMPILER_CHECK_ARGUMENTS([ARGUMENT], [RUN-IF-TRUE],
1009     +# [RUN-IF-FALSE])
1010     # ------------------------------------------------------------
1011     -# Check that the c and c++ compilers support an argument
1012     -AC_DEFUN([TOOLCHAIN_COMPILER_CHECK_ARGUMENTS],
1013     +# Check that the C compiler supports an argument
1014     +AC_DEFUN([TOOLCHAIN_C_COMPILER_CHECK_ARGUMENTS],
1015     [
1016     - AC_MSG_CHECKING([if compiler supports "$1"])
1017     + AC_MSG_CHECKING([if the C compiler supports "$1"])
1018     supports=yes
1019    
1020     saved_cflags="$CFLAGS"
1021     @@ -1213,6 +1280,23 @@
1022     AC_LANG_POP([C])
1023     CFLAGS="$saved_cflags"
1024    
1025     + AC_MSG_RESULT([$supports])
1026     + if test "x$supports" = "xyes" ; then
1027     + m4_ifval([$2], [$2], [:])
1028     + else
1029     + m4_ifval([$3], [$3], [:])
1030     + fi
1031     +])
1032     +
1033     +# TOOLCHAIN_CXX_COMPILER_CHECK_ARGUMENTS([ARGUMENT], [RUN-IF-TRUE],
1034     +# [RUN-IF-FALSE])
1035     +# ------------------------------------------------------------
1036     +# Check that the C++ compiler supports an argument
1037     +AC_DEFUN([TOOLCHAIN_CXX_COMPILER_CHECK_ARGUMENTS],
1038     +[
1039     + AC_MSG_CHECKING([if the C++ compiler supports "$1"])
1040     + supports=yes
1041     +
1042     saved_cxxflags="$CXXFLAGS"
1043     CXXFLAGS="$CXXFLAG $1"
1044     AC_LANG_PUSH([C++])
1045     @@ -1220,7 +1304,32 @@
1046     [supports=no])
1047     AC_LANG_POP([C++])
1048     CXXFLAGS="$saved_cxxflags"
1049     +
1050     + AC_MSG_RESULT([$supports])
1051     + if test "x$supports" = "xyes" ; then
1052     + m4_ifval([$2], [$2], [:])
1053     + else
1054     + m4_ifval([$3], [$3], [:])
1055     + fi
1056     +])
1057    
1058     +# TOOLCHAIN_COMPILER_CHECK_ARGUMENTS([ARGUMENT], [RUN-IF-TRUE],
1059     +# [RUN-IF-FALSE])
1060     +# ------------------------------------------------------------
1061     +# Check that the C and C++ compilers support an argument
1062     +AC_DEFUN([TOOLCHAIN_COMPILER_CHECK_ARGUMENTS],
1063     +[
1064     + TOOLCHAIN_C_COMPILER_CHECK_ARGUMENTS([$1],
1065     + [C_COMP_SUPPORTS="yes"],
1066     + [C_COMP_SUPPORTS="no"])
1067     + TOOLCHAIN_CXX_COMPILER_CHECK_ARGUMENTS([$1],
1068     + [CXX_COMP_SUPPORTS="yes"],
1069     + [CXX_COMP_SUPPORTS="no"])
1070     +
1071     + AC_MSG_CHECKING([if both compilers support "$1"])
1072     + supports=no
1073     + if test "x$C_COMP_SUPPORTS" = "xyes" -a "x$CXX_COMP_SUPPORTS" = "xyes"; then supports=yes; fi
1074     +
1075     AC_MSG_RESULT([$supports])
1076     if test "x$supports" = "xyes" ; then
1077     m4_ifval([$2], [$2], [:])
1078     @@ -1311,3 +1420,20 @@
1079     AC_SUBST(JT_HOME)
1080     AC_SUBST(JTREGEXE)
1081     ])
1082     +
1083     +AC_DEFUN_ONCE([TOOLCHAIN_SETUP_GCC6_COMPILER_FLAGS],
1084     +[
1085     + # These flags are required for GCC 6 builds as undefined behaviour in OpenJDK code
1086     + # runs afoul of the more aggressive versions of these optimisations.
1087     + # Notably, value range propagation now assumes that the this pointer of C++
1088     + # member functions is non-null.
1089     + NO_DELETE_NULL_POINTER_CHECKS_CFLAG="-fno-delete-null-pointer-checks"
1090     + TOOLCHAIN_COMPILER_CHECK_ARGUMENTS([$NO_DELETE_NULL_POINTER_CHECKS_CFLAG -Werror],
1091     + [], [NO_DELETE_NULL_POINTER_CHECKS_CFLAG=""])
1092     + AC_SUBST([NO_DELETE_NULL_POINTER_CHECKS_CFLAG])
1093     + NO_LIFETIME_DSE_CFLAG="-fno-lifetime-dse"
1094     + TOOLCHAIN_COMPILER_CHECK_ARGUMENTS([$NO_LIFETIME_DSE_CFLAG -Werror],
1095     + [], [NO_LIFETIME_DSE_CFLAG=""])
1096     + CFLAGS_JDK="${CFLAGS_JDK} ${NO_DELETE_NULL_POINTER_CHECKS_CFLAG} ${NO_LIFETIME_DSE_CFLAG}"
1097     + AC_SUBST([NO_LIFETIME_DSE_CFLAG])
1098     +])