Skip to contentSkip to conversation

kbuild: Fix compilation for latest pahole release

PATCH In review Jiri Olsa 5 participants 12 messages Sep 4, 2022 – Oct 18, 2022

Subsystems (2)
lore
Share & tools
lore

Jiri Olsa

author reviewer
#0 lore raw

cover kbuild: Fix compilation for latest pahole release

hi,
new version of pahole (1.24) is causing compilation fail for 5.15 stable kernel, discussed in here [1][2]. Sending fix for that plus one dependency patch.

Note for patch 1:
there was one extra line change in scripts/pahole-flags.sh file in its linux tree merge commit:

fc02cb2b37fe Merge tag 'net-next-for-5.16' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next

not sure how/if to track that, I squashed the change in.

thanks,
jirka

[1] https://lore.kernel.org/bpf/[email protected]/
[2] https://lore.kernel.org/bpf/YwQRKkmWqsf%[email protected]/
---
Jiri Olsa (1):
kbuild: Unify options for BTF generation for vmlinux and modules

Martin Rodriguez Reboredo (1):
kbuild: Add skip_encoding_btf_enum64 option to pahole

 Makefile                  |  3 +++
 scripts/Makefile.modfinal |  2 +-
 scripts/link-vmlinux.sh   | 11 +----------
 scripts/pahole-flags.sh   | 24 ++++++++++++++++++++++++
 4 files changed, 29 insertions(+), 11 deletions(-)
 create mode 100755 scripts/pahole-flags.sh
author reviewer
#1 lore raw

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

From: Jiri Olsa <[email protected]>

commit e27f05147bff21408c1b8410ad8e90cd286e7952 upstream.

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.

[ fixed issues found by kernel test robot ]

---
 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 0802acf352d2..6aa52276e969 100644
@@ -480,6 +480,8 @@ LZ4		= lz4c
 XZ		= xz
 ZSTD		= zstd
 
+PAHOLE_FLAGS	= $(shell PAHOLE=$(PAHOLE) $(srctree)/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 ff805777431c..ce9661d968a3 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 $@; \
 	else								\
 		printf "Skipping BTF generation for %s due to unavailability of vmlinux\n" $@ 1>&2; \
 	fi;
scripts/link-vmlinux.sh +1 -10
index 3819a461465d..57ef6accbb40 100755
@@ -211,7 +211,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"
@@ -226,16 +225,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..e6093adf4c06
@@ -0,0 +1,20 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0
+
+extra_paholeopt=
+
+if ! [ -x "$(command -v ${PAHOLE})" ]; then
+	exit 0
+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.37.2
author reviewer
#2 lore raw

PATCH 2/2 kbuild: Add skip_encoding_btf_enum64 option to pahole

In reply to Jiri Olsa

From: Martin Rodriguez Reboredo <[email protected]>

New pahole (version 1.24) generates by default new BTF_KIND_ENUM64 BTF tag, which is not supported by stable kernel.

As a result the kernel with CONFIG_DEBUG_INFO_BTF option will fail to compile with following error:

BTFIDS vmlinux
FAILED: load BTF from vmlinux: Invalid argument

New pahole provides --skip_encoding_btf_enum64 option to skip BTF_KIND_ENUM64 generation and produce BTF supported by stable kernel.

Adding this option to scripts/pahole-flags.sh.

This change does not have equivalent commit in linus tree, because linus tree has support for BTF_KIND_ENUM64 tag, so it does not need to be disabled.

---
 scripts/pahole-flags.sh | 4 ++++
 1 file changed, 4 insertions(+)
scripts/pahole-flags.sh +4 -0
index e6093adf4c06..7acee326aa6c 100755
@@ -17,4 +17,8 @@ if [ "${pahole_ver}" -ge "121" ]; then
 	extra_paholeopt="${extra_paholeopt} --btf_gen_floats"
 fi
 
+if [ "${pahole_ver}" -ge "124" ]; then
+	extra_paholeopt="${extra_paholeopt} --skip_encoding_btf_enum64"
+fi
+
 echo ${extra_paholeopt}
Signature · 1 line
2.37.2
#3 lore raw

Re: [PATCH stable 5.15 2/2] kbuild: Add skip_encoding_btf_enum64 option to pahole

FYI: kernel test robot notices the stable kernel rule is not satisfied.

Hi,

Thanks for your patch.

FYI: kernel test robot notices the stable kernel rule is not satisfied.

Rule: 'Cc: [email protected]' or 'commit <sha1> upstream.'
Subject: [PATCH stable 5.15 2/2] kbuild: Add skip_encoding_btf_enum64 option to pahole

The check is based on https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html

Signature · 2 lines
0-DAY CI Kernel Test Service
https://01.org/lkp
maintainer
#4 lore raw

Re: [PATCH stable 5.15 2/2] kbuild: Add skip_encoding_btf_enum64 option to pahole

Quoted 11 lines · kernel test robot

Hi,

Thanks for your patch.

FYI: kernel test robot notices the stable kernel rule is not satisfied.

Rule: 'Cc: stable(a)vger.kernel.org' or 'commit <sha1> upstream.'
Subject: [PATCH stable 5.15 2/2] kbuild: Add skip_encoding_btf_enum64 option to pahole

The check is based on https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html

Nice catch, but this one is ok :)

maintainer
#5 lore raw
In reply to Jiri Olsa
Quoted 5 lines · Jiri Olsa

hi,
new version of pahole (1.24) is causing compilation fail for 5.15 stable kernel, discussed in here [1][2]. Sending fix for that plus one dependency patch.

Quoted 7 lines

Note for patch 1:
there was one extra line change in scripts/pahole-flags.sh file in its linux tree merge commit:

fc02cb2b37fe Merge tag 'net-next-for-5.16' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next

not sure how/if to track that, I squashed the change in.

Squashing is fine, thanks.

And do we also need this for kernels older than 5.15? Like 5.10 and 5.4?

thanks,

greg k-h

#6 lore raw
Quoted 10 lines · Greg KH
Quoted 9 lines · Jiri Olsa

hi,
new version of pahole (1.24) is causing compilation fail for 5.15 stable kernel, discussed in here [1][2]. Sending fix for that plus one dependency patch.

Note for patch 1:
there was one extra line change in scripts/pahole-flags.sh file in its linux tree merge commit:

Quoted 7 lines
Quoted 3 lines

fc02cb2b37fe Merge tag 'net-next-for-5.16' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next

not sure how/if to track that, I squashed the change in.

Squashing is fine, thanks.

And do we also need this for kernels older than 5.15? Like 5.10 and 5.4?

yes, 5.10 needs similar patchset, but this for 5.15 won't apply there, so I'll send it separately

5.4 passes compilation, but I don't think it will boot properly, still need to check on that

in any case, more patches are coming ;-)

jirka

maintainer
#7 lore raw
Quoted 19 lines · Jiri Olsa
Quoted 10 lines · Greg KH
Quoted 9 lines · Jiri Olsa

hi,
new version of pahole (1.24) is causing compilation fail for 5.15 stable kernel, discussed in here [1][2]. Sending fix for that plus one dependency patch.

Note for patch 1:
there was one extra line change in scripts/pahole-flags.sh file in its linux tree merge commit:

Quoted 7 lines
Quoted 3 lines

fc02cb2b37fe Merge tag 'net-next-for-5.16' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next

not sure how/if to track that, I squashed the change in.

Squashing is fine, thanks.

And do we also need this for kernels older than 5.15? Like 5.10 and 5.4?

Quoted 7 lines

yes, 5.10 needs similar patchset, but this for 5.15 won't apply there, so I'll send it separately

5.4 passes compilation, but I don't think it will boot properly, still need to check on that

in any case, more patches are coming ;-)

Ok, these two are now queued up, feel free to send the rest when you have them ready.

thanks,

greg k-h

#8 lore raw
Quoted 23 lines · Greg KH
Quoted 22 lines · Jiri Olsa
Quoted 10 lines · Greg KH
Quoted 9 lines · Jiri Olsa

hi,
new version of pahole (1.24) is causing compilation fail for 5.15 stable kernel, discussed in here [1][2]. Sending fix for that plus one dependency patch.

Note for patch 1:
there was one extra line change in scripts/pahole-flags.sh file in its linux tree merge commit:

Quoted 7 lines
Quoted 3 lines

fc02cb2b37fe Merge tag 'net-next-for-5.16' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next

not sure how/if to track that, I squashed the change in.

Squashing is fine, thanks.

And do we also need this for kernels older than 5.15? Like 5.10 and 5.4?

yes, 5.10 needs similar patchset, but this for 5.15 won't apply there, so I'll send it separately

Quoted 7 lines
Quoted 4 lines

5.4 passes compilation, but I don't think it will boot properly, still need to check on that

in any case, more patches are coming ;-)

Ok, these two are now queued up, feel free to send the rest when you have them ready.

hi,
as for 5.10 changes, I have them ready, pushed in here:
git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git pahole_fix_5_10

but it looks like CONFIG_DEBUG_INFO_BTF is not being used in 5.10, because I had to backport other similar option, that would break the build even earlier (--skip_encoding_btf_vars), or people use just old pahole ;-)

I suggest we wait with this change until somebody actually wants this fixed, AFAICS there's no report of broken 5.10 build yet

thanks,
jirka

#9 lore raw
Quoted 36 lines · Jiri Olsa
Quoted 23 lines · Greg KH
Quoted 22 lines · Jiri Olsa
Quoted 10 lines · Greg KH
Quoted 9 lines · Jiri Olsa

hi,
new version of pahole (1.24) is causing compilation fail for 5.15 stable kernel, discussed in here [1][2]. Sending fix for that plus one dependency patch.

Note for patch 1:
there was one extra line change in scripts/pahole-flags.sh file in its linux tree merge commit:

Quoted 7 lines
Quoted 3 lines

fc02cb2b37fe Merge tag 'net-next-for-5.16' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next

not sure how/if to track that, I squashed the change in.

Squashing is fine, thanks.

And do we also need this for kernels older than 5.15? Like 5.10 and 5.4?

yes, 5.10 needs similar patchset, but this for 5.15 won't apply there, so I'll send it separately

Quoted 7 lines
Quoted 4 lines

5.4 passes compilation, but I don't think it will boot properly, still need to check on that

in any case, more patches are coming ;-)

Ok, these two are now queued up, feel free to send the rest when you have them ready.

hi,
as for 5.10 changes, I have them ready, pushed in here:
git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git pahole_fix_5_10

Quoted 7 lines

but it looks like CONFIG_DEBUG_INFO_BTF is not being used in 5.10, because I had to backport other similar option, that would break the build even earlier (--skip_encoding_btf_vars), or people use just old pahole ;-)

I suggest we wait with this change until somebody actually wants this fixed, AFAICS there's no report of broken 5.10 build yet

Consider this your first report :)

My build containers include the latest pahole, as I have noticed more issues with older pahole in newer kernels than newer pahole in older kernels, as least until now. I have tripped over this issue on both 5.19 and 5.10, as the stable-only commit b775fbf532dc ("kbuild: Add skip_encoding_btf_enum64 option to pahole") was only applied to 5.15, even though it is needed in all kernels prior to 6.0.

Please consider explicitly sending the 5.10 series to stable and requesting b775fbf532dc to be applied to 5.19.

Cheers,
Nathan

#10 lore raw
Quoted 42 lines · Nathan Chancellor
Quoted 41 lines · Jiri Olsa
Quoted 23 lines · Greg KH
Quoted 22 lines · Jiri Olsa
Quoted 10 lines · Greg KH
Quoted 9 lines · Jiri Olsa

hi,
new version of pahole (1.24) is causing compilation fail for 5.15 stable kernel, discussed in here [1][2]. Sending fix for that plus one dependency patch.

Note for patch 1:
there was one extra line change in scripts/pahole-flags.sh file in its linux tree merge commit:

Quoted 7 lines
Quoted 3 lines

fc02cb2b37fe Merge tag 'net-next-for-5.16' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next

not sure how/if to track that, I squashed the change in.

Squashing is fine, thanks.

And do we also need this for kernels older than 5.15? Like 5.10 and 5.4?

yes, 5.10 needs similar patchset, but this for 5.15 won't apply there, so I'll send it separately

Quoted 7 lines
Quoted 4 lines

5.4 passes compilation, but I don't think it will boot properly, still need to check on that

in any case, more patches are coming ;-)

Ok, these two are now queued up, feel free to send the rest when you have them ready.

hi,
as for 5.10 changes, I have them ready, pushed in here:
git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git pahole_fix_5_10

but it looks like CONFIG_DEBUG_INFO_BTF is not being used in 5.10, because I had to backport other similar option, that would break the build even earlier (--skip_encoding_btf_vars), or people use just old pahole ;-)

Quoted 4 lines
Quoted 2 lines

I suggest we wait with this change until somebody actually wants this fixed, AFAICS there's no report of broken 5.10 build yet

Consider this your first report :)

va bene ;-)

Quoted 9 lines

My build containers include the latest pahole, as I have noticed more issues with older pahole in newer kernels than newer pahole in older kernels, as least until now. I have tripped over this issue on both 5.19 and 5.10, as the stable-only commit b775fbf532dc ("kbuild: Add skip_encoding_btf_enum64 option to pahole") was only applied to 5.15, even though it is needed in all kernels prior to 6.0.

Please consider explicitly sending the 5.10 series to stable and

sure I'll rebase and post it

Quoted 1 line

requesting b775fbf532dc to be applied to 5.19.

hm, it was already posted for 5.19:
https://lore.kernel.org/bpf/[email protected]/

Greg,
is there something missing for it to be taken?

thanks,
jirka

maintainer
#11 lore raw
Quoted 62 lines · Jiri Olsa
Quoted 42 lines · Nathan Chancellor
Quoted 41 lines · Jiri Olsa
Quoted 23 lines · Greg KH
Quoted 22 lines · Jiri Olsa
Quoted 10 lines · Greg KH
Quoted 9 lines · Jiri Olsa

hi,
new version of pahole (1.24) is causing compilation fail for 5.15 stable kernel, discussed in here [1][2]. Sending fix for that plus one dependency patch.

Note for patch 1:
there was one extra line change in scripts/pahole-flags.sh file in its linux tree merge commit:

Quoted 7 lines
Quoted 3 lines

fc02cb2b37fe Merge tag 'net-next-for-5.16' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next

not sure how/if to track that, I squashed the change in.

Squashing is fine, thanks.

And do we also need this for kernels older than 5.15? Like 5.10 and 5.4?

yes, 5.10 needs similar patchset, but this for 5.15 won't apply there, so I'll send it separately

Quoted 7 lines
Quoted 4 lines

5.4 passes compilation, but I don't think it will boot properly, still need to check on that

in any case, more patches are coming ;-)

Ok, these two are now queued up, feel free to send the rest when you have them ready.

hi,
as for 5.10 changes, I have them ready, pushed in here:
git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git pahole_fix_5_10

but it looks like CONFIG_DEBUG_INFO_BTF is not being used in 5.10, because I had to backport other similar option, that would break the build even earlier (--skip_encoding_btf_vars), or people use just old pahole ;-)

Quoted 4 lines
Quoted 2 lines

I suggest we wait with this change until somebody actually wants this fixed, AFAICS there's no report of broken 5.10 build yet

Consider this your first report :)

va bene ;-)

Quoted 9 lines

My build containers include the latest pahole, as I have noticed more issues with older pahole in newer kernels than newer pahole in older kernels, as least until now. I have tripped over this issue on both 5.19 and 5.10, as the stable-only commit b775fbf532dc ("kbuild: Add skip_encoding_btf_enum64 option to pahole") was only applied to 5.15, even though it is needed in all kernels prior to 6.0.

Please consider explicitly sending the 5.10 series to stable and

sure I'll rebase and post it

Quoted 7 lines
Quoted 1 line

requesting b775fbf532dc to be applied to 5.19.

hm, it was already posted for 5.19:
https://lore.kernel.org/bpf/[email protected]/

Greg,
is there something missing for it to be taken?

Ick, sorry, this got lost. Now queued up.

greg k-h