|
|
8b8236 |
From 184bc480d753610efbcb0731f7f4c2ba2bdce256 Mon Sep 17 00:00:00 2001
|
|
|
ad57ea |
From: Song Liu <songliubraving@fb.com>
|
|
|
ad57ea |
Date: Wed, 13 Oct 2021 01:03:55 -0700
|
|
|
8b8236 |
Subject: [PATCH] kpatch-build: add support for clang pgo
|
|
|
ad57ea |
|
|
|
ad57ea |
For clang with Profile-Guided Optimization (PGO), profile data is needed
|
|
|
ad57ea |
to compile the livepatch properly. Add option -p|--profile-data, which
|
|
|
ad57ea |
specifies the profile data file. This option is only valid with
|
|
|
ad57ea |
CONFIG_CC_IS_CLANG and CONFIG_PGO_CLANG.
|
|
|
ad57ea |
|
|
|
ad57ea |
Signed-off-by: Song Liu <songliubraving@fb.com>
|
|
|
ad57ea |
---
|
|
|
8b8236 |
kpatch-build/kpatch-build | 20 +++++++++++++++++++-
|
|
|
8b8236 |
1 file changed, 19 insertions(+), 1 deletion(-)
|
|
|
ad57ea |
|
|
|
ad57ea |
diff --git a/kpatch-build/kpatch-build b/kpatch-build/kpatch-build
|
|
|
8b8236 |
index 634095d5..1f3fc99b 100755
|
|
|
ad57ea |
--- a/kpatch-build/kpatch-build
|
|
|
ad57ea |
+++ b/kpatch-build/kpatch-build
|
|
|
8b8236 |
@@ -535,9 +535,10 @@ usage() {
|
|
|
ad57ea |
echo " --skip-cleanup Skip post-build cleanup" >&2
|
|
|
ad57ea |
echo " --skip-compiler-check Skip compiler version matching check" >&2
|
|
|
ad57ea |
echo " (not recommended)" >&2
|
|
|
ad57ea |
+ echo " -p, --profile-data specify profile data for PGO (clang only)" >&2
|
|
|
ad57ea |
}
|
|
|
ad57ea |
|
|
|
8b8236 |
-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"
|
|
|
8b8236 |
+options="$(getopt -o ha:r:s:c:v:j:t:n:o:dRp: -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,profile-data" -- "$@")" || die "getopt failed"
|
|
|
ad57ea |
|
|
|
ad57ea |
eval set -- "$options"
|
|
|
ad57ea |
|
|
|
8b8236 |
@@ -619,6 +620,10 @@ while [[ $# -gt 0 ]]; do
|
|
|
ad57ea |
echo "WARNING: Skipping compiler version matching check (not recommended)"
|
|
|
ad57ea |
SKIPCOMPILERCHECK=1
|
|
|
ad57ea |
;;
|
|
|
ad57ea |
+ -p|--profile-data)
|
|
|
ad57ea |
+ PROFILE_DATA="$(readlink -f "$2")"
|
|
|
ad57ea |
+ shift
|
|
|
ad57ea |
+ ;;
|
|
|
ad57ea |
*)
|
|
|
ad57ea |
[[ "$1" = "--" ]] && shift && continue
|
|
|
ad57ea |
[[ ! -f "$1" ]] && die "patch file '$1' not found"
|
|
|
8b8236 |
@@ -896,6 +901,16 @@ fi
|
|
|
ad57ea |
|
|
|
8b8236 |
if [[ -n "$CONFIG_CC_IS_CLANG" ]]; then
|
|
|
ad57ea |
echo "WARNING: Clang support is experimental"
|
|
|
8b8236 |
+ if [[ -z "$PROFILE_DATA" ]] && [[ -n "$CONFIG_PGO_CLANG" ]]; then
|
|
|
ad57ea |
+ die "Please specify profile-data for CONFIG_PGO_CLANG"
|
|
|
ad57ea |
+ fi
|
|
|
8b8236 |
+ if [[ -n "$PROFILE_DATA" ]] && [[ -z "$CONFIG_PGO_CLANG" ]]; then
|
|
|
ad57ea |
+ echo "WARNING profile-data specified w/o CONFIG_PGO_CLANG, ignore it"
|
|
|
ad57ea |
+ fi
|
|
|
ad57ea |
+else
|
|
|
ad57ea |
+ if [[ -n "$PROFILE_DATA" ]]; then
|
|
|
ad57ea |
+ die "Only supports profile-data with Clang"
|
|
|
ad57ea |
+ fi
|
|
|
ad57ea |
fi
|
|
|
ad57ea |
|
|
|
ad57ea |
if [[ "$SKIPCOMPILERCHECK" -eq 0 ]]; then
|
|
|
8b8236 |
@@ -943,6 +958,9 @@ declare -a MAKEVARS
|
|
|
8b8236 |
if [[ -n "$CONFIG_CC_IS_CLANG" ]]; then
|
|
|
8b8236 |
MAKEVARS+=("CC=${KPATCH_CC_PREFIX}${CLANG}")
|
|
|
ad57ea |
MAKEVARS+=("HOSTCC=clang")
|
|
|
8b8236 |
+ if [[ -n "$CONFIG_PGO_CLANG" ]]; then
|
|
|
ad57ea |
+ MAKEVARS+=("CFLAGS_PGO_CLANG=-fprofile-use=$PROFILE_DATA")
|
|
|
ad57ea |
+ fi
|
|
|
ad57ea |
else
|
|
|
8b8236 |
MAKEVARS+=("CC=${KPATCH_CC_PREFIX}${GCC}")
|
|
|
ad57ea |
fi
|