RFR: 8370438: Offer link time optimization support on library level [v2]

Erik Joelsson erikj at openjdk.org
Wed Oct 29 14:07:56 UTC 2025


On Wed, 29 Oct 2025 12:59:07 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:
> 
>   Do not enable LTO for some libs in this PR

This change on its own doesn't do anything. Do you plan on following up immediately with a set of suggested libs to enable this on? Have you noticed any impact on build performance when enabling this on any JDK libs? I very much doubt any component owner is going to test and apply this on their own. Without that, this is a dead feature and I wouldn't want it to go in.

I wonder if it would be a good idea to add a global on/off switch (configure arg) for this whole thing, I'm really not sure. It kind of depends on what the impact is. If the impact is unknown, then a global on/off switch, default off, would let every distributor evaluate this on their own. That would of course also require that at least some libs have this enabled.

make/common/NativeCompilation.gmk line 101:

> 99: #   SYSROOT_LDFLAGS the linker flags for using the specific sysroot
> 100: #   OPTIMIZATION sets optimization level to NONE, LOW, HIGH, HIGHEST, HIGHEST_JVM, SIZE
> 101: #   LINK_TIME_OPTIMIZATION if set to true, it enables additionally link time optimization

Suggestion:

#   LINK_TIME_OPTIMIZATION if set to true, enables link time optimization

-------------

PR Review: https://git.openjdk.org/jdk/pull/27976#pullrequestreview-3393619643
PR Review Comment: https://git.openjdk.org/jdk/pull/27976#discussion_r2473244871


More information about the client-libs-dev mailing list