RFR: 8370438: Offer link time optimization support on library level [v5]
Julian Waters
jwaters at openjdk.org
Thu Nov 6 09:12:03 UTC 2025
On Thu, 6 Nov 2025 08:57:27 GMT, Matthias Baesken <mbaesken at openjdk.org> wrote:
>> make/hotspot/lib/JvmFeatures.gmk line 186:
>>
>>> 184: else ifeq ($(call isCompiler, microsoft), true)
>>> 185: JVM_CFLAGS_FEATURES += $(CXX_O_FLAG_LTO)
>>> 186: JVM_LDFLAGS_FEATURES += $(LDFLAGS_LTO)
>>
>> Now that we have variables for LTO flags, we shouldn't need compiler type checks for adding them. We can keep the conditionals for the other flags, but adding LTO flags looks compiler agnostic.
>
> We still add CXX_O_FLAG_HIGHEST_JVM to the JVM_LDFLAGS_FEATURES for gcc/clang , but not for msvc. Not sure why. So there is still a bit of difference between compilers.
That's due to how the toolchains work, with VC you're passing the options directly to the linker, while for gcc/clang you're passing the optimization flag to the driver, which understands the optimization option, unlike link.exe (Technically you're passing it to the compiler for gcc/clang I believe, both of them use the compiler's middle end to optimize your code during the link step when LTO is enabled from what I recall)
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/27976#discussion_r2498129638
More information about the client-libs-dev
mailing list