[tip: objtool/core] klp-build: Allow passing options to make via '--'
From: tip-bot2 for Dylan Hatch
Date: Wed Nov 25 2026 - 03:41:14 EST
The following commit has been merged into the objtool/core branch of tip:
Commit-ID: 961ebd091e3f0927b228a7321581c7fc4b32c27c
Gitweb: https://git.kernel.org/tip/961ebd091e3f0927b228a7321581c7fc4b32c27c
Author: Dylan Hatch <dylanbhatch@xxxxxxxxxx>
AuthorDate: Thu, 12 Nov 2026 22:03:55
Committer: Josh Poimboeuf <jpoimboe@xxxxxxxxxx>
CommitterDate: Sat, 21 Nov 2026 23:24:39 -08:00
klp-build: Allow passing options to make via '--'
Livepatch builds rely on reproducing the original kernel build
environment, including any make flags or command-line variables used
during the original build (such as 'CC=...', 'KBUILD_BUILD_TIMESTAMP=...',
or custom wrapper Makefiles via '-f').
While these options can already be passed through the MAKEFLAGS
environment variable, passing them directly on the command line is more
ergonomic.
Refactor the make invocations to use a common MAKE array and allow
passing arbitrary make options after '--' on the klp-build command line:
klp-build [OPTIONS] PATCH_FILE(s) [-- MAKE_OPTIONS]
Acked-by: Song Liu <song@xxxxxxxxxx>
Signed-off-by: Dylan Hatch <dylanbhatch@xxxxxxxxxx>
Link: https://patch.msgid.link/20261112220355.1952137-1-dylanbhatch@xxxxxxxxxx
Signed-off-by: Josh Poimboeuf <jpoimboe@xxxxxxxxxx>
---
scripts/livepatch/klp-build | 29 +++++++++++++++++++++--------
1 file changed, 21 insertions(+), 8 deletions(-)
diff --git a/scripts/livepatch/klp-build b/scripts/livepatch/klp-build
index b52a848..1fd405d 100755
--- a/scripts/livepatch/klp-build
+++ b/scripts/livepatch/klp-build
@@ -125,7 +125,7 @@ trap trap_err ERR
__usage() {
cat <<EOF
-Usage: $SCRIPT [OPTIONS] PATCH_FILE(s)
+Usage: $SCRIPT [OPTIONS] PATCH_FILE(s) [-- MAKE_OPTIONS]
Generate a livepatch module.
Options:
@@ -158,11 +158,23 @@ process_args() {
local long
local args
local patch
+ local klp_args=()
+ local make_args=()
+
+ while [[ $# -gt 0 ]]; do
+ if [[ "$1" == "--" ]]; then
+ shift
+ make_args=("$@")
+ break
+ fi
+ klp_args+=("$1")
+ shift
+ done
short="hfj:o:vdS:T"
long="help,show-first-changed,jobs:,output:,no-replace,verbose,debug,short-circuit:,keep-tmp"
- args=$(getopt --options "$short" --longoptions "$long" -- "$@") || {
+ args=$(getopt --options "$short" --longoptions "$long" -- "${klp_args[@]}") || {
echo; usage; exit
}
eval set -- "$args"
@@ -237,6 +249,7 @@ process_args() {
KEEP_TMP="$keep_tmp"
PATCHES=("$@")
+ MAKE=("make" "${make_args[@]}")
for patch in "${PATCHES[@]}"; do
[[ -f "$patch" ]] || die "$patch doesn't exist"
@@ -317,12 +330,12 @@ set_kernelversion() {
stash_file "$file"
- if [[ -n "$(make -s listnewconfig 2>/dev/null)" ]]; then
+ if [[ -n "$("${MAKE[@]}" -s listnewconfig 2>/dev/null)" ]]; then
die ".config mismatch, check your .config or run 'make olddefconfig'"
fi
- make syncconfig &>/dev/null || die "make syncconfig failed"
+ "${MAKE[@]}" syncconfig &>/dev/null || die "make syncconfig failed"
- kernelrelease="$(make -s kernelrelease)"
+ kernelrelease="$("${MAKE[@]}" -s kernelrelease)"
[[ -z "$kernelrelease" ]] && die "failed to get kernel version"
sed -i "2i echo $kernelrelease; exit 0" scripts/setlocalversion
@@ -526,7 +539,7 @@ fix_patches() {
clean_kernel() {
local cmd=()
- cmd=("make")
+ cmd=("${MAKE[@]}")
cmd+=("--silent")
cmd+=("-j$JOBS")
cmd+=("clean")
@@ -539,7 +552,7 @@ build_kernel() {
local log="$TMP_DIR/build.log"
local cmd=()
- cmd=("make")
+ cmd=("${MAKE[@]}")
# When a patch to a kernel module references a newly created unexported
# symbol which lives in vmlinux or another kernel module, the patched
@@ -859,7 +872,7 @@ build_patch_module() {
cflags+=("-fdata-sections")
[[ $REPLACE -eq 0 ]] && cflags+=("-DKLP_NO_REPLACE")
- cmd=("make")
+ cmd=("${MAKE[@]}")
if [[ -v VERBOSE ]]; then
cmd+=("V=1")
else