From: "mark.yang" <[email protected]> kernel-arch pins TOOLCHAIN to gcc, so a clang kernel needs TOOLCHAIN and the KERNEL_* variables overridden per recipe. Modules and make-mod-scripts then keep the gcc defaults and run make against the shared kernel build tree with a different compiler: kbuild detects the CC_VERSION_TEXT mismatch, re-runs syncconfig and silently drops compiler-dependent options such as CONFIG_CFI_CLANG.
Add toolchain-clang variants of KERNEL_CC, KERNEL_LD and KERNEL_AR and a KERNEL_TOOLCHAIN switch covering all kernel-arch recipes, so the kernel, modules and make-mod-scripts change toolchain together. The default stays gcc. -fuse-ld is left out of KERNEL_CC because the kernel links with KERNEL_LD directly and kbuild's -Werror=unused-command-line-argument rejects the unused option. KERNEL_LD uses ld.lld when the distro has ld-is-lld (clang-cross only installs the symlink then), GNU ld.bfd otherwise. Signed-off-by: mark.yang <[email protected]> --- meta/classes-recipe/kernel-arch.bbclass | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/meta/classes-recipe/kernel-arch.bbclass b/meta/classes-recipe/kernel-arch.bbclass index 7aea9cd3e8..7e83a09b1c 100644 --- a/meta/classes-recipe/kernel-arch.bbclass +++ b/meta/classes-recipe/kernel-arch.bbclass @@ -76,9 +76,20 @@ KERNEL_CC = "${CCACHE}${HOST_PREFIX}gcc ${HOST_CC_KERNEL_ARCH} \ -ffile-prefix-map=${STAGING_KERNEL_DIR}=${KERNEL_SRC_PATH} \ -ffile-prefix-map=${STAGING_KERNEL_BUILDDIR}=${KERNEL_SRC_PATH} \ " +KERNEL_CC:toolchain-clang = "${CCACHE}${HOST_PREFIX}clang ${HOST_CC_KERNEL_ARCH} \ + ${DEBUG_PREFIX_MAP} \ + -ffile-prefix-map=${STAGING_KERNEL_DIR}=${KERNEL_SRC_PATH} \ + -ffile-prefix-map=${STAGING_KERNEL_BUILDDIR}=${KERNEL_SRC_PATH} \ +" KERNEL_LD = "${HOST_PREFIX}ld.bfd ${HOST_LD_KERNEL_ARCH}" +KERNEL_LD:toolchain-clang = "${@bb.utils.contains('DISTRO_FEATURES', 'ld-is-lld', '${HOST_PREFIX}ld.lld', '${HOST_PREFIX}ld.bfd', d)} ${HOST_LD_KERNEL_ARCH}" KERNEL_AR = "${HOST_PREFIX}ar ${HOST_AR_KERNEL_ARCH}" +KERNEL_AR:toolchain-clang = "${HOST_PREFIX}llvm-ar ${HOST_AR_KERNEL_ARCH}" KERNEL_OBJCOPY = "${HOST_PREFIX}objcopy ${HOST_OBJCOPY_KERNEL_ARCH}" # Code in package.py can't handle options on KERNEL_STRIP KERNEL_STRIP = "${HOST_PREFIX}strip" -TOOLCHAIN = "gcc" +# The kernel, out-of-tree modules and make-mod-scripts share one kernel build +# tree and must agree on the toolchain, so switch it with KERNEL_TOOLCHAIN +# rather than setting TOOLCHAIN on individual recipes. +KERNEL_TOOLCHAIN ?= "gcc" +TOOLCHAIN = "${KERNEL_TOOLCHAIN}"
-=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#240413): https://lists.openembedded.org/g/openembedded-core/message/240413 Mute This Topic: https://lists.openembedded.org/mt/120168204/21656 Group Owner: [email protected] Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]] -=-=-=-=-=-=-=-=-=-=-=-
