From 111e92cce05f7e32996b7f0dd56d42e2d86e61ee Mon Sep 17 00:00:00 2001 From: John Crispin Date: Sat, 19 Sep 2026 11:34:58 +0200 Subject: [PATCH] xdp-tools: find the arch headers of the toolchain for the BPF programs The configure script of xdp-tools sets ARCH_INCLUDES only from the multiarch directory of a native compiler. For a cross compiler it stays empty, and clang takes for the BPF programs from /usr/include of the host. On hosts that have only in the multiarch directory, such as Debian without gcc-multilib, the build fails: /usr/include/linux/types.h:5:10: fatal error: 'asm/types.h' file not found Add the include directories of the toolchain with -idirafter. They are searched after the headers of xdp-tools and of the system, as the multiarch directory of a native build, so they do not replace the Linux headers that xdp-tools ships. The target compiler already has them as system directories. The configure script also tests for bpftool with the bash redirection &>. /bin/sh may be dash, which runs the command in the background instead, so configure drops a working bpftool and takes the output of whereis. Add a second patch that uses >/dev/null 2>&1, which every shell supports. Signed-off-by: John Crispin --- package/network/utils/xdp-tools/Makefile | 3 +- ...onfigure-do-not-use-bash-redirection.patch | 31 +++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 package/network/utils/xdp-tools/patches/0004-configure-do-not-use-bash-redirection.patch diff --git a/package/network/utils/xdp-tools/Makefile b/package/network/utils/xdp-tools/Makefile index 67236ea3177..6ea4fb0bbe6 100644 --- a/package/network/utils/xdp-tools/Makefile +++ b/package/network/utils/xdp-tools/Makefile @@ -1,7 +1,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=xdp-tools -PKG_RELEASE:=2 +PKG_RELEASE:=3 PKG_VERSION:=1.6.3 PKG_HASH:=78da363ff7dcf1a586f47800f16d644022bd33f3844864061a44616fce854fd8 @@ -150,6 +150,7 @@ CONFIGURE_VARS += \ CFLAGS="$(TARGET_CFLAGS)" \ LDFLAGS="$(TARGET_LDFLAGS)" \ CLANG="$(CLANG)" \ + ARCH_INCLUDES="$(patsubst %,-idirafter%,$(TOOLCHAIN_INC_DIRS))" \ BPFTOOL="$(STAGING_DIR_HOST)/usr/sbin/bpftool" ifneq ($(findstring s,$(OPENWRT_VERBOSE)),) diff --git a/package/network/utils/xdp-tools/patches/0004-configure-do-not-use-bash-redirection.patch b/package/network/utils/xdp-tools/patches/0004-configure-do-not-use-bash-redirection.patch new file mode 100644 index 00000000000..8b9e31978bb --- /dev/null +++ b/package/network/utils/xdp-tools/patches/0004-configure-do-not-use-bash-redirection.patch @@ -0,0 +1,31 @@ +From: John Crispin +Subject: [PATCH] configure: do not use a bash redirection + +configure runs with /bin/sh, but uses the bash redirection &> to check +for bpftool. A POSIX shell such as dash runs "command -v $BPFTOOL" in +the background instead, so configure replaces BPFTOOL with the output +of whereis and does not find bpftool, although it is available. + +Use >/dev/null 2>&1, which all shells support. + +Signed-off-by: John Crispin +--- + configure | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +--- a/configure ++++ b/configure +@@ -109,11 +109,11 @@ + exit 1 + fi + +- if ! command -v $BPFTOOL &>/dev/null; then ++ if ! command -v $BPFTOOL >/dev/null 2>&1; then + BPFTOOL=$(whereis -b bpftool | awk '{print $2}') + fi + +- if command -v $BPFTOOL &>/dev/null && $BPFTOOL gen help 2>&1 | grep 'gen skeleton.*name' > /dev/null; then ++ if command -v $BPFTOOL >/dev/null 2>&1 && $BPFTOOL gen help 2>&1 | grep 'gen skeleton.*name' > /dev/null; then + bpftool_version=$($BPFTOOL version | head -n 1) + echo "using $bpftool_version" + else