[8u112] Request for review & approval for CR8151841: Build needs additional flags to compile with GCC 6

Andrew Hughes gnu.andrew at redhat.com
Thu Jul 7 20:21:02 UTC 2016

Webrev: http://cr.openjdk.java.net/~andrew/8u/8151841/webrev.01/
Bug: https://bugs.openjdk.java.net/browse/JDK-8151841

This is a backport of the original fix to support building OpenJDK
with GCC 6. It was necessary to cherry-pick parts of a number of
earlier fixes to make this work with the build system in 8:

8149647: Incremental enhancements from build-infra
8032045: Enable compiler and linker safety switches for debug builds

and so I'm requesting a review of the 8 version of the patch here as well
as approval for 8u.

In brief, the patch makes OpenJDK build with GCC 6 by explicitly specifying
the C++ standard to use (-std=gnu++98) and disabling two optimisations with
-fno-lifetime-dse and -fno-delete-null-pointer-checks. Further information
on the changes is available in the GCC 6 release notes [0]. GCC 6 uses
a newer C++ standard, C++14, with which the OpenJDK codebase is not yet
compliant. The simplest way to fix this, especially for existing releases,
is to explicitly request the previous default, gnu++98. The deletion
of null pointer checks and more aggressive lifetime dead store elimination
in 6 lead to a crashing virtual machine being built, so we disable them
if GCC >= 6 is used.

To make the original patch work with 8u, a number of changes from other
fixes had to also be brought over:

* We need to check we are using GCC 6 or above, so we need to bring
TOOLCHAIN_CHECK_COMPILER_VERSION is converted back to a traditional
numbered rather than named argument macro so we don't need to backport
* We bring over the introduction of COMMON_CCXXFLAGS_JDK from 8030245
as we need to apply the -std option only to the C++ compiler, not the
C compiler. If passed to the C compiler, it will produce a warning,
and this is converted to an error at one point in the build
(a -Werror in libsctp).

Generally, we've kept things in toolchain.m4 (8034788 introduced flags.m4,
separating out some code, and so many of these changes are in that file
in 9) and avoid named argument macros. Otherwise, it's largely the
same as the 9 version. We have adopted the longer name for
the -fno-delete-null-pointer-checks flag variable as suggested in the
review of the update to this patch for the new HotSpot build [1].

[0] https://gcc.gnu.org/gcc-6/porting_to.html
[1] http://mail.openjdk.java.net/pipermail/hotspot-dev/2016-July/023840.html
Andrew :)

Senior Free Java Software Engineer
Red Hat, Inc. (http://www.redhat.com)

PGP Key: ed25519/35964222 (hkp://keys.gnupg.net)
Fingerprint = 5132 579D D154 0ED2 3E04  C5A0 CFDA 0F9B 3596 4222

More information about the jdk8u-dev mailing list