| Message ID | 20260708022856.2087339-1-mark.yang@lge.com |
|---|---|
| Headers | show |
| Series | kernel: make the kernel toolchain switchable to clang | expand |
Why do we have this series, when it is almost identical to the one sent by Harish Sadineni ? Bruce On Tue, Jul 7, 2026 at 10:30 PM mark.yang via lists.openembedded.org <mark.yang=lge.com@lists.openembedded.org> wrote: > > From: "mark.yang" <mark.yang@lge.com> > > Building the kernel with clang currently means overriding TOOLCHAIN and > the KERNEL_* variables in a bbappend. The kernel builds, but modules and > make-mod-scripts keep the gcc defaults and run the shared kernel build > tree with the other compiler. kbuild then re-runs syncconfig against the > shared .config and silently drops compiler-dependent options: a > CONFIG_CFI_CLANG kernel loses kCFI as soon as any module is built. > Documentation/kbuild/llvm.rst requires the same toolchain for every make > invocation against one tree. > > This series adds a KERNEL_TOOLCHAIN switch so the kernel, modules and > make-mod-scripts move to clang together. gcc remains the default. > > Tested on qemux86-64 with clang and gcc: both toolchains > build linux-yocto, make-mod-scripts and cryptodev-module, the shared > .config stays consistent across module builds (also with ld-is-lld), > and core-image-sato boots. > > mark.yang (3): > module.bbclass/make-mod-scripts: inhibit default dependencies > kernel-yocto: export CLANG_FLAGS for the kconfiglib config audit > kernel-arch: add KERNEL_TOOLCHAIN for building the kernel with clang > > meta/classes-recipe/kernel-arch.bbclass | 13 ++++++++++++- > meta/classes-recipe/kernel-yocto.bbclass | 7 +++++++ > meta/classes-recipe/module.bbclass | 5 +++++ > .../make-mod-scripts/make-mod-scripts_1.0.bb | 5 +++++ > 4 files changed, 29 insertions(+), 1 deletion(-) > > > -=-=-=-=-=-=-=-=-=-=-=- > Links: You receive all messages sent to this group. > View/Reply Online (#240415): https://lists.openembedded.org/g/openembedded-core/message/240415 > Mute This Topic: https://lists.openembedded.org/mt/120168206/1050810 > Group Owner: openembedded-core+owner@lists.openembedded.org > Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [bruce.ashfield@gmail.com] > -=-=-=-=-=-=-=-=-=-=-=- >
Hi Bruce, Bad timing on my part - I posted this before spotting Harish's series, sorry for the noise. It's not quite the same though: the point of this series is patches 1 and 3, keeping the kernel, out-of-tree modules and make-mod-scripts on one toolchain. With only the kernel recipe switched to clang, modules and make-mod-scripts still run make against the shared kernel build tree with the gcc defaults; kbuild notices the CC_VERSION_TEXT mismatch and re-runs syncconfig, silently dropping compiler-dependent options from the shared .config - CONFIG_CFI_CLANG for example disappears as soon as any out-of-tree module is built, with no error anywhere. Reproduced on qemux86-64 with cryptodev-module. I'll drop the two patches that overlap with Harish's series and send a v2 with the module/make-mod-scripts side rebased on top of his. Mark
From: "mark.yang" <mark.yang@lge.com> Building the kernel with clang currently means overriding TOOLCHAIN and the KERNEL_* variables in a bbappend. The kernel builds, but modules and make-mod-scripts keep the gcc defaults and run the shared kernel build tree with the other compiler. kbuild then re-runs syncconfig against the shared .config and silently drops compiler-dependent options: a CONFIG_CFI_CLANG kernel loses kCFI as soon as any module is built. Documentation/kbuild/llvm.rst requires the same toolchain for every make invocation against one tree. This series adds a KERNEL_TOOLCHAIN switch so the kernel, modules and make-mod-scripts move to clang together. gcc remains the default. Tested on qemux86-64 with clang and gcc: both toolchains build linux-yocto, make-mod-scripts and cryptodev-module, the shared .config stays consistent across module builds (also with ld-is-lld), and core-image-sato boots. mark.yang (3): module.bbclass/make-mod-scripts: inhibit default dependencies kernel-yocto: export CLANG_FLAGS for the kconfiglib config audit kernel-arch: add KERNEL_TOOLCHAIN for building the kernel with clang meta/classes-recipe/kernel-arch.bbclass | 13 ++++++++++++- meta/classes-recipe/kernel-yocto.bbclass | 7 +++++++ meta/classes-recipe/module.bbclass | 5 +++++ .../make-mod-scripts/make-mod-scripts_1.0.bb | 5 +++++ 4 files changed, 29 insertions(+), 1 deletion(-)