Created attachment 764818 [details, diff] openjdk-11-undefined-symbols.patch With gcc-11.2 and a bunch of aggressive optimization flags (including -O3 -flto -fdevirtualize-at-ltrans), dev-java/openjdk-11.0.14_p9-r1 fails to build. Linking $WORKDIR/jdk11u-jdk-11.0.14-ga/build/linux-x86_64-normal-server-release/support/modules_libs/java.base/server/libjvm.so results in the following errors (same for ../../../../hotspot/variant-server/libjvm/gtest/libjvm.so): /usr/lib/gcc/x86_64-pc-linux-gnu/11.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: /tmp/portage/dev-java/openjdk-11.0.14_p9-r1/temp/ccnOSc05.ltrans17.ltrans.o: in function `G1CMOopClosure::do_oop(oopDesc**)': <artificial>:(.text+0x5857): undefined reference to `void G1CMOopClosure::do_oop_work<oopDesc*>(oopDesc**)' /usr/lib/gcc/x86_64-pc-linux-gnu/11.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: /tmp/portage/dev-java/openjdk-11.0.14_p9-r1/temp/ccnOSc05.ltrans17.ltrans.o: in function `G1CMOopClosure::do_oop(unsigned int*)': <artificial>:(.text+0x5861): undefined reference to `void G1CMOopClosure::do_oop_work<unsigned int>(unsigned int*)' /usr/lib/gcc/x86_64-pc-linux-gnu/11.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: /tmp/portage/dev-java/openjdk-11.0.14_p9-r1/temp/ccnOSc05.ltrans17.ltrans.o: in function `G1RootRegionScanClosure::do_oop(oopDesc**)': <artificial>:(.text+0x5867): undefined reference to `void G1RootRegionScanClosure::do_oop_work<oopDesc*>(oopDesc**)' collect2: error: ld returned 1 exit status The reason is that the definitions of these functions are marked inline, but they're not visible everywhere the declarations are visible. And (speculative) devirtualization in the compiler can call the functions from unexpected places. See bug #833097 (related issue in openjdk:8) for a more detailed explanation. Including the header with the definitions in the affected compilation units fixes the problem for me, see attached patch.
The bug has been referenced in the following commit(s): https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=3fb095f88d00b6e9f0ac6be366117c2f7736c8db commit 3fb095f88d00b6e9f0ac6be366117c2f7736c8db Author: Georgy Yakovlev <gyakovlev@gentoo.org> AuthorDate: 2023-04-06 00:24:47 +0000 Commit: Georgy Yakovlev <gyakovlev@gentoo.org> CommitDate: 2023-04-06 00:27:42 +0000 profiles/base: mask openjdk:11[lto] Bug: https://bugs.gentoo.org/833097 Bug: https://bugs.gentoo.org/833098 Signed-off-by: Georgy Yakovlev <gyakovlev@gentoo.org> profiles/base/package.use.mask | 6 ++++++ 1 file changed, 6 insertions(+) https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=970458062aa4c59f525e447cc9f7b6251acdb2d1 commit 970458062aa4c59f525e447cc9f7b6251acdb2d1 Author: Georgy Yakovlev <gyakovlev@gentoo.org> AuthorDate: 2023-04-06 00:22:21 +0000 Commit: Georgy Yakovlev <gyakovlev@gentoo.org> CommitDate: 2023-04-06 00:27:41 +0000 dev-java/openjdk: handle lto Bug: https://bugs.gentoo.org/833098 Closes: https://bugs.gentoo.org/833097 Signed-off-by: Georgy Yakovlev <gyakovlev@gentoo.org> dev-java/openjdk/metadata.xml | 1 + dev-java/openjdk/openjdk-11.0.18_p10.ebuild | 10 +++++++++- dev-java/openjdk/openjdk-17.0.6_p10.ebuild | 10 +++++++++- dev-java/openjdk/openjdk-8.362_p09.ebuild | 6 ++++++ 4 files changed, 25 insertions(+), 2 deletions(-)
Like I described in https://bugs.gentoo.org/833097 openjdk:11 now filters out -flto* flags and has USE=lto, which activates --with-jvm-features=link-time-opt it is masked now, however, until it's fixed upstream. this way users with global -flto in cflags will get a build without lto just fine.
Old version 11.0.14_p9-r1 is gone. In case the problem persist with presently stable 11.0.22_p7, please re-open.