Skip to content

Commit

Permalink
[WIP] base: linux-lmp: build the kernel with clang
Browse files Browse the repository at this point in the history
- Tested only on v90 main-next

Signed-off-by: Jose Quaresma <[email protected]>
  • Loading branch information
quaresmajose committed Sep 12, 2023
1 parent f7382a9 commit 6d7f542
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
25 changes: 25 additions & 0 deletions meta-lmp-base/recipes-kernel/linux/linux-lmp-clang.inc
Original file line number Diff line number Diff line change
@@ -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"
2 changes: 2 additions & 0 deletions meta-lmp-base/recipes-kernel/linux/linux-lmp.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 6d7f542

Please sign in to comment.