Skip to contentSkip to conversation

bpftool: Fix for building bpftool-native

PATCH Superseded Ryan Eatmon 1 participant 3 messages May 16, 2025

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 bpftool: Fix for building bpftool-native

The bpftool is configured to use the DEBUG_PREFIX_MAP when building, but this causes a problem when building bpftool-native. Ubuntu 22.04 has gcc-11 as the default and DEBUG_PREFIX_MAP contains an option that is only gcc-13 and beyond.

Simple fix is to remove the offending option when building bpftool-native.

---
 meta-arago-test/recipes-devtools/bpftool/bpftool-ti.inc   | 1 +
 meta-arago-test/recipes-devtools/bpftool/bpftool.bbappend | 4 ++++
 2 files changed, 5 insertions(+)
 create mode 100644 meta-arago-test/recipes-devtools/bpftool/bpftool-ti.inc
 create mode 100644 meta-arago-test/recipes-devtools/bpftool/bpftool.bbappend
meta-arago-test/recipes-devtools/bpftool/bpftool-ti.inc new file +1 -0
new file mode 100644
index 00000000..0310ebaa
@@ -0,0 +1 @@
+DEBUG_PREFIX_MAP:remove:class-native = "-fcanon-prefix-map"
meta-arago-test/recipes-devtools/bpftool/bpftool.bbappend new file +4 -0
new file mode 100644
index 00000000..b2dfa9d5
@@ -0,0 +1,4 @@
+BPFTOOL_TI = ""
+BPFTOOL_TI:ti-soc = "bpftool-ti.inc"
+
+require ${BPFTOOL_TI}
Signature · 1 line
2.17.1
#1 lore raw

PATCH 2/3 xdp-tools-arago: Add version v1.5.4

This is a sideport and update from a recipe in meta-dpdk [1]. There are no other version of this recipe in any of the standard locations (oe-core, meta-oe), so we will carry this here for the time being.

There is a big "hack" fix with this recipe to get around an oe-core multilib issue. On arm and aarch64 some of the /usr/include/asm headers are renamed and wrapped in the multilib system that uses the wordsize for the platform (based on defines in the compiler), it chooses the renamed file. The issue is that the original file is renamed to either -32.h or -64.h based on the target architecture, but only one of them is created. Usually this is ok, but for this package it presents a problem.

Some of the files are built using clang with the -target bpf option to build BPF programs. In this case all of the defines are changed from arm/aarch64 to just bpf, and this short circuits the multilib setup as bpf is not checked in the wordsize.h that is installed by the multilib flow. The fallback wordsize is 32 bits in this case. Since aarch64 is 64 bit, but the bpf is looking for the 32 bit headers we get compile errors.

The hack solution is to copy the needed files from the sysroot into the source for the program that the needed xx-32.h files are found. There is likely a better way to handle this in the long run, but for now this allows us to build the package.

[1] https://git.yoctoproject.org/meta-dpdk/tree/dynamic-layers/clang-layer/recipes-support/xdp-tools?id=3493058e7dcf00c78517ec5efb6457ebb1e85089

---
 ...0001-configure-skip-toolchain-checks.patch | 44 ++++++++++++++++
 ...issing-prefix-map-settings-for-OE-bu.patch | 40 ++++++++++++++
 ...-not-detect-libbpf-header-from-sysro.patch | 44 ++++++++++++++++
 .../0003-Makefile-fix-KeyError-failure.patch  | 31 +++++++++++
 .../0004-Makefile-fix-libxdp.pc-error.patch   | 34 ++++++++++++
 .../xdp-tools/xdp-tools-arago_1.5.4.bb        | 52 +++++++++++++++++++
 6 files changed, 245 insertions(+)
 create mode 100644 meta-arago-test/recipes-support/xdp-tools/xdp-tools-arago/0001-configure-skip-toolchain-checks.patch
 create mode 100644 meta-arago-test/recipes-support/xdp-tools/xdp-tools-arago/0001-defines.mk-Add-missing-prefix-map-settings-for-OE-bu.patch
 create mode 100644 meta-arago-test/recipes-support/xdp-tools/xdp-tools-arago/0002-Makefile-It-does-not-detect-libbpf-header-from-sysro.patch
 create mode 100644 meta-arago-test/recipes-support/xdp-tools/xdp-tools-arago/0003-Makefile-fix-KeyError-failure.patch
 create mode 100644 meta-arago-test/recipes-support/xdp-tools/xdp-tools-arago/0004-Makefile-fix-libxdp.pc-error.patch
 create mode 100644 meta-arago-test/recipes-support/xdp-tools/xdp-tools-arago_1.5.4.bb
meta-arago-test/recipes-support/xdp-tools/xdp-tools-arago/0001-configure-skip-toolchain-checks.patch new file +44 -0
new file mode 100644
index 00000000..b5f2780e
@@ -0,0 +1,44 @@
+From 9c9dce2e5f04de65b7b00321f96fff6071546ea1 Mon Sep 17 00:00:00 2001
+From: Naveen Saini <[email protected]>
+Date: Mon, 17 Oct 2022 15:44:16 +0800
+Subject: [PATCH] configure: skip toolchain checks
+
+Current logic fetch full command line along with the tool. i.e
+gcc -m64 -march=skylake -mtune=generic ...
+
+Which throws ERROR: Cannot find tool -m64
+
+So need to re-write for loop, so it can work in cross-compilation
+environment too.
+
+Upstream-Status: Inappropriate
+
+Signed-off-by: Naveen Saini <[email protected]>
+
+---
+ configure | 12 ++++++------
+ 1 file changed, 6 insertions(+), 6 deletions(-)
+
+diff --git a/configure b/configure
+index b4e824f..10618fc 100755
+--- a/configure
++++ b/configure
+@@ -70,12 +70,12 @@ check_toolchain()
+
+     CLANG=$(find_tool clang "$CLANG")
+ 
+-    for TOOL in $PKG_CONFIG $CC $OBJCOPY $CLANG $M4 $READELF; do
+-        if [ ! $(command -v ${TOOL} 2>/dev/null) ]; then
+-            echo "*** ERROR: Cannot find tool ${TOOL}" ;
+-            exit 1;
+-        fi;
+-    done
++    #for TOOL in $PKG_CONFIG $CC $OBJCOPY $CLANG $M4 $READELF; do
++    #    if [ ! $(command -v ${TOOL} 2>/dev/null) ]; then
++    #        echo "*** ERROR: Cannot find tool ${TOOL}" ;
++    #        exit 1;
++    #    fi;
++    #done
+ 
+     ARCH_NAME=$($CC -print-multiarch 2>/dev/null)
+ 
meta-arago-test/recipes-support/xdp-tools/xdp-tools-arago/0001-defines.mk-Add-missing-prefix-map-settings-for-OE-bu.patch new file +40 -0
new file mode 100644
index 00000000..b76f2e62
@@ -0,0 +1,40 @@
+From a7698c7172a8a178efd73bdc0ce31d4aa3646f6e Mon Sep 17 00:00:00 2001
+From: Ryan Eatmon <[email protected]>
+Date: Mon, 5 May 2025 14:30:10 -0500
+Subject: [PATCH] defines.mk: Add missing prefix-map settings for OE builds
+
+The defines was only pulling in one of the four *-prefix-map options
+from CFLAGS.
+
+Upstream-Status: OE-Specific
+
+Signed-off-by: Ryan Eatmon <[email protected]>
+---
+ lib/defines.mk | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/lib/defines.mk b/lib/defines.mk
+index 411a97e..6061e81 100644
+--- a/lib/defines.mk
++++ b/lib/defines.mk
+@@ -26,7 +26,7 @@ TEST_DIR = $(LIB_DIR)/testing
+ LIBXDP_DIR := $(LIB_DIR)/libxdp
+ LIBBPF_DIR := $(LIB_DIR)/libbpf
+ 
+-DEFINES := -DBPF_DIR_MNT=\"$(BPF_DIR_MNT)\" -DBPF_OBJECT_PATH=\"$(BPF_OBJECT_DIR)\" \
++DEFINES := -DBPF_DIR_MNT=\"$(BPF_DIR_MNT)\" -DBPF_OBJECT_PATH=\"$(OE_BPF_OBJECT_DIR)\" \
+ 	-DMAX_DISPATCHER_ACTIONS=$(MAX_DISPATCHER_ACTIONS) -DTOOLS_VERSION=\"$(TOOLS_VERSION)\" \
+ 	-DLIBBPF_VERSION=\"$(LIBBPF_VERSION)\" -DRUNDIR=\"$(RUNDIR)\"
+ 
+@@ -43,7 +43,7 @@ endif
+ DEFINES += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
+ 
+ CFLAGS += -std=gnu11 -Wextra -Werror $(DEFINES) $(ARCH_INCLUDES)
+-BPF_CFLAGS += $(DEFINES) $(filter -ffile-prefix-map=%,$(CFLAGS)) $(filter -I%,$(CFLAGS)) $(ARCH_INCLUDES)
++BPF_CFLAGS += $(DEFINES) $(filter -fcoverage-prefix-map=%,$(CFLAGS)) $(filter -fdebug-prefix-map=%,$(CFLAGS)) $(filter -ffile-prefix-map=%,$(CFLAGS)) $(filter -fmacro-prefix-map=%,$(CFLAGS)) $(filter -I%,$(CFLAGS)) $(ARCH_INCLUDES)
+ 
+ CONFIGMK := $(LIB_DIR)/../config.mk
+ LIBMK := Makefile $(CONFIGMK) $(LIB_DIR)/defines.mk $(LIB_DIR)/common.mk $(LIB_DIR)/../version.mk
+-- 
+2.17.1
+
meta-arago-test/recipes-support/xdp-tools/xdp-tools-arago/0002-Makefile-It-does-not-detect-libbpf-header-from-sysro.patch new file +44 -0

44 lines not on this page · raw message

meta-arago-test/recipes-support/xdp-tools/xdp-tools-arago/0003-Makefile-fix-KeyError-failure.patch new file +31 -0
new file mode 100644
index 00000000..d0133bcb
@@ -0,0 +1,31 @@
+From 157546fbc4f18751c52b3c8788879c05cf253331 Mon Sep 17 00:00:00 2001
+From: Naveen Saini <[email protected]>
+Date: Mon, 17 Oct 2022 16:02:46 +0800
+Subject: [PATCH 3/4] Makefile: fix KeyError failure
+
+Error:
+Exception: KeyError: 'getpwuid(): uid not found: 11857215'
+
+Upstream-Status: Inappropriate
+
+Signed-off-by: Naveen Saini <[email protected]>
+---
+ lib/libxdp/Makefile | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/lib/libxdp/Makefile b/lib/libxdp/Makefile
+index 8f459d8..9a340a3 100644
+--- a/lib/libxdp/Makefile
++++ b/lib/libxdp/Makefile
+@@ -54,7 +54,7 @@ install: all
+ 	$(Q)install -d -m 0755 $(DESTDIR)$(BPF_OBJECT_DIR)
+ 	$(Q)install -m 0644 $(LIB_HEADERS) $(DESTDIR)$(HDRDIR)/
+ 	$(Q)install -m 0644 $(PC_FILE) $(DESTDIR)$(LIBDIR)/pkgconfig/
+-	$(Q)cp -fpR $(SHARED_LIBS) $(STATIC_LIBS) $(DESTDIR)$(LIBDIR)
++	$(Q)cp -fpR --no-preserve=ownership $(SHARED_LIBS) $(STATIC_LIBS) $(DESTDIR)$(LIBDIR)
+ 	$(Q)install -m 0644 $(XDP_OBJS) $(DESTDIR)$(BPF_OBJECT_DIR)
+ 	$(if $(MAN_FILES),$(Q)install -m 0755 -d $(DESTDIR)$(MANDIR)/man3)
+ 	$(if $(MAN_FILES),$(Q)install -m 0644 $(MAN_FILES) $(DESTDIR)$(MANDIR)/man3)
+-- 
+2.25.1
+
meta-arago-test/recipes-support/xdp-tools/xdp-tools-arago/0004-Makefile-fix-libxdp.pc-error.patch new file +34 -0
new file mode 100644
index 00000000..b1e15e52
@@ -0,0 +1,34 @@
+From 46b3ff797135574aa0ee42f633a281d44f48da95 Mon Sep 17 00:00:00 2001
+From: Naveen Saini <[email protected]>
+Date: Mon, 17 Oct 2022 16:05:15 +0800
+Subject: [PATCH 4/4] Makefile: fix libxdp.pc error
+
+Error:
+do_populate_sysroot: QA Issue: libxdp.pc failed sanity test (tmpdir) in
+path ... xdp-tools/1.2.8-r0/sysroot-destdir/usr/lib/pkgconfig [pkgconfig]
+
+Upstream-Status: Inappropriate
+
+Signed-off-by: Naveen Saini <[email protected]>
+---
+ lib/libxdp/Makefile | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/lib/libxdp/Makefile b/lib/libxdp/Makefile
+index 9a340a3..bc39177 100644
+--- a/lib/libxdp/Makefile
++++ b/lib/libxdp/Makefile
+@@ -76,8 +76,8 @@ $(OBJDIR)/libxdp.so.$(LIBXDP_VERSION): $(SHARED_OBJS)
+ 		      $^ $(LDFLAGS) $(LDLIBS) -o $@
+ 
+ $(OBJDIR)/libxdp.pc:
+-	$(Q)sed -e "s|@PREFIX@|$(PREFIX)|" \
+-			-e "s|@LIBDIR@|$(LIBDIR)|" \
++	$(Q)sed -e "s|@PREFIX@|$(prefix)|" \
++			-e "s|@LIBDIR@|$(libdir)|" \
+ 			-e "s|@VERSION@|$(TOOLS_VERSION)|" \
+ 			< libxdp.pc.template > $@
+ 
+-- 
+2.25.1
+
meta-arago-test/recipes-support/xdp-tools/xdp-tools-arago_1.5.4.bb new file +52 -0

52 lines not on this page · raw message

Signature · 1 line
2.17.1
#2 lore raw

PATCH 3/3 ti-test: Add xdp-tools

In reply to Ryan Eatmon

Add in the new xdp-tools package.

---
 meta-arago-test/recipes-core/packagegroups/ti-test.bb | 1 +
 1 file changed, 1 insertion(+)
meta-arago-test/recipes-core/packagegroups/ti-test.bb +1 -0
index 3d0c1209..caf8b622 100644
@@ -55,6 +55,7 @@ TI_TEST_BASE = "\
     stress-ng \
     tcpdump \
     v4l-utils \
+    xdp-tools-arago \
     yavta \
 "
 
Signature · 1 line
2.17.1