Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

base: linux-lmp: build with clang #842

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 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,36 @@
# https://github.com/kraj/meta-clang#kernel-build-with-clang

TOOLCHAIN:forcevariable = "clang"

DEPENDS:append:toolchain-clang = " clang-cross-${TARGET_ARCH}"

# https://github.com/kraj/meta-clang/issues/856
KERNEL_CC:remove:toolchain-clang = "-fuse-ld=bfd"

# 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"

python __anonymous() {
kernel_vars = [
['KERNEL_CC', 'gcc', 'clang'],
['KERNEL_LD', 'ld.bfd', 'ld.lld'],
['KERNEL_AR', 'ar', 'llvm-ar'],
]
for [var, match, rep] in kernel_vars:
v = d.getVar(var, False)
d.setVar(var , v.replace('${HOST_PREFIX}%s' % match, '${HOST_PREFIX}%s' % rep))
}
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