From be7587c36dac85e2c418797a57cadb91ee156562 Mon Sep 17 00:00:00 2001 From: Pete Swain Date: Tue, 21 Jun 2022 19:00:06 -0700 Subject: [PATCH] add --make-opt, --cdo-opt Add a new kpatch-build options --make-opt=arg_for_make and --cdo-opt=arg_for_create-diff-object. These accumulate and are passed to the underlying make. This merges with the existing MAKEVARS/CDO_FLAGS processing, and allows site-specific make param overrides to be used, (matching params used to create the kernel to be patched) without hacking kpatch-build, even when turning on debug in create-diff-object. Signed-off-by: Pete Swain --- kpatch-build/kpatch-build | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/kpatch-build/kpatch-build b/kpatch-build/kpatch-build index c723625f1..68eaad394 100755 --- a/kpatch-build/kpatch-build +++ b/kpatch-build/kpatch-build @@ -56,6 +56,8 @@ declare -a PATCH_LIST APPLIED_PATCHES=0 OOT_MODULE= KLP_REPLACE=1 +declare -a MAKEVARS +declare -a CDO_FLAGS # default tools may be overridden by env : "${GCC:="${CROSS_COMPILE:-}gcc"}" @@ -549,9 +551,11 @@ usage() { echo " --skip-cleanup Skip post-build cleanup" >&2 echo " --skip-compiler-check Skip compiler version matching check" >&2 echo " (not recommended)" >&2 + echo " --make-opt pass an arg to make" >&2 + echo " --cdo-opt pass an arg to create-diff-object" >&2 } -options="$(getopt -o ha:r:s:c:v:j:t:n:o:dR -l "help,archversion:,sourcerpm:,sourcedir:,config:,vmlinux:,jobs:,target:,name:,output:,oot-module:,oot-module-src:,debug,skip-gcc-check,skip-compiler-check,skip-cleanup,non-replace" -- "$@")" || die "getopt failed" +options="$(getopt -o ha:r:s:c:v:j:t:n:o:dR -l "help,archversion:,sourcerpm:,sourcedir:,cdo-opt:,config:,vmlinux:,jobs:,target:,make-opt:,name:,output:,oot-module:,oot-module-src:,debug,skip-gcc-check,skip-compiler-check,skip-cleanup,non-replace" -- "$@")" || die "getopt failed" eval set -- "$options" @@ -633,6 +637,14 @@ while [[ $# -gt 0 ]]; do echo "WARNING: Skipping compiler version matching check (not recommended)" SKIPCOMPILERCHECK=1 ;; + --make-opt) + MAKEVARS+=("$2") + shift + ;; + --cdo-opt) + CDO_FLAGS+=("$2") + shift + ;; *) [[ "$1" = "--" ]] && shift && continue [[ ! -f "$1" ]] && die "patch file '$1' not found" @@ -902,7 +914,7 @@ if [[ -n "$CONFIG_LIVEPATCH" ]] && (kernel_is_rhel || kernel_version_gte 4.9.0); if use_klp_arch; then USE_KLP_ARCH=1 KPATCH_LDFLAGS="--unique=.parainstructions --unique=.altinstructions" - CDO_FLAGS="--klp-arch" + CDO_FLAGS+=(--klp-arch) fi if [[ "$KLP_REPLACE" -eq 1 ]] ; then @@ -989,7 +1001,6 @@ echo "Building original source" unset KPATCH_GCC_TEMPDIR KPATCH_CC_PREFIX="$TOOLSDIR/kpatch-cc " -declare -a MAKEVARS if [[ -n "$CONFIG_CC_IS_CLANG" ]]; then MAKEVARS+=("CC=${KPATCH_CC_PREFIX}${CLANG}") MAKEVARS+=("HOSTCC=${HOSTCC:-${CLANG}}") @@ -1146,7 +1157,7 @@ for i in $FILES; do # create-diff-object orig.o patched.o parent-name parent-symtab # Module.symvers patch-mod-name output.o - "$TOOLSDIR"/create-diff-object $CDO_FLAGS "orig/$i" "patched/$i" "$KOBJFILE_NAME" \ + "$TOOLSDIR"/create-diff-object "${CDO_FLAGS[@]}" "orig/$i" "patched/$i" "$KOBJFILE_NAME" \ "$SYMTAB" "$SYMVERS_FILE" "${MODNAME//-/_}" \ "output/$i" 2>&1 | logger 1 check_pipe_status create-diff-object