Repository navigation
feat(esp32): record debug info relative to the project root (#1414) - #1777
Merged
Merged
Conversation
DW_AT_comp_dir was absolute, so two identical sketches in two directories compiled to different objects and zccache could never serve the second one (#1347's persist_failed mechanism, measured at ~1.3 s per fresh dir in #1414 finding 1). BuildLayout::debug_prefix_map_args emits -fdebug-prefix-map=<project>=. (the compile workspace is already anchored at the project root and sources are project-relative), plus a fbuild-build label when the build root sits outside the project. The ESP32 orchestrator adds them next to the existing -fmacro-prefix-map flags, before user build_flags. rebuild_signature normalizes the OLD path of -f{debug,file,macro}-prefix-map so the new flag does not give every project a unique core-cache key.
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
`crates/fbuild-paths/src/lib.rs` crossed the 1000-LOC gate (1107) when the debug-prefix-map code landed, and the LOC Gate job rejects any .rs file over 1000 lines that was not already over it on the base commit. Move `DEBUG_PREFIX_MAP_ROOT`, the free `debug_prefix_map_args` function and the `BuildLayout::debug_prefix_map_args` impl block into `debug_prefix_map.rs`, with the tests in the sibling `debug_prefix_map_tests.rs` (the crate's existing convention). lib.rs is back to 998 LOC. Also route the "is the build root inside the project" decision through `fbuild_core::path::normalize_for_key` instead of a raw `Path::starts_with` (`ban_raw_path_prefix_compare`, #952): a raw-vs-canonicalized pair would otherwise emit a second, conflicting map for a build root that is already covered by the project map. No behavior change for normalized inputs: same flags, same order.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Makes the ESP32 build record debug-info paths relative to the project root, so
two byte-identical sketches in two directories compile to identical objects
and a compiler cache can serve the second one. First half of #1414
finding 1.
Why
The compiler records its working directory as
DW_AT_comp_dir(absolute), so afresh project directory always produced a fresh object even though the flags and
source bytes were identical. That is the
persist_failed: "same cache key produced different staged output bytes"mechanism #1347 documented for theframework stage, reaching the sketch stage: #1414 measured one real compiler
execution per fresh directory, ~1.3 s for a blink.
Verified on this host with host gcc — two directories, same source, same flags:
What
fbuild_paths::BuildLayout::debug_prefix_map_args()(+ freedebug_prefix_map_args(project_dir, build_dir)) returns-fdebug-prefix-map=<project>=..compile_cwd_from_outputalready anchorsthe compile workspace at the project root and passes sources
project-relative, so this makes
DW_AT_comp_dirand every recorded sourcepath location-independent. A build root outside the project
(
FBUILD_BUILD_DIR, explicit override) is mapped too, to the stable labelfbuild-build, because stages that compile into it have no.fbuildcomponent and pass absolute paths.
user_flagsnext to the existing-fmacro-prefix-mapflags, before the user's ownbuild_flagsso a user mapstill wins.
rebuild_signature:-f{debug,file,macro}-prefix-map=OLD=NEWnow normalizesOLDlike any other path-bearing flag value. Without this the new flag wouldput the project path into the signature and give every project a unique core
cache key — exactly the cache it exists to fill.
-fdebug-prefix-mapand not-ffile-prefix-map: the umbrella spelling isGCC 8+, while avr-gcc 7.3 and the legacy ESP32 GCC 5 only have the debug
variant, and
__FILE__is already covered by the existing-fmacro-prefix-mapflags. Debug info is the part that was not covered.
Cost / behaviour change
objects and the core-cache key are invalidated once).
DW_AT_comp_diris., andsource names are the same project-relative ones already on the command line.
Start gdb/lldb from the project root and it finds the files. A debugger
started elsewhere needs
set substitute-path <project> ..addr2linewants-p/a relative path, orset substitute-path.Tests
crates/fbuild-paths: 4 new tests (build dir inside project → one flag;external build root →
fbuild-buildlabel; build dir == project → one flag;remap targets identical for two different project paths).
crates/fbuild-build-engine: 1 new test — two projects with the same-fdebug-prefix-mapproduce the same project-anchored rebuild signature,while a different remap target still differs.
Scope: #1414 finding 1 only. Findings 2 (
compile-core-varianthaving compilednothing) and 4 (esptool re-proved per build) were already shipped in
#1537/#1559 and #1547; finding 5 (~930 ms unattributed) is still open and is
about adding phases before optimizing blind.