Add Clang toolchain support for kernel builds
A message that is not in the archive (sent off-list or not yet received): [email protected]
Hi all,
Please ignore this v3, some unintended changes got included in patch 4. I'll resend a corrected v3 shortly.
Thanks,
Harish
Quoted 50 lines · Harish via lists.openembedded.org
From: Harish Sadineni <[email protected]>
v2 -> v3:
- Guard against TOOLCHAIN being unset: used.getVar('TOOLCHAIN')or '' instead ofd.getVar('TOOLCHAIN')directly (suggested by Bruce Ashfield).v1 -> v2:
- TOOLCHAIN:riscv64 now explicitly falls back to "gcc" instead of "" when rust is not inKERNEL_FEATURES, avoiding an empty TOOLCHAIN value.This series adds LLVM/Clang toolchain support for kernel builds, defaulting to GCC but enabling Clang automatically for riscv64 when Rust is enabled.
(quoted diff) +0
-5-Convert existing GCC tool definitions (KERNEL_CC, KERNEL_LD, KERNEL_AR, etc.) to use the :toolchain-gcc override, so they only apply when TOOLCHAIN = "gcc" the existing default behavior is preserved as a no-op. -Introduce parallel :toolchain-clang definitions using clang, ld.lld, llvm-ar, llvm-objcopy, and llvm-strip, making it possible to build the kernel with the LLVM/Clang toolchain. -Automatically select the Clang toolchain for riscv64 kernel builds when Rust support is enabled, since upstream kernel Rust support on riscv64 requires LLVM/clang (per https://docs.kernel.org/rust/arch-support.html). GCC remains the default everywhere else, including riscv64 without Rust. -Add lld-native to DEPENDS, since the lld linker is required when building the kernel with Clang. -Fix a config-check failure under Clang: do_kernel_configcheck was erroring out with kconfiglib.KconfigError: ... Sorry, this assembler is not supported (from scripts/Kconfig.include). Resolved by setting CLANG_FLAGS = "-fintegrated-as" whenever TOOLCHAIN contains "clang" this flag is picked up by the kernel build system during config checks so the assembler test passes.Harish Sadineni (4):
kernel-arch: Add clang toolchain support
kernel-yocto-rust: use clang toolchain for riscv64 when Rust is
enabled
kernel-yocto-rust: Add lld-native to DEPENDS
kernel-yocto: SetCLANG_FLAGSfor kernel config checks when using
clangmeta/classes-recipe/kernel-arch.bbclass | 23 +++++++++++++++---- meta/classes-recipe/kernel-yocto-rust.bbclass | 3 +++ meta/classes-recipe/kernel-yocto.bbclass | 3 +++ meta/recipes-kernel/linux/linux-yocto.inc | 4 ++++ 4 files changed, 28 insertions(+), 5 deletions(-)-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#240489): https://lists.openembedded.org/g/openembedded-core/message/240489
Mute This Topic: https://lists.openembedded.org/mt/120174988/8054390
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-