RFR: 8370438: Offer link time optimization support on library level

Matthias Baesken mbaesken at openjdk.org
Thu Oct 30 15:51:46 UTC 2025


On Thu, 30 Oct 2025 13:22:12 GMT, Erik Joelsson <erikj at openjdk.org> wrote:

> > However it might not work for all versions of these compilers.
> 
> When introducing new compiler flags, you need to do one of:
> 
> 1. Verify that the flags are supported on all versions of the compiler we support. There is a minimum version defined for each. Reading the documentation to find out when the compiler feature was introduced is enough, you don't need to actually test every version yourself.
> 2. If 1 couldn't be proved, then only add the flag conditionally with a check in configure.

The compiler flags are not really 'new' but borrowed from Hotspot LTO.

`MSVC ( -GL -LTCG:INCREMENTAL ): ` available for a long time (~20 years), all our supported compilers

`AIX :` we only support XLC 14.X, there it is available

`gcc   :`  -flto=auto -fuse-linker-plugin -fno-strict-aliasing -fno-fat-lto-objects
         since 4.8  (-flto=auto is documented since gcc-10 but older compilers seem to understand it too)

`clang:`  I can find -flto in the clang13 manual (https://releases.llvm.org/13.0.0/tools/clang/docs/UsersManual.html) but cannot find -flto=auto , so maybe we should just just -flto in the link flags for clang ?

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

PR Comment: https://git.openjdk.org/jdk/pull/27976#issuecomment-3468699988


More information about the client-libs-dev mailing list