diff mbox series

[meta-oe,6/6] bpftrace: Keep -fcanon-prefix-map away from the build host gcc

Message ID 20260912235456.2358617-6-khem.raj@oss.qualcomm.com
State New
Headers show
Series [meta-oe,1/6] openjpeg: fix run-ptest with busybox sed | expand

Commit Message

Khem Raj Sept. 12, 2026, 11:54 p.m. UTC
cmake/BuildBPF.cmake compiles the BPF data source with the plain gcc it
finds in PATH (find_program(GCC gcc)) rather than with the cross
compiler, because the BTF encoding step needs gcc plus pahole. The
recipe exports DEBUG_PREFIX_MAP and
0001-cmake-BuildBPF.cmake-introduce-DEBUG_PREFIX_MAP.patch hands it to
that command so the embedded objects do not carry build paths.

DEBUG_PREFIX_MAP also picks up DEBUG_PREFIX_MAP_EXTRA, which is
-fcanon-prefix-map for the gcc toolchain
(meta/classes/toolchain/gcc.bbclass). That option only exists in
GCC >= 13: the cross compiler always has it, the build host's gcc may
not, and the ptest enabled build then fails with

  gcc: error: unrecognized command-line option '-fcanon-prefix-map';
       did you mean '-fmacro-prefix-map='?

Drop it, the way frr and kernel-selftest already do for the same reason.
The four -ffile-prefix-map= rewrites are all this needs: with the extra
removed tests/data/data_source.o still contains no build paths, only
/usr/src/debug/bpftrace/0.26.1.

Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
 .../recipes-devtools/bpftrace/bpftrace_0.26.1.bb      | 11 +++++++++++
 1 file changed, 11 insertions(+)
diff mbox series

Patch

diff --git a/meta-oe/dynamic-layers/meta-python/recipes-devtools/bpftrace/bpftrace_0.26.1.bb b/meta-oe/dynamic-layers/meta-python/recipes-devtools/bpftrace/bpftrace_0.26.1.bb
index 836f4d2483..a2f6a93f66 100644
--- a/meta-oe/dynamic-layers/meta-python/recipes-devtools/bpftrace/bpftrace_0.26.1.bb
+++ b/meta-oe/dynamic-layers/meta-python/recipes-devtools/bpftrace/bpftrace_0.26.1.bb
@@ -28,6 +28,17 @@  inherit bash-completion cmake ptest pkgconfig

 export DEBUG_PREFIX_MAP

+# cmake/BuildBPF.cmake compiles the BPF data source with the plain gcc it finds
+# in PATH, i.e. the build host's compiler (see its own commentary for why it has
+# to be gcc), and 0001-cmake-BuildBPF.cmake-introduce-DEBUG_PREFIX_MAP.patch
+# hands it DEBUG_PREFIX_MAP so the embedded objects do not leak build paths.
+# -fcanon-prefix-map, which DEBUG_PREFIX_MAP_EXTRA adds for the gcc toolchain,
+# only exists in GCC >= 13: the target compiler always has it, the build host's
+# gcc may not, and then the build dies with
+#   gcc: error: unrecognized command-line option '-fcanon-prefix-map'
+# The -ffile-prefix-map= rewrites are all this needs, so drop the extra.
+DEBUG_PREFIX_MAP:remove = "-fcanon-prefix-map"
+
 PACKAGECONFIG ?= " \
         ${@bb.utils.contains('PTEST_ENABLED', '1', 'tests', '', d)} \
         ${@bb.utils.contains("DISTRO_FEATURES", "systemd", "systemd", "", d)} \