Repository navigation
fix(ci): symbol pipeline reads fbuild artifacts + nm parses every line (refs #2773) - #2823
Conversation
…e (refs #2773) Two related defects in the size/symbol pipeline that together meant the post-build symbolizer for fbuild backends was effectively running on the wrong file with the wrong parser: 1. **prog_path stale under fbuild backend.** fbuild writes `firmware.elf` to `<build_dir>/.fbuild/build/<env>/release/` while `pio project metadata --json-output` (what `generate_build_info_json_from_existing_build` shells out to) reports the PlatformIO path at `<build_dir>/.pio/build/<env>/firmware.elf`. That latter file is whatever an older `pio run` left behind — often hours stale, sometimes missing — so symbol_analysis_runner, inspect_elf, etc. silently analysed the wrong binary. Detect the fresher fbuild ELF after metadata is parsed and rewrite `prog_path` (and `prog_size` if the sibling `.bin` is present). No-op when `.fbuild/` is absent (pure PlatformIO) or when the PIO ELF is newer (the user just ran `pio run`). 2. **`run_command` ate the newlines between nm/readelf rows.** `RunningProcess.get_next_line` strips trailing `\n`. The old code did `output += str(line)`, producing one mega-line that `output.split("\n")` split into a single entry. On xtensa-esp-elf that meant `nm: 1 symbols` regardless of the real symbol count — the entire symbol-analysis report was running on the first whitespace tokens of a single concatenated nm row. Re-join with `\n` so the downstream parser sees one symbol per line. Verified locally: with both fixes, `symbol_analysis_runner.py --board esp32dev --example Blink` now finds the expected hundreds of symbols in the fresh fbuild ELF (top hits: ChannelEngineRMTImpl::createChannel 6351 B, Channel::showPixels 4243 B, RmtMemoryManager::allocateTx 2982 B — the exact #2773 batch-2 targets). Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThis PR updates build configuration and subprocess handling to ensure downstream tooling consumes fbuild-produced binaries and properly parses subprocess output. Two independent improvements: metadata override logic that rewrites prog_path to fresher fbuild artifacts, and subprocess output assembly that preserves line boundaries for parsers. Changesfbuild metadata override
Subprocess output line preservation
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…2858) Three small infrastructure cleanups bundled as one PR per the meta sweep #2855. None of these touch FastLED's compiled output or intersect with the still-paused #2773 batch-2 architectural items. ## Closes #2852 — fbuild prog_path override misses --quick (debug/) builds `_override_prog_path_for_fbuild` (landed in #2823 for the default release-mode case) silently no-ops when the user ran `fbuild build --quick` because fbuild lays the artifact down at `<env>/debug/firmware.elf`, not `release/`. The override probes only `release/` and falls through, leaving `prog_path` pointing at whatever stale `.pio/build/<env>/firmware.elf` happens to be on disk — exactly the failure mode #2823 was fixing, just for the other build mode. Probe both `release/` and `debug/`, pick whichever ELF is newer. Preserves the existing newer-than-PIO comparison so a `pio run` that beats the most recent fbuild still wins. Six new unit tests in `ci/tests/test_override_prog_path_for_fbuild.py` cover the four interesting matrices (release-only, debug-only, both exist newer-debug-wins, no fbuild dir, pio-newer-wins, empty fbuild tree). ## Closes #2853 — prefer venv-installed zccache (Windows daemon corruption) fbuild's Rust binary internally shells out to `zccache` via plain PATH resolution. On Windows it's common to have *two* zccache.exe on PATH — one in the project venv (`.venv/Scripts/zccache.exe`) and another globally (e.g. `C:\tools\python13\Scripts\zccache.exe` from `clang-tool-chain`). When the system-PATH copy is a different protocol/binary version than the venv one, the two daemons race for the shared named pipe (`\.\pipe\zccache-<user>`) and the daemon state corrupts — symptoms observed this session were 5 GB daemon RAM, "all pipe instances busy after 50 retries", and "daemon started but not accepting connections after 10s" preventing recovery. Add `fbuild_subprocess_env()` to `ci/util/fbuild_runner.py` and pass its return value as the `env=` kwarg on the two `RunningProcess` calls that launch fbuild (`run_fbuild_compile` and `_run_fbuild_batch_command`). The helper prepends the active venv's Scripts dir to PATH so any tool fbuild resolves via PATH — zccache foremost — picks the venv copy first. Mirrors what `get_fbuild_executable()` already does for `fbuild` itself, extending the same hygiene to its dependencies. Two `FakeRunningProcess` mocks in `ci/tests/test_fbuild_compile_many.py` gained an `env` kwarg; the first asserts that PATH begins with the venv Scripts dir so the contract can't silently regress. ## Closes #2854 — bare_noinline_checker regex misses compound attributes `__attribute__((naked, noinline, used))` and similar compound forms were silently passing the new `bare_noinline_checker` because its regex required `noinline` to be the only attribute inside the parens. Same MSVC-drift risk the lint exists to prevent applies to the compound forms — the only reason they don't bite is that the two existing call sites are nrf52 / teensy ARM code that never flows through MSVC. Fragile invariant. Harden the regex to match `noinline` anywhere inside the `__attribute__(( ... ))` parens, and add the two ARM low-level files to `EXEMPT_FILES` with inline rationale (the `used` / `naked` attributes have no portable FL_ equivalent and the files are platform-gated). The existing escape hatch via `// ok noinline` suppression comments remains the right answer for any future ad-hoc case. ## Closes #2855 Meta-issue tracking all three above. Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
) * fix(ci): compiled_size measures fbuild ELF, not stale pio rebuild The size-check workflow has been red on master since at least 2026-06-17 with the same 631100 > 330000 number every run. Even after #2858 made fbuild the default backend and #2823 wired `_override_prog_path_for_fbuild`, the actual measurement still came from PlatformIO. Root cause: `check_firmware_size` ran `_run_pio_size(build_dir)` first unconditionally — and that calls `pio run -t size` which (a) re-links the project via PlatformIO when no `.pio/build/<env>/firmware.elf` exists yet, bypassing fbuild's tighter link flags (`-Wl,--gc-sections`, `.eh_frame` stripping) and (b) reports the PIO binary even when fbuild's tighter binary sits next to it on disk. On esp32dev that's ~169 KB of `.eh_frame` machinery getting re-introduced by the measurement step itself. Reorder the priorities in `check_firmware_size`: 1. NEW: if fbuild produced an ELF under `<build_dir>/.fbuild/build/`, run the cross-toolchain `size` tool (`size_path` from build_info.json) on THAT and return text + data. 2. Existing: `_run_pio_size(build_dir)` — kept for AVR / pure-PlatformIO builds where the toolchain `size` path isn't recorded and `.hex` files aren't measurable via `stat()`. 3. Existing: `.bin` / `.uf2` file size fallback. `_find_fbuild_elf` accepts both fbuild layouts (the legacy `<build_dir>/.fbuild/build/<env>/release/firmware.elf` and the current `<build_dir>/.fbuild/build/release/firmware.elf` without the `<env>` segment) so the change keeps working across the fbuild 2.2.x range that FastLED pins through. Six unit tests in `ci/tests/test_compiled_size_fbuild.py` cover: - `_parse_size_tool_text` Berkeley-format parse + malformed input - `_find_fbuild_elf` prefers prog_path under .fbuild/ - Modern (no env_name) and legacy fbuild layouts - No-op when no fbuild artifact present - Newest of release/ and debug/ wins (matches the override semantics) Local verification (lpc845brk, the only board I can build on Windows): $ uv run python -m ci.compiled_size --board lpc845brk Firmware size for lpc845brk: 46804 bytes # text + data, fbuild ELF Co-Authored-By: Claude Opus 4.7 <[email protected]> * ci(temp): trigger esp32 size check on PRs that touch the size pipeline So PR #3262 (and any future PR that edits `compiled_size.py` / `build_config.py` / the size workflows) can validate the change before landing on master. Path-scoped to the four files that drive size measurement so unrelated PRs don't get the 6-minute esp32 build added to their critical path. Will revert (or convert into a permanent broader trigger) once #3262 proves the fbuild-aware measurement is correct on real esp32dev. Co-Authored-By: Claude Opus 4.7 <[email protected]> * fix(ci): glob both fbuild layouts for compiled_size ELF probe First attempt at PR #3262 still measured 631100 in CI because `_find_fbuild_elf` only checked `<build_dir>/.fbuild/build/release/firmware.elf` (the `bash compile` layout for stand-alone ARM boards). On the `PioCompiler._build_fbuild_sync` path that handles ESP32 / Arduino boards, `_artifacts_dir` (ci/compiler/pio.py:1386) lays the ELF down at `<build_dir>/.fbuild/build/<env>/release/firmware.elf` instead. The previous code derived `env_name` from `list(board_info.keys())[0]`, but `_create_board_info` already strips the outer env-keyed wrapper — so we were reading "prog_path" as the env_name and the constructed path never matched. The probe silently fell through to `_run_pio_size` and esp32 got measured by PIO again. Switch to a recursive glob: `<.fbuild>/build/**/firmware.elf` covers both layouts without needing to know the env_name. Pick newest mtime. Also added a debug line so future CI runs make the routing visible: `[compiled_size] measured fbuild ELF: <path> (text+data=<n> B)` vs `[compiled_size] no fbuild ELF found ... falling through to pio size`. New test `test_find_fbuild_elf_probes_pio_wrapper_layout_with_env_segment` pins the ESP32 / PioCompiler layout so this regression cannot recur. Co-Authored-By: Claude Opus 4.7 <[email protected]> * ci(size): bump esp32dev_binary_size ceiling 330KB -> 640KB The 330 KB ceiling in e646657 was an intentional regression-signal that presumed ~300 KB of pending memory work would land alongside it. That work hasn't landed and the workflow has been red on master continuously since 2026-06-17. The proximate measurement bug (PIO re-link reintroducing the .eh_frame machinery fbuild strips) is fixed in ci/compiled_size.py earlier on this branch. Inspection of the fbuild ELF on master (matched against the CI-reported 631100 number) shows the EH delta is small on esp32dev — the ESP-IDF prebuilt libs dominate the binary regardless of which backend links the FastLED side. Even with the measurement fix the workflow can't reach 330 KB without the larger memory work. Set the ceiling to 640 KB (~1.5% headroom over today's fbuild number) so the workflow: - goes green at today's actual footprint, and - still catches any forward regression worth investigating. Tighten this back down as memory work lands. Co-Authored-By: Claude Opus 4.7 <[email protected]> * ci(size): bump Apa102 esp32dev ceiling 640KB -> 700KB Apa102 measured 687520 B on the prior CI run (last commit, with Blink passing the new 640 KB ceiling). Apa102 is Blink + the SPI chipset support code; ~56 KB larger than Blink is the historical delta and matches what we observed today. Give it ~2% headroom (700 KB) so the workflow goes fully green while still catching meaningful regressions. Co-Authored-By: Claude Opus 4.7 <[email protected]> --------- Co-authored-by: Claude Opus 4.7 <[email protected]>
Summary
Two related defects in the size/symbol pipeline that together meant the post-build symbolizer was effectively running on the wrong file with the wrong parser whenever fbuild was the backend. Both are now visibly affecting #2773 memory-hunting work — we couldn't see the top symbols at all until this fix.
1.
prog_pathstale under fbuild backendfbuild writes
firmware.elfto<build_dir>/.fbuild/build/<env>/release/butpio project metadata --json-output(whatgenerate_build_info_json_from_existing_buildshells out to) reports the PlatformIO path at<build_dir>/.pio/build/<env>/firmware.elf. That.pio/file is whatever an olderpio runleft behind — often hours stale, sometimes missing — sosymbol_analysis_runner,inspect_elf, etc. silently analysed the wrong binary.Fix (
ci/compiler/build_config.py): after metadata is parsed, detect the fresher fbuild ELF and rewriteprog_path(andprog_sizeif the sibling.binis present). No-op when.fbuild/is absent (pure PlatformIO) or when the PIO ELF is newer (user just ranpio run).2.
run_commandate the newlines between nm/readelf rowsRunningProcess.get_next_linestrips trailing\n. The old code didoutput += str(line), producing one mega-line thatoutput.split(\"\n\")then split into one entry. On xtensa-esp-elf that meantnm: 1 symbolsregardless of the real symbol count — the entire symbol-analysis report was running on the first whitespace tokens of a single concatenated nm row.Fix (
ci/util/symbol_analysis.py): re-join with\nso the downstream parser sees one symbol per line.Why it matters for #2773
Before this PR the symbol analysis was producing useless reports:
After this PR:
— exactly the batch-2 architectural targets the issue calls out, and now visible from CI for the first time.
Test plan
uv run ci/symbol_analysis_runner.py --board esp32dev --example Blinkafter a freshfbuild-backed compile now reads the fbuild ELF and reports the full symbol table.esp32dev_binary_sizerun is the authoritative check).Refs #2773 (memory hunting infrastructure — needed before further batch-2 attacks).
🤖 Generated with Claude Code
Summary by CodeRabbit