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

Julian Waters jwaters at openjdk.org
Fri Nov 21 06:18:31 UTC 2025


On Fri, 7 Nov 2025 15:06:51 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:
> 
>   Add lto to EXTRA_FLAGS, not to OPT

Not really fond of the way this was done, but oh well, I can live with the changes regardless.

make/autoconf/flags-cflags.m4 line 327:

> 325:     C_O_FLAG_NONE="-Od"
> 326:     C_O_FLAG_SIZE="-O1"
> 327:     C_O_FLAG_LTO="-GL"

There is sometimes warning spam during linking if -Gy is not set alongside -GL last I remember. This probably won't break LTO builds, but it could possibly be annoying. Whether you want to add the flag is up to you, however.

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

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


More information about the client-libs-dev mailing list