package/libbpf: fix bpftrace build with kernel headers > 5.11 & < 6.0

Buildroot commit 97e2f63bdf in 2026.02-rc1
bumped bpftrace from 0.23.3 to 0.24.2.

This release includes upstream commit
d4f5838227

which was added to version 0.24.0 and makes use of btf_enum64 that was
added to the linux kernel in version 6.0:
6089fb325c

causing build errors when the toolchain contains kernel headers between
versions 5.12 and 5.19 because the libbpf package does not update their
headers so we need to raise the BR2_TOOLCHAIN_HEADERS_AT_LEAST_ version
number again.

The build error can be reproduced with this defconfig

BR2_aarch64=y
BR2_KERNEL_HEADERS_VERSION=y
BR2_DEFAULT_KERNEL_VERSION="5.11.22"
BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_5_11=y
BR2_TOOLCHAIN_BUILDROOT_CXX=y
BR2_PER_PACKAGE_DIRECTORIES=y
BR2_PACKAGE_BPFTRACE=y

on the 2026.02.x branch as of 0be927b89a.

Fixes:
https://autobuild.buildroot.net/results/8f7/8f7ce88a070e825ef178275a13d969349f05593b/

Signed-off-by: Bernd Kuhls <bernd@kuhls.net>
Signed-off-by: Arnout Vandecappelle <arnout@rnout.be>
This commit is contained in:
Bernd Kuhls
2026-04-25 23:16:38 +02:00
committed by Arnout Vandecappelle
parent 7e5241e14a
commit 7102aa5ffd

View File

@@ -18,14 +18,14 @@ define LIBBPF_BUILD_CMDS
-C $(@D)/src
endef
# 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.
# bpftrace uses btf_enum64 that was added since kernel 6.0 so we need to
# update some uapi headers in STAGING_DIR if the toolchain is build with
# linux-headers < 6.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=5329722057d41aebc31e391907a501feaa42f7d9
# https://github.com/bpftrace/bpftrace/commit/fea31939899db48fa6d28f5ce880bfc39250ec9f
ifeq ($(BR2_TOOLCHAIN_HEADERS_AT_LEAST_5_11),)
# https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=6089fb325cf737eeb2c4d236c94697112ca860da
# https://github.com/bpftrace/bpftrace/commit/d4f58382270c21b2c718aa0a6574c105f29e77a9
ifeq ($(BR2_TOOLCHAIN_HEADERS_AT_LEAST_6_0),)
LIBBPF_UPDATE_UAPI_HEADERS = install_uapi_headers UAPIDIR=/usr/include/bpf
define LIBBPF_FIX_STAGING_PC