Skip to content

Add a native compatibility shim for build_type=debug and debug_build_flags #36

Closed

Description

@zackees

Parent: #34

Problem

PlatformIO's debug mode is a declarative feature, not just a pile of user flags. build_type = debug changes the build mode, strips existing optimization/debug flags, adds __PLATFORMIO_BUILD_DEBUG__, and applies debug_build_flags (defaulting to -Og -g2 -ggdb2 when not overridden).

PlatformIO source evidence

  • Build mode is derived from build_type / special targets: .cache/platformio-core/platformio/builder/tools/piobuild.py:47-57
  • Debug mode is activated during dependency processing: .cache/platformio-core/platformio/builder/tools/piobuild.py:118-128
  • Debug configuration removes prior -O*/-g*, adds __PLATFORMIO_BUILD_DEBUG__, and merges debug_build_flags: .cache/platformio-core/platformio/builder/tools/piomisc.py:91-127
  • PlatformIO has regression tests for default and custom debug flags: .cache/platformio-core/tests/commands/test_run.py:200-248

Current fbuild state

  • BuildProfile only has Release and Quick: crates/fbuild-core/src/lib.rs:55-69
  • The native build pipeline only reads build_flags / build_src_flags: crates/fbuild-build/src/pipeline.rs:106-111

Requested change

Design and implement a native compatibility shim for the declarative debug subset:

  • parse build_type = debug
  • parse debug_build_flags
  • apply PlatformIO-like debug semantics to effective compile/link flags
  • add __PLATFORMIO_BUILD_DEBUG__
  • decide how this maps onto fbuild's internal profile model (debug profile vs reworked profile abstraction)

Scope notes

  • This issue is about the declarative debug subset only
  • It should not pull in arbitrary extra_scripts / full SCons behavior
  • build_type = test can be left out of the first implementation if that reduces risk, but the support boundary should be explicit

Acceptance criteria

  • A native fbuild build reproduces PlatformIO-like debug flag semantics for representative cases
  • Default debug flags match PlatformIO expectations unless explicitly overridden
  • Existing optimization/debug flags are cleaned up before new debug flags are applied
  • Regression tests cover both default and custom debug_build_flags

Activity

  1. zackees commented on Apr 17, 2026

    @zackees
    MemberAuthor

    Closing this as completed on current main.

    The native debug compatibility shim is already implemented:

    • PlatformIOConfig parses build_type and debug_build_flags in crates/fbuild-config/src/ini_parser.rs
    • BuildContext::new() applies the debug path in crates/fbuild-build/src/pipeline.rs when build_type == "debug"
    • apply_debug_build_type() strips prior -O* / -g*, adds -D__PLATFORMIO_BUILD_DEBUG__, and applies debug_build_flags

    Current regression coverage also matches the issue intent:

    • cargo test -p fbuild-config test_get_build_type_reads_debug
    • cargo test -p fbuild-config test_get_debug_build_flags -- --nocapture
    • cargo test -p fbuild-build test_apply_debug_build_type_replaces_opt_flags_and_adds_debug_define
    • cargo test -p fbuild-build test_debug_mode_then_build_unflags_can_remove_debug_flags_again

    Those all pass on current main, so the requested declarative debug subset is in place.

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

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions