All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 5.10] kbuild: fix BTF build with pahole 1.24
@ 2022-10-27 12:01 Dominique Martinet
  2022-10-27 12:58 ` Jiri Olsa
  0 siblings, 1 reply; 4+ messages in thread
From: Dominique Martinet @ 2022-10-27 12:01 UTC (permalink / raw)
  To: Greg Kroah-Hartman, stable
  Cc: Dominique Martinet, Martin Rodriguez Reboredo, Jiri Olsa,
	Andrii Nakryiko

pahole 1.24 broke builds on kernel <6.0 which do not have the
new BTF_KIND_ENUM64 BTF tag.
The 5.15 branch fixed this in commit b775fbf532dc01ae53a6fc56168fd30cb4b0c658
("kbuild: Add skip_encoding_btf_enum64 option to pahole"), which
we cannot use directly for 5.10 because 5.10 does not have the
pahole-flags.sh script, itself introduced in upstream commit
0baced0e0938f2895ceba54038eaf15ed91032e7 ("kbuild: Unify options
for BTF generation for vmlinux and modules")

that last commit is difficult to backport as 5.10 does not have BTF
for modules support: work around the problem by just copying the
pahole-flags.sh script and calling it directly in link-vmlinux.sh,
which is hopefully acceptable as the flags are not shared in this tree.

Note that compared to 5.15 the flags script does not have
--btf_gen_floats as linux 5.10 did not have that BTF tag yet;
but any new flag added to 5.15 will not be able to be added to 5.10 in
an identical way for any future breakage.

Cc: Martin Rodriguez Reboredo <yakoyoku@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
CC: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Dominique Martinet <asmadeus@codewreck.org>
---

This came up after updating nixpkgs to pahole 1.24.
https://github.com/NixOS/nixpkgs/pull/194551
Their 5.15's kernel built just fine as it already got some special
handling added, but since that handling was not added to other stable
kernels it started breaking builds after merging...

This shouldn't break anything, and should also as a byproduct fix some
builds with pahole 1.18 through 1.21 although I'm not sure if it never
has been backported to 5.10 because it's not a problem there or because
nobody cared (I probably only started caring after the 1.22 release)

Anyway, if more can be shared I think it'll make things simpler for
everyone going forward :)


 scripts/link-vmlinux.sh |  2 +-
 scripts/pahole-flags.sh | 21 +++++++++++++++++++++
 2 files changed, 22 insertions(+), 1 deletion(-)
 create mode 100755 scripts/pahole-flags.sh

diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
index d0b44bee9286..c24da7b68619 100755
--- a/scripts/link-vmlinux.sh
+++ b/scripts/link-vmlinux.sh
@@ -161,7 +161,7 @@ gen_btf()
 	vmlinux_link ${1}
 
 	info "BTF" ${2}
-	LLVM_OBJCOPY=${OBJCOPY} ${PAHOLE} -J ${1}
+	LLVM_OBJCOPY="${OBJCOPY}" ${PAHOLE} -J $("${srctree}/scripts/pahole_flags.sh") ${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
diff --git a/scripts/pahole-flags.sh b/scripts/pahole-flags.sh
new file mode 100755
index 000000000000..8c82173e42e5
--- /dev/null
+++ b/scripts/pahole-flags.sh
@@ -0,0 +1,21 @@
+#!/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 "124" ]; then
+	extra_paholeopt="${extra_paholeopt} --skip_encoding_btf_enum64"
+fi
+
+echo ${extra_paholeopt}
-- 
2.37.3


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 5.10] kbuild: fix BTF build with pahole 1.24
  2022-10-27 12:01 [PATCH 5.10] kbuild: fix BTF build with pahole 1.24 Dominique Martinet
@ 2022-10-27 12:58 ` Jiri Olsa
  2022-10-27 15:02   ` Greg Kroah-Hartman
  2022-10-27 21:56   ` Dominique Martinet
  0 siblings, 2 replies; 4+ messages in thread
From: Jiri Olsa @ 2022-10-27 12:58 UTC (permalink / raw)
  To: Dominique Martinet
  Cc: Greg Kroah-Hartman, stable, Martin Rodriguez Reboredo, Andrii Nakryiko

On Thu, Oct 27, 2022 at 09:01:58PM +0900, Dominique Martinet wrote:
> pahole 1.24 broke builds on kernel <6.0 which do not have the
> new BTF_KIND_ENUM64 BTF tag.
> The 5.15 branch fixed this in commit b775fbf532dc01ae53a6fc56168fd30cb4b0c658
> ("kbuild: Add skip_encoding_btf_enum64 option to pahole"), which
> we cannot use directly for 5.10 because 5.10 does not have the
> pahole-flags.sh script, itself introduced in upstream commit
> 0baced0e0938f2895ceba54038eaf15ed91032e7 ("kbuild: Unify options
> for BTF generation for vmlinux and modules")
> 
> that last commit is difficult to backport as 5.10 does not have BTF
> for modules support: work around the problem by just copying the
> pahole-flags.sh script and calling it directly in link-vmlinux.sh,
> which is hopefully acceptable as the flags are not shared in this tree.
> 
> Note that compared to 5.15 the flags script does not have
> --btf_gen_floats as linux 5.10 did not have that BTF tag yet;
> but any new flag added to 5.15 will not be able to be added to 5.10 in
> an identical way for any future breakage.
> 
> Cc: Martin Rodriguez Reboredo <yakoyoku@gmail.com>
> Cc: Jiri Olsa <jolsa@kernel.org>
> CC: Andrii Nakryiko <andrii@kernel.org>
> Signed-off-by: Dominique Martinet <asmadeus@codewreck.org>

hi,
I sent this backport just recently:
  https://lore.kernel.org/bpf/Y1lkASXgeW0jfP8o@kroah.com/T/#t

it's split into several patches, hopefuly fixing the issue for you

jirka

> ---
> 
> This came up after updating nixpkgs to pahole 1.24.
> https://github.com/NixOS/nixpkgs/pull/194551
> Their 5.15's kernel built just fine as it already got some special
> handling added, but since that handling was not added to other stable
> kernels it started breaking builds after merging...
> 
> This shouldn't break anything, and should also as a byproduct fix some
> builds with pahole 1.18 through 1.21 although I'm not sure if it never
> has been backported to 5.10 because it's not a problem there or because
> nobody cared (I probably only started caring after the 1.22 release)
> 
> Anyway, if more can be shared I think it'll make things simpler for
> everyone going forward :)
> 
> 
>  scripts/link-vmlinux.sh |  2 +-
>  scripts/pahole-flags.sh | 21 +++++++++++++++++++++
>  2 files changed, 22 insertions(+), 1 deletion(-)
>  create mode 100755 scripts/pahole-flags.sh
> 
> diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
> index d0b44bee9286..c24da7b68619 100755
> --- a/scripts/link-vmlinux.sh
> +++ b/scripts/link-vmlinux.sh
> @@ -161,7 +161,7 @@ gen_btf()
>  	vmlinux_link ${1}
>  
>  	info "BTF" ${2}
> -	LLVM_OBJCOPY=${OBJCOPY} ${PAHOLE} -J ${1}
> +	LLVM_OBJCOPY="${OBJCOPY}" ${PAHOLE} -J $("${srctree}/scripts/pahole_flags.sh") ${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
> diff --git a/scripts/pahole-flags.sh b/scripts/pahole-flags.sh
> new file mode 100755
> index 000000000000..8c82173e42e5
> --- /dev/null
> +++ b/scripts/pahole-flags.sh
> @@ -0,0 +1,21 @@
> +#!/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 "124" ]; then
> +	extra_paholeopt="${extra_paholeopt} --skip_encoding_btf_enum64"
> +fi
> +
> +echo ${extra_paholeopt}
> -- 
> 2.37.3
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 5.10] kbuild: fix BTF build with pahole 1.24
  2022-10-27 12:58 ` Jiri Olsa
@ 2022-10-27 15:02   ` Greg Kroah-Hartman
  2022-10-27 21:56   ` Dominique Martinet
  1 sibling, 0 replies; 4+ messages in thread
From: Greg Kroah-Hartman @ 2022-10-27 15:02 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: Dominique Martinet, stable, Martin Rodriguez Reboredo, Andrii Nakryiko

On Thu, Oct 27, 2022 at 02:58:47PM +0200, Jiri Olsa wrote:
> On Thu, Oct 27, 2022 at 09:01:58PM +0900, Dominique Martinet wrote:
> > pahole 1.24 broke builds on kernel <6.0 which do not have the
> > new BTF_KIND_ENUM64 BTF tag.
> > The 5.15 branch fixed this in commit b775fbf532dc01ae53a6fc56168fd30cb4b0c658
> > ("kbuild: Add skip_encoding_btf_enum64 option to pahole"), which
> > we cannot use directly for 5.10 because 5.10 does not have the
> > pahole-flags.sh script, itself introduced in upstream commit
> > 0baced0e0938f2895ceba54038eaf15ed91032e7 ("kbuild: Unify options
> > for BTF generation for vmlinux and modules")
> > 
> > that last commit is difficult to backport as 5.10 does not have BTF
> > for modules support: work around the problem by just copying the
> > pahole-flags.sh script and calling it directly in link-vmlinux.sh,
> > which is hopefully acceptable as the flags are not shared in this tree.
> > 
> > Note that compared to 5.15 the flags script does not have
> > --btf_gen_floats as linux 5.10 did not have that BTF tag yet;
> > but any new flag added to 5.15 will not be able to be added to 5.10 in
> > an identical way for any future breakage.
> > 
> > Cc: Martin Rodriguez Reboredo <yakoyoku@gmail.com>
> > Cc: Jiri Olsa <jolsa@kernel.org>
> > CC: Andrii Nakryiko <andrii@kernel.org>
> > Signed-off-by: Dominique Martinet <asmadeus@codewreck.org>
> 
> hi,
> I sent this backport just recently:
>   https://lore.kernel.org/bpf/Y1lkASXgeW0jfP8o@kroah.com/T/#t
> 
> it's split into several patches, hopefuly fixing the issue for you

Yes, this should be resolved in the next 5.10.y release.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 5.10] kbuild: fix BTF build with pahole 1.24
  2022-10-27 12:58 ` Jiri Olsa
  2022-10-27 15:02   ` Greg Kroah-Hartman
@ 2022-10-27 21:56   ` Dominique Martinet
  1 sibling, 0 replies; 4+ messages in thread
From: Dominique Martinet @ 2022-10-27 21:56 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: Greg Kroah-Hartman, stable, Martin Rodriguez Reboredo, Andrii Nakryiko

Jiri Olsa wrote on Thu, Oct 27, 2022 at 02:58:47PM +0200:
> On Thu, Oct 27, 2022 at 09:01:58PM +0900, Dominique Martinet wrote:
> > pahole 1.24 broke builds on kernel <6.0 which do not have the
> > new BTF_KIND_ENUM64 BTF tag.
> > The 5.15 branch fixed this in commit b775fbf532dc01ae53a6fc56168fd30cb4b0c658
> > ("kbuild: Add skip_encoding_btf_enum64 option to pahole"), which
> > we cannot use directly for 5.10 because 5.10 does not have the
> > pahole-flags.sh script, itself introduced in upstream commit
> > 0baced0e0938f2895ceba54038eaf15ed91032e7 ("kbuild: Unify options
> > for BTF generation for vmlinux and modules")
> > 
> > that last commit is difficult to backport as 5.10 does not have BTF
> > for modules support: work around the problem by just copying the
> > pahole-flags.sh script and calling it directly in link-vmlinux.sh,
> > which is hopefully acceptable as the flags are not shared in this tree.
> > 
> > Note that compared to 5.15 the flags script does not have
> > --btf_gen_floats as linux 5.10 did not have that BTF tag yet;
> > but any new flag added to 5.15 will not be able to be added to 5.10 in
> > an identical way for any future breakage.
> > 
> > Cc: Martin Rodriguez Reboredo <yakoyoku@gmail.com>
> > Cc: Jiri Olsa <jolsa@kernel.org>
> > CC: Andrii Nakryiko <andrii@kernel.org>
> > Signed-off-by: Dominique Martinet <asmadeus@codewreck.org>
> 
> I sent this backport just recently:
>   https://lore.kernel.org/bpf/Y1lkASXgeW0jfP8o@kroah.com/T/#t
> 
> it's split into several patches, hopefuly fixing the issue for you

Ah, sorry I didn't think of checking the lists for an in-flight patch;
this is better than what I've sent and what I would have done if I had
taken the time -- checked patches and they look good to me.

Thanks !
-- 
Dominique

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-10-27 21:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-27 12:01 [PATCH 5.10] kbuild: fix BTF build with pahole 1.24 Dominique Martinet
2022-10-27 12:58 ` Jiri Olsa
2022-10-27 15:02   ` Greg Kroah-Hartman
2022-10-27 21:56   ` Dominique Martinet

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.