On Fri, 24 Oct 2025 13:24:43 GMT, Erik Joelsson <[email protected]> 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.
>
> make/autoconf/flags-ldflags.m4 line 72:
> 
>> 70:         -fPIC"
>> 71: 
>> 72:     LDFLAGS_LTO="-flto=auto -fuse-linker-plugin -fno-strict-aliasing"
> 
> I notice that the compiler args for GCC and Clang are different, but the 
> linker args are the same. Just want to make sure that's intentional.

Yes they are different, this is 'borrowed' from Hotspot flags, see
https://github.com/openjdk/jdk/blob/9625993611bb6acf84d428bea4a65d33b9d66e5f/make/hotspot/lib/JvmFeatures.gmk#L178

where we supported LTO for some time.

> 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 YES, it enables additionally link 
>> time optimization
> 
> For boolean options, we use the vales `true`/`false`.

Thanks for the advice, I'll change it!

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

PR Review Comment: https://git.openjdk.org/jdk/pull/27976#discussion_r2468661804
PR Review Comment: https://git.openjdk.org/jdk/pull/27976#discussion_r2468644852

Reply via email to