Skip to content

Commit 613fe16

Browse files
nathanchanceborkmann
authored andcommitted
kbuild: Add CONFIG_PAHOLE_VERSION
There are a few different places where pahole's version is turned into a three digit form with the exact same command. Move this command into scripts/pahole-version.sh to reduce the amount of duplication across the tree. Create CONFIG_PAHOLE_VERSION so the version code can be used in Kconfig to enable and disable configuration options based on the pahole version, which is already done in a couple of places. Signed-off-by: Nathan Chancellor <[email protected]> Signed-off-by: Daniel Borkmann <[email protected]> Acked-by: Andrii Nakryiko <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent f67644b commit 613fe16

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

MAINTAINERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3524,6 +3524,7 @@ F: net/sched/cls_bpf.c
35243524
F: samples/bpf/
35253525
F: scripts/bpf_doc.py
35263526
F: scripts/pahole-flags.sh
3527+
F: scripts/pahole-version.sh
35273528
F: tools/bpf/
35283529
F: tools/lib/bpf/
35293530
F: tools/testing/selftests/bpf/

init/Kconfig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,10 @@ config CC_HAS_ASM_INLINE
8686
config CC_HAS_NO_PROFILE_FN_ATTR
8787
def_bool $(success,echo '__attribute__((no_profile_instrument_function)) int x();' | $(CC) -x c - -c -o /dev/null -Werror)
8888

89+
config PAHOLE_VERSION
90+
int
91+
default $(shell,$(srctree)/scripts/pahole-version.sh $(PAHOLE))
92+
8993
config CONSTRUCTORS
9094
bool
9195

scripts/pahole-version.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/sh
2+
# SPDX-License-Identifier: GPL-2.0
3+
#
4+
# Usage: $ ./pahole-version.sh pahole
5+
#
6+
# Prints pahole's version in a 3-digit form, such as 119 for v1.19.
7+
8+
if [ ! -x "$(command -v "$@")" ]; then
9+
echo 0
10+
exit 1
11+
fi
12+
13+
"$@" --version | sed -E 's/v([0-9]+)\.([0-9]+)/\1\2/'

0 commit comments

Comments
 (0)