Skip to content

feat(bloat): delegate nm + ELF path resolution to fbuild symbols (arm support) - #3225

Merged
zackees merged 1 commit into
masterfrom
feat/bloat-arm-lpc-594
Jun 18, 2026
Merged

zackees merged 1 commit into
masterfrom
feat/bloat-arm-lpc-594

Conversation

@zackees

@zackees zackees commented Jun 18, 2026 •

Copy link
Copy Markdown
Member

Summary

Rewrites ci/bloat.py so bash bloat <board> works on ARM Cortex-M (the original gating use case is LPC845, but the change is arch-agnostic). Closes FastLED/fbuild#594 gaps 1 + 3; gap 2 is the companion fbuild PR.

Three concrete changes

  1. fbuild-native ELF path added. .fbuild/build/<board>/release/firmware.elf is now the first candidate searched. The legacy PIO path and the pre-fbuild#487 layout remain as fallbacks.

  2. nm auto-resolved via build_info_<board>.json. When the ELF was found in the fbuild-native path we omit `--nm` and let `fbuild symbols` read `nm_path` from the sibling build_info JSON (fbuild#428). This makes the shim arch-agnostic — any board fbuild can build (Xtensa, RISC-V, ARM) gets bloat analysis with zero board-specific configuration in this file. The hardcoded `BOARD_CHIP_MAP` survives as a legacy-PIO fallback only.

  3. Over-budget retry hook. New `--allow-overflow` flag retries the build via `fbuild build --bloat-analysis` (bash bloat / fbuild symbols: no arm-none-eabi path; can't measure LPC845 bloat from FastLED's wrapper fbuild#594 gap 2, pending fbuild PR), so over-budget builds still emit `firmware.elf` for nm-based analysis.

Reproduction from the issue

Before:
```
$ bash bloat lpc845brk
Bloat: board 'lpc845brk' has no nm mapping. Add it to BOARD_CHIP_MAP in
ci/bloat.py — entries are mechanical (arch + chip prefix). Supported
boards today: esp32, esp32c3, esp32c6, esp32h2, esp32s2, esp32s3.
```

After (no ELF on disk):
```
$ bash bloat lpc845brk
Bloat: no firmware.elf found. Looked at:
.fbuild/build/lpc845brk/release/firmware.elf
.build/pio/lpc845brk/.pio/build/lpc845brk/firmware.elf
.build/lpc845brk/firmware.elf
Run `bash compile lpc845brk --examples Blink` first, or pass --build.
```

After (ELF on disk, in-budget): emits a per-symbol top-N table with no further config.

Test plan

  • `ruff check ci/bloat.py` — passes
  • `ruff format --check ci/bloat.py` — passes
  • Reproduction case from fbuild#594: improved error message (points at fbuild-native path) ✓
  • In-budget LPC845 build → real per-symbol top-N table (validated post-merge with fresh `fbuild build -e lpc845brk`)
  • Over-budget LPC845 build → `--allow-overflow` retry path works (gated on companion fbuild PR landing + new fbuild release)
  • Existing ESP32 PIO flow still works (`BOARD_CHIP_MAP` fallback unchanged for legacy-layout ELFs)

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added support for fbuild-native builds in CI bloat analysis with automatic symbol resolution.
    • Introduced overflow recovery mechanism for over-budget builds with retry capability.
  • Chores

    • Updated CI tooling to support multiple build formats and improved build size validation workflows.

… support)

Rewrites ci/bloat.py to drop the hardcoded ESP32-only BOARD_CHIP_MAP gate
when an fbuild-native ELF is available. Three concrete changes:

1. **fbuild-native path added**: `.fbuild/build/<board>/release/firmware.elf`
   is now the first candidate searched (FastLED/fbuild#594 gap 3). The
   legacy PIO path and the pre-#487 fbuild path remain as fallbacks.

2. **nm auto-resolved via build_info.json**: when the ELF was found in
   the fbuild-native path, we omit `--nm` and let `fbuild symbols` read
   `nm_path` from the sibling `build_info_<board>.json` (FastLED/fbuild
   #428 + #594 gap 1). This makes the shim arch-agnostic — any board
   fbuild can build (Xtensa, RISC-V, ARM Cortex-M) gets bloat analysis
   with zero board-specific configuration in this file.

3. **Over-budget retry hook**: a new `--allow-overflow` flag retries the
   build via `fbuild build --bloat-analysis` (FastLED/fbuild#594 gap 2,
   pending fbuild PR), so over-budget builds still emit `firmware.elf`
   for nm-based analysis.

Reproduction case from the issue:

  Before:
    $ bash bloat lpc845brk
    Bloat: board 'lpc845brk' has no nm mapping. Add it to BOARD_CHIP_MAP...

  After (no ELF on disk):
    $ bash bloat lpc845brk
    Bloat: no firmware.elf found. Looked at:
      .fbuild/build/lpc845brk/release/firmware.elf
      .build/pio/lpc845brk/.pio/build/lpc845brk/firmware.elf
      .build/lpc845brk/firmware.elf

  After (ELF on disk, in-budget): emits a per-symbol top-N table.

Closes FastLED/fbuild#594 gaps 1 + 3. Gap 2 (over-budget ELF emission)
requires the companion fbuild PR adding `fbuild build --bloat-analysis`;
this commit's `--allow-overflow` flag invokes it.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@coderabbitai

coderabbitai Bot commented Jun 18, 2026 •

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

ci/bloat.py is updated to support fbuild-native ELF discovery (.fbuild/build/<board>/release/firmware.elf), auto-resolved nm via build_info_<board>.json, a renamed resolve_pio_nm() for legacy PIO builds, a refactored run_fbuild_symbols() that conditionally omits --nm, a new run_fbuild_build_bloat() overflow-retry helper, and a new --allow-overflow CLI flag with updated main() control flow.

Changes

fbuild-native ELF support and overflow retry

Layer / File(s) Summary
ElfLocation dataclass and find_elf search order
ci/bloat.py
Introduces ElfLocation(elf, fbuild_native) and rewrites find_elf() to return it, prioritizing .fbuild/build/<board>/release/firmware.elf before legacy PIO and legacy fbuild layout paths. Module docstring and overflow-retry documentation bullets are updated.
Legacy PIO nm resolution and run_fbuild_symbols refactor
ci/bloat.py
Renames resolve_nm() to resolve_pio_nm() with updated error messaging; clarifies that BOARD_CHIP_MAP and PIO_NM_BY_ARCH are for legacy PIO only. Refactors run_fbuild_symbols() to accept ElfLocation and `nm: Path
Overflow retry helper and --allow-overflow CLI flag
ci/bloat.py
Adds run_fbuild_build_bloat() to rerun fbuild build --bloat-analysis with PLATFORMIO_SRC_DIR set to the example directory. Adds --allow-overflow flag to the CLI argument parser; simplifies board help text.
Rewritten main() control flow
ci/bloat.py
main() wraps find_elf() in a try/except, retries via run_fbuild_build_bloat() when --allow-overflow is set, selects nm based on location.fbuild_native, prints updated metadata, and calls the refactored run_fbuild_symbols(location=..., nm=...).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related issues

Possibly related PRs

  • FastLED/FastLED#2883: Implements the original find_elf, resolve_nm, and run_fbuild_symbols functions that this PR directly refactors and extends.

Poem

🐇 Hoppity-hop through the build tree I go,
Seeking the ELF where the firmware does glow.
fbuild-native first, then legacy PIO,
Overflow? No panic — we'll retry, you know!
nm auto-resolves so the symbols align,
Every byte counted, each function in line. ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 71.43% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat(bloat): delegate nm + ELF path resolution to fbuild symbols (arm support)' accurately summarizes the main change: delegating nm and ELF resolution to fbuild to enable ARM support.
Linked Issues check ✅ Passed The PR fully addresses all three acceptance criteria from issue #594: fbuild-native ELF path detection, automatic nm resolution via build_info.json, and over-budget retry mechanism with --allow-overflow flag.
Out of Scope Changes check ✅ Passed All changes in ci/bloat.py are directly scoped to enabling ARM support and fbuild-native builds; no unrelated modifications detected.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/bloat-arm-lpc-594

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

bash bloat / fbuild symbols: no arm-none-eabi path; can't measure LPC845 bloat from FastLED's wrapper

1 participant