From 7e5241e14aab1b6ff31c30bca05f9fa2ce81b6c1 Mon Sep 17 00:00:00 2001 From: Bernd Kuhls Date: Sat, 25 Apr 2026 23:16:37 +0200 Subject: [PATCH] package/libbpf: fix bpftrace build with kernel headers 5.{9, 10} Buildroot added the bpftrace package in 2024 with commit 338acb27ff3e07560290085d7c6a2feab633c869 which initially provided version 0.19.1. This release includes upstream commit https://github.com/bpftrace/bpftrace/commit/fea31939899db48fa6d28f5ce880bfc39250ec9f which was added to version 0.17.0 in 2022 and makes use of certain variables of struct bpf_btf_info which were added to the linux kernel in 2020 with version 5.11: https://github.com/torvalds/linux/commit/5329722057d41aebc31e391907a501feaa42f7d9 + __aligned_u64 name; + __u32 name_len; + __u32 kernel_btf; The libbpf package updates toolchain headers with its bundled version only when the toolchain headers are version 5.8 or older, this condition is part of the initial version of the package added in 2020 with buildroot commit f7b8508e4fe9c96bf679cc5423cc1500b6523e83. This version limit should have been raised when the bpftrace package was added to avoid build errors when the toolchain contains header versions 5.9 or 5.10. This situation caused build errors in the autobuilder, the last one in February 2025: /home/autobuild/autobuild/instance-18/output-1/build/bpftrace-0.19.1/src/bpffeature.cpp: In member function 'bool bpftrace::BPFfeature::has_module_btf()': /home/autobuild/autobuild/instance-18/output-1/build/bpftrace-0.19.1/src/bpffeature.cpp:573:8: error: 'struct bpf_btf_info' has no member named 'name' 573 | info.name = (__u64)name; | ^~~~ /home/autobuild/autobuild/instance-18/output-1/build/bpftrace-0.19.1/src/bpffeature.cpp:574:8: error: 'struct bpf_btf_info' has no member named 'name_len' 574 | info.name_len = sizeof(name); The problem disappeared from the autobuilders due to newer headers versions used for the buildroot toolchain or other build errors occurring earlier, like llvm version mismatches. The build error can today still be reproduced with this defconfig BR2_aarch64=y BR2_KERNEL_HEADERS_5_10=y BR2_TOOLCHAIN_BUILDROOT_CXX=y BR2_PER_PACKAGE_DIRECTORIES=y BR2_PACKAGE_BPFTRACE=y on the 2026.02.x branch as of 0be927b89a319c9ac35249354558e9f4cb102fd0. To fix the problem we raise the BR2_TOOLCHAIN_HEADERS_AT_LEAST_ version number. Fixes: https://autobuild.buildroot.net/results/dbe/dbecf88c7edba357cee8fea31294ddb9f4d188ad/ https://autobuild.buildroot.net/results/df5/df59e038de47f63d14e1be7bd12dd16a69636f79/ https://autobuild.buildroot.net/results/359/3595d39dd53a686bbf996dd4e532ced44906b9e3/ https://autobuild.buildroot.net/results/e4f/e4f95a5f30a605eadb81802075ea6bb1e2880684/ https://autobuild.buildroot.net/results/bd0/bd075cb8c55f9f8a017711dc804b8d81ae89b4c5/ Signed-off-by: Bernd Kuhls Signed-off-by: Arnout Vandecappelle --- package/libbpf/libbpf.mk | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/package/libbpf/libbpf.mk b/package/libbpf/libbpf.mk index a4bd270cbd..4b742ab966 100644 --- a/package/libbpf/libbpf.mk +++ b/package/libbpf/libbpf.mk @@ -18,13 +18,14 @@ define LIBBPF_BUILD_CMDS -C $(@D)/src endef -# bpf/bpf.h installed by libbpf uses bpf_iter_link_info that was added since -# kernel 5.9, so we need to update some uapi headers in STAGING_DIR if the -# toolchain is build with linux-headers < 5.9. -# Otherwise bpf/bpf.h 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=a5cbe05a6673b85bed2a63ffcfea6a96c6410cff -ifeq ($(BR2_TOOLCHAIN_HEADERS_AT_LEAST_5_9),) +# bpftrace uses variables from bpf_btf_info that were added since kernel +# 5.11, so we need to update some uapi headers in STAGING_DIR if the +# toolchain is build with linux-headers < 5.11. +# 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=5329722057d41aebc31e391907a501feaa42f7d9 +# https://github.com/bpftrace/bpftrace/commit/fea31939899db48fa6d28f5ce880bfc39250ec9f +ifeq ($(BR2_TOOLCHAIN_HEADERS_AT_LEAST_5_11),) LIBBPF_UPDATE_UAPI_HEADERS = install_uapi_headers UAPIDIR=/usr/include/bpf define LIBBPF_FIX_STAGING_PC