klp-build: Support clang/llvm built kernel
Song Liu
maintainerPATCH 1/1 klp-build: Support clang/llvm built kernel
When the kernel is built with clang/llvm, it is expected to run make with "make LLVM=1 ...". The same is needed when building livepatches.
Use CONFIG_CC_IS_CLANG as the flag to detect kernel built with clang/llvm, and add LLVM=1 to make commands from klp-build
--- scripts/livepatch/klp-build | 6 ++++++ 1 file changed, 6 insertions(+)
scripts/livepatch/klp-build +6 -0
@@ -49,6 +49,7 @@ KMOD_DIR="$TMP_DIR/kmod" STASH_DIR="$TMP_DIR/stash" TIMESTAMP="$TMP_DIR/timestamp" PATCH_TMP_DIR="$TMP_DIR/tmp" +USE_LLVM=0 KLP_DIFF_LOG="$DIFF_DIR/diff.log"
@@ -249,6 +250,8 @@ validate_config() { [[ -v CONFIG_GCC_PLUGIN_RANDSTRUCT ]] && \ die "kernel option 'CONFIG_GCC_PLUGIN_RANDSTRUCT' not supported" + [[ -v CONFIG_CC_IS_CLANG ]] && USE_LLVM=1 + return 0 }
@@ -480,6 +483,7 @@ clean_kernel() { cmd+=("--silent") cmd+=("-j$JOBS") cmd+=("clean") + [[ "$USE_LLVM" -eq 1 ]] && cmd+=("LLVM=1") ( cd "$SRC"
@@ -519,6 +523,7 @@ build_kernel() { cmd+=("OBJTOOL_ARGS=${objtool_args[*]}") cmd+=("vmlinux") cmd+=("modules") + [[ "$USE_LLVM" -eq 1 ]] && cmd+=("LLVM=1") ( cd "$SRC"
@@ -764,6 +769,7 @@ build_patch_module() { cmd+=("--directory=.") cmd+=("M=$KMOD_DIR") cmd+=("KCFLAGS=${cflags[*]}") + [[ "$USE_LLVM" -eq 1 ]] && cmd+=("LLVM=1") # Build a "normal" kernel module with init.c and the diffed objects (
Signature · 1 line
2.47.3
Josh Poimboeuf
maintainerQuoted 7 lines · Song Liu
When the kernel is built with clang/llvm, it is expected to run make with "make LLVM=1 ...". The same is needed when building livepatches.
Use
CONFIG_CC_IS_CLANGas the flag to detect kernel built with clang/llvm, and add LLVM=1 to make commands from klp-buildSigned-off-by Song Liu <[email protected]>
Indeed, I had tested by exporting LLVM=1, but this is better... Thanks!
Signature · 1 line
Josh
Josh Poimboeuf
maintainerQuoted 7 lines · Song Liu
When the kernel is built with clang/llvm, it is expected to run make with "make LLVM=1 ...". The same is needed when building livepatches.
Use
CONFIG_CC_IS_CLANGas the flag to detect kernel built with clang/llvm, and add LLVM=1 to make commands from klp-buildSigned-off-by Song Liu <[email protected]>
Peter informed me that "LLVM=" has different syntaxes:
LLVM=1
LLVM=-22
LLVM=/opt/llvm/
Debian has parallel llvm (and gcc) toolchains, and suffixes them with -$ver.
So we dropped this patch for now. "export LLVM=1" still works. Not sure if you have any other ideas?
At the very least we should probably check that LLVM=<whatever> and/or CC=clang are set appropriately before doing a CONFIG_CC_IS_CLANG build, and error out if not.
Signature · 1 line
Josh
Song Liu
maintainerQuoted 16 lines · Josh Poimboeuf
Quoted 7 lines · Song Liu
When the kernel is built with clang/llvm, it is expected to run make with "make LLVM=1 ...". The same is needed when building livepatches.
Use
CONFIG_CC_IS_CLANGas the flag to detect kernel built with clang/llvm, and add LLVM=1 to make commands from klp-buildSigned-off-by Song Liu <[email protected]>Peter informed me that "LLVM=" has different syntaxes:
LLVM=1
LLVM=-22
LLVM=/opt/llvm/
Quoted 5 lines
Debian has parallel llvm (and gcc) toolchains, and suffixes them with -$ver.
So we dropped this patch for now. "export LLVM=1" still works. Not sure if you have any other ideas?
Hmm... I guess "export LLVM=something" is probably the best option for now.
Thanks,
Song