mirror of
https://gitlab.com/buildroot.org/buildroot.git
synced 2026-08-01 21:23:51 -09:00
package/bpftrace: fix build with per-package directories
Buildroot commitf7b8508e4fin 2021.08-rc1 added the libbpf package which contains the usage of the 'install_uapi_headers' make target to update toolchain headers older than kernel version 5.9. This does not work with per-package directories. Building this defconfig that includes all packages depending on libbpf: BR2_x86_64=y BR2_x86_rocketlake=y BR2_KERNEL_HEADERS_VERSION=y BR2_DEFAULT_KERNEL_VERSION="5.8.18" BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_5_8=y BR2_TOOLCHAIN_BUILDROOT_CXX=y BR2_PER_PACKAGE_DIRECTORIES=y BR2_PACKAGE_BPFTRACE=y BR2_PACKAGE_DPDK=y BR2_PACKAGE_IPROUTE2=y BR2_PACKAGE_HOST_PAHOLE=y on the 2026.02.x branch as of0be927b89ais broken: output/build/bpftrace-0.24.2/src/attached_probe.cpp: In static member function 'static bpftrace::Result<std::unique_ptr<bpftrace::AttachedIterProbe> > bpftrace::AttachedIterProbe::make(bpftrace::Probe&, const bpftrace::BpfProgram&, std::optional<int>)': output/build/bpftrace-0.24.2/src/attached_probe.cpp:1435:30: error: aggregate 'bpf_iter_link_info linfo' has incomplete type and cannot be defined 1435 | union bpf_iter_link_info linfo; libbpf overwrites kernel header files installed in $STAGING_DIR when they are too old by adding 'install_uapi_headers' as make target. In the case of per-package directories these header files are stored only in output/per-package/libbpf/. When output/per-package/bpftrace/ is populated, the content of output/per-package/ from other packages overwrites the header files installed by libbpf because the list of rsync'ed packages is sorted alphabetically: https://gitlab.com/buildroot.org/buildroot/-/blob/2026.02.1/package/pkg-generic.mk#L796 To prevent this problem let libbpf install the updated kernel headers in a new directory. Other packages need to find this directory. This mostly happens through pkg-config, but bpftrace doesn't use that: https://github.com/bpftrace/bpftrace/blob/v0.25.1/cmake/FindLibBpf.cmake#L9 Therefore, use a configure option in bpftrace to set the correct path. Please note that libbpf will add '/linux' to the path provided in $UAPIDIR: https://github.com/libbpf/libbpf/blob/v1.7.0/src/Makefile#L169 so the headers end up in the previously non-existing directory $(STAGING_DIR)/usr/include/bpf/linux/: $ find output/per-package/libbpf/host/x86_64-buildroot-linux-gnu/sysroot/ -iname bpf.h -exec ls -lao {} \; -rw-r--r-- 1 bernd 26434 25. Apr 13:15 output/per-package/libbpf/host/x86_64-buildroot-linux-gnu/sysroot/usr/include/bpf/bpf.h -rw-r--r-- 1 bernd 283012 25. Apr 13:15 output/per-package/libbpf/host/x86_64-buildroot-linux-gnu/sysroot/usr/include/bpf/linux/bpf.h -rw-r--r-- 12 bernd 160166 25. Apr 13:08 output/per-package/libbpf/host/x86_64-buildroot-linux-gnu/sysroot/usr/include/linux/bpf.h bpf.h with 283012 bytes is the update-to-date version needed for bpftrace: $ grep -m1 bpf_iter_link_info output/per-package/libbpf/host/x86_64-buildroot-linux-gnu/sysroot/usr/include/bpf/linux/bpf.h union bpf_iter_link_info { $ $ grep -m1 bpf_iter_link_info output/per-package/libbpf/host/x86_64-buildroot-linux-gnu/sysroot/usr/include/linux/bpf.h $ By adding '-I$(STAGING_DIR)/usr/include/bpf' to the CXXFLAGS of bpftrace its include finds the correct header: https://github.com/bpftrace/bpftrace/blob/v0.25.1/src/bpfprogram.cpp#L3 #include <linux/bpf.h> The dpdk package uses pkg-config` to detect libbpf and will use the updated .pc file: https://github.com/DPDK/dpdk/blob/v25.11/drivers/net/tap/bpf/meson.build#L7 The iproute2 package is not affected by the problem because it contains "matching sanitized kernel headers": https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/tree/README?h=v6.17.0#n44 As a host package pahole is also not affected. Fixes: https://autobuild.buildroot.net/results/d8b/d8b416e40bf7bd019cd93e6f2d42c98fc12d4160/ Signed-off-by: Bernd Kuhls <bernd@kuhls.net> Signed-off-by: Arnout Vandecappelle <arnout@rnout.be>
This commit is contained in:
committed by
Arnout Vandecappelle
parent
7716db8a12
commit
f07fb2bcd2
@@ -28,6 +28,7 @@ endif
|
|||||||
BPFTRACE_CONF_OPTS += \
|
BPFTRACE_CONF_OPTS += \
|
||||||
-DBUILD_SHARED_LIBS:BOOL=OFF \
|
-DBUILD_SHARED_LIBS:BOOL=OFF \
|
||||||
-DBUILD_TESTING: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
|
||||||
|
|
||||||
$(eval $(cmake-package))
|
$(eval $(cmake-package))
|
||||||
|
|||||||
@@ -25,7 +25,12 @@ endef
|
|||||||
# toolchain.
|
# toolchain.
|
||||||
# https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=a5cbe05a6673b85bed2a63ffcfea6a96c6410cff
|
# https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=a5cbe05a6673b85bed2a63ffcfea6a96c6410cff
|
||||||
ifeq ($(BR2_TOOLCHAIN_HEADERS_AT_LEAST_5_9),)
|
ifeq ($(BR2_TOOLCHAIN_HEADERS_AT_LEAST_5_9),)
|
||||||
LIBBPF_UPDATE_UAPI_HEADERS = install_uapi_headers
|
LIBBPF_UPDATE_UAPI_HEADERS = install_uapi_headers UAPIDIR=/usr/include/bpf
|
||||||
|
|
||||||
|
define LIBBPF_FIX_STAGING_PC
|
||||||
|
$(SED) 's/-I$${includedir}/-I$${includedir}\/bpf -I$${includedir}/' $(STAGING_DIR)/usr/lib/pkgconfig/libbpf.pc
|
||||||
|
endef
|
||||||
|
LIBBPF_POST_INSTALL_STAGING_HOOKS += LIBBPF_FIX_STAGING_PC
|
||||||
endif
|
endif
|
||||||
|
|
||||||
define LIBBPF_INSTALL_STAGING_CMDS
|
define LIBBPF_INSTALL_STAGING_CMDS
|
||||||
|
|||||||
Reference in New Issue
Block a user