public inbox for live-patching@vger.kernel.org
 help / color / mirror / Atom feed
From: Song Liu <song@kernel.org>
To: live-patching@vger.kernel.org
Cc: jpoimboe@kernel.org, kernel-team@meta.com, jikos@kernel.org,
	mbenes@suse.cz, pmladek@suse.com, joe.lawrence@redhat.com,
	Song Liu <song@kernel.org>
Subject: [PATCH] klp-build: Support clang/llvm built kernel
Date: Thu, 29 Jan 2026 09:03:21 -0800	[thread overview]
Message-ID: <20260129170321.700854-1-song@kernel.org> (raw)

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

Signed-off-by: Song Liu <song@kernel.org>
---
 scripts/livepatch/klp-build | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/scripts/livepatch/klp-build b/scripts/livepatch/klp-build
index a73515a82272..6a446ca7d968 100755
--- a/scripts/livepatch/klp-build
+++ b/scripts/livepatch/klp-build
@@ -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
 	(
-- 
2.47.3


             reply	other threads:[~2026-01-29 17:03 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-29 17:03 Song Liu [this message]
2026-01-29 18:08 ` [PATCH] klp-build: Support clang/llvm built kernel Josh Poimboeuf
2026-02-05 16:25 ` Josh Poimboeuf
2026-02-05 16:50   ` Song Liu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260129170321.700854-1-song@kernel.org \
    --to=song@kernel.org \
    --cc=jikos@kernel.org \
    --cc=joe.lawrence@redhat.com \
    --cc=jpoimboe@kernel.org \
    --cc=kernel-team@meta.com \
    --cc=live-patching@vger.kernel.org \
    --cc=mbenes@suse.cz \
    --cc=pmladek@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox