Skip to contentSkip to conversation

package/libbpf: update UAPI header installation work-around

PATCH Applied Thomas Petazzoni via buildroot 2 participants 12 messages Aug 27 – Sep 4

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 package/libbpf: update UAPI header installation work-around

bpftrace often needs very recent kernel headers, more recent than the runtime version actually needed. We already had a workaround in libbpf making sure that if the kernel headers are older than 6.1, we would install the libbpf provided headers instead.

As we are about to update bpftrace to a newer version that uses BPF_TRACE_KPROBE_SESSION, which was introduced in Linux 6.10, we need to update this workaround accordingly and ensure that the libbpf header is installed if the kernel headers are older than 6.10.

This is necessary for the update of bpftrace to 0.26.1.

---
 package/libbpf/libbpf.mk | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
package/libbpf/libbpf.mk +3 -5
index 5a6d574331..0683ec12c1 100644
@@ -18,14 +18,12 @@ define LIBBPF_BUILD_CMDS
 		-C $(@D)/src
 endef
 
-# bpftrace uses bpf_iter_link_info.task that was added since kernel 6.1
+# bpftrace uses BPF_TRACE_KPROBE_SESSION that was added since kernel 6.10
 # so we need to update some uapi headers in STAGING_DIR if the toolchain
-# is build with linux-headers < 6.1.
+# is build with linux-headers < 6.1.0
 # Otherwise bpftrace is broken due to out of date linux/bpf.h installed
 # by the toolchain.
-# https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=f0d74c4da1f060d2a66976193712a5e6abd361f5
-# https://github.com/bpftrace/bpftrace/commit/7578314df67df6bbdffaf493ff3b4d182b235b34
-ifeq ($(BR2_TOOLCHAIN_HEADERS_AT_LEAST_6_1),)
+ifeq ($(BR2_TOOLCHAIN_HEADERS_AT_LEAST_6_10),)
 LIBBPF_UPDATE_UAPI_HEADERS = install_uapi_headers UAPIDIR=/usr/include/bpf
 
 define LIBBPF_FIX_STAGING_PC
Signature · 6 lines
2.55.0

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

PATCH 2/3 package/bpftrace: bump to version 0.26.1 to fix build with LLVM 22

Since Buildroot commit 25cb3813e7fc6ed3e455f983cf0e09c7bc02fccb which bumped LLVM from 21.x to 22.x, the build of bpftrace is broken as bpftrace 0.24.2 only supports LLVM up to 21.

We tried backporting the bpftrace patch that allows using LLVM up to version 22 but the patch didn't apply cleanly but more importantly it wasn't clear if this patch was sufficient. Therefore, we opt for bumping bpftrace entirely to fix the issue.

Packaging changes:

- The new version of bpftrace no longer needs host-bison/host-flex, because bpftrace is now using a handwritten parser.

- Pass -DUSE_SYSTEM_LIBBPF:BOOL=ON to ensure the system libbpf version is used, and not the bundled version

- Now depends on kernel headers >= 5.10 because it needs CAP_BPF and CAP_PERFMON

Fixes:

https://autobuild.buildroot.net/results/a3e3fd696685864977c688aa11c2653357cf6207/

---
 package/bpftrace/Config.in     | 6 +++---
 package/bpftrace/bpftrace.hash | 2 +-
 package/bpftrace/bpftrace.mk   | 7 +++----
 3 files changed, 7 insertions(+), 8 deletions(-)
package/bpftrace/Config.in +3 -3
index 8af94443ab..2beb2fdb95 100644
@@ -14,7 +14,7 @@ config BR2_PACKAGE_BPFTRACE
 	depends on BR2_TOOLCHAIN_GCC_AT_LEAST_7 # bcc -> clang
 	depends on BR2_INSTALL_LIBSTDCPP # bcc -> clang
 	depends on BR2_HOST_GCC_AT_LEAST_7 # bcc -> clang
-	depends on BR2_TOOLCHAIN_HEADERS_AT_LEAST_4_13 # libbpf
+	depends on BR2_TOOLCHAIN_HEADERS_AT_LEAST_5_10 # CAP_BPF, CAP_PERFMON
 	depends on BR2_USE_WCHAR # bcc -> clang, bcc -> python3, libbpf
 	depends on BR2_TOOLCHAIN_HAS_THREADS # bcc -> clang, bcc -> python3, libbpf
 	depends on !BR2_STATIC_LIBS # bcc -> clang, bcc -> python3, libbpf
@@ -47,10 +47,10 @@ config BR2_PACKAGE_BPFTRACE
 
 	  https://www.github.com/iovisor/bpftrace
 
-comment "bpftrace needs a glibc toolchain w/ C++, gcc >= 7, host gcc >= 7, kernel headers >= 4.13"
+comment "bpftrace needs a glibc toolchain w/ C++, gcc >= 7, host gcc >= 7, kernel headers >= 5.10"
 	depends on BR2_PACKAGE_BPFTRACE_ARCH_SUPPORTS
 	depends on BR2_USE_MMU
 	depends on BR2_TOOLCHAIN_HAS_SYNC_4
 	depends on !BR2_TOOLCHAIN_USES_GLIBC || !BR2_INSTALL_LIBSTDCPP \
 		|| !BR2_TOOLCHAIN_GCC_AT_LEAST_7 || !BR2_HOST_GCC_AT_LEAST_7 \
-		|| !BR2_TOOLCHAIN_HEADERS_AT_LEAST_4_13
+		|| !BR2_TOOLCHAIN_HEADERS_AT_LEAST_5_10
package/bpftrace/bpftrace.hash +1 -1
index 4add96aee3..48572d1c58 100644
@@ -1,3 +1,3 @@
 # locally calculated
-sha256  e0514aa3e1a032b0b2de2cf3c281bfee9b9e80509498e70ed78786bbd64db373  bpftrace-0.24.2.tar.gz
+sha256  555368f32f94bfcb74b119a3d9c67b68200be6375b8f452f794a2d3f6ebbcd16  bpftrace-0.26.1.tar.gz
 sha256  cfc7749b96f63bd31c3c42b5c471bf756814053e847c10f3eb003417bc523d30  LICENSE
package/bpftrace/bpftrace.mk +3 -4
index f530d4861b..7c9bc6b7a4 100644
@@ -4,7 +4,7 @@
 #
 ################################################################################
 
-BPFTRACE_VERSION = 0.24.2
+BPFTRACE_VERSION = 0.26.1
 BPFTRACE_SITE = $(call github,bpftrace,bpftrace,v$(BPFTRACE_VERSION))
 BPFTRACE_LICENSE = Apache-2.0
 BPFTRACE_LICENSE_FILES = LICENSE
@@ -13,8 +13,6 @@ BPFTRACE_DEPENDENCIES = \
 	bzip2 \
 	cereal \
 	elfutils \
-	host-bison \
-	host-flex \
 	host-vim \
 	libbpf \
 	llvm \
@@ -29,6 +27,7 @@ BPFTRACE_CONF_OPTS += \
 	-DBUILD_SHARED_LIBS:BOOL=OFF \
 	-DBUILD_TESTING:BOOL=OFF \
 	-DCMAKE_CXX_FLAGS="$(TARGET_CXXFLAGS) -I$(STAGING_DIR)/usr/include/bpf" \
-	-DENABLE_MAN:BOOL=OFF
+	-DENABLE_MAN:BOOL=OFF \
+	-DUSE_SYSTEM_LIBBPF:BOOL=ON
 
 $(eval $(cmake-package))
Signature · 6 lines
2.55.0

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

Re: [Buildroot] [PATCH 2/3] package/bpftrace: bump to version 0.26.1 to fix build with LLVM 22

In reply of:

Quoted 17 lines

Since Buildroot commit 25cb3813e7fc6ed3e455f983cf0e09c7bc02fccb which bumped LLVM from 21.x to 22.x, the build of bpftrace is broken as bpftrace 0.24.2 only supports LLVM up to 21.

We tried backporting the bpftrace patch that allows using LLVM up to version 22 but the patch didn't apply cleanly but more importantly it wasn't clear if this patch was sufficient. Therefore, we opt for bumping bpftrace entirely to fix the issue.

Packaging changes:

- The new version of bpftrace no longer needs host-bison/host-flex, because bpftrace is now using a handwritten parser.

- Pass -DUSE_SYSTEM_LIBBPF:BOOL=ON to ensure the system libbpf version is used, and not the bundled version

Quoted 8 lines

- Now depends on kernel headers >= 5.10 because it needs CAP_BPF and CAP_PERFMON

Fixes:

https://autobuild.buildroot.net/results/a3e3fd696685864977c688aa11c2653357cf6207/

Applied to 2026.05.x. Thanks

Quoted 79 lines
---
 package/bpftrace/Config.in     | 6 +++---
 package/bpftrace/bpftrace.hash | 2 +-
 package/bpftrace/bpftrace.mk   | 7 +++----
 3 files changed, 7 insertions(+), 8 deletions(-)
package/bpftrace/Config.in +3 -3
index 8af94443ab..2beb2fdb95 100644
@@ -14,7 +14,7 @@ config BR2_PACKAGE_BPFTRACE
 	depends on BR2_TOOLCHAIN_GCC_AT_LEAST_7 # bcc -> clang
 	depends on BR2_INSTALL_LIBSTDCPP # bcc -> clang
 	depends on BR2_HOST_GCC_AT_LEAST_7 # bcc -> clang
-	depends on BR2_TOOLCHAIN_HEADERS_AT_LEAST_4_13 # libbpf
+	depends on BR2_TOOLCHAIN_HEADERS_AT_LEAST_5_10 # CAP_BPF, CAP_PERFMON
 	depends on BR2_USE_WCHAR # bcc -> clang, bcc -> python3, libbpf
 	depends on BR2_TOOLCHAIN_HAS_THREADS # bcc -> clang, bcc -> python3, libbpf
 	depends on !BR2_STATIC_LIBS # bcc -> clang, bcc -> python3, libbpf
@@ -47,10 +47,10 @@ config BR2_PACKAGE_BPFTRACE
 
 	  https://www.github.com/iovisor/bpftrace
 
-comment "bpftrace needs a glibc toolchain w/ C++, gcc >= 7, host gcc >= 7, kernel headers >= 4.13"
+comment "bpftrace needs a glibc toolchain w/ C++, gcc >= 7, host gcc >= 7, kernel headers >= 5.10"
 	depends on BR2_PACKAGE_BPFTRACE_ARCH_SUPPORTS
 	depends on BR2_USE_MMU
 	depends on BR2_TOOLCHAIN_HAS_SYNC_4
 	depends on !BR2_TOOLCHAIN_USES_GLIBC || !BR2_INSTALL_LIBSTDCPP \
 		|| !BR2_TOOLCHAIN_GCC_AT_LEAST_7 || !BR2_HOST_GCC_AT_LEAST_7 \
-		|| !BR2_TOOLCHAIN_HEADERS_AT_LEAST_4_13
+		|| !BR2_TOOLCHAIN_HEADERS_AT_LEAST_5_10
package/bpftrace/bpftrace.hash +1 -1
index 4add96aee3..48572d1c58 100644
@@ -1,3 +1,3 @@
 # locally calculated
-sha256  e0514aa3e1a032b0b2de2cf3c281bfee9b9e80509498e70ed78786bbd64db373  bpftrace-0.24.2.tar.gz
+sha256  555368f32f94bfcb74b119a3d9c67b68200be6375b8f452f794a2d3f6ebbcd16  bpftrace-0.26.1.tar.gz
 sha256  cfc7749b96f63bd31c3c42b5c471bf756814053e847c10f3eb003417bc523d30  LICENSE
package/bpftrace/bpftrace.mk +3 -4
index f530d4861b..7c9bc6b7a4 100644
@@ -4,7 +4,7 @@
 #
 ################################################################################
 
-BPFTRACE_VERSION = 0.24.2
+BPFTRACE_VERSION = 0.26.1
 BPFTRACE_SITE = $(call github,bpftrace,bpftrace,v$(BPFTRACE_VERSION))
 BPFTRACE_LICENSE = Apache-2.0
 BPFTRACE_LICENSE_FILES = LICENSE
@@ -13,8 +13,6 @@ BPFTRACE_DEPENDENCIES = \
 	bzip2 \
 	cereal \
 	elfutils \
-	host-bison \
-	host-flex \
 	host-vim \
 	libbpf \
 	llvm \
@@ -29,6 +27,7 @@ BPFTRACE_CONF_OPTS += \
 	-DBUILD_SHARED_LIBS:BOOL=OFF \
 	-DBUILD_TESTING:BOOL=OFF \
 	-DCMAKE_CXX_FLAGS="$(TARGET_CXXFLAGS) -I$(STAGING_DIR)/usr/include/bpf" \
-	-DENABLE_MAN:BOOL=OFF
+	-DENABLE_MAN:BOOL=OFF \
+	-DUSE_SYSTEM_LIBBPF:BOOL=ON
 
 $(eval $(cmake-package))
Signature · 6 lines
2.55.0

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

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

#3 lore raw

PATCH 3/3 support/testing: add bpftrace test

In reply to Thomas Petazzoni via buildroot

This commit adds a simple bpftrace test that ensures that not only it builds fine, but it also runs properly on a minimal test scenario.

Assisted-by GPT-5.6
---
 DEVELOPERS                                    |  2 +
 .../testing/tests/package/test_bpftrace.py    | 66 +++++++++++++++++++
 .../test_bpftrace/linux-bpftrace.fragment     |  4 ++
 3 files changed, 72 insertions(+)
 create mode 100644 support/testing/tests/package/test_bpftrace.py
 create mode 100644 support/testing/tests/package/test_bpftrace/linux-bpftrace.fragment
DEVELOPERS +2 -0
index 5eb438906f..080aaac5e0 100644
@@ -3297,6 +3297,8 @@ F:	support/testing/tests/package/sample_python_flask_expects_json.py
 F:	support/testing/tests/package/sample_python_git.py
 F:	support/testing/tests/package/sample_python_pyudev.py
 F:	support/testing/tests/package/sample_python_unittest_xml_reporting.py
+F:	support/testing/tests/package/test_bpftrace.py
+F:	support/testing/tests/package/test_bpftrace/linux-bpftrace.fragment
 F:	support/testing/tests/package/test_nodejs.py
 F:	support/testing/tests/package/test_python_augeas.py
 F:	support/testing/tests/package/test_python_crccheck.py
support/testing/tests/package/test_bpftrace.py new file +66 -0

66 lines not on this page · raw message

support/testing/tests/package/test_bpftrace/linux-bpftrace.fragment new file +4 -0
new file mode 100644
index 0000000000..35359b08f6
@@ -0,0 +1,4 @@
+CONFIG_FTRACE=y
+CONFIG_FTRACE_SYSCALLS=y
+CONFIG_FUNCTION_TRACER=y
+CONFIG_KPROBES=y
Signature · 6 lines
2.55.0

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

Re: [Buildroot] [PATCH 3/3] support/testing: add bpftrace test

support/testing/tests/package/test_bpftrace.py line 17

Quoted 12 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Thomas" == Thomas Petazzoni via buildroot <[email protected]> writes:

This commit adds a simple bpftrace test that ensures that not only it builds fine, but it also runs properly on a minimal test scenario.

support/testing/tests/package/test_bpftrace.py new file +7 -0
+    config = f"""
+        BR2_aarch64=y
+        BR2_TOOLCHAIN_EXTERNAL=y
+        BR2_TARGET_GENERIC_GETTY_PORT="ttyAMA0"
+        BR2_LINUX_KERNEL=y
+        BR2_LINUX_KERNEL_CUSTOM_VERSION=y
+        BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="6.6.32"

Any specific reason to use such an old kernel? The qemu_aarch64_virt defconfig uses a 6.18 kernel. Is it to match the default ARM 15.2 external toolchain? If so, that one is built against 6.6.44.

cat output/host/usr/aarch64-buildroot-linux-gnu/sysroot/usr/include/linux/version.h #define LINUX_VERSION_CODE 394796
#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + ((c) > 255 ? 255 : (c))) #define LINUX_VERSION_MAJOR 6
#define LINUX_VERSION_PATCHLEVEL 6
#define LINUX_VERSION_SUBLEVEL 44

Signature · 5 lines
Bye, Peter Korsgaard
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#5 lore raw

Re: [Buildroot] [PATCH 3/3] support/testing: add bpftrace test

Hi Peter, Thomas,

Quoted 18 lines · Peter Korsgaard
Quoted 3 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Thomas" == Thomas Petazzoni via buildroot <[email protected]> writes:

This commit adds a simple bpftrace test that ensures that not only

it

support/testing/tests/package/test_bpftrace.py line 17

Quoted 9 lines

builds fine, but it also runs properly on a minimal test scenario.

support/testing/tests/package/test_bpftrace.py new file +7 -0
+    config = f"""
+        BR2_aarch64=y
+        BR2_TOOLCHAIN_EXTERNAL=y
+        BR2_TARGET_GENERIC_GETTY_PORT="ttyAMA0"
+        BR2_LINUX_KERNEL=y
+        BR2_LINUX_KERNEL_CUSTOM_VERSION=y
+        BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="6.6.32"

Any specific reason to use such an old kernel? The qemu_aarch64_virt defconfig uses a 6.18 kernel. Is it to match the default ARM 15.2 external toolchain? If so, that one is built against 6.6.44.

Quoted 6 lines

cat output/host/usr/aarch64-buildroot-linux-gnu/sysroot/usr/include/linux/version.h #define LINUX_VERSION_CODE 394796
#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + ((c) > 255 ? 255 : (c))) #define LINUX_VERSION_MAJOR 6
#define LINUX_VERSION_PATCHLEVEL 6
#define LINUX_VERSION_SUBLEVEL 44

I initially had the same question. Then, I assumed this new runtime test has been simply copied from the existing test_bcc:
https://gitlab.com/buildroot.org/buildroot/-/blob/master/support/testing/tests/package/test_bcc.py
which was written with kernel 6.6.32, which was the latest LTS at that time.

Once the next 2026.08 release will be complete, I think we will do a cleanup in runtime tests, to add a Aarch64 builtin kernel at the latest LTS. So all those runtime tests will be updated.

Quoted 2 lines

--
Bye, Peter Korsgaard

Best regards,

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

#6 lore raw

Re: [Buildroot] [PATCH 3/3] support/testing: add bpftrace test

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Julien" == Julien Olivain <[email protected]> writes:

Hi,

Quoted 9 lines

I initially had the same question. Then, I assumed this new runtime test has been simply copied from the existing test_bcc:
https://gitlab.com/buildroot.org/buildroot/-/blob/master/support/testing/tests/package/test_bcc.py
which was written with kernel 6.6.32, which was the latest LTS at that time.

Once the next 2026.08 release will be complete, I think we will do a cleanup in runtime tests, to add a Aarch64 builtin kernel at the latest LTS. So all those runtime tests will be updated.

Ok, good.

Signature · 5 lines
Bye, Peter Korsgaard
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#7 lore raw

Re: [Buildroot] [PATCH 3/3] support/testing: add bpftrace test

In reply to Julien Olivain via buildroot
Quoted 4 lines · Julien Olivain

I initially had the same question. Then, I assumed this new runtime test has been simply copied from the existing test_bcc:
https://gitlab.com/buildroot.org/buildroot/-/blob/master/support/testing/tests/package/test_bcc.py
which was written with kernel 6.6.32, which was the latest LTS at that time.

Absolutely correct. And of course, I see no problem in migrating all these tests to 6.18.

Quoted 3 lines

Once the next 2026.08 release will be complete, I think we will do a cleanup in runtime tests, to add a Aarch64 builtin kernel at the latest LTS. So all those runtime tests will be updated.

I vaguely remember that one intern from Romain Naour was working on this, I even vaguely remember seeing patches implementing this, no?

Thomas

Signature · 7 lines
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#8 lore raw

Re: [Buildroot] [PATCH 3/3] support/testing: add bpftrace test

Hi Thomas, All,

Quoted 10 lines · Thomas Petazzoni
Quoted 4 lines · Julien Olivain

I initially had the same question. Then, I assumed this new runtime test has been simply copied from the existing test_bcc:
https://gitlab.com/buildroot.org/buildroot/-/blob/master/support/testing/tests/package/test_bcc.py
which was written with kernel 6.6.32, which was the latest LTS at that time.

Absolutely correct. And of course, I see no problem in migrating all these tests to 6.18.

Quoted 6 lines
Quoted 3 lines

Once the next 2026.08 release will be complete, I think we will do a cleanup in runtime tests, to add a Aarch64 builtin kernel at the latest LTS. So all those runtime tests will be updated.

I vaguely remember that one intern from Romain Naour was working on this, I even vaguely remember seeing patches implementing this, no?

If I try to summarize the state of this activity:

I merged a series a while back, updating many kernels in runtime tests:
https://patchwork.ozlabs.org/project/buildroot/list/?series=500282&state=*

Then, there is an initiative to build the runtime test pre-built Kernels from the Gitlab CI:
https://patchwork.buildroot.org/project/buildroot/list/?series=210
Ideally we would like to add new kernels (aarch64 for ex).

Then, there is ongoing work to switch most tests on the new relevant pre-built kernels. I think the most advance ongoing work is at:
https://gitlab.com/kubu93/buildroot/-/commits/prebuilt-aarch64-kernel-v7

Quoted 5 lines

Thomas
--
Thomas Petazzoni, co-owner and CEO, Bootlin Embedded Linux and Kernel engineering and training
https://bootlin.com

Best regards,

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

#9 lore raw

Re: [Buildroot] [PATCH 3/3] support/testing: add bpftrace test

In reply to Thomas Petazzoni via buildroot

In reply of:

Quoted 5 lines

This commit adds a simple bpftrace test that ensures that not only it builds fine, but it also runs properly on a minimal test scenario.

Assisted-by GPT-5.6

Applied to 2025.02.x & 2026.05.x. Thanks

Quoted 110 lines
---
 DEVELOPERS                                    |  2 +
 .../testing/tests/package/test_bpftrace.py    | 66 +++++++++++++++++++
 .../test_bpftrace/linux-bpftrace.fragment     |  4 ++
 3 files changed, 72 insertions(+)
 create mode 100644 support/testing/tests/package/test_bpftrace.py
 create mode 100644 support/testing/tests/package/test_bpftrace/linux-bpftrace.fragment
DEVELOPERS +2 -0
index 5eb438906f..080aaac5e0 100644
@@ -3297,6 +3297,8 @@ F:	support/testing/tests/package/sample_python_flask_expects_json.py
 F:	support/testing/tests/package/sample_python_git.py
 F:	support/testing/tests/package/sample_python_pyudev.py
 F:	support/testing/tests/package/sample_python_unittest_xml_reporting.py
+F:	support/testing/tests/package/test_bpftrace.py
+F:	support/testing/tests/package/test_bpftrace/linux-bpftrace.fragment
 F:	support/testing/tests/package/test_nodejs.py
 F:	support/testing/tests/package/test_python_augeas.py
 F:	support/testing/tests/package/test_python_crccheck.py
support/testing/tests/package/test_bpftrace.py new file +66 -0
new file mode 100644
index 0000000000..70ccfe8b20
@@ -0,0 +1,66 @@
+import os
+
+import infra.basetest
+
+
+# gitlab-runner: 2xlarge
+class TestBpftrace(infra.basetest.BRTest):
+    kern_fragment = infra.filepath(
+        "tests/package/test_bpftrace/linux-bpftrace.fragment"
+    )
+    config = f"""
+        BR2_aarch64=y
+        BR2_TOOLCHAIN_EXTERNAL=y
+        BR2_TARGET_GENERIC_GETTY_PORT="ttyAMA0"
+        BR2_LINUX_KERNEL=y
+        BR2_LINUX_KERNEL_CUSTOM_VERSION=y
+        BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="6.6.32"
+        BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
+        BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="board/qemu/aarch64-virt/linux.config"
+        BR2_LINUX_KERNEL_CONFIG_FRAGMENT_FILES="{kern_fragment}"
+        BR2_LINUX_KERNEL_NEEDS_HOST_OPENSSL=y
+        BR2_PACKAGE_BUSYBOX_SHOW_OTHERS=y
+        BR2_PACKAGE_BPFTRACE=y
+        BR2_PACKAGE_TAR=y
+        BR2_TARGET_ROOTFS_EXT2=y
+        BR2_TARGET_ROOTFS_EXT2_4=y
+        BR2_TARGET_ROOTFS_EXT2_SIZE="256M"
+        # BR2_TARGET_ROOTFS_TAR is not set
+        """
+
+    def test_run(self):
+        drive = os.path.join(self.builddir, "images", "rootfs.ext4")
+        kern = os.path.join(self.builddir, "images", "Image")
+        self.emulator.boot(
+            arch="aarch64",
+            kernel=kern,
+            kernel_cmdline=["root=/dev/vda console=ttyAMA0"],
+            options=[
+                "-M",
+                "virt",
+                "-cpu",
+                "cortex-a57",
+                "-m",
+                "256M",
+                "-drive",
+                f"file={drive},if=virtio,format=raw",
+            ],
+        )
+        self.emulator.login()
+
+        self.assertRunOk("mount -t debugfs none /sys/kernel/debug/")
+
+        # Check that bpftrace can find a syscall tracepoint.
+        self.assertRunOk("bpftrace -l 'tracepoint:syscalls:sys_enter_execve'")
+
+        # Compile and attach a tracepoint program, then trigger it with the
+        # command executed by bpftrace. The marker avoids matching volatile
+        # fields such as PIDs or command names.
+        cmd = (
+            "bpftrace -e 'tracepoint:syscalls:sys_enter_execve "
+            '{ printf("buildroot-bpftrace-test\\n"); exit(); }\' '
+            "-c /bin/true"
+        )
+        output, ret = self.emulator.run(cmd)
+        self.assertEqual(ret, 0)
+        self.assertIn("buildroot-bpftrace-test", "\n".join(output))
support/testing/tests/package/test_bpftrace/linux-bpftrace.fragment new file +4 -0
new file mode 100644
index 0000000000..35359b08f6
@@ -0,0 +1,4 @@
+CONFIG_FTRACE=y
+CONFIG_FTRACE_SYSCALLS=y
+CONFIG_FUNCTION_TRACER=y
+CONFIG_KPROBES=y
Signature · 6 lines
2.55.0

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

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

#10 lore raw
In reply to Thomas Petazzoni via buildroot
Quoted 5 lines · Thomas Petazzoni via buildroot

bpftrace often needs very recent kernel headers, more recent than the runtime version actually needed. We already had a workaround in libbpf making sure that if the kernel headers are older than 6.1, we would install the libbpf provided headers instead.

Quoted 8 lines

As we are about to update bpftrace to a newer version that uses BPF_TRACE_KPROBE_SESSION, which was introduced in Linux 6.10, we need to update this workaround accordingly and ensure that the libbpf header is installed if the kernel headers are older than 6.10.

This is necessary for the update of bpftrace to 0.26.1.

Series applied to master, thanks.
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#11 lore raw
In reply to Thomas Petazzoni via buildroot

In reply of:

Quoted 5 lines

bpftrace often needs very recent kernel headers, more recent than the runtime version actually needed. We already had a workaround in libbpf making sure that if the kernel headers are older than 6.1, we would install the libbpf provided headers instead.

Quoted 8 lines

As we are about to update bpftrace to a newer version that uses BPF_TRACE_KPROBE_SESSION, which was introduced in Linux 6.10, we need to update this workaround accordingly and ensure that the libbpf header is installed if the kernel headers are older than 6.10.

This is necessary for the update of bpftrace to 0.26.1.

Applied to 2026.05.x. Thanks

Quoted 33 lines
---
 package/libbpf/libbpf.mk | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
package/libbpf/libbpf.mk +3 -5
index 5a6d574331..0683ec12c1 100644
@@ -18,14 +18,12 @@ define LIBBPF_BUILD_CMDS
 		-C $(@D)/src
 endef
 
-# bpftrace uses bpf_iter_link_info.task that was added since kernel 6.1
+# bpftrace uses BPF_TRACE_KPROBE_SESSION that was added since kernel 6.10
 # so we need to update some uapi headers in STAGING_DIR if the toolchain
-# is build with linux-headers < 6.1.
+# is build with linux-headers < 6.1.0
 # Otherwise bpftrace is broken due to out of date linux/bpf.h installed
 # by the toolchain.
-# https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=f0d74c4da1f060d2a66976193712a5e6abd361f5
-# https://github.com/bpftrace/bpftrace/commit/7578314df67df6bbdffaf493ff3b4d182b235b34
-ifeq ($(BR2_TOOLCHAIN_HEADERS_AT_LEAST_6_1),)
+ifeq ($(BR2_TOOLCHAIN_HEADERS_AT_LEAST_6_10),)
 LIBBPF_UPDATE_UAPI_HEADERS = install_uapi_headers UAPIDIR=/usr/include/bpf
 
 define LIBBPF_FIX_STAGING_PC
Signature · 6 lines
2.55.0

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

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