summaryrefslogtreecommitdiffstats
path: root/recipes-core/openjdk
diff options
context:
space:
mode:
authorAndré Draszik <andre.draszik@jci.com>2018-03-15 13:45:47 +0200
committerMaxin B. John <maxin.john@intel.com>2018-03-15 13:47:20 +0200
commitaf897090975d102d6136b2b64164b78da3b381c9 (patch)
tree146aabc72c97c5ee67ae6db4d7e81e109bbac470 /recipes-core/openjdk
parent536cee3023d3464f9eb798459509719bed765c10 (diff)
downloadmeta-java-af897090975d102d6136b2b64164b78da3b381c9.tar.gz
openjdk-8: fix build with --as-needed host toolchains (Ubuntu 16.04)
As per the commit message - build on hosts with --as-needed toolchains (Ubuntu 16.04) using system provided zlib fails: If the (host) toolchain has been configured to unconditionally add --as-needed to the linker command line then linking can fail when using system libraries. The reason is that the order of command line arguments becomes important with --as-needed and the JDK build system places needed system libraries at the beginning of the command line where it would normally place the object files from its own bundled compiled version. Having those system libraries early in the command line is not useful, as they are discarded by the linker at that point in time as it hasn't seen any reference to the symbols provided yet. As it seems a generic pattern in the makefiles here, just place the $EXPECTED_OBJS early in the command line, before any additional libraries, so as to fix this once and for all. Signed-off-by: André Draszik <andre.draszik@jci.com> Signed-off-by: Maxin B. John <maxin.john@intel.com>
Diffstat (limited to 'recipes-core/openjdk')
-rw-r--r--recipes-core/openjdk/openjdk-8-release-16xbyy.inc1
-rw-r--r--recipes-core/openjdk/patches-openjdk-8/0010-build-fix-build-on-as-needed-toolchains-generic.patch91
2 files changed, 92 insertions, 0 deletions
diff --git a/recipes-core/openjdk/openjdk-8-release-16xbyy.inc b/recipes-core/openjdk/openjdk-8-release-16xbyy.inc
index ab72830..bd4a349 100644
--- a/recipes-core/openjdk/openjdk-8-release-16xbyy.inc
+++ b/recipes-core/openjdk/openjdk-8-release-16xbyy.inc
@@ -15,6 +15,7 @@ PATCHES_URI = "\
15 file://0007-jdk-use-correct-include-for-poll.patch \ 15 file://0007-jdk-use-correct-include-for-poll.patch \
16 file://0008-jdk-use-correct-include-for-signal.patch \ 16 file://0008-jdk-use-correct-include-for-signal.patch \
17 file://0009-jdk-disable-backtrace-musl-build-fix.patch \ 17 file://0009-jdk-disable-backtrace-musl-build-fix.patch \
18 file://0010-build-fix-build-on-as-needed-toolchains-generic.patch \
18" 19"
19# some patches extracted from http://cr.openjdk.java.net/~rkennke/shark-build-hotspot/webrev.01/hotspot.patch 20# some patches extracted from http://cr.openjdk.java.net/~rkennke/shark-build-hotspot/webrev.01/hotspot.patch
20# reported via http://mail.openjdk.java.net/pipermail/build-dev/2015-January/013972.html 21# reported via http://mail.openjdk.java.net/pipermail/build-dev/2015-January/013972.html
diff --git a/recipes-core/openjdk/patches-openjdk-8/0010-build-fix-build-on-as-needed-toolchains-generic.patch b/recipes-core/openjdk/patches-openjdk-8/0010-build-fix-build-on-as-needed-toolchains-generic.patch
new file mode 100644
index 0000000..7decd5e
--- /dev/null
+++ b/recipes-core/openjdk/patches-openjdk-8/0010-build-fix-build-on-as-needed-toolchains-generic.patch
@@ -0,0 +1,91 @@
1From 84bcdb9cdab0e0be9cdfededfb518d3cea9009e3 Mon Sep 17 00:00:00 2001
2From: =?UTF-8?q?Andr=C3=A9=20Draszik?= <andre.draszik at jci.com>
3Date: Mon, 12 Mar 2018 15:40:58 +0000
4Subject: [PATCH] build: fix build on --as-needed toolchains (generic)
5MIME-Version: 1.0
6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit
8
9If the (host) toolchain has been configured to
10unconditionally add --as-needed to the linker command line
11then linking fails when using the system zlib:
12 + ...gcc -lz -L<sysroot>/usr/lib -L<sysroot>/lib \
13 -Wl,-rpath-link,<sysroot>/usr/lib -Wl,-rpath-link,<sysroot>/lib \
14 -Wl,-rpath,<sysroot>/usr/lib -Wl,-rpath,<sysroot>/lib \
15 -Wl,-O1 -Xlinker --hash-style=both -Xlinker -z -Xlinker defs -Xlinker -O1 \
16 -Xlinker --allow-shlib-undefined -Xlinker -soname=libunpack.so \
17 -Xlinker -z -Xlinker origin -Xlinker -rpath -Xlinker '$ORIGIN' \
18 -lc \
19 -Xlinker -version-script=<src>/jdk/make/mapfiles/libunpack/mapfile-vers-unpack200 \
20 -o $build/jdk/objs/unpackexe/unpack200 \
21 $build/jdk/objs/unpackexe/bands.o $build/jdk/objs/unpackexe/bytes.o \
22 $build/jdk/objs/unpackexe/coding.o $build/jdk/objs/unpackexe/main.o \
23 $build/jdk/objs/unpackexe/unpack.o $build/jdk/objs/unpackexe/utils.o \
24 $build/jdk/objs/unpackexe/zip.o -lstdc++
25 $build/jdk/objs/unpackexe/zip.o: In function `jar::deflate_bytes(bytes&, bytes&)':
26 $src/jdk/src/share/native/com/sun/java/util/jar/pack/zip.cpp:464: undefined reference to `deflateInit2_'
27 $src/jdk/src/share/native/com/sun/java/util/jar/pack/zip.cpp:507: undefined reference to `deflate'
28 $src/jdk/src/share/native/com/sun/java/util/jar/pack/zip.cpp:514: undefined reference to `deflateEnd'
29 $src/jdk/src/share/native/com/sun/java/util/jar/pack/zip.cpp:502: undefined reference to `deflate'
30 $src/jdk/src/share/native/com/sun/java/util/jar/pack/zip.cpp:518: undefined reference to `deflateEnd'
31 $build/jdk/objs/unpackexe/zip.o: In function `jar::get_crc32(unsigned int, unsigned char*, unsigned int)':
32 $src/jdk/src/share/native/com/sun/java/util/jar/pack/zip.cpp:61: undefined reference to `crc32'
33 $src/jdk/src/share/native/com/sun/java/util/jar/pack/zip.cpp:61: undefined reference to `crc32'
34 $src/jdk/src/share/native/com/sun/java/util/jar/pack/zip.cpp:61: undefined reference to `crc32'
35 $build/jdk/objs/unpackexe/zip.o: In function `gunzip::free()':
36 $src/jdk/src/share/native/com/sun/java/util/jar/pack/zip.cpp:645: undefined reference to `inflateEnd'
37 $build/jdk/objs/unpackexe/zip.o: In function `read_input_via_gzip(unpacker*, void*, long, long)':
38 $src/jdk/src/share/native/com/sun/java/util/jar/pack/zip.cpp:548: undefined reference to `inflate'
39 $src/jdk/src/share/native/com/sun/java/util/jar/pack/zip.cpp:548: undefined reference to `inflate'
40 $build/jdk/objs/unpackexe/zip.o: In function `gunzip::start(int)':
41 $src/jdk/src/share/native/com/sun/java/util/jar/pack/zip.cpp:637: undefined reference to `inflateInit2_'
42 collect2: error: ld returned 1 exit status
43
44(as happened on a Ubuntu 16.04 xenial host:
45 gcc --version
46 gcc (Ubuntu 5.4.0-6ubuntu1~16.04.9) 5.4.0 20160609
47 Copyright (C) 2015 Free Software Foundation, Inc.
48 This is free software; see the source for copying conditions. There is NO
49 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
50)
51
52The reason is that the order of command line arguments
53becomes important with --as-needed and the JDK build system
54places -lz at the beginning of the command line where it
55would normally place the zlib object files from its own
56bundled compiled version.
57
58Having -lz early in the command line is not useful, as it
59is discarded by the linker at that point in time as it
60hasn't seen any reference to the symbols provided yet.
61
62As it seems a generic pattern in the makefiles here, just
63place the $EXPECTED_OBJS early in the command line, before
64any additional libraries, so as to fix this once and for
65all.
66
67Signed-off-by: André Draszik <andre.draszik at jci.com>
68---
69Upstream-Status: Pending
70 make/common/NativeCompilation.gmk | 5 ++---
71 1 file changed, 2 insertions(+), 3 deletions(-)
72
73diff --git a/make/common/NativeCompilation.gmk b/make/common/NativeCompilation.gmk
74index e7ea22ce..79f081fd 100644
75--- a/make/common/NativeCompilation.gmk
76+++ b/make/common/NativeCompilation.gmk
77@@ -477,9 +477,8 @@ define SetupNativeCompilation
78
79 $$($1_TARGET) : $$($1_EXPECTED_OBJS) $$($1_RES) $$($1_GEN_MANIFEST)
80 $$(call LINKING_EXE_MSG,$$($1_BASENAME))
81- $$($1_LDEXE) $$($1_LDFLAGS) $$($1_EXTRA_LDFLAGS) $(EXE_OUT_OPTION)$$($1_TARGET) \
82- $$($1_EXPECTED_OBJS) $$($1_RES) $$($1_LDFLAGS_SUFFIX) \
83- $$($1_EXTRA_LDFLAGS_SUFFIX)
84+ $$($1_LDEXE) $$($1_EXPECTED_OBJS) $$($1_LDFLAGS) $$($1_EXTRA_LDFLAGS) $(EXE_OUT_OPTION)$$($1_TARGET) \
85+ $$($1_RES) $$($1_LDFLAGS_SUFFIX) $$($1_EXTRA_LDFLAGS_SUFFIX)
86 ifneq (,$$($1_GEN_MANIFEST))
87 $(MT) -nologo -manifest $$($1_GEN_MANIFEST) -outputresource:$$@;#1
88 endif
89--
902.16.2
91