Skip to content

fbuild: ESP32 board build_flags / build_unflags aren't propagating from ci/boards.py #3298

Closed

Description

@zackees

Context

Discovered while landing PR #3295 (#3279 Phase 4). The PR ports the band-aid size-strip flags (-Os, -fno-exceptions, -fno-rtti, -fno-unwind-tables, -fno-asynchronous-unwind-tables, -ffunction-sections, -fdata-sections, plus build_unflags = -Og -g) from root platformio.ini's [env:esp32dev] section to ci/boards.py::ESP32DEV.build_flags / .build_unflags, since CI no longer reads root after the #3278 sever.

Symptom

After porting the flags, bash compile esp32dev --examples Blink (which CI uses) still produces an identical 401240-byte ELF before and after adding them — two consecutive PR commits (456b502 with build_flags only, 6177716 adding build_unflags too) both produced the same 401240-byte binary. That's strong evidence fbuild's compile pipeline is not honouring board-level build_flags / build_unflags for the ESP32 toolchain.

The synthesised platformio.ini DOES contain the flags correctly (verified by Board.to_platformio_ini() locally), so the data is reaching the file fbuild reads — but fbuild itself appears to either drop them or get them overridden later by the platform's default toolchain config.

Reproduce

  1. Check out PR feat(ci): deprecate PioCompiler backend + Phase 4 cleanup (#3279) #3295 at commit 8764099.
  2. bash compile esp32dev --examples Blink.
  3. Observe the resulting ELF at .build/pio/esp32dev/.pio/build/esp32dev/firmware.elf is ~401 KB despite ESP32DEV.build_flags containing -Os -fno-exceptions -fno-rtti -ffunction-sections -fdata-sections etc.
  4. Compare the actual compiler command line fbuild emits (or firmware.map's --gc-sections evidence) against what ci/boards.py specifies — most likely the flags either never reach the compile commands or are overridden by the framework's own command-line later.

Why it matters

PR #3268 introduced a 330 KB ceiling in check_esp32_size.yml predicated on those band-aid flags working. With the legacy root-merge path gone, the ceiling is unreachable until fbuild has a working flag-port surface. PR #3295 raises the ceiling back to 700 KB as a stopgap. Tightening it back to 330 KB requires fixing this fbuild gap first.

Acceptance

  • Board.build_flags and Board.build_unflags from ci/boards.py reach the actual compile commands fbuild issues for ESP32 boards.
  • bash compile esp32dev --examples Blink with the size-strip flag set produces an ELF measurably smaller than 401 KB (target: ≤ 330 KB).
  • check_esp32_size.yml can be tightened back to max_size: 330000.

Refs

Activity

  1. zackees commented on Jul 27, 2026

    @zackees
    MemberAuthor

    Re-measured on current master (2026-07-27). The propagation gap this issue describes is fixed — the remaining redness has a different cause.

    Flags now reach the compile commands

    bash compile esp32dev --examples Blink, then inspecting .build/pio/esp32dev/.fbuild/build/release/compile_commands.json (58 TUs):

    flag present in
    -Os 58/58
    -fno-exceptions 58/58
    -fno-rtti 58/58
    -fno-unwind-tables 58/58
    -ffunction-sections 58/58
    -fdata-sections 58/58

    build_unflags also works: a token-exact scan across all entries finds no -g* at all, and no -O token other than -Os. Both -Og and -g are correctly stripped.

    Method caveat for anyone re-verifying: a substring grep for -g first reported it surviving in all 58 entries. That was a false positive from matching inside longer flag names. Tokenize the command lines — substring-matching will make you "confirm" a propagation bug that no longer exists.

    What's left is code size, not plumbing

    With the flags fully applied, esp32dev Blink is 391543 bytes (382 KB) — down from the 401240 bytes recorded in the issue body, so the flags are measurably doing something, but still ~52 KB over the 330 KB ceiling.

    Against this issue's acceptance criteria:

    • ✅ Board.build_flags / build_unflags reach the actual compile commands
    • ⚠️ ELF measurably smaller than 401 KB — yes (391543), but not the ≤ 330 KB target
    • ⚠️ check_esp32_size.yml tightened to 330000 — already at 330000, but CI stays red on the size gap

    Suggested disposition

    The specific defect named in the title is resolved. The residual ~52 KB is per-symbol code size, which is exactly what #2974 / #2886 and their children track — not a fbuild flag-port problem.

    Suggest closing this as "propagation fixed" and letting the remainder live in the bloat metas. Leaving that call to a maintainer rather than closing unilaterally.

    Meanwhile #3743 corrects check_esp32_size.yml, which still tells readers the redness is caused by this issue and to "fix #3298" — that comment now sends people after an already-fixed bug.

  2. zackees commented on Jul 27, 2026

    @zackees
    MemberAuthor

    Correction to my previous comment: the size gap figure was wrong.

    391543 − 330000 = 61543 bytes (~61.5 KB) over the ceiling, not the "~52 KB" I wrote. That came from mixing units — comparing 382 KB (391543/1024) against the 330 KB ceiling read as decimal. In KiB it's 382.4 − 322.3 = 60.1 KiB.

    Everything else in that comment stands: the flags do reach all 58 TUs, build_unflags strips both -Og and -g, and the binary is measurably down from 401240 → 391543. Only the remaining-gap number was off.

  3. moved this from Triage to Done in FastLED Trackeron Jul 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions