bpftrace: fix buildpaths QA issue in bpftrace-dbg and bpftrace-ptest
cover bpftrace: fix buildpaths QA issue in bpftrace-dbg and bpftrace-ptest
Hello,
I marked the patch as 'Inappropriate', but please let me know if that's worth upstreaming.
Best regards,
João Marcos Costa (1):
bpftrace: fix buildpaths QA issue in bpftrace-dbg and bpftrace-ptest
...BPF.cmake-introduce-DEBUG_PREFIX_MAP.patch | 36 +++++++++++++++++++ .../bpftrace/bpftrace_0.25.1.bb | 3 ++ 2 files changed, 39 insertions(+) create mode 100644 meta-oe/dynamic-layers/meta-python/recipes-devtools/bpftrace/bpftrace/0001-cmake-BuildBPF.cmake-introduce-DEBUG_PREFIX_MAP.patch
Signature · 1 line
2.47.0
PATCH 1/1 bpftrace: fix buildpaths QA issue in bpftrace-dbg and bpftrace-ptest
With the current version, I had the QA issues below:
WARNING: bpftrace-0.25.1-r0 do_package_qa: QA Issue:
File /usr/lib/bpftrace/ptest/tests/.debug/bpftrace_test in package bpftrace-dbg contains reference to TMPDIR [buildpaths]
WARNING: bpftrace-0.25.1-r0 do_package_qa: QA Issue:
File /usr/lib/bpftrace/ptest/tests/bpftrace_test in package bpftrace-ptest contains reference to TMPDIR [buildpaths]
A bit of find + grep + strings show that this originally comes from:
field_analyser.cpp.o: [my tmpdir...]/bpftrace/0.25.1/build/tests/data field_analyser.cpp.o: [my tmpdir...]/bpftrace/0.25.1/sources/bpftrace-0.25.1/tests/data/data_source.c field_analyser.cpp.o: [my tmpdir...]/bpftrace/0.25.1/sources/bpftrace-0.25.1/tests/data
The .rodata section is infected with these, and after some more digging, the paths come from debug symbols (i.e., .debug_line_str) in data_source.o:
build/tests/data/data_source.o: /src/update-2026.01/build/tmp/work/riscv64.../bpftrace/0.25.1/build/tests/data build/tests/data/data_source.o: /src/update-2026.01/build/tmp/work/riscv64.../bpftrace/0.25.1/sources/bpftrace-0.25.1/tests/data/data_source.c build/tests/data/data_source.o: /src/update-2026.01/build/tmp/work/riscv64.../bpftrace/0.25.1/build/tests/data build/tests/data/data_source.o: /src/update-2026.01/build/tmp/work/riscv64.../bpftrace/0.25.1/sources/bpftrace-0.25.1/tests/data
I'm not familiar with the magic performed by BuildBPF.cmake, but as far as I can tell, gcc is being invoked with "-g" and no prefix mapping, so there is no way of stopping the source path(s) from ending in data_source.o.
This patch adds a "bridge" between this .cmake file and bpftrace's recipe, where I export DEBUG_PREFIX_MAP, so gcc is invoked with the -ffile-prefix-map flags from OE Core.
The end result is:
$ strings ./build/tests/data/data_source.o | grep "debug\/bpftrace" /usr/src/debug/bpftrace/0.25.1/tests/data/data_source.c /usr/src/debug/bpftrace/0.25.1/tests/data /usr/src/debug/bpftrace/0.25.1/tests/data /usr/src/debug/bpftrace/0.25.1/tests/data
--- ...BPF.cmake-introduce-DEBUG_PREFIX_MAP.patch | 36 +++++++++++++++++++ .../bpftrace/bpftrace_0.25.1.bb | 3 ++ 2 files changed, 39 insertions(+) create mode 100644 meta-oe/dynamic-layers/meta-python/recipes-devtools/bpftrace/bpftrace/0001-cmake-BuildBPF.cmake-introduce-DEBUG_PREFIX_MAP.patch
meta-oe/dynamic-layers/meta-python/recipes-devtools/bpftrace/bpftrace/0001-cmake-BuildBPF.cmake-introduce-DEBUG_PREFIX_MAP.patch new file +36 -0
@@ -0,0 +1,36 @@ +From af36170841d9836926953e17d93e9562e594c9aa Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Jo=C3=A3o=20Marcos=20Costa?= <[email protected]> +Date: Wed, 24 Jun 2026 18:46:14 +0200 +Subject: [PATCH] cmake/BuildBPF.cmake: introduce DEBUG_PREFIX_MAP +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Upstream-Status: Inappropriate + +Signed-off-by: João Marcos Costa <[email protected]> +--- + cmake/BuildBPF.cmake | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/cmake/BuildBPF.cmake b/cmake/BuildBPF.cmake +index cb8cd687..95ae1dc1 100644 +--- a/cmake/BuildBPF.cmake ++++ b/cmake/BuildBPF.cmake +@@ -86,11 +86,12 @@ function(bpf NAME) + add_custom_target(${NAME}_gen_bitcode DEPENDS ${ARG_BITCODE}) + add_dependencies(${NAME} ${NAME}_gen_bitcode) + endif() ++ separate_arguments(DEBUG_PREFIX_MAP_LIST NATIVE_COMMAND "$ENV{DEBUG_PREFIX_MAP}") + add_custom_command( + OUTPUT ${ARG_OBJECT} + DEPENDS ${ARG_SOURCE} ${ARG_DEPENDS} + # See above: fresh compilation and the use of `gcc`. +- COMMAND ${GCC} -Wno-attributes -g -I ${CMAKE_CURRENT_BINARY_DIR} -c ${CMAKE_CURRENT_SOURCE_DIR}/${ARG_SOURCE} -o ${CMAKE_CURRENT_BINARY_DIR}/${ARG_OBJECT} ++ COMMAND ${GCC} -Wno-attributes -g ${DEBUG_PREFIX_MAP_LIST} -I ${CMAKE_CURRENT_BINARY_DIR} -c ${CMAKE_CURRENT_SOURCE_DIR}/${ARG_SOURCE} -o ${CMAKE_CURRENT_BINARY_DIR}/${ARG_OBJECT} + COMMAND cmake -E env LLVM_OBJCOPY=${LLVM_OBJCOPY} ${PAHOLE} -J ${CMAKE_CURRENT_BINARY_DIR}/${ARG_OBJECT} + VERBATIM + ) +-- +2.47.0 +
meta-oe/dynamic-layers/meta-python/recipes-devtools/bpftrace/bpftrace_0.25.1.bb +3 -0
@@ -18,11 +18,14 @@ DEPENDS += "${@bb.utils.contains('PTEST_ENABLED', '1', 'pahole-native llvm-nativ SRC_URI = "git://github.com/iovisor/bpftrace;branch=release/0.25.x;protocol=https;tag=v${PV} \ file://run-ptest \ file://0002-CMakeLists.txt-allow-to-set-BISON_FLAGS-like-l.patch \ + file://0001-cmake-BuildBPF.cmake-introduce-DEBUG_PREFIX_MAP.patch \ " SRCREV = "e491811e5d648288c01f42ce087967b271f504a0" inherit bash-completion cmake ptest pkgconfig +export DEBUG_PREFIX_MAP + PACKAGECONFIG ?= " \ ${@bb.utils.contains('PTEST_ENABLED', '1', 'tests', '', d)} \ ${@bb.utils.contains("DISTRO_FEATURES", "systemd", "systemd", "", d)} \
Signature · 1 line
2.47.0