From: mark.yang@lge.com
To: openembedded-core@lists.openembedded.org
Cc: "mark.yang" <mark.yang@lge.com>
Subject: [PATCH] lto.inc: introduce LTO_DEFAULT variable to support per-package overrides with Clang
Date: Fri, 30 Jan 2026 18:54:52 +0900 [thread overview]
Message-ID: <20260130095452.3522876-1-mark.yang@lge.com> (raw)
From: "mark.yang" <mark.yang@lge.com>
Currently, LTO variable is set with a toolchain-clang override directly.
This causes priority issues where package-specific overrides (e.g., LTO:pn-perl = "")
are ignored when the Clang toolchain is active, making it difficult to disable LTO
for specific failing recipes.
This patch refactors the logic by introducing an intermediate `LTO_DEFAULT` variable.
- `LTO_DEFAULT` handles the toolchain-specific flags (GCC vs Clang).
- `LTO` is assigned `LTO_DEFAULT` as a default value.
This structure allows `LTO` to be cleanly overridden by recipe-specific overrides
(like `pn-${PN}`) regardless of the active toolchain.
Added a toolchain-gcc override for alsa-lib because -flto-partition=none is not
supported by Clang.
Signed-off-by: mark.yang <mark.yang@lge.com>
---
meta/conf/distro/include/lto.inc | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/meta/conf/distro/include/lto.inc b/meta/conf/distro/include/lto.inc
index 227f0c5c2a1..8752249685a 100644
--- a/meta/conf/distro/include/lto.inc
+++ b/meta/conf/distro/include/lto.inc
@@ -28,7 +28,7 @@ LTO:pn-grub-efi = ""
# Custom LTO flags
# disable partitioning/streaming algorithm since its uses ASM
# constructs not compatible with lto
-LTOEXTRA:pn-alsa-lib = "-flto-partition=none"
+LTOEXTRA:pn-alsa-lib:toolchain-gcc = "-flto-partition=none"
LTOEXTRA ?= ""
@@ -43,9 +43,11 @@ LTOEXTRA ?= ""
# -fuse-linker-plugin
# ensures that libraries participate in LTO by supplying intermediate
# code from .a files to linker
-LTO ?= "-flto -ffat-lto-objects -fuse-linker-plugin ${LTOEXTRA}"
+LTO_DEFAULT = "-flto -ffat-lto-objects -fuse-linker-plugin ${LTOEXTRA}"
-LTO:toolchain-clang = "${@bb.utils.contains('DISTRO_FEATURES', 'thin-lto', '-flto=thin ${LTOEXTRA}', '-flto ${LTOEXTRA}', d)}"
+LTO_DEFAULT:toolchain-clang = "${@bb.utils.contains('DISTRO_FEATURES', 'thin-lto', '-flto=thin ${LTOEXTRA}', '-flto ${LTOEXTRA}', d)}"
+
+LTO ?= "${LTO_DEFAULT}"
SELECTED_OPTIMIZATION:append = "${@bb.utils.contains('DISTRO_FEATURES', 'lto', ' ${LTO}', '', d)}"
TARGET_LDFLAGS:append:class-target = "${@bb.utils.contains('DISTRO_FEATURES', 'lto', ' ${LTO}', '', d)}"
reply other threads:[~2026-01-30 9:55 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260130095452.3522876-1-mark.yang@lge.com \
--to=mark.yang@lge.com \
--cc=openembedded-core@lists.openembedded.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox