Webrev: https://cr.openjdk.java.net/~andrew/openjdk8/8223219/webrev.01/
Bug: https://bugs.openjdk.java.net/browse/JDK-8223219

There's quite a long story to this one, more detail of which is in the
bug report. In short, JDK-8199552 was backported as part of a CPU with
no review and so little explanation for the changes contained therein,
which differ from the same change in OpenJDK 11.

The end result is that -fstack-protector is added for only two
architectures - x86 and x86_64 - and it ends up appearing twice for the
JDK part of the build, the second appearance overriding any options
specified using --with-extra-cflags. This is a problem for distros which
may want to use -fstack-protector-strong instead. This patch simplifies
it down to one addition for all architectures.

We've been using this patch (or a variant of it) since the January CPU
on all architectures we build on (AArch64, s390, s390x, ppc, ppc64,
ppc64le, x86 & x86_64) without known issues.

Before patch:

 [7] CFLAGS := -Wall -Wno-parentheses -Wextra -Wno-unused
-Wno-unused-parameter -Wformat=2 -pipe -D_GNU_SOURCE -D_REENTRANT
-D_LARGEFILE64_SOURCE -fno-omit-frame-pointer -fstack-protector
-D_LP64=1 -D_LITTLE_ENDIAN -DLINUX -DARCH='"amd64"' -Damd64 -DNDEBUG
-DRELEASE='"1.8.0-internal"' -I/home/andrew/builder/8u-dev/jdk/include
-I/home/andrew/builder/8u-dev/jdk/include/linux
-I/home/andrew/projects/openjdk/upstream/jdk8u-dev/jdk/src/share/javavm/export
-I/home/andrew/projects/openjdk/upstream/jdk8u-dev/jdk/src/solaris/javavm/export
-I/home/andrew/projects/openjdk/upstream/jdk8u-dev/jdk/src/share/native/common
-I/home/andrew/projects/openjdk/upstream/jdk8u-dev/jdk/src/solaris/native/common
-O2 -pipe -march=core2 -mno-tls-direct-seg-refs -Wno-error=return-type
-Wno-error=deprecated-declarations -fno-strict-aliasing
-fstack-protector -fno-delete-null-pointer-checks -fno-lifetime-dse
-fPIC -I/home/andrew/builder/8u-dev/jdk/gensrc_headers
-I/home/andrew/projects/openjdk/upstream/jdk8u-dev/jdk/src/share/nativ\
e/java/lang/fdlibm/include

After patch (the -fstack-protector duplicate after -fno-strict-aliasing
is gone):

 [7] CFLAGS := -Wall -Wno-parentheses -Wextra -Wno-unused
-Wno-unused-parameter -Wformat=2 -pipe -fstack-protector -D_GNU_SOURCE
-D_REENTRANT -D_LARGEFILE64_SOURCE -fno-omit-frame-pointer -D_LP64=1
-D_LITTLE_ENDIAN -DLINUX -DARCH='"amd64"' -Damd64 -DNDEBUG
-DRELEASE='"1.8.0-internal"' -I/home/andrew/builder/8u-dev/jdk/include
-I/home/andrew/builder/8u-dev/jdk/include/linux
-I/home/andrew/projects/openjdk/upstream/jdk8u-dev/jdk/src/share/javavm/export
-I/home/andrew/projects/openjdk/upstream/jdk8u-dev/jdk/src/solaris/javavm/export
-I/home/andrew/projects/openjdk/upstream/jdk8u-dev/jdk/src/share/native/common
-I/home/andrew/proje\
cts/openjdk/upstream/jdk8u-dev/jdk/src/solaris/native/common -O2 -pipe
-march=core2 -ggdb -mno-tls-direct-seg-refs -Wno-error=return-type
-Wno-error=deprecated-declarations -fno-strict-aliasing
-fno-delete-null-pointer-checks -fno-lifetime-dse -fPIC
-I/home/andrew/builder/8u-dev/jdk/gensrc_headers
-I/home/andrew/projects/openjdk/upstream/jdk8u-dev/jdk/src/share/native/java/lang/fdlibm/include

Ok to push?

Thanks,
-- 
Andrew :)

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

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

Reply via email to