Skip to contentSkip to conversation

Enable BTF headers for Linux kernel

RFC PATCH Superseded Francis Laniel 2 participants 7 messages Dec 21, 2021 – Dec 22, 2021

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover Enable BTF headers for Linux kernel

Hi.

First of all, I hope you are fine and the same for your relatives.

Extended Berkeley Packet Filter (eBPF) is a virtual machine inside the kernel which permits executing safe code [1].
This code can, for example, be used to hook kernel events.

BPF Compile Once - Run Everywhere (BPF CO-RE) is thought as an evolution of conventional BPF program [2].
BPF CO-RE relies on BPF Type Format (BTF) to be executed on different kernels. This is done thanks to libbpf, the BPF loader, which resolves symbols contained into the BPF binary against symbols offered by the kernel.

Kernel shares its BTF symbols through /sys/kernel/btf/vmlinux which is enabled by CONFIG_DEBUG_INFO_BTF.
Nonetheless, CONFIG_DEBUG_INFO_BTF relies on pahole to convert DWARF symbols to BTF [3].
Thus, this series enable BTF headers for Linux kernel by:
1. First, adding pahole as host package by compiling it from source taken from its git repository.
2. Second, adding pahole as kernel dependencies if user selected BR2_PACKAGE_HOST_PAHOLE.

I understand Buildroot and BPF can seem to be far from each other at first glance.
But Buildroot, while mainly used to generate embedded Linux systems, is also used to generate "qemu ready" image [4].
More particularly, minikube, a tool used to deploy Kubernetes locally, relies on buildroot to generate its system image [5, 6].

I use minikube daily to test a tool we develop for Kubernetes and I wrote a patch to enable CONFIG_DEBUG_INFO_BTF [7, 8].
Thus, I thought it could be a good idea to share this patch upstream as this feature would be welcomed by the community [9].

Regarding the series itself, I tested it by compiling a system for qemu_x86_defconfig and setting:
* BR2_LINUX_KERNEL_NEEDS_HOST_LIBELF
* BR2_PACKAGE_HOST_PAHOLE
Then, I booted the system using qemu to check if /sys/kernel/btf/vmlinux exists, which is the case:
# [ -f /sys/kernel/btf/vmlinux ] && echo yes
yes

If you have any remarks regarding this series, feel free to share as I would be happy to handle them to increase this contribution quality.

Francis Laniel (2):
package/pahole: new host package
linux: Add host-pahole as linux dependencies if selected by user.

 DEVELOPERS                    |  3 +++
 linux/linux.mk                |  6 ++++++
 package/Config.in.host        |  1 +
 package/pahole/Config.in.host |  8 ++++++++
 package/pahole/pahole.hash    |  2 ++
 package/pahole/pahole.mk      | 20 ++++++++++++++++++++
 6 files changed, 40 insertions(+)
 create mode 100644 package/pahole/Config.in.host
 create mode 100644 package/pahole/pahole.hash
 create mode 100644 package/pahole/pahole.mk

Best regards and thank you in advance for your reviews.

---
[1] https://man7.org/linux/man-pages/man2/bpf.2.html
[2] https://nakryiko.com/posts/bpf-portability-and-co-re/
[3] https://elixir.bootlin.com/linux/v5.15.10/source/lib/Kconfig.debug#L315
[4] https://petermalmgren.com/qemu-buildroot/
[5] https://github.com/kubernetes/minikube
[6] https://github.com/kubernetes/minikube/blob/7dc8836303721c4486c007945beb5272cf28601c/deploy/iso/minikube-iso/configs/minikube_defconfig
[7] https://github.com/kinvolk/inspektor-gadget
[8] https://github.com/kinvolk/minikube/commit/44327414939f8acc08e095e789bc41f7dc73099e
[9] https://github.com/kubernetes/minikube/pull/12707#issuecomment-986990849

Signature · 6 lines
2.30.2

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#1 lore raw

RFC PATCH 1/2 package/pahole: new host package

pahole is a tool used to show data structure embedded in debugging information formats like DWARF.
It is notably needed by the Linux kernel to generate BPF Type Format (BTF) information used by Compile Once - Run Everywhere (CO-RE) BPF tools.

---
 DEVELOPERS                    |  3 +++
 package/Config.in.host        |  1 +
 package/pahole/Config.in.host |  6 ++++++
 package/pahole/pahole.hash    |  2 ++
 package/pahole/pahole.mk      | 20 ++++++++++++++++++++
 5 files changed, 32 insertions(+)
 create mode 100644 package/pahole/Config.in.host
 create mode 100644 package/pahole/pahole.hash
 create mode 100644 package/pahole/pahole.mk
DEVELOPERS +3 -0
index 64db6c51d0..70df957415 100644
@@ -939,6 +939,9 @@ N:	Floris Bos <[email protected]>
 F:	package/ipmitool/
 F:	package/odhcploc/
 
+N:	Francis Laniel <[email protected]>
+F:	package/pahole/
+
 N:	Francisco Gonzalez <[email protected]>
 F:	package/ser2net/
 
package/Config.in.host +1 -0
index 6e5a5c5fc5..ae512c5643 100644
@@ -60,6 +60,7 @@ menu "Host utilities"
 	source "package/omap-u-boot-utils/Config.in.host"
 	source "package/openocd/Config.in.host"
 	source "package/opkg-utils/Config.in.host"
+	source "package/pahole/Config.in.host"
 	source "package/parted/Config.in.host"
 	source "package/patchelf/Config.in.host"
 	source "package/pigz/Config.in.host"
package/pahole/Config.in.host new file +6 -0
new file mode 100644
index 0000000000..e427629632
@@ -0,0 +1,6 @@
+config BR2_PACKAGE_HOST_PAHOLE
+	bool "host pahole"
+	help
+	  Pahole and other DWARF utils.
+
+	  https://git.kernel.org/pub/scm/devel/pahole/pahole.git
package/pahole/pahole.hash new file +2 -0
new file mode 100644
index 0000000000..2573fde8c9
@@ -0,0 +1,2 @@
+# Locally computed
+sha256 76b7eaf5747dbb7250a1a50185136d4639e0d70aa11c5d7c68139c0c8ca9be80 pahole-v1.22-br1.tar.gz
package/pahole/pahole.mk new file +20 -0
new file mode 100644
index 0000000000..1f69f5391e
@@ -0,0 +1,20 @@
+########################################################################
+#
+# pahole
+#
+########################################################################
+
+PAHOLE_VERSION = v1.22
+PAHOLE_SITE = git://git.kernel.org/pub/scm/devel/pahole/pahole.git
+PAHOLE_SITE_METHOD = git
+# pahole contains git submodule and relies on them to be built.
+# We need to add this option to fetch the submodules before creating the
+# archive.
+PAHOLE_GIT_SUBMODULES = YES
+# Better to build it statically so we do not rely on the host having
+# corresponding libraries.
+HOST_PAHOLE_CONF_OPTS = -DBUILD_SHARED_LIBS=OFF -D__LIB=lib
+PAHOLE_LICENSE = GPL-2.0
+PAHOLE_LICENSE_FILES = COPYING
+
+$(eval $(host-cmake-package))
Signature · 6 lines
2.30.2

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#2 lore raw

Re: [Buildroot] [RFC PATCH v1 1/2] package/pahole: new host package

Hi Francis,

Some relatively minor nitpicks.

Quoted 61 lines · Francis Laniel

pahole is a tool used to show data structure embedded in debugging information formats like DWARF.
It is notably needed by the Linux kernel to generate BPF Type Format (BTF) information used by Compile Once - Run Everywhere (CO-RE) BPF tools.

---
  DEVELOPERS                    |  3 +++
  package/Config.in.host        |  1 +
  package/pahole/Config.in.host |  6 ++++++
  package/pahole/pahole.hash    |  2 ++
  package/pahole/pahole.mk      | 20 ++++++++++++++++++++
  5 files changed, 32 insertions(+)

create mode 100644 package/pahole/Config.in.host create mode 100644 package/pahole/pahole.hash create mode 100644 package/pahole/pahole.mk

DEVELOPERS +3 -0
index 64db6c51d0..70df957415 100644
@@ -939,6 +939,9 @@ N:	Floris Bos <[email protected]>
  F:	package/ipmitool/
  F:	package/odhcploc/
 
+N:	Francis Laniel <[email protected]>
+F:	package/pahole/
+
  N:	Francisco Gonzalez <[email protected]>
  F:	package/ser2net/
 
package/Config.in.host +1 -0
index 6e5a5c5fc5..ae512c5643 100644
@@ -60,6 +60,7 @@ menu "Host utilities"
  	source "package/omap-u-boot-utils/Config.in.host"
  	source "package/openocd/Config.in.host"
  	source "package/opkg-utils/Config.in.host"
+	source "package/pahole/Config.in.host"
  	source "package/parted/Config.in.host"
  	source "package/patchelf/Config.in.host"
  	source "package/pigz/Config.in.host"
package/pahole/Config.in.host new file +6 -0
new file mode 100644
index 0000000000..e427629632
@@ -0,0 +1,6 @@
+config BR2_PACKAGE_HOST_PAHOLE
+	bool "host pahole"
+	help
+	  Pahole and other DWARF utils.
+
+	  https://git.kernel.org/pub/scm/devel/pahole/pahole.git
package/pahole/pahole.hash new file +0 -0
new file mode 100644
index 0000000000..2573fde8c9

package/pahole/pahole.hash line 2

Quoted 2 lines
package/pahole/pahole.hash new file +2 -0
@@ -0,0 +1,2 @@
+# Locally computed
+sha256 76b7eaf5747dbb7250a1a50185136d4639e0d70aa11c5d7c68139c0c8ca9be80 pahole-v1.22-br1.tar.gz

You should also add COPYING to the hash file.

package/pahole/pahole.mk line 7

Quoted 13 lines
package/pahole/pahole.mk new file +7 -0
new file mode 100644
index 0000000000..1f69f5391e
@@ -0,0 +1,20 @@
+########################################################################
+#
+# pahole
+#
+########################################################################
+
+PAHOLE_VERSION = v1.22

There's a v1.23 now.

package/pahole/pahole.mk line 8

Quoted 1 line
package/pahole/pahole.mk new file +1 -0
+PAHOLE_SITE = git://git.kernel.org/pub/scm/devel/pahole/pahole.git

kernel.org also has a tarball download:

PAHOLE_SITE = https://git.kernel.org/pub/scm/devel/pahole/pahole.git/snapshot

(cfr. e.g. f2fs-tools).

That also allows you to set VERSION without the v, which we prefer because
that way it can be used in CPE info and in release-monitoring.

package/pahole/pahole.mk line 10

Quoted 2 lines
package/pahole/pahole.mk new file +2 -0
+PAHOLE_SITE_METHOD = git
+# pahole contains git submodule and relies on them to be built.

Darn, so much for the tarball download :-(

This is something we'd typically put in a comment or the commit message so
later down the line people remember why we didn't choose a tarball download.

However, we normally prefer to unbundle dependencies, and we already have
libbpf (though not for the host at the moment). For host packages, the unbundling isn't terribly important, so if it's difficult, don't bother. But if it's easy to use an external bpf rather than the submodule, then please do that.

package/pahole/pahole.mk line 12

Quoted 2 lines
package/pahole/pahole.mk new file +2 -0
+# We need to add this option to fetch the submodules before creating the
+# archive.

This comment is redundant, the first sentence was enough.

package/pahole/pahole.mk line 15

Quoted 3 lines
package/pahole/pahole.mk new file +3 -0
+PAHOLE_GIT_SUBMODULES = YES
+# Better to build it statically so we do not rely on the host having
+# corresponding libraries.

This doesn't make a whole lot of sense to me... We're building it, so the
libraries are there, otherwise it would fail to build, right? Again, not terribly important for a host package, but we prefer to do special stuff if not needed.

package/pahole/pahole.mk line 16

Quoted 1 line
package/pahole/pahole.mk new file +1 -0
+HOST_PAHOLE_CONF_OPTS = -DBUILD_SHARED_LIBS=OFF -D__LIB=lib

Why is the __LIB=lib needed? What does it do? It's enough to mention this in
the commit message.

Regards,
Arnout

package/pahole/pahole.mk line 20

Quoted 5 lines
package/pahole/pahole.mk new file +4 -0
+PAHOLE_LICENSE = GPL-2.0
+PAHOLE_LICENSE_FILES = COPYING
+
+$(eval $(host-cmake-package))

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#3 lore raw

Re: [Buildroot] [RFC PATCH v1 1/2] package/pahole: new host package

Hi.

Thank you for your reviews, I comment some inline.

Le mardi 21 décembre 2021 22:44:56 CET, vous avez écrit :

Quoted 78 lines

Hi Francis,

Some relatively minor nitpicks.

Quoted 70 lines · Francis Laniel

pahole is a tool used to show data structure embedded in debugging information formats like DWARF.
It is notably needed by the Linux kernel to generate BPF Type Format (BTF) information used by Compile Once - Run Everywhere (CO-RE) BPF tools.

---

  DEVELOPERS                    |  3 +++
  package/Config.in.host        |  1 +
  package/pahole/Config.in.host |  6 ++++++
  package/pahole/pahole.hash    |  2 ++
  package/pahole/pahole.mk      | 20 ++++++++++++++++++++
  5 files changed, 32 insertions(+)

create mode 100644 package/pahole/Config.in.host create mode 100644 package/pahole/pahole.hash create mode 100644 package/pahole/pahole.mk

DEVELOPERS +3 -0
index 64db6c51d0..70df957415 100644
@@ -939,6 +939,9 @@ N:	Floris Bos <[email protected]>
 
  F:	package/ipmitool/
  F:	package/odhcploc/
 
+N:	Francis Laniel <[email protected]>
+F:	package/pahole/
+
 
  N:	Francisco Gonzalez <[email protected]>

F: package/ser2net/

package/Config.in.host +1 -0
index 6e5a5c5fc5..ae512c5643 100644
@@ -60,6 +60,7 @@ menu "Host utilities"
 
  	source "package/omap-u-boot-utils/Config.in.host"
  	source "package/openocd/Config.in.host"
  	source "package/opkg-utils/Config.in.host"
 
+	source "package/pahole/Config.in.host"
 

source "package/parted/Config.in.host"
source "package/patchelf/Config.in.host"
source "package/pigz/Config.in.host"

package/pahole/Config.in.host new file +6 -0
new file mode 100644
index 0000000000..e427629632
@@ -0,0 +1,6 @@
+config BR2_PACKAGE_HOST_PAHOLE
+	bool "host pahole"
+	help
+	  Pahole and other DWARF utils.
+
+	  https://git.kernel.org/pub/scm/devel/pahole/pahole.git
package/pahole/pahole.hash new file +2 -0
new file mode 100644
index 0000000000..2573fde8c9
@@ -0,0 +1,2 @@
+# Locally computed
+sha256 76b7eaf5747dbb7250a1a50185136d4639e0d70aa11c5d7c68139c0c8ca9be80
Quoted 1 line

pahole-v1.22-br1.tar.gz

You should also add COPYING to the hash file.

Quoted 15 lines

package/pahole/pahole.mk line 7

Quoted 13 lines
package/pahole/pahole.mk new file +7 -0
new file mode 100644
index 0000000000..1f69f5391e
@@ -0,0 +1,20 @@
+########################################################################
+#
+# pahole
+#
+########################################################################
+
+PAHOLE_VERSION = v1.22

There's a v1.23 now.

Thank you for it, I jumped to v1.23.

Quoted 21 lines

package/pahole/pahole.mk line 8

Quoted 1 line
package/pahole/pahole.mk new file +1 -0
+PAHOLE_SITE = git://git.kernel.org/pub/scm/devel/pahole/pahole.git

kernel.org also has a tarball download:

PAHOLE_SITE =
https://git.kernel.org/pub/scm/devel/pahole/pahole.git/snapshot

(cfr. e.g. f2fs-tools).

That also allows you to set VERSION without the v, which we prefer because
that way it can be used in CPE info and in release-monitoring.

package/pahole/pahole.mk line 10

Quoted 2 lines
package/pahole/pahole.mk new file +2 -0
+PAHOLE_SITE_METHOD = git
+# pahole contains git submodule and relies on them to be built.

Darn, so much for the tarball download :-(

This is something we'd typically put in a comment or the commit message so
later down the line people remember why we didn't choose a tarball download.

Quoted 5 lines

However, we normally prefer to unbundle dependencies, and we already have
libbpf (though not for the host at the moment). For host packages, the unbundling isn't terribly important, so if it's difficult, don't bother. But if it's easy to use an external bpf rather than the submodule, then please do that.

I tried to modify libbpf recipe to add host-libbpf and add it at dependencies to host-pahole but sadly I was not successful.
Thus, I stick with getting pahole from its git repository with its submodules.

Quoted 14 lines

package/pahole/pahole.mk line 12

Quoted 2 lines
package/pahole/pahole.mk new file +2 -0
+# We need to add this option to fetch the submodules before creating the
+# archive.

This comment is redundant, the first sentence was enough.

package/pahole/pahole.mk line 15

Quoted 3 lines
package/pahole/pahole.mk new file +3 -0
+PAHOLE_GIT_SUBMODULES = YES
+# Better to build it statically so we do not rely on the host having
+# corresponding libraries.

This doesn't make a whole lot of sense to me... We're building it, so the
libraries are there, otherwise it would fail to build, right? Again, not terribly important for a host package, but we prefer to do special stuff if not needed.

Quoted 4 lines

package/pahole/pahole.mk line 16

Quoted 1 line
package/pahole/pahole.mk new file +1 -0
+HOST_PAHOLE_CONF_OPTS = -DBUILD_SHARED_LIBS=OFF -D__LIB=lib

Why is the __LIB=lib needed? What does it do? It's enough to mention this
in the commit message.

This seems needed as directory for some build artifact, it is described in pahole README to build it.
I added a comment in pahole.mk as well as in commit message.

Quoted 1 line

Regards,

Best regards.

Quoted 6 lines

Arnout

package/pahole/pahole.mk line 20

Quoted 4 lines
package/pahole/pahole.mk new file +4 -0
+PAHOLE_LICENSE = GPL-2.0
+PAHOLE_LICENSE_FILES = COPYING
+
+$(eval $(host-cmake-package))

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#4 lore raw

RFC PATCH 2/2 linux: Add host-pahole as linux dependencies if selected by user.

In reply to Francis Laniel

If user set BR2_PACKAGE_HOST_PAHOLE, we add host-pahole to linux dependencies in case the user also wants to compile the kernel with CONFIG_DEBUG_BTF_INFO which relies on pahole to generate BTF information used by CO-RE BPF tools.

---
 linux/linux.mk                | 6 ++++++
 package/pahole/Config.in.host | 2 ++
 2 files changed, 8 insertions(+)
linux/linux.mk +6 -0
index 61fdc0c76c..057d898c86 100644
@@ -120,6 +120,12 @@ ifeq ($(BR2_PACKAGE_HOST_UBOOT_TOOLS),y)
 LINUX_DEPENDENCIES += host-uboot-tools
 endif
 
+# If host-pahole is selected by the user, assume it is needed to create a custom
+# kernel with CONFIG_DEBUG_INFO_BTF.
+ifeq ($(BR2_PACKAGE_HOST_PAHOLE),y)
+LINUX_DEPENDENCIES += host-pahole
+endif
+
 ifneq ($(ARCH_XTENSA_OVERLAY_FILE),)
 define LINUX_XTENSA_OVERLAY_EXTRACT
 	$(call arch-xtensa-overlay-extract,$(@D),linux)
package/pahole/Config.in.host +2 -0
index e427629632..521874961b 100644
@@ -3,4 +3,6 @@ config BR2_PACKAGE_HOST_PAHOLE
 	help
 	  Pahole and other DWARF utils.
 
+	  Select this if you want to build a kernel with CONFIG_DEBUG_INFO_BTF set.
+
 	  https://git.kernel.org/pub/scm/devel/pahole/pahole.git
Signature · 6 lines
2.30.2

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#5 lore raw

Re: [Buildroot] [RFC PATCH v1 2/2] linux: Add host-pahole as linux dependencies if selected by user.

Quoted 15 lines · Francis Laniel

If user set BR2_PACKAGE_HOST_PAHOLE, we add host-pahole to linux dependencies in case the user also wants to compile the kernel with CONFIG_DEBUG_BTF_INFO which relies on pahole to generate BTF information used by CO-RE BPF tools.

---
  linux/linux.mk                | 6 ++++++
  package/pahole/Config.in.host | 2 ++
  2 files changed, 8 insertions(+)
linux/linux.mk +0 -0
index 61fdc0c76c..057d898c86 100644

linux/linux.mk ifeq ($(BR2_PACKAGE_HOST_UBOOT_TOOLS),y) · line 126

Quoted 7 lines
linux/linux.mk +4 -0
@@ -120,6 +120,12 @@ ifeq ($(BR2_PACKAGE_HOST_UBOOT_TOOLS),y)
  LINUX_DEPENDENCIES += host-uboot-tools
  endif
 
+# If host-pahole is selected by the user, assume it is needed to create a custom
+# kernel with CONFIG_DEBUG_INFO_BTF.
+ifeq ($(BR2_PACKAGE_HOST_PAHOLE),y)
+LINUX_DEPENDENCIES += host-pahole

This is not a super user-friendly way to do it, but it's hard to do better.

One way would be to make an explicit Config.in option for it (similar to
openssl). Or an option that also sets CONFIG_DEBUG_INFO_BTF. But I think that adds too much complexity to Buildroot for relatively little gain.

Perhaps a better improvement would be to add a check if the config option is
set and print a warning if not.

else
define LINUX_FIXUP_CONFIG_PAHOLE_CHECK

	if grep -q "^CONFIG_DEBUG_INFO_BTF=y" $(KCONFIG_DOT_CONFIG); then \
		echo "To use CONFIG_DEBUG_INFO_BTF, enable host-pahole 
(BR2_PACKAGE_HOST_PAHOLE)" 1>&2; \
		return 1; \
	fi

endef

(and add LINUX_FIXUP_CONFIG_PAHOLE_CHECK to the end of LINUX_KCONFIG_FIXUP_CMDS).

It's still pretty clunky though, so maybe not that much of an improvement...

Anyway, I'd merge this patch without that change (but no time today).

Regards,
Arnout

Quoted 11 lines
linux/linux.mk +2 -0
+endif
+
  ifneq ($(ARCH_XTENSA_OVERLAY_FILE),)
  define LINUX_XTENSA_OVERLAY_EXTRACT
  	$(call arch-xtensa-overlay-extract,$(@D),linux)
package/pahole/Config.in.host +0 -0
index e427629632..521874961b 100644

package/pahole/Config.in.host config BR2_PACKAGE_HOST_PAHOLE · line 8

Quoted 6 lines
package/pahole/Config.in.host +2 -0
@@ -3,4 +3,6 @@ config BR2_PACKAGE_HOST_PAHOLE
  	help
  	  Pahole and other DWARF utils.
 
+	  Select this if you want to build a kernel with CONFIG_DEBUG_INFO_BTF set.
+
  	  https://git.kernel.org/pub/scm/devel/pahole/pahole.git

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#6 lore raw

Re: [Buildroot] [RFC PATCH v1 2/2] linux: Add host-pahole as linux dependencies if selected by user.

Quoted 46 lines · Le mardi 21 décembre 2021, 22:58:29 CET Arnout Vandecappelle a écrit :
Quoted 23 lines · Francis Laniel

If user set BR2_PACKAGE_HOST_PAHOLE, we add host-pahole to linux dependencies in case the user also wants to compile the kernel with CONFIG_DEBUG_BTF_INFO which relies on pahole to generate BTF information used by CO-RE BPF tools.

---

  linux/linux.mk                | 6 ++++++
  package/pahole/Config.in.host | 2 ++
  2 files changed, 8 insertions(+)
linux/linux.mk +1 -0
index 61fdc0c76c..057d898c86 100644
@@ -120,6 +120,12 @@ ifeq ($(BR2_PACKAGE_HOST_UBOOT_TOOLS),y)
 
  LINUX_DEPENDENCIES += host-uboot-tools
  endif
 
+# If host-pahole is selected by the user, assume it is needed to create a

custom +# kernel with CONFIG_DEBUG_INFO_BTF.

linux/linux.mk ifeq ($(BR2_PACKAGE_HOST_UBOOT_TOOLS),y) · line 126

Quoted 2 lines
linux/linux.mk +2 -0
+ifeq ($(BR2_PACKAGE_HOST_PAHOLE),y)
+LINUX_DEPENDENCIES += host-pahole

This is not a super user-friendly way to do it, but it's hard to do
better.

One way would be to make an explicit Config.in option for it (similar to
openssl). Or an option that also sets CONFIG_DEBUG_INFO_BTF. But I think that adds too much complexity to Buildroot for relatively little gain.

Perhaps a better improvement would be to add a check if the config option
is set and print a warning if not.

else
define LINUX_FIXUP_CONFIG_PAHOLE_CHECK

	if grep -q "^CONFIG_DEBUG_INFO_BTF=y" $(KCONFIG_DOT_CONFIG); then \
		echo "To use CONFIG_DEBUG_INFO_BTF, enable host-pahole
(BR2_PACKAGE_HOST_PAHOLE)" 1>&2; \
		return 1; \
	fi

endef

Quoted 7 lines

(and add LINUX_FIXUP_CONFIG_PAHOLE_CHECK to the end of LINUX_KCONFIG_FIXUP_CMDS).

It's still pretty clunky though, so maybe not that much of an
improvement...

Anyway, I'd merge this patch without that change (but no time today).

When I first wrote this patch, I was looking for a solution to add dependencies conditionally to Linux kernel CONFIG_ but I did not find it.
Your solution is cool, so I added as well as an option (like one used for OpenSSL and libelf).
I will send v2 within 10 minutes.

Quoted 24 lines

Regards,
Arnout

Quoted 21 lines
linux/linux.mk +2 -0
+endif
+
 
  ifneq ($(ARCH_XTENSA_OVERLAY_FILE),)
  define LINUX_XTENSA_OVERLAY_EXTRACT
 
  	$(call arch-xtensa-overlay-extract,$(@D),linux)
package/pahole/Config.in.host +1 -0
index e427629632..521874961b 100644
@@ -3,4 +3,6 @@ config BR2_PACKAGE_HOST_PAHOLE
 
  	help
 
  	  Pahole and other DWARF utils.
 
+	  Select this if you want to build a kernel with CONFIG_DEBUG_INFO_BTF

set. +

Quoted 6 lines
Quoted 1 line

https://git.kernel.org/pub/scm/devel/pahole/pahole.git

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot