From: "mark.yang" <[email protected]>

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 <[email protected]>
---
 meta/conf/distro/include/lto.inc | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/meta/conf/distro/include/lto.inc b/meta/conf/distro/include/lto.inc
index b8193725a1..227f0c5c2a 100644
--- a/meta/conf/distro/include/lto.inc
+++ b/meta/conf/distro/include/lto.inc
@@ -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)}"
 
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#229832): 
https://lists.openembedded.org/g/openembedded-core/message/229832
Mute This Topic: https://lists.openembedded.org/mt/117395681/21656
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to