[yocto] [meta-java][PATCH 07/14] openjdk-8: add patch for compiling with enabled security flags

André Draszik git at andred.net
Mon Mar 5 01:30:59 PST 2018


From: André Draszik <andre.draszik at jci.com>

Rather than carrying an OE specific patch that just silences the
warning on some platform only, backport the upstream patch
to actually fix the issue.

Signed-off-by: André Draszik <andre.draszik at jci.com>
---
 recipes-core/openjdk/openjdk-8-release-162b12.inc  |  2 +-
 ...x-compilation-with-security-flags-enabled.patch | 41 ++++++++++++++++
 ...openjdk8-silence-d_fortify_source-warning.patch | 56 ----------------------
 3 files changed, 42 insertions(+), 57 deletions(-)
 create mode 100644 recipes-core/openjdk/patches-openjdk-8/0002-hotspot-fix-compilation-with-security-flags-enabled.patch
 delete mode 100644 recipes-core/openjdk/patches-openjdk-8/openjdk8-silence-d_fortify_source-warning.patch

diff --git a/recipes-core/openjdk/openjdk-8-release-162b12.inc b/recipes-core/openjdk/openjdk-8-release-162b12.inc
index 5a577b9..a36bc6a 100644
--- a/recipes-core/openjdk/openjdk-8-release-162b12.inc
+++ b/recipes-core/openjdk/openjdk-8-release-162b12.inc
@@ -7,6 +7,7 @@ PATCHES_URI = "\
     file://openjdk8-find-compiler-fix-env-respect.patch;striplevel=0 \
     file://openjdk8-prevent-debuginfo-in-favour-of-openembedded-package-split.patch;striplevel=0 \
     file://0001-jdk-comparison-between-pointer-and-integer.patch \
+    file://0002-hotspot-fix-compilation-with-security-flags-enabled.patch \
 "
 # some patches extracted from http://cr.openjdk.java.net/~rkennke/shark-build-hotspot/webrev.01/hotspot.patch
 # reported via http://mail.openjdk.java.net/pipermail/build-dev/2015-January/013972.html
@@ -17,7 +18,6 @@ PATCHES_URI_append_class-target = "\
     file://openjdk8-fix-shark-stdc++11.patch;striplevel=0 \
     file://openjdk8-fix-assembler-flag-handling-in-makefile.patch;striplevel=0 \
     file://openjdk8-fix-adlc-flags.patch;striplevel=0 \
-    file://openjdk8-silence-d_fortify_source-warning.patch;striplevel=0 \
     file://openjdk8-add-missing-linker-flags.patch;striplevel=0 \
     file://openjdk8-fix-libpng-neon-build.patch;striplevel=0 \
 "
diff --git a/recipes-core/openjdk/patches-openjdk-8/0002-hotspot-fix-compilation-with-security-flags-enabled.patch b/recipes-core/openjdk/patches-openjdk-8/0002-hotspot-fix-compilation-with-security-flags-enabled.patch
new file mode 100644
index 0000000..f06e791
--- /dev/null
+++ b/recipes-core/openjdk/patches-openjdk-8/0002-hotspot-fix-compilation-with-security-flags-enabled.patch
@@ -0,0 +1,41 @@
+From bdea8cf299313388ec41ea20281deca6dc4f764d Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Andr=C3=A9=20Draszik?= <andre.draszik at jci.com>
+Date: Tue, 27 Feb 2018 14:41:06 +0000
+Subject: [PATCH 2/8] hotspot: fix compilation with security flags enabled
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+| hotspot/src/share/vm/code/dependencies.cpp: In function 'static void Dependencies::write_dependency_to(xmlStream*, Dependencies::DepType, GrowableArray<Dependencies::DepArgument>*, Klass*)':
+| hotspot/src/share/vm/code/dependencies.cpp:498:6: error: '%d' directive writing between 1 and 10 bytes into a region of size 9 [-Werror=format-overflow=]
+|  void Dependencies::write_dependency_to(xmlStream* xtty,
+|       ^~~~~~~~~~~~
+| hotspot/src/share/vm/code/dependencies.cpp:498:6: note: directive argument in the range [0, 2147483647]
+| hotspot/src/share/vm/code/dependencies.cpp:528:27: note: 'sprintf' output between 3 and 12 bytes into a destination of size 10
+|        char xn[10]; sprintf(xn, "x%d", j);
+|                     ~~~~~~~^~~~~~~~~~~~~~
+
+Backport a patch to fix this.
+
+Upstream-Status: Backport [http://hg.openjdk.java.net/jdk10/jdk10/hotspot/rev/eb11b3f0ae65]
+Signed-off-by: André Draszik <andre.draszik at jci.com>
+---
+ hotspot/src/share/vm/code/dependencies.cpp | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/hotspot/src/share/vm/code/dependencies.cpp b/hotspot/src/share/vm/code/dependencies.cpp
+index 7317036d..c71d921d 100644
+--- a/hotspot/src/share/vm/code/dependencies.cpp
++++ b/hotspot/src/share/vm/code/dependencies.cpp
+@@ -525,7 +525,7 @@ void Dependencies::write_dependency_to(xmlStream* xtty,
+         xtty->object("x", arg.metadata_value());
+       }
+     } else {
+-      char xn[10]; sprintf(xn, "x%d", j);
++      char xn[12]; sprintf(xn, "x%d", j);
+       if (arg.is_oop()) {
+         xtty->object(xn, arg.oop_value());
+       } else {
+-- 
+2.16.2
+
diff --git a/recipes-core/openjdk/patches-openjdk-8/openjdk8-silence-d_fortify_source-warning.patch b/recipes-core/openjdk/patches-openjdk-8/openjdk8-silence-d_fortify_source-warning.patch
deleted file mode 100644
index 2c2e333..0000000
--- a/recipes-core/openjdk/patches-openjdk-8/openjdk8-silence-d_fortify_source-warning.patch
+++ /dev/null
@@ -1,56 +0,0 @@
-makefiles: Add -Wno-cpp to CFLAGS
-
-The security flag '-D_FORTIFY_SOURCE' requires at least -O to work,
-otherwise a warning is given. If CFLAGS additionally contains -Werror,
-this warning turns into an error. As Openjdk build system intentionally
-deoptimizes certains files due to potential bad codegen during optimization,
-build will fail when both '-D_FORTIFY_SOURCE' and '-Werror' are used.
-As turning the optimizations back on will likely break things, the
-warning is silenced instead.
-
-Upstream-Status: Inappropriate [Yocto-specific fixes]
-
-Signed-off-by: Erkka Kääriä <erkka.kaaria at intel.com>
----
- hotspot/make/linux/makefiles/amd64.make | 2 ++
- hotspot/make/linux/makefiles/i486.make  | 2 ++
- hotspot/make/linux/makefiles/zero.make  | 2 ++
- 3 files changed, 6 insertions(+)
-
-diff --git hotspot/make/linux/makefiles/amd64.make hotspot/make/linux/makefiles/amd64.make
-index 2b77dba..db3965b 100644
---- hotspot/make/linux/makefiles/amd64.make
-+++ hotspot/make/linux/makefiles/amd64.make
-@@ -31,4 +31,6 @@ CFLAGS += -DVM_LITTLE_ENDIAN
-
- CFLAGS += -D_LP64=1
-
-+CFLAGS += -Wno-cpp
-+
- OPT_CFLAGS/compactingPermGenGen.o = -O1
-diff --git hotspot/make/linux/makefiles/i486.make hotspot/make/linux/makefiles/i486.make
-index 86e825d..6a92f09 100644
---- hotspot/make/linux/makefiles/i486.make
-+++ hotspot/make/linux/makefiles/i486.make
-@@ -31,4 +31,6 @@ OPT_CFLAGS/sharedRuntimeTrans.o = $(OPT_CFLAGS/NOOPT)
- # Must also specify if CPU is little endian
- CFLAGS += -DVM_LITTLE_ENDIAN
-
-+CFLAGS += -Wno-cpp
-+
- OPT_CFLAGS/compactingPermGenGen.o = -O1
-diff --git hotspot/make/linux/makefiles/zero.make hotspot/make/linux/makefiles/zero.make
-index 0270711..2b05f33 100644
---- hotspot/make/linux/makefiles/zero.make
-+++ hotspot/make/linux/makefiles/zero.make
-@@ -28,5 +28,7 @@
- # Select which files to use (in top.make)
- TYPE = ZERO
-
-+CFLAGS += -Wno-cpp
-+
- # Install libjvm.so, etc in in server directory.
- VM_SUBDIR = server
---
-2.7.4
-
-- 
2.16.2




More information about the yocto mailing list