Skip to content

Apply PlatformIO build_unflags to the effective native flag scopes #37

@zackees

Description

@zackees

Parent: #34

Problem

build_unflags is more than user-flag cleanup. PlatformIO applies it against the effective SCons environment after board flags, user flags, framework scripts, and other mutations have contributed to the final flag scopes.

PlatformIO source evidence

  • ProcessProgramDeps() applies board extra flags, then BUILD_FLAGS, then framework scripts, then ConfigureDebugTarget(), and only after that calls ProcessUnFlags(BUILD_UNFLAGS): .cache/platformio-core/platformio/builder/tools/piobuild.py:94-128
  • ProcessUnFlags() removes matching entries across parsed flag scopes, including ASPPFLAGS: .cache/platformio-core/platformio/builder/tools/piobuild.py:256-266
  • PlatformIO has a regression test where build_unflags removes values injected by an extra_scripts SCons mutation, not just values typed directly in build_flags: .cache/platformio-core/tests/commands/test_run.py:143-197

Current fbuild state

  • PLATFORMIO_BUILD_UNFLAGS is recognized as supported and has an accessor: crates/fbuild-config/src/pio_env.rs:15-21, crates/fbuild-config/src/pio_env.rs:111-121
  • I could not find any code path where those unflags are applied to the effective native flag set
  • fbuild currently merges user flags by appending/replacing some flag classes, e.g. ESP32 apply_user_flags(): crates/fbuild-build/src/esp32/orchestrator.rs:1257-1276

Requested change

Implement build_unflags in native mode against the final effective flag scopes that fbuild assembles, not only against raw user-provided build_flags.

Questions to resolve

  • Which scopes should be covered in fbuild (compile, link, assembler, include paths, libs)?
  • Should support be exact-match only, or also special-case macro/key semantics as fbuild already does for -D replacement?
  • How should this interact with platform-specific orchestrators that currently assemble flags differently?

Acceptance criteria

  • build_unflags affects the effective native build result
  • Removal is applied after board/framework/profile/user contributions are combined
  • Tests cover at least one removal from each supported scope
  • If any PlatformIO build_unflags behavior is intentionally out of scope, the limitation is documented and diagnosed clearly

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions