Skip to content

Commit

Permalink
add --make-opt, --cdo-opt
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
swine committed Oct 12, 2022
1 parent 0aff647 commit f4b626b
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions kpatch-build/kpatch-build
Original file line number Diff line number Diff line change
Expand Up @@ -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"}"
Expand Down Expand Up @@ -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"

Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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}}")
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit f4b626b

Please sign in to comment.