Skip to content

fix(bloat): force ELF delete before each measure-opt-ins compile - #2941

Merged
zackees merged 1 commit into
masterfrom
feat/2940-elf-delete-before-compile
Jun 7, 2026
Merged

zackees merged 1 commit into
masterfrom
feat/2940-elf-delete-before-compile

Conversation

@zackees

@zackees zackees commented Jun 7, 2026 •

Copy link
Copy Markdown
Member

Closes #2940. Forces PIO relink between configs by deleting the prior ELF; the cached objects still make rebuild fast. Smoke test before fix: baseline reported stage3's 280,738 B (stale). After fix: 339,962 B (correct). Refs #2886.

Summary by CodeRabbit

  • Tests
    • Updated measurement workflow to automatically clear previously compiled binaries between configuration changes, ensuring firmware measurements reflect the current build state and preventing inaccuracies from stale artifacts.

Closes #2940.

PIO's link step decides whether to relink based on object-file
timestamps, NOT on platformio.ini / sdkconfig changes. When the
script switched configs that affected only the sdkconfig (e.g.
stage3 → baseline), the previous config's ELF stayed on disk and
the downstream `bash bloat` step measured it.

Smoke test before this fix (after a prior stage3 run left an
overlay-built ELF on disk):

    uv run python tests/measure_esp32s3_opt_ins.py --config baseline
    → baseline reported 280,738 B  # WRONG — that's stage3's number

Smoke test after this fix (same starting state):

    uv run python tests/measure_esp32s3_opt_ins.py --config baseline
    → baseline reported 339,962 B  # CORRECT — matches the pinned
      tests/data/esp32s3_bloat_baseline.txt

The fix: a tiny `_force_relink()` helper deletes
`.build/pio/esp32s3/.pio/build/esp32s3/firmware.elf` (if present)
before each compile. Object cache stays intact for speed; only the
link step is forced.

## Files

- tests/measure_esp32s3_opt_ins.py:
  - New `_ELF_PATH` constant.
  - New `_force_relink()` helper.
  - `measure_one()` calls it after patching platformio.ini, before
    running compile.

## Verification

- `bash lint` -> all linters pass (ruff, ty, C++, JS setup).
- Smoke test produces 339,962 B for baseline — matching pinned.

Refs #2886, #2940, #2939, #2935.
@zackees
zackees merged commit e518aeb into master Jun 7, 2026
@fastled-project-sync fastled-project-sync Bot moved this to Triage in FastLED Tracker Jun 7, 2026
@fastled-project-sync fastled-project-sync Bot moved this from Triage to Done in FastLED Tracker Jun 7, 2026
@coderabbitai

coderabbitai Bot commented Jun 7, 2026 •

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 3cbfd136-2219-43c3-b863-8f4842528649

📥 Commits

Reviewing files that changed from the base of the PR and between 73673d7 and 8e073dc.

📒 Files selected for processing (1)
  • tests/measure_esp32s3_opt_ins.py

📝 Walkthrough

Walkthrough

The PR modifies the ESP32-S3 measurement script to fix a stale-ELF bug: when switching between OptInConfigs that share object files, PlatformIO's link step may skip relinking if timestamps unchanged. The fix adds a constant locating the firmware ELF, a _force_relink() helper that deletes it, and calls that helper in measure_one() after config patching to force a fresh link on each measurement.

Changes

ELF Deletion and Relinking

Layer / File(s) Summary
ELF deletion and relinking integration
tests/measure_esp32s3_opt_ins.py
Adds _ELF_PATH constant pointing to the ESP32-S3 firmware ELF location, introduces _force_relink() helper to conditionally delete the stale ELF file, and integrates the deletion into measure_one() after platformio.ini patching to ensure PlatformIO relinking occurs on each config measurement.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related issues

  • FastLED/FastLED#2905: The change directly concerns tests/measure_esp32s3_opt_ins.py measurement accuracy and ELF artifact handling in build measurement workflows.

Possibly related PRs

  • FastLED/FastLED#2906: Both PRs modify the same measurement driver tests/measure_esp32s3_opt_ins.py; this PR adds ELF deletion logic to prevent stale build artifacts measured by the multi-config measurement logic introduced in PR#2906.

Poem

🐰 A firmware.elf stale and forlorn,
Each config measured at the wrong morn!
With a delete here, a relink there,
The metrics now show what is fair.
Fresh ELFs bloom where old ones were born! 🏗️

✨ 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/2940-elf-delete-before-compile

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.

@zackees
zackees deleted the feat/2940-elf-delete-before-compile branch August 21, 2026 19:15
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.

Force ELF delete before each measurement compile to defeat PIO link skip (#2886)

1 participant