diff mbox series

cargo_common: map the cargo vendoring directory for the C compiler

Message ID 20260911112708.719078-1-f_l_k@t-online.de
State New
Headers show
Series cargo_common: map the cargo vendoring directory for the C compiler | expand

Commit Message

Markus Volk Sept. 11, 2026, 11:27 a.m. UTC
Crates that ship C or assembly sources, ring being a prominent one,
compile them through the cc crate rather than rustc. RUST_DEBUG_REMAP
only passes --remap-path-prefix to rustc, and DEBUG_PREFIX_MAP covers
S, B and the sysroots, so nothing rewrites the paths below CARGO_HOME.
The build directory of every vendored crate therefore ends up in the
debug symbols, which trips the buildpaths QA check and leaves recipes
working around it by dropping their -dbg package.

Add the vendoring directory to DEBUG_PREFIX_MAP so those objects are
remapped like the rest.

Tested on corei7-64 with yazi and eilmeldung, both of which had dropped
their -dbg package for this reason: after the change they package the
debug symbols with no reference to the build tree left.

AI-Generated: Uses Claude Code (Claude Opus 5)
Signed-off-by: Markus Volk <f_l_k@t-online.de>
---
 meta/classes-recipe/cargo_common.bbclass | 5 +++++
 1 file changed, 5 insertions(+)
diff mbox series

Patch

diff --git a/meta/classes-recipe/cargo_common.bbclass b/meta/classes-recipe/cargo_common.bbclass
index 2e1df9d9d3..37ae729ea6 100644
--- a/meta/classes-recipe/cargo_common.bbclass
+++ b/meta/classes-recipe/cargo_common.bbclass
@@ -51,6 +51,11 @@  CARGO_TARGET_SUBDIR = "${RUST_HOST_SYS}/${BUILD_DIR}"
 # Where we download our registry and dependencies to
 export CARGO_HOME = "${UNPACKDIR}/cargo_home"
 
+# Crates that compile C or assembly sources do so through the cc crate, which
+# is not covered by the rustc specific RUST_DEBUG_REMAP, so map the vendoring
+# directory for the C compiler as well.
+DEBUG_PREFIX_MAP += "-ffile-prefix-map=${CARGO_HOME}=${TARGET_DBGSRC_DIR}"
+
 # Don't instruct cargo to use crates downloaded by bitbake. Some rust packages,
 # for example the rust compiler itself, come with their own vendored sources.
 # Specifying two [source.crates-io] will not work.