Skip to content

bash compile --backend platformio silently discards root platformio.ini build_flags #2664

Description

@zackees

Surprise

I added build flags to [env:esp32c6] in the root platformio.ini, ran bash compile esp32c6 --examples AutoResearch --backend platformio, and the build succeeded — but the flags were not present in the compiled firmware. After several increasingly heavy-handed cache busts (touching source, deleting .build/pio/esp32c6/.pio, forcing a full rebuild) the symbols still indicated the flags hadn't been compiled in. The compiled-in flags were exactly the set carried by the Board entry in ci/boards.py.

Root cause

bash compile --backend platformio ultimately synthesises a fresh PlatformIO project at .build/pio/<env>/platformio.ini from the Board definition in ci/boards.py. That synthesised file does not inherit build_flags from the root platformio.ini. Repro: after a build run, inspect the generated file —

# .build/pio/esp32c6/platformio.ini
[env:esp32c6]
board = esp32-c6-devkitc-1
platform = …
framework = arduino
board_build.flash_size = 4MB
board_upload.flash_size = 4MB
board_build.partitions = huge_app.csv
build_flags =
    -funwind-tables               # ← only what ci/boards.py says
    -fopt-info-all=…
    -Wl,-Map,…
…

The root platformio.ini is ignored by this code path. (It IS read by fbuild deploy, which makes the divergence even more confusing — flags 'work' under fbuild but vanish under PIO.)

Why this matters

Anyone reading the root platformio.ini reasonably assumes that's where env-level config lives. I lost about an hour of debug time on ESP32-C6 (USB-CDC routing flag silently absent → silent device) before noticing the generated file. Subtler defines (CORE_DEBUG_LEVEL, CONFIG_PARLIO_*) would just produce mysteriously different runtime behaviour with zero log signal.

Proposed fix

Either:

  1. Merge root [env:<board>].build_flags into the synthesised PIO config. Read the root platformio.ini and forward overrides for the matching [env:<board>] section.
  2. Make the synthesised platformio.ini extends = ../../../platformio.ini::env:<board> so PIO's own override semantics apply.
  3. Document the divergence. A loud note in CLAUDE.md and at the top of platformio.ini saying 'the bash-compile path does not read this file — edit ci/boards.py instead' would at least save the next person the same hour.

Option 1 or 2 keeps the existing single source of truth for users who already wrote configuration in the obvious place.

Environment

Activity

  1. added a commit that references this issue on Jun 5, 2026
    2579bd1
  2. moved this from Triage to Done in FastLED Trackeron Jun 5, 2026
  3. added a commit that references this issue on Jun 19, 2026
    30ee2eb
  4. zackees commented on Jun 19, 2026

    @zackees
    MemberAuthor

    Replaced by the documented separation in root `./platformio.ini`'s new header comment (#3295): root is for `bash debug` only; CI compile, size-check, bloat, tests, and `bash autoresearch` all synthesise their own `platformio.ini` from `ci/boards.py`. The original `--backend platformio` symptom (discarded root `build_flags`) is now intentional behaviour by orthogonality.

    Refs: #3274 (parent), #3278 / #3291 (sever), #3279 / #3295 (Phase 4 cleanup).

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