RFR: JDK-8190284 link-time-opt should not be using -fwhole-program
Magnus Ihse Bursie
magnus.ihse.bursie at oracle.com
Fri Oct 27 12:52:29 UTC 2017
When building hotspot with link-time-opt, we are currently using
-fwhole-program to the linker. This causes all public symbols to be
removed. To counter this, the attribute "externally_visible" has been
added to JNIEXPORT for arm (the platform that traditionally has used
This is not an appropriate way of doing things.
The gcc documentation says about "-fwhole-program": "This option should
not be used in combination with -flto. Instead relying on a linker
plugin should provide safer and more precise information."
If we replace -fwhole-program with -fuse-linker-plugin, the need to use
I intend to push this to jdk10/hs. This is a blocker for JDK-8189610.
I have verified that with this change I can build a link-time-opt
libjvm.so on my linux-x64 workstation, that passes superficial tests,
and that is ~4% smaller in size than a non-lto build.
diff --git a/make/hotspot/lib/JvmFeatures.gmk
@@ -157,7 +157,7 @@
# like the old build, but it's probably not right.
JVM_CFLAGS_FEATURES += -O3 -flto
- JVM_LDFLAGS_FEATURES += -O3 -flto -fwhole-program -fno-strict-aliasing
+ JVM_LDFLAGS_FEATURES += -O3 -flto -fuse-linker-plugin
ifeq ($(call check-jvm-feature, minimal), true)
More information about the build-dev