RFR: 8370438: Offer link time optimization support on library level [v8]
Erik Joelsson
erikj at openjdk.org
Thu Nov 6 14:01:59 UTC 2025
On Thu, 6 Nov 2025 13:52:23 GMT, Matthias Baesken <mbaesken at openjdk.org> wrote:
>> We currently have support for LTO (link time optimization) for Hotspot/libjvm, that can be enabled as a JVM feature.
>> But for other JDK native libs, we do not have support for this feature.
>> LTO and sometimes lead to faster and also in some cases smaller binaries, so support for this might be interesting also for other libs and not only libjvm.
>
> Matthias Baesken has updated the pull request incrementally with one additional commit since the last revision:
>
> Simplify lto flag assignment for hs in JvmFeatures.gmk
make/hotspot/lib/JvmFeatures.gmk line 182:
> 180: JVM_LDFLAGS_FEATURES += $(LDFLAGS_LTO)
> 181: else
> 182: JVM_LDFLAGS_FEATURES += $(CXX_O_FLAG_HIGHEST_JVM) $(LDFLAGS_LTO)
That's better, but looking at this again, if we are now abstracting LTO support into `SetupNativeCompilation`, then CompileJvm.gmk/JvmFeatures.gmk should use that instead of adding the flags manually. What I mean is, in this conditional on the jvm feature `link-time-opt`, a variable should be set that causes `LINK_TIME_OPTIMIZATION` to be set to true for libjvm. No LTO flags should be explicitly added here, just the optimization flag for gcc/clang.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/27976#discussion_r2499068717
More information about the client-libs-dev
mailing list