From: mark.yang@lge.com
To: openembedded-core@lists.openembedded.org
Cc: "mark.yang" <mark.yang@lge.com>
Subject: [PATCH v2 0/3] kernel: make the kernel toolchain switchable to clang
Date: Tue, 14 Jul 2026 22:26:39 +0900 [thread overview]
Message-ID: <20260714132642.2225115-1-mark.yang@lge.com> (raw)
From: "mark.yang" <mark.yang@lge.com>
Since v1, clang kernel toolchain support has been merged to master
with 928d81916f ("kernel-arch: Add clang toolchain support") and
e88ee794a3 ("kernel-yocto: Set CLANG_FLAGS for kernel config checks
when using clang"), superseding two of the three v1 patches. As
discussed on the v1 thread, this rework contains what remains on top
of current master.
On current master a clang kernel only builds when ld-is-lld happens to
be in DISTRO_FEATURES, since nothing else stages a bare ld.lld:
scripts/Kconfig.include:41: linker 'ld.lld ' not found
Full log: https://errors.yoctoproject.org/Errors/Build/242422/
Patch 1 falls back to GNU ld in that case.
kbuild wants the same toolchain for every make invocation against a
build tree (Documentation/kbuild/llvm.rst: "The same value used for
LLVM= should be set for each invocation of make"), and the out-of-tree
module and make-mod-scripts builds run make against that same tree.
Setting TOOLCHAIN on the kernel recipe alone leaves them on the gcc
defaults: kbuild spots the CC_VERSION_TEXT mismatch and silently
regenerates .config. On current master, building cryptodev-module
after a clang kernel succeeds without a warning, produces a gcc .ko
and flips the shared .config back to CONFIG_CC_IS_GCC.
The toolchain has to be known at parse time to set up the cross
toolchain dependencies, so this needs to be a configuration variable.
Patch 2 moves modules and make-mod-scripts onto explicit cross
toolchain dependencies and patch 3 adds a KERNEL_TOOLCHAIN switch
covering all kernel-arch recipes.
Tested on qemux86-64 (master c2bd43b373, clang 22.1.8, gcc 16.1.0):
with KERNEL_TOOLCHAIN unset, core-image-minimal and cryptodev-module
build with gcc as before. With KERNEL_TOOLCHAIN = "clang" the kernel,
make-mod-scripts and cryptodev-module all build with clang, the shared
.config keeps CONFIG_CC_IS_CLANG after the module build, and linking
uses GNU ld, or LLD with ld-is-lld in DISTRO_FEATURES.
mark.yang (3):
kernel-arch: fall back to GNU ld unless ld-is-lld is in
DISTRO_FEATURES
module.bbclass/make-mod-scripts: inhibit default dependencies
kernel-arch: add KERNEL_TOOLCHAIN to switch the whole kernel toolchain
meta/classes-recipe/kernel-arch.bbclass | 5 +++--
meta/classes-recipe/module.bbclass | 3 +++
meta/recipes-kernel/make-mod-scripts/make-mod-scripts_1.0.bb | 3 +++
3 files changed, 9 insertions(+), 2 deletions(-)
next reply other threads:[~2026-07-14 13:26 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-14 13:26 mark.yang [this message]
2026-07-14 13:26 ` [PATCH v2 1/3] kernel-arch: fall back to GNU ld unless ld-is-lld is in DISTRO_FEATURES mark.yang
2026-07-14 13:26 ` [PATCH v2 2/3] module.bbclass/make-mod-scripts: inhibit default dependencies mark.yang
2026-07-15 11:34 ` [OE-core] " Mathieu Dubois-Briand
2026-07-15 13:48 ` Mathieu Dubois-Briand
2026-07-16 6:40 ` mark.yang
2026-07-14 13:26 ` [PATCH v2 3/3] kernel-arch: add KERNEL_TOOLCHAIN to switch the whole kernel toolchain mark.yang
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=20260714132642.2225115-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