Skip to contentSkip to conversation

kbuild: Unify options for BTF generation for vmlinux and modules

PATCH Superseded Jiri Olsa 2 participants 5 messages Oct 26, 2021 – Oct 28, 2021

Subsystems (4)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Jiri Olsa

author
#0 lore raw

PATCH v2 1/1 kbuild: Unify options for BTF generation for vmlinux and modules

Using new PAHOLE_FLAGS variable to pass extra arguments to pahole for both vmlinux and modules BTF data generation.

Adding new scripts/pahole-flags.sh script that detect and prints pahole options.

---
v2 changes:
- posting separately from original patchset
- added Andrii's ack

 Makefile                  |  3 +++
 scripts/Makefile.modfinal |  2 +-
 scripts/link-vmlinux.sh   | 11 +----------
 scripts/pahole-flags.sh   | 20 ++++++++++++++++++++
 4 files changed, 25 insertions(+), 11 deletions(-)
 create mode 100755 scripts/pahole-flags.sh
Makefile +3 -0
index 437ccc66a1c2..ee514b80c62e 100644
@@ -480,6 +480,8 @@ LZ4		= lz4c
 XZ		= xz
 ZSTD		= zstd
 
+PAHOLE_FLAGS	= $(shell PAHOLE=$(PAHOLE) scripts/pahole-flags.sh)
+
 CHECKFLAGS     := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \
 		  -Wbitwise -Wno-return-void -Wno-unknown-attribute $(CF)
 NOSTDINC_FLAGS :=
@@ -534,6 +536,7 @@ export KBUILD_CFLAGS CFLAGS_KERNEL CFLAGS_MODULE
 export KBUILD_AFLAGS AFLAGS_KERNEL AFLAGS_MODULE
 export KBUILD_AFLAGS_MODULE KBUILD_CFLAGS_MODULE KBUILD_LDFLAGS_MODULE
 export KBUILD_AFLAGS_KERNEL KBUILD_CFLAGS_KERNEL
+export PAHOLE_FLAGS
 
 # Files to ignore in find ... statements
 
scripts/Makefile.modfinal +1 -1
index 1fb45b011e4b..7f39599e9fae 100644
@@ -40,7 +40,7 @@ quiet_cmd_ld_ko_o = LD [M]  $@
 quiet_cmd_btf_ko = BTF [M] $@
       cmd_btf_ko = 							\
 	if [ -f vmlinux ]; then						\
-		LLVM_OBJCOPY="$(OBJCOPY)" $(PAHOLE) -J --btf_base vmlinux $@; \
+		LLVM_OBJCOPY="$(OBJCOPY)" $(PAHOLE) -J $(PAHOLE_FLAGS) --btf_base vmlinux $@; \
 		$(RESOLVE_BTFIDS) -b vmlinux $@; 			\
 	else								\
 		printf "Skipping BTF generation for %s due to unavailability of vmlinux\n" $@ 1>&2; \
scripts/link-vmlinux.sh +1 -10
index d74cee5c4326..3ea7cece7c97 100755
@@ -205,7 +205,6 @@ vmlinux_link()
 gen_btf()
 {
 	local pahole_ver
-	local extra_paholeopt=
 
 	if ! [ -x "$(command -v ${PAHOLE})" ]; then
 		echo >&2 "BTF: ${1}: pahole (${PAHOLE}) is not available"
@@ -220,16 +219,8 @@ gen_btf()
 
 	vmlinux_link ${1}
 
-	if [ "${pahole_ver}" -ge "118" ] && [ "${pahole_ver}" -le "121" ]; then
-		# pahole 1.18 through 1.21 can't handle zero-sized per-CPU vars
-		extra_paholeopt="${extra_paholeopt} --skip_encoding_btf_vars"
-	fi
-	if [ "${pahole_ver}" -ge "121" ]; then
-		extra_paholeopt="${extra_paholeopt} --btf_gen_floats"
-	fi
-
 	info "BTF" ${2}
-	LLVM_OBJCOPY="${OBJCOPY}" ${PAHOLE} -J ${extra_paholeopt} ${1}
+	LLVM_OBJCOPY="${OBJCOPY}" ${PAHOLE} -J ${PAHOLE_FLAGS} ${1}
 
 	# Create ${2} which contains just .BTF section but no symbols. Add
 	# SHF_ALLOC because .BTF will be part of the vmlinux image. --strip-all
scripts/pahole-flags.sh new file +20 -0
new file mode 100755
index 000000000000..2b99fc77019c
@@ -0,0 +1,20 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0
+
+extra_paholeopt=
+
+if ! [ -x "$(command -v ${PAHOLE})" ]; then
+	return
+fi
+
+pahole_ver=$(${PAHOLE} --version | sed -E 's/v([0-9]+)\.([0-9]+)/\1\2/')
+
+if [ "${pahole_ver}" -ge "118" ] && [ "${pahole_ver}" -le "121" ]; then
+	# pahole 1.18 through 1.21 can't handle zero-sized per-CPU vars
+	extra_paholeopt="${extra_paholeopt} --skip_encoding_btf_vars"
+fi
+if [ "${pahole_ver}" -ge "121" ]; then
+	extra_paholeopt="${extra_paholeopt} --btf_gen_floats"
+fi
+
+echo ${extra_paholeopt}
Signature · 1 line
2.31.1
#1 lore raw
I love your patch! Yet something to improve:

Hi Jiri,

I love your patch! Yet something to improve:

[auto build test ERROR on bpf-next/master]

url:    https://github.com/0day-ci/linux/commits/Jiri-Olsa/kbuild-Unify-options-for-BTF-generation-for-vmlinux-and-modules/20211027-052639
base:   https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git master
config: mips-allyesconfig (attached as .config)
compiler: mips-linux-gcc (GCC) 11.2.0

reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/cd9d0571d9b0204fb3c1badf41ca847ba840e40c
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Jiri-Olsa/kbuild-Unify-options-for-BTF-generation-for-vmlinux-and-modules/20211027-052639 git checkout cd9d0571d9b0204fb3c1badf41ca847ba840e40c
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross ARCH=mips

If you fix the issue, kindly add following tag as appropriate

All errors (new ones prefixed by >>):

>> /bin/sh: 1: scripts/pahole-flags.sh: not found
>> /bin/sh: 1: scripts/pahole-flags.sh: not found
>> /bin/sh: 1: scripts/pahole-flags.sh: not found
--
>> /bin/sh: 1: scripts/pahole-flags.sh: not found
>> /bin/sh: 1: scripts/pahole-flags.sh: not found
>> /bin/sh: 1: scripts/pahole-flags.sh: not found
>> /bin/sh: 1: scripts/pahole-flags.sh: not found
>> /bin/sh: 1: scripts/pahole-flags.sh: not found
>> /bin/sh: 1: scripts/pahole-flags.sh: not found
>> /bin/sh: 1: scripts/pahole-flags.sh: not found
>> /bin/sh: 1: scripts/pahole-flags.sh: not found
>> /bin/sh: 1: scripts/pahole-flags.sh: not found
>> /bin/sh: 1: scripts/pahole-flags.sh: not found
>> /bin/sh: 1: scripts/pahole-flags.sh: not found
>> /bin/sh: 1: scripts/pahole-flags.sh: not found
>> /bin/sh: 1: scripts/pahole-flags.sh: not found
   scripts/genksyms/parse.y: warning: 9 shift/reduce conflicts [-Wconflicts-sr]
   scripts/genksyms/parse.y: warning: 5 reduce/reduce conflicts [-Wconflicts-rr]
>> /bin/sh: 1: scripts/pahole-flags.sh: not found
>> /bin/sh: 1: scripts/pahole-flags.sh: not found

arch/mips/kernel/asm-offsets.c:26:6: error: no previous prototype for 'output_ptreg_defines' [-Werror=missing-prototypes]
26 | void output_ptreg_defines(void)
| ^~~~~~~~~~~~~~~~~~~~
arch/mips/kernel/asm-offsets.c:78:6: error: no previous prototype for 'output_task_defines' [-Werror=missing-prototypes]
78 | void output_task_defines(void)
| ^~~~~~~~~~~~~~~~~~~
arch/mips/kernel/asm-offsets.c:92:6: error: no previous prototype for 'output_thread_info_defines' [-Werror=missing-prototypes]
92 | void output_thread_info_defines(void)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
arch/mips/kernel/asm-offsets.c:108:6: error: no previous prototype for 'output_thread_defines' [-Werror=missing-prototypes]
108 | void output_thread_defines(void)
| ^~~~~~~~~~~~~~~~~~~~~
arch/mips/kernel/asm-offsets.c:136:6: error: no previous prototype for 'output_thread_fpu_defines' [-Werror=missing-prototypes]
136 | void output_thread_fpu_defines(void)
| ^~~~~~~~~~~~~~~~~~~~~~~~~
arch/mips/kernel/asm-offsets.c:179:6: error: no previous prototype for 'output_mm_defines' [-Werror=missing-prototypes]
179 | void output_mm_defines(void)
| ^~~~~~~~~~~~~~~~~
arch/mips/kernel/asm-offsets.c:218:6: error: no previous prototype for 'output_sc_defines' [-Werror=missing-prototypes]
218 | void output_sc_defines(void)
| ^~~~~~~~~~~~~~~~~
arch/mips/kernel/asm-offsets.c:253:6: error: no previous prototype for 'output_signal_defined' [-Werror=missing-prototypes]
253 | void output_signal_defined(void)
| ^~~~~~~~~~~~~~~~~~~~~
arch/mips/kernel/asm-offsets.c:320:6: error: no previous prototype for 'output_pbe_defines' [-Werror=missing-prototypes]
320 | void output_pbe_defines(void)
| ^~~~~~~~~~~~~~~~~~
arch/mips/kernel/asm-offsets.c:332:6: error: no previous prototype for 'output_pm_defines' [-Werror=missing-prototypes]
332 | void output_pm_defines(void)
| ^~~~~~~~~~~~~~~~~
arch/mips/kernel/asm-offsets.c:346:6: error: no previous prototype for 'output_kvm_defines' [-Werror=missing-prototypes]
346 | void output_kvm_defines(void)
| ^~~~~~~~~~~~~~~~~~
arch/mips/kernel/asm-offsets.c:390:6: error: no previous prototype for 'output_cps_defines' [-Werror=missing-prototypes]
390 | void output_cps_defines(void)
| ^~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make[2]: *** [scripts/Makefile.build:121: arch/mips/kernel/asm-offsets.s] Error 1
make[2]: Target '__build' not remade because of errors.
make[1]: *** [Makefile:1222: prepare0] Error 2
make[1]: Target 'prepare' not remade because of errors.
make: *** [Makefile:219: __sub-make] Error 2
make: Target 'prepare' not remade because of errors.

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

#2 lore raw
In reply to Jiri Olsa
I love your patch! Yet something to improve:

Hi Jiri,

I love your patch! Yet something to improve:

[auto build test ERROR on bpf-next/master]

url:    https://github.com/0day-ci/linux/commits/Jiri-Olsa/kbuild-Unify-options-for-BTF-generation-for-vmlinux-and-modules/20211027-052639
base:   https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git master
config: powerpc64-buildonly-randconfig-r006-20211027 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 5db7568a6a1fcb408eb8988abdaff2a225a8eb72)

reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# install powerpc64 cross compiling tool for clang build
# apt-get install binutils-powerpc64-linux-gnu
# https://github.com/0day-ci/linux/commit/cd9d0571d9b0204fb3c1badf41ca847ba840e40c
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Jiri-Olsa/kbuild-Unify-options-for-BTF-generation-for-vmlinux-and-modules/20211027-052639 git checkout cd9d0571d9b0204fb3c1badf41ca847ba840e40c
# save the attached .config to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=powerpc distclean

If you fix the issue, kindly add following tag as appropriate

All errors (new ones prefixed by >>):

>> /bin/sh: 1: scripts/pahole-flags.sh: not found
>> /bin/sh: 1: scripts/pahole-flags.sh: not found
>> /bin/sh: 1: scripts/pahole-flags.sh: not found
>> /bin/sh: 1: scripts/pahole-flags.sh: not found
>> /bin/sh: 1: scripts/pahole-flags.sh: not found
>> /bin/sh: 1: scripts/pahole-flags.sh: not found
>> /bin/sh: 1: scripts/pahole-flags.sh: not found
>> /bin/sh: 1: scripts/pahole-flags.sh: not found
>> /bin/sh: 1: scripts/pahole-flags.sh: not found
>> /bin/sh: 1: scripts/pahole-flags.sh: not found
>> /bin/sh: 1: scripts/pahole-flags.sh: not found
>> /bin/sh: 1: scripts/pahole-flags.sh: not found
>> /bin/sh: 1: scripts/pahole-flags.sh: not found
>> /bin/sh: 1: scripts/pahole-flags.sh: not found
>> /bin/sh: 1: scripts/pahole-flags.sh: not found
>> /bin/sh: 1: scripts/pahole-flags.sh: not found
>> /bin/sh: 1: scripts/pahole-flags.sh: not found
>> /bin/sh: 1: scripts/pahole-flags.sh: not found
>> /bin/sh: 1: scripts/pahole-flags.sh: not found
>> /bin/sh: 1: scripts/pahole-flags.sh: not found

/bin/sh: 1: scripts/pahole-flags.sh: not found
/bin/sh: 1: scripts/pahole-flags.sh: not found
/bin/sh: 1: scripts/pahole-flags.sh: not found
/bin/sh: 1: scripts/pahole-flags.sh: not found
--

>> /bin/sh: 1: scripts/pahole-flags.sh: not found
>> /bin/sh: 1: scripts/pahole-flags.sh: not found
>> /bin/sh: 1: scripts/pahole-flags.sh: not found
--
>> /bin/sh: 1: scripts/pahole-flags.sh: not found
>> /bin/sh: 1: scripts/pahole-flags.sh: not found
>> /bin/sh: 1: scripts/pahole-flags.sh: not found
>> /bin/sh: 1: scripts/pahole-flags.sh: not found
>> /bin/sh: 1: scripts/pahole-flags.sh: not found
>> /bin/sh: 1: scripts/pahole-flags.sh: not found
>> /bin/sh: 1: scripts/pahole-flags.sh: not found
>> /bin/sh: 1: scripts/pahole-flags.sh: not found
>> /bin/sh: 1: scripts/pahole-flags.sh: not found
>> /bin/sh: 1: scripts/pahole-flags.sh: not found
>> /bin/sh: 1: scripts/pahole-flags.sh: not found
   scripts/genksyms/parse.y: warning: 9 shift/reduce conflicts [-Wconflicts-sr]
   scripts/genksyms/parse.y: warning: 5 reduce/reduce conflicts [-Wconflicts-rr]
>> /bin/sh: 1: scripts/pahole-flags.sh: not found
>> /bin/sh: 1: scripts/pahole-flags.sh: not found

clang-14: error: unsupported argument '-mpower4' to option 'Wa,'
clang-14: error: unsupported argument '-many' to option 'Wa,' make[2]: *** [scripts/Makefile.build:277: scripts/mod/empty.o] Error 1 make[2]: Target '__build' not remade because of errors. make[1]: *** [Makefile:1221: prepare0] Error 2
make[1]: Target 'prepare' not remade because of errors.
make: *** [Makefile:219: __sub-make] Error 2
make: Target 'prepare' not remade because of errors.

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

#3 lore raw
In reply to Jiri Olsa
I love your patch! Yet something to improve:

Hi Jiri,

I love your patch! Yet something to improve:

[auto build test ERROR on bpf-next/master]

url:    https://github.com/0day-ci/linux/commits/Jiri-Olsa/kbuild-Unify-options-for-BTF-generation-for-vmlinux-and-modules/20211027-052639
base:   https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git master
config: openrisc-buildonly-randconfig-r001-20211027 (attached as .config)
compiler: or1k-linux-gcc (GCC) 11.2.0

reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/cd9d0571d9b0204fb3c1badf41ca847ba840e40c
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Jiri-Olsa/kbuild-Unify-options-for-BTF-generation-for-vmlinux-and-modules/20211027-052639 git checkout cd9d0571d9b0204fb3c1badf41ca847ba840e40c
# save the attached .config to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=openrisc SHELL=/bin/bash

If you fix the issue, kindly add following tag as appropriate

All errors (new ones prefixed by >>):

>> /bin/bash: scripts/pahole-flags.sh: No such file or directory
>> /bin/bash: scripts/pahole-flags.sh: No such file or directory
>> /bin/bash: scripts/pahole-flags.sh: No such file or directory
>> /bin/bash: scripts/pahole-flags.sh: No such file or directory
>> /bin/bash: scripts/pahole-flags.sh: No such file or directory
>> /bin/bash: scripts/pahole-flags.sh: No such file or directory
>> /bin/bash: scripts/pahole-flags.sh: No such file or directory
>> /bin/bash: scripts/pahole-flags.sh: No such file or directory
>> /bin/bash: scripts/pahole-flags.sh: No such file or directory
>> /bin/bash: scripts/pahole-flags.sh: No such file or directory
>> /bin/bash: scripts/pahole-flags.sh: No such file or directory
>> /bin/bash: scripts/pahole-flags.sh: No such file or directory
>> /bin/bash: scripts/pahole-flags.sh: No such file or directory
>> /bin/bash: scripts/pahole-flags.sh: No such file or directory
>> /bin/bash: scripts/pahole-flags.sh: No such file or directory
>> /bin/bash: scripts/pahole-flags.sh: No such file or directory
>> /bin/bash: scripts/pahole-flags.sh: No such file or directory
>> /bin/bash: scripts/pahole-flags.sh: No such file or directory
>> /bin/bash: scripts/pahole-flags.sh: No such file or directory
>> /bin/bash: scripts/pahole-flags.sh: No such file or directory

/bin/bash: scripts/pahole-flags.sh: No such file or directory /bin/bash: scripts/pahole-flags.sh: No such file or directory make[1]: *** [Makefile:1871: init] Error 2
make[1]: *** [Makefile:1871: arch/openrisc] Error 2 /bin/bash: scripts/pahole-flags.sh: No such file or directory /bin/bash: scripts/pahole-flags.sh: No such file or directory /bin/bash: scripts/pahole-flags.sh: No such file or directory /bin/bash: scripts/pahole-flags.sh: No such file or directory /bin/bash: scripts/pahole-flags.sh: No such file or directory /bin/bash: scripts/pahole-flags.sh: No such file or directory /bin/bash: scripts/pahole-flags.sh: No such file or directory make[1]: *** [Makefile:1871: security] Error 2 make[1]: *** [Makefile:1871: mm] Error 2
make[1]: *** [Makefile:1871: block] Error 2 make[1]: *** [Makefile:1871: kernel] Error 2 make[1]: *** [Makefile:1871: net] Error 2
make[1]: *** [Makefile:1871: lib] Error 2
make[1]: *** [Makefile:1871: fs] Error 2
make[1]: *** [Makefile:1871: drivers] Error 2 make[1]: *** [Makefile:1871: sound] Error 2 make[1]: Target '__all' not remade because of errors.
--

>> /bin/bash: scripts/pahole-flags.sh: No such file or directory

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

author
#4 lore raw
In reply to Jiri Olsa
Quoted 8 lines · Jiri Olsa

Using new PAHOLE_FLAGS variable to pass extra arguments to pahole for both vmlinux and modules BTF data generation.

Adding new scripts/pahole-flags.sh script that detect and prints pahole options.

I'm checking on reported build failures and will send v3

jirka

Quoted 105 lines

---
v2 changes:
- posting separately from original patchset
- added Andrii's ack

 Makefile                  |  3 +++
 scripts/Makefile.modfinal |  2 +-
 scripts/link-vmlinux.sh   | 11 +----------
 scripts/pahole-flags.sh   | 20 ++++++++++++++++++++
 4 files changed, 25 insertions(+), 11 deletions(-)
 create mode 100755 scripts/pahole-flags.sh
Makefile +3 -0
index 437ccc66a1c2..ee514b80c62e 100644
@@ -480,6 +480,8 @@ LZ4		= lz4c
 XZ		= xz
 ZSTD		= zstd
 
+PAHOLE_FLAGS	= $(shell PAHOLE=$(PAHOLE) scripts/pahole-flags.sh)
+
 CHECKFLAGS     := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \
 		  -Wbitwise -Wno-return-void -Wno-unknown-attribute $(CF)
 NOSTDINC_FLAGS :=
@@ -534,6 +536,7 @@ export KBUILD_CFLAGS CFLAGS_KERNEL CFLAGS_MODULE
 export KBUILD_AFLAGS AFLAGS_KERNEL AFLAGS_MODULE
 export KBUILD_AFLAGS_MODULE KBUILD_CFLAGS_MODULE KBUILD_LDFLAGS_MODULE
 export KBUILD_AFLAGS_KERNEL KBUILD_CFLAGS_KERNEL
+export PAHOLE_FLAGS
 
 # Files to ignore in find ... statements
 
scripts/Makefile.modfinal +1 -1
index 1fb45b011e4b..7f39599e9fae 100644
@@ -40,7 +40,7 @@ quiet_cmd_ld_ko_o = LD [M]  $@
 quiet_cmd_btf_ko = BTF [M] $@
       cmd_btf_ko = 							\
 	if [ -f vmlinux ]; then						\
-		LLVM_OBJCOPY="$(OBJCOPY)" $(PAHOLE) -J --btf_base vmlinux $@; \
+		LLVM_OBJCOPY="$(OBJCOPY)" $(PAHOLE) -J $(PAHOLE_FLAGS) --btf_base vmlinux $@; \
 		$(RESOLVE_BTFIDS) -b vmlinux $@; 			\
 	else								\
 		printf "Skipping BTF generation for %s due to unavailability of vmlinux\n" $@ 1>&2; \
scripts/link-vmlinux.sh +1 -10
index d74cee5c4326..3ea7cece7c97 100755
@@ -205,7 +205,6 @@ vmlinux_link()
 gen_btf()
 {
 	local pahole_ver
-	local extra_paholeopt=
 
 	if ! [ -x "$(command -v ${PAHOLE})" ]; then
 		echo >&2 "BTF: ${1}: pahole (${PAHOLE}) is not available"
@@ -220,16 +219,8 @@ gen_btf()
 
 	vmlinux_link ${1}
 
-	if [ "${pahole_ver}" -ge "118" ] && [ "${pahole_ver}" -le "121" ]; then
-		# pahole 1.18 through 1.21 can't handle zero-sized per-CPU vars
-		extra_paholeopt="${extra_paholeopt} --skip_encoding_btf_vars"
-	fi
-	if [ "${pahole_ver}" -ge "121" ]; then
-		extra_paholeopt="${extra_paholeopt} --btf_gen_floats"
-	fi
-
 	info "BTF" ${2}
-	LLVM_OBJCOPY="${OBJCOPY}" ${PAHOLE} -J ${extra_paholeopt} ${1}
+	LLVM_OBJCOPY="${OBJCOPY}" ${PAHOLE} -J ${PAHOLE_FLAGS} ${1}
 
 	# Create ${2} which contains just .BTF section but no symbols. Add
 	# SHF_ALLOC because .BTF will be part of the vmlinux image. --strip-all
scripts/pahole-flags.sh new file +20 -0
new file mode 100755
index 000000000000..2b99fc77019c
@@ -0,0 +1,20 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0
+
+extra_paholeopt=
+
+if ! [ -x "$(command -v ${PAHOLE})" ]; then
+	return
+fi
+
+pahole_ver=$(${PAHOLE} --version | sed -E 's/v([0-9]+)\.([0-9]+)/\1\2/')
+
+if [ "${pahole_ver}" -ge "118" ] && [ "${pahole_ver}" -le "121" ]; then
+	# pahole 1.18 through 1.21 can't handle zero-sized per-CPU vars
+	extra_paholeopt="${extra_paholeopt} --skip_encoding_btf_vars"
+fi
+if [ "${pahole_ver}" -ge "121" ]; then
+	extra_paholeopt="${extra_paholeopt} --btf_gen_floats"
+fi
+
+echo ${extra_paholeopt}
Signature · 1 line
2.31.1