From 6d7f5424b67e29bccea95708a835d0709294fa7d Mon Sep 17 00:00:00 2001 From: Jose Quaresma Date: Mon, 26 Sep 2022 11:56:13 +0000 Subject: [PATCH] [WIP] base: linux-lmp: build the kernel with clang - Tested only on v90 main-next Signed-off-by: Jose Quaresma --- .../recipes-kernel/linux/linux-lmp-clang.inc | 25 +++++++++++++++++++ .../recipes-kernel/linux/linux-lmp.inc | 2 ++ 2 files changed, 27 insertions(+) create mode 100644 meta-lmp-base/recipes-kernel/linux/linux-lmp-clang.inc diff --git a/meta-lmp-base/recipes-kernel/linux/linux-lmp-clang.inc b/meta-lmp-base/recipes-kernel/linux/linux-lmp-clang.inc new file mode 100644 index 0000000000..6f68d28372 --- /dev/null +++ b/meta-lmp-base/recipes-kernel/linux/linux-lmp-clang.inc @@ -0,0 +1,25 @@ +# https://github.com/kraj/meta-clang#kernel-build-with-clang + +TOOLCHAIN:forcevariable = "clang" + +DEPENDS:append:toolchain-clang = " clang-cross-${TARGET_ARCH}" +KERNEL_CC:toolchain-clang = "${CCACHE}clang ${HOST_CC_KERNEL_ARCH} ${DEBUG_PREFIX_MAP} -fdebug-prefix-map=${STAGING_KERNEL_DIR}=${KERNEL_SRC_PATH}" +KERNEL_LD:toolchain-clang = "${CCACHE}ld.lld" +KERNEL_AR:toolchain-clang = "${CCACHE}llvm-ar" + +# FIXME: hacks +do_kernel_configcheck[noexec] = "1" + +# error: taking address of packed member 'xxx' of class or structure 'yyy' may result in an unaligned pointer value [-Werror,-Waddress-of-packed-member] +# because kernel don't use CFLAGS we need to pass it over EXTRA_OEMAKE +EXTRA_OEMAKE += 'CFLAGS="-Wno-address-of-packed-member"' + +# explicitly enable LLVM +# https://docs.kernel.org/kbuild/llvm.html +KERNEL_EXTRA_ARGS += "LLVM=1" + +# verbose build +#KERNEL_EXTRA_ARGS += "V=1" + +# disable pararel make +#PARALLEL_MAKE = "-j1" diff --git a/meta-lmp-base/recipes-kernel/linux/linux-lmp.inc b/meta-lmp-base/recipes-kernel/linux/linux-lmp.inc index 080bcc5de2..93a164e924 100644 --- a/meta-lmp-base/recipes-kernel/linux/linux-lmp.inc +++ b/meta-lmp-base/recipes-kernel/linux/linux-lmp.inc @@ -26,3 +26,5 @@ do_deploy:append() { cp -a ${B}/.config ${DEPLOYDIR}/${KERNEL_CONFIG_NAME} ln -sf ${KERNEL_CONFIG_NAME} ${DEPLOYDIR}/${KERNEL_CONFIG_LINK_NAME} } + +require linux-lmp-clang.inc