Repository navigation
fix(ci): compiled_size measures fbuild ELF, not stale pio rebuild - #3262
Conversation
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]>
|
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 (1)
📝 WalkthroughWalkthrough
Changesfbuild ELF firmware size measurement
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 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 |
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]>
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
ci/tests/test_compiled_size_fbuild.py (1)
95-96: ⚡ Quick winMove stdlib imports to module top-level.
osandtimeare imported inside the test body; this violates the repository import-order rule for Python files.As per coding guidelines, “All system imports must be at the top of the file in proper order: standard library, third-party, local.”
Proposed diff
from pathlib import Path +import os +import time from typing import Any import pytest @@ - # Make debug newer than release. - import os - import time - + # Make debug newer than release. older = time.time() - 60 os.utime(release_elf, (older, older))🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@ci/tests/test_compiled_size_fbuild.py` around lines 95 - 96, Move the `os` and `time` imports from inside the test body (where they are currently located at lines 95-96) to the top of the module file. Place these standard library imports at the module level before any third-party or local imports, following the repository's import-order convention of organizing imports as: standard library first, then third-party, then local imports.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@ci/compiled_size.py`:
- Around line 208-221: The env_name extraction at line 208 in _find_fbuild_elf
incorrectly retrieves field names from board_info (like "prog_path" or
"size_path") instead of the actual board/environment name, causing the legacy
path candidates to be malformed. Add the board parameter to the _find_fbuild_elf
function signature and update the call site at line 241 in check_firmware_size
to pass the board argument. Then replace the env_name extraction logic that uses
board_info.keys() with the passed board parameter directly.
---
Nitpick comments:
In `@ci/tests/test_compiled_size_fbuild.py`:
- Around line 95-96: Move the `os` and `time` imports from inside the test body
(where they are currently located at lines 95-96) to the top of the module file.
Place these standard library imports at the module level before any third-party
or local imports, following the repository's import-order convention of
organizing imports as: standard library first, then third-party, then local
imports.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 5a3e2fde-34d4-4dec-a0d8-8f72a6263b5e
📒 Files selected for processing (3)
.github/workflows/check_esp32_size.ymlci/compiled_size.pyci/tests/test_compiled_size_fbuild.py
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]>
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]>
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]>
Summary
The
esp32dev_binary_sizeworkflow has been red on master since at least 2026-06-17 — every run reports the same631100 > 330000. Even though #2858 made fbuild the default backend and #2823 wired_override_prog_path_for_fbuild, the actual size measurement was still coming from PlatformIO.Root cause:
check_firmware_sizeran_run_pio_size(build_dir)first unconditionally — and that callspio run -t size, which:.pio/build/<env>/firmware.elfexists yet, bypassing fbuild's tighter link flags (-Wl,--gc-sections,.eh_framestripping).On esp32dev that's ~169 KB of
.eh_framemachinery getting re-introduced by the measurement step itself — exactly the symptom flagged in the goal ("eh frames are making their way into the build").Fix
Reorder the priorities in
check_firmware_size:<build_dir>/.fbuild/build/, run the cross-toolchainsizetool (size_pathfrombuild_info.json) on THAT and returntext + data._run_pio_size(build_dir)— kept for AVR / pure-PlatformIO builds where the toolchainsizepath isn't recorded and.hexfiles aren't measurable viastat()..bin/.uf2file size fallback._find_fbuild_elfaccepts both fbuild layouts (legacy<build_dir>/.fbuild/build/<env>/release/firmware.elfand current<build_dir>/.fbuild/build/release/firmware.elfwithout the<env>segment) so the change works across the fbuild 2.2.x range that FastLED pins through.Test plan
uv run pytest ci/tests/test_compiled_size_fbuild.py -v— 6/6 pass (new tests)uv run pytest ci/tests/test_override_prog_path_for_fbuild.py -v— 6/6 pass (existing tests, untouched)bash lint— cleanuv run python -m ci.compiled_size --board lpc845brk→Firmware size for lpc845brk: 46804 bytes(text + data measured from the fbuild ELF directly, no pio invocation)esp32dev_binary_sizeworkflow on this PR. Expected: size drops to fbuild's actual link output (~462 KB if the.eh_framedelta lands as documented in commit e646657). May still need a budget bump separately if the post-strip size still exceeds 330 KB — but at minimum the measurement will match what fbuild actually produced.🤖 Generated with Claude Code
Summary by CodeRabbit
Release Notes
Chores
New Features
Tests
sizeparsing and for correctly locating the newest fbuild build artifact (including release vs debug selection and fallback when none are found).