Skip to content

fix(build): escaped quotes in build_flags defines are mangled before reaching gcc (ESP32 sketch compile) #947

Description

@zackees

Context

NightDriverStrip env:demo sets build_src_flags = ... -DPROJECT_NAME="\"Demo\"" (standard PlatformIO idiom for a string-valued define — SCons passes flags through a shell layer, so gcc receives the argv element -DPROJECT_NAME="Demo").

Under fbuild (Rust, ESP32 orchestrator, compile-sketch phase), every use of PROJECT_NAME fails with:

<command-line>: error: unable to find string literal operator 'operator""Demo' with 'const char [1]', 'unsigned int' arguments
src/effectmanager_persistence.cpp:262:31: note: in expansion of macro 'PROJECT_NAME'

i.e. the macro value reaching gcc is ""Demo""-shaped — backslashes stripped, literal quotes kept. fbuild-config's parse_flags preserves the token verbatim, so the corruption happens downstream in flag re-tokenization (fbuild_core::shell_split::split deliberately treats \ as literal and strips quote chars — correct for Windows paths, wrong for escaped-quote defines) or in the compile-command assembly.

Reproduced in the #942 Docker profiling harness: cold fbuild build /tmp/nds -e demo (NightDriverStrip @ 5911331) fails after ~11.5 min in compile-sketch. This blocks the #942 Phase 1 baseline (and any real project using string-valued defines, which is a very common PlatformIO pattern).

Acceptance criteria

  • -DNAME="\"Value\"" in build_flags/build_src_flags reaches the compiler as the argv element -DNAME="Value" (direct-exec semantics), on the ESP32 path at minimum.
  • Unit test covering escaped-quote defines through the flag pipeline (INI → argv).
  • Audit of the other orchestrators' (esp8266, rp2040, stm32) use of shell_split for the same hazard — fix or file follow-ups.
  • NightDriverStrip env:demo compiles past effectmanager_persistence.cpp in the meta: profiling-driven build performance burndown (Docker Linux, NightDriverStrip, cold vs hot cache) #942 harness.

Decisions

  • Severity: HIGH — user-facing build failure on a very common flag idiom.
  • Fix shape: make the flag tokenizer shell-unescape \" inside double-quoted regions (or bypass re-tokenization for already-tokenized flags) while keeping backslashes literal outside quotes so Windows paths stay safe. Exact location pending trace.

Part of #942 (blocks Phase 1 baseline).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status
    Triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions