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 <linux/types.h> for the BPF programs from
/usr/include of the host. On hosts that have <asm/types.h> 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 <john@phrozen.org>
This commit is contained in:
John Crispin committed 2026-09-22 18:18:58 +02:00
1 parent 5433adbc6e
commit 111e92cce0
2 files changed
+33 -1

No files matched your search

+2 -1
View File
@@ -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)),)
@@ -0,0 +1,31 @@
From: John Crispin <john@phrozen.org>
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 <john@phrozen.org>
---
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