* [Buildroot] [PATCH 2/2] package/linux-tools: add host-bpftool support
2021-08-10 6:45 [Buildroot] [PATCH 1/2] package/linux-headers: enable host build James Hilliard
@ 2021-08-10 6:45 ` James Hilliard
2021-12-28 22:33 ` [Buildroot] [PATCH 1/2] package/linux-headers: enable host build Thomas Petazzoni
1 sibling, 0 replies; 4+ messages in thread
From: James Hilliard @ 2021-08-10 6:45 UTC (permalink / raw)
To: buildroot; +Cc: James Hilliard, Yann E . MORIN, Thomas Petazzoni
This will be required for building systemd with bpf support.
Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
---
package/Config.in.host | 1 +
package/linux-tools/Config.in.host | 11 +++++++++++
package/linux-tools/linux-tool-bpftool.mk.in | 20 ++++++++++++++++++++
package/linux-tools/linux-tools.mk | 17 +++++++++++++++++
4 files changed, 49 insertions(+)
create mode 100644 package/linux-tools/Config.in.host
diff --git a/package/Config.in.host b/package/Config.in.host
index 8d443ea255..98cc67b238 100644
--- a/package/Config.in.host
+++ b/package/Config.in.host
@@ -45,6 +45,7 @@ menu "Host utilities"
source "package/jsmin/Config.in.host"
source "package/kmod/Config.in.host"
source "package/libp11/Config.in.host"
+ source "package/linux-tools/Config.in.host"
source "package/lld/Config.in.host"
source "package/lpc3250loader/Config.in.host"
source "package/lttng-babeltrace/Config.in.host"
diff --git a/package/linux-tools/Config.in.host b/package/linux-tools/Config.in.host
new file mode 100644
index 0000000000..b228f9b02d
--- /dev/null
+++ b/package/linux-tools/Config.in.host
@@ -0,0 +1,11 @@
+config BR2_PACKAGE_HOST_LINUX_TOOLS
+ bool
+
+config BR2_PACKAGE_HOST_LINUX_TOOLS_BPFTOOL
+ bool "host bpftool"
+ select BR2_PACKAGE_HOST_LINUX_TOOLS
+ help
+ bpftool is a tool for for inspection and simple manipulation
+ of eBPF programs and maps.
+
+ These tools are available only from kernel version 4.15.
diff --git a/package/linux-tools/linux-tool-bpftool.mk.in b/package/linux-tools/linux-tool-bpftool.mk.in
index 0c4d3693a3..c5e6fb97db 100644
--- a/package/linux-tools/linux-tool-bpftool.mk.in
+++ b/package/linux-tools/linux-tool-bpftool.mk.in
@@ -5,6 +5,7 @@
################################################################################
LINUX_TOOLS += bpftool
+HOST_LINUX_TOOLS += host-bpftool
BPFTOOL_DEPENDENCIES = binutils elfutils
@@ -17,6 +18,9 @@ BPFTOOL_DEPENDENCIES += zlib
endif
BPFTOOL_MAKE_OPTS = $(LINUX_MAKE_FLAGS)
+HOST_BPFTOOL_MAKE_OPTS = $(HOST_MAKE_FLAGS) \
+ CFLAGS="$(HOST_CFLAGS)" \
+ LDFLAGS="$(HOST_LDFLAGS)"
define BPFTOOL_BUILD_CMDS
$(Q)if ! grep install $(LINUX_DIR)/tools/bpf/bpftool/Makefile >/dev/null 2>&1 ; then \
@@ -29,9 +33,25 @@ define BPFTOOL_BUILD_CMDS
$(BPFTOOL_MAKE_OPTS)
endef
+define HOST_BPFTOOL_BUILD_CMDS
+ $(Q)if ! grep install $(HOST_LINUX_HEADERS_DIR)/tools/bpf/bpftool/Makefile >/dev/null 2>&1 ; then \
+ echo "Your kernel version is too old and does not have install section in the bpf tools." ; \
+ echo "At least kernel 4.15 must be used." ; \
+ exit 1 ; \
+ fi
+
+ $(HOST_MAKE_ENV) $(MAKE1) -C $(HOST_LINUX_HEADERS_DIR) \
+ $(HOST_BPFTOOL_MAKE_OPTS) \
+ tools/bpf/bpftool
+endef
+
define BPFTOOL_INSTALL_TARGET_CMDS
$(TARGET_MAKE_ENV) $(MAKE1) -C $(LINUX_DIR)/tools/bpf/bpftool \
$(BPFTOOL_MAKE_OPTS) \
DESTDIR=$(TARGET_DIR) \
install
endef
+
+define HOST_BPFTOOL_INSTALL_CMDS
+ $(INSTALL) -m 0755 -D $(HOST_LINUX_HEADERS_DIR)/tools/bpf/bpftool/bpftool $(HOST_DIR)/usr/sbin/bpftool
+endef
diff --git a/package/linux-tools/linux-tools.mk b/package/linux-tools/linux-tools.mk
index 81b1fbc176..0375883d95 100644
--- a/package/linux-tools/linux-tools.mk
+++ b/package/linux-tools/linux-tools.mk
@@ -21,6 +21,7 @@ include $(sort $(wildcard package/linux-tools/*.mk.in))
# We only need the kernel to be extracted, not actually built
LINUX_TOOLS_PATCH_DEPENDENCIES = linux
+HOST_LINUX_TOOLS_DEPENDENCIES = host-linux-headers
# Install Linux kernel tools in the staging directory since some tools
# may install shared libraries and headers (e.g. cpupower).
@@ -34,6 +35,10 @@ LINUX_TOOLS_POST_BUILD_HOOKS += $(foreach tool,$(LINUX_TOOLS),\
$(if $(BR2_PACKAGE_LINUX_TOOLS_$(call UPPERCASE,$(tool))),\
$(call UPPERCASE,$(tool))_BUILD_CMDS))
+HOST_LINUX_TOOLS_POST_BUILD_HOOKS += $(foreach tool,$(LINUX_TOOLS),\
+ $(if $(BR2_PACKAGE_HOST_LINUX_TOOLS_$(call UPPERCASE,$(tool))),\
+ HOST_$(call UPPERCASE,$(tool))_BUILD_CMDS))
+
LINUX_TOOLS_POST_INSTALL_STAGING_HOOKS += $(foreach tool,$(LINUX_TOOLS),\
$(if $(BR2_PACKAGE_LINUX_TOOLS_$(call UPPERCASE,$(tool))),\
$(call UPPERCASE,$(tool))_INSTALL_STAGING_CMDS))
@@ -42,6 +47,10 @@ LINUX_TOOLS_POST_INSTALL_TARGET_HOOKS += $(foreach tool,$(LINUX_TOOLS),\
$(if $(BR2_PACKAGE_LINUX_TOOLS_$(call UPPERCASE,$(tool))),\
$(call UPPERCASE,$(tool))_INSTALL_TARGET_CMDS))
+HOST_LINUX_TOOLS_POST_INSTALL_HOOKS += $(foreach tool,$(LINUX_TOOLS),\
+ $(if $(BR2_PACKAGE_HOST_LINUX_TOOLS_$(call UPPERCASE,$(tool))),\
+ HOST_$(call UPPERCASE,$(tool))_INSTALL_CMDS))
+
define LINUX_TOOLS_LINUX_CONFIG_FIXUPS
$(foreach tool,$(LINUX_TOOLS),\
$(if $(BR2_PACKAGE_LINUX_TOOLS_$(call UPPERCASE,$(tool))),\
@@ -49,6 +58,13 @@ define LINUX_TOOLS_LINUX_CONFIG_FIXUPS
)
endef
+define HOST_LINUX_TOOLS_LINUX_CONFIG_FIXUPS
+ $(foreach tool,$(LINUX_TOOLS),\
+ $(if $(BR2_PACKAGE_HOST_LINUX_TOOLS_$(call UPPERCASE,$(tool))),\
+ $(HOST_$(call UPPERCASE,$(tool))_LINUX_CONFIG_FIXUPS))
+ )
+endef
+
define LINUX_TOOLS_INSTALL_INIT_SYSTEMD
$(foreach tool,$(LINUX_TOOLS),\
$(if $(BR2_PACKAGE_LINUX_TOOLS_$(call UPPERCASE,$(tool))),\
@@ -72,3 +88,4 @@ define LINUX_TOOLS_INSTALL_INIT_OPENRC
endef
$(eval $(generic-package))
+$(eval $(host-generic-package))
--
2.25.1
_______________________________________________
buildroot mailing list
buildroot@busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Buildroot] [PATCH 1/2] package/linux-headers: enable host build
2021-08-10 6:45 [Buildroot] [PATCH 1/2] package/linux-headers: enable host build James Hilliard
2021-08-10 6:45 ` [Buildroot] [PATCH 2/2] package/linux-tools: add host-bpftool support James Hilliard
@ 2021-12-28 22:33 ` Thomas Petazzoni
2022-01-31 2:22 ` James Hilliard
1 sibling, 1 reply; 4+ messages in thread
From: Thomas Petazzoni @ 2021-12-28 22:33 UTC (permalink / raw)
To: James Hilliard; +Cc: Yann E . MORIN, buildroot
Hello James,
On Tue, 10 Aug 2021 00:45:46 -0600
James Hilliard <james.hilliard1@gmail.com> wrote:
> This will be used for building tools that are included with the kernel,
> such as host-bpftool.
>
> Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
I'm sorry, but I fail to see how this can make sense, for a number of
reasons:
* For external toolchains, package/linux-headers/Config.in.host is not
even included, which means that no version of kernel headers are
defined.
* Even for internal toolchains, the kernel headers version selected
for the target, which you re-use here for the host kernel headers,
has no correlation with the actual kernel running on the build
machine. If you are running an oldish 3.10 kernel on your build
machine, install host-linux-headers 5.15, and build host-bpftool
based on that, you'll run into issue.
So, perhaps the first thing is to figure out why the host variant of
bpftool needs kernel headers. What are these tool doing on the host?
What is the use case?
Then if we really want to build them for the host, I guess the only
solution is to ask the user to install the kernel headers matching their
build machine (so with some hidden option
BR2_NEEDS_HOST_KERNEL_HEADERS, which is selected by your package, and
then with logic in support/dependencies/ to check that).
Thanks!
Thomas
--
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 4+ messages in thread