]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core.git/commitdiff
lto.inc: add clang specific LTO configuration
authormark.yang <mark.yang@lge.com>
Thu, 22 Jan 2026 05:51:43 +0000 (14:51 +0900)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Tue, 27 Jan 2026 11:37:48 +0000 (11:37 +0000)
This commit adds support for Clang-specific LTO options.

1. -fuse-linker-plugin is not supported by Clang.
2. -ffat-lto-objects is used to ensure that object files (.o) are generated as ELF
   even when LTO is applied. During the dwarfsrcfiles process, if LTO is used
   with the Clang toolchain, static library object files are skipped if they are
   LLVM bitcode instead of ELF. Therefore, it is recommended to add this to
   LTOEXTRA if necessary.
3. Adding 'thin-lto' to DISTRO_FEATURES enables -flto=thin.

Signed-off-by: mark.yang <mark.yang@lge.com>
Signed-off-by: Antonin Godard <antonin.godard@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/conf/distro/include/lto.inc

index b8193725a15a06a0ecfd1fff37c9a7d6238b72a8..227f0c5c2a16721c90a24d8c763e9af7b3719c4e 100644 (file)
@@ -45,6 +45,8 @@ LTOEXTRA ?= ""
 # code from .a files to linker
 LTO ?= "-flto -ffat-lto-objects -fuse-linker-plugin ${LTOEXTRA}"
 
+LTO:toolchain-clang = "${@bb.utils.contains('DISTRO_FEATURES', 'thin-lto', '-flto=thin ${LTOEXTRA}', '-flto ${LTOEXTRA}', d)}"
+
 SELECTED_OPTIMIZATION:append = "${@bb.utils.contains('DISTRO_FEATURES', 'lto', ' ${LTO}', '', d)}"
 TARGET_LDFLAGS:append:class-target = "${@bb.utils.contains('DISTRO_FEATURES', 'lto', ' ${LTO}', '', d)}"