Skip to content

fix(build,windows): work around zccache#619 PCH path-spelling drift - #2685

Merged
zackees merged 1 commit into
masterfrom
chore/fix-windows-pch-cstdio-redefinition
Jun 2, 2026
Merged

zackees merged 1 commit into
masterfrom
chore/fix-windows-pch-cstdio-redefinition

Conversation

@zackees

@zackees zackees commented Jun 2, 2026 •

Copy link
Copy Markdown
Member

Summary

Targets the Windows-only `bash test --cpp` failure that has been blocking the Stop hook after PRs #2683 / #2684. The host-build was failing with "error: redefinition of 'LogLevel'" for a wide swath of TUs (channel_manager, blur, stdio, perf_primitives, font/truetype, several src/ headers) because the same physical `fl/stl/cstdio.h` got two different canonical path spellings — one via the PCH, one via the consumer TU's direct include — and `#pragma once` failed to dedupe across the PCH boundary.

Root cause

Filed upstream as zackees/zccache#619: clang on Windows joins an `-I` root with a relative include using a literal backslash separator (`src\fl/stl/cstdio.h`), and the resulting spelling drifts between PCH-build-time and consumer-TU-time when any include path also carries spelling inconsistency. zccache already has `StrictPathsMode::Consistent` that catches exactly this, but it's off by default.

What this PR changes (until the upstream fix lands)

  1. `ci/meson/shared/meson.build` — fixes one upstream contributor in our own build: replace meson's `/` path-join operator (which emits the native separator on Windows even when the operands are forward-slash spelled) with literal `+ '/' +` concatenation. This cleans up the `-I` flags zccache sees, and is a correct change independent of the upstream work.

  2. Six `src/` files — remove redundant direct `#include "fl/stl/cstdio.h"` lines:

    • `fl/net/http/chunked_encoding.cpp.hpp`, `fl/net/http/stream_client.cpp.hpp`, `fl/net/http/stream_server.cpp.hpp`, `fl/system/engine_events.cpp.hpp` — dead includes (0 cstdio.h symbols referenced).
    • `fl/remote/transport/serial.h` — uses 4 cstdio symbols (`fl::println`, `fl::available`, `fl::read`, `fl::readLine`); keeps relying on the `strstream.h -> ostream.h -> cstdio.h` transitive chain already in scope.
    • `fl/stl/istream.h` — uses just `fl::available`; forward-declares it locally instead of pulling all of cstdio.h.
  3. Six `tests/` files — same fix: remove the redundant direct include. PCH reaches cstdio.h transitively via `ostream.h` so test TUs that genuinely use cstdio.h symbols (blur.cpp, stdio.cpp, perf_primitives.hpp) keep working.

  4. `src/platforms/esp/32/drivers/lcd_spi/channel_driver_lcd_clockless.cpp.hpp` — gate the `esp_rom_printf` call that PR chore(lint): clear pre-existing bash-lint baseline failures #2684 added under `#ifndef FASTLED_STUB_IMPL`. The host stub doesn't have `esp_rom_printf` declared.

Each workaround comment references forge-ci/zccache#619 so future maintainers can revert these once the upstream fix lands.

Test plan

  • `bash test --cpp` -> 249/249 passed on Windows host with zccache 1.11.9 + clang 21.1.5.
  • `bash lint` clean (no new violations introduced by this PR).
  • Diff is minimal: 73 insertions / 17 deletions across 14 files. No public API change.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Chores
    • Fixed Windows build system path normalization to ensure consistent forward-slash formatting in include paths.
    • Optimized header include patterns across multiple modules to improve build reliability on Windows platforms.

Filed root-cause report upstream: forge-ci/zccache#619 (Windows PCH
path-spelling mismatch defeats `#pragma once` across the PCH boundary).
This PR ships the targeted workarounds needed to unblock host-build
tests against the current Stop-hook policy while the upstream fix lands.

Symptom:
  error: redefinition of 'LogLevel'
  note: 'C:/.../src\fl/stl/cstdio.h' included multiple times,
        additional include site here

The same physical cstdio.h header was reached via two different
canonical path spellings — one with mixed slashes (the literal
backslash inserted by clang-on-Windows when joining the `-I` root with
the relative include) and one resolved through the PCH cache — and
`#pragma once` failed to dedupe.

Changes:

1. `ci/meson/shared/meson.build` — replace meson's `/` path-join operator
   with literal `+ '/' +` concatenation. The `/` operator emits the
   native separator on Windows (backslash) even when both operands are
   forward-slash-spelled, which was injecting a trailing backslash into
   every `-IC:/.../src\` flag and feeding zccache an inconsistent
   spelling. This is a real bug in our build setup and gets fixed
   regardless of the upstream zccache work; it just isn't sufficient on
   its own to clear the dedup failure.

2. Six SOURCE-tree files (`src/fl/...`) — remove redundant direct
   `#include "fl/stl/cstdio.h"` lines where cstdio.h was already
   reachable transitively through ostream.h via the PCH. Two of these
   (istream.h, serial.h) actually used cstdio.h symbols; istream.h
   forward-declares the one symbol it needs (`fl::available`), serial.h
   keeps relying on the strstream.h -> ostream.h -> cstdio.h chain that
   is already in scope.

3. Six TEST-tree files — same fix: remove the redundant direct include.
   Each gets an explanatory comment referencing zccache#619 so future
   maintainers can revert the workaround once the upstream fix lands.

4. `src/platforms/esp/32/drivers/lcd_spi/channel_driver_lcd_clockless.cpp.hpp`
   — gate the `esp_rom_printf` call that PR #2684 added under
   `#ifndef FASTLED_STUB_IMPL`. The function compiles on host stub
   (where FASTLED_STUB_IMPL is set) and `esp_rom_printf` is undeclared
   there; the host stub doesn't run the ISR anyway.

Verified: `bash test --cpp` -> 249/249 passed on Windows host with
zccache 1.11.9 + clang 21.1.5.
@coderabbitai

coderabbitai Bot commented Jun 2, 2026 •

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: f0918df5-e35b-4e98-b746-a32099f976f6

📥 Commits

Reviewing files that changed from the base of the PR and between c19281d and dc242d5.

📒 Files selected for processing (14)
  • ci/meson/shared/meson.build
  • src/fl/net/http/chunked_encoding.cpp.hpp
  • src/fl/net/http/stream_client.cpp.hpp
  • src/fl/net/http/stream_server.cpp.hpp
  • src/fl/remote/transport/serial.h
  • src/fl/stl/istream.h
  • src/fl/system/engine_events.cpp.hpp
  • src/platforms/esp/32/drivers/lcd_spi/channel_driver_lcd_clockless.cpp.hpp
  • tests/fl/channels/channel_manager.cpp
  • tests/fl/font/truetype.cpp
  • tests/fl/gfx/blur.cpp
  • tests/fl/gfx/perf_primitives.hpp
  • tests/fl/stl/stdio.cpp
  • tests/timeout_watchdog.h

📝 Walkthrough

Walkthrough

This PR addresses Windows PCH path-spelling inconsistencies by normalizing Meson-emitted include paths to absolute forward-slash form, removing direct fl/stl/cstdio.h includes across source and test files (replacing them with documented comments), adding a forward declaration for fl::available() in istream.h, and wrapping ISR debug logging in a stub-build conditional.

Changes

PCH path workaround and build normalization

Layer / File(s) Summary
Meson build path normalization
ci/meson/shared/meson.build
path_norm_root normalizes meson.project_source_root() to forward-slash form, and path_norm_I_src, path_norm_I_tests, path_norm_I_stub are reconstructed using literal string concatenation with '/' instead of Meson's / operator to ensure emitted -I flags use consistent forward-slash spelling.
istream.h forward declaration
src/fl/stl/istream.h
Removes direct inclusion of fl/stl/cstdio.h, adds forward declaration of int fl::available() FL_NOEXCEPT;, and includes fl/stl/noexcept.h to decouple from full cstdio dependency.
Network and transport header include removal
src/fl/net/http/chunked_encoding.cpp.hpp, src/fl/net/http/stream_client.cpp.hpp, src/fl/net/http/stream_server.cpp.hpp, src/fl/remote/transport/serial.h, src/fl/system/engine_events.cpp.hpp
These files remove direct fl/stl/cstdio.h includes and add comments documenting the Windows PCH path-spelling drift workaround (forge-ci/zccache#619), relying on transitive includes through the PCH chain.
Test file include removal
tests/fl/channels/channel_manager.cpp, tests/fl/font/truetype.cpp, tests/fl/gfx/blur.cpp, tests/fl/gfx/perf_primitives.hpp, tests/fl/stl/stdio.cpp, tests/timeout_watchdog.h
Test files remove direct fl/stl/cstdio.h includes and add comments explaining reliance on PCH transitive inclusion to supply cstdio symbols for output and serialization operations.
ISR logging stub build conditional
src/platforms/esp/32/drivers/lcd_spi/channel_driver_lcd_clockless.cpp.hpp
Wraps esp_rom_printf debug logging on ISR transmit failure in #ifndef FASTLED_STUB_IMPL, conditionally excluding the log call when stub implementations are active.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related issues

Possibly related PRs

  • FastLED/FastLED#2332: Normalizes -I paths in ci/meson/shared/meson.build to absolute forward-slash form using the same variables (path_norm_root, path_norm_I_src/tests/stub).
  • FastLED/FastLED#2385: Modifies ci/meson/shared/meson.build to normalize Meson source/include-root paths into consistent forward-slash -I arguments for zccache strict-path correctness.
  • FastLED/FastLED#2327: Aligns test Meson build logic to remove /./ vs / mismatches in test_abs_include_args, addressing the same include-path-spelling issue targeted by this PR's Meson normalization.

Poem

🐰 A rabbit hops through paths so grand,
Forward slashes held in paw in hand,
No more chaos, no more strife—
PCH dreams now crystal-clear in life! ✨
Headers dance in harmony,
Meson builds now clean and free.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/fix-windows-pch-cstdio-redefinition

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 Infer (1.2.0)
tests/fl/channels/channel_manager.cpp

tests/fl/channels/channel_manager.cpp:5:10: fatal error: 'fl/channels/manager.h' file not found
5 | #include "fl/channels/manager.h"
| ^~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
Error: the following clang command did not run successfully:
/opt/infer-linux-x86_64-v1.2.0/lib/infer/facebook-clang-plugins/clang/install/bin/clang-18
@/tmp/coderabbit-infer/dc242d5cbc809d897b7e9d61b1ab871d6c673f3e-ed6a96dcecd03c75/tmp/clang_command_.tmp.c85db9.txt
++Contents of '/tmp/coderabbit-infer/dc242d5cbc809d897b7e9d61b1ab871d6c673f3e-ed6a96dcecd03c75/tmp/clang_command_.tmp.c85db9.txt':
"-cc1" "-load"
"/opt/infer-linux-x86_64-v1.2.0/lib/infer/infer/bin/../../facebook-clang-plugins/libtooling/build/FacebookClangPlugin.dylib"
"-add-plugin" "BiniouASTExporter" "-plugin-arg-BiniouASTExporter" "-"
"-plugin-arg-BiniouASTExporter" "PREPEND_CURRENT_DIR=1"
"-plugin-arg-BiniouASTExporter" "MAX_STRING_SIZE=65535" "-cc1" "-triple"
"x86_64-unknown-linux-gnu" "-emi

... [truncated 1118 characters] ...

b/clang/18/include"
"-internal-isystem" "/usr/local/include" "-internal-isystem"
"/usr/lib/gcc/x86_64-linux-gnu/12/../../../../x86_64-linux-gnu/include"
"-internal-externc-isystem" "/usr/include/x86_64-linux-gnu"
"-internal-externc-isystem" "/include" "-internal-externc-isystem"
"/usr/include" "-Wno-ignored-optimization-argument" "-Wno-everything"
"-fdeprecated-macro" "-ferror-limit" "19" "-fgnuc-version=4.2.1"
"-fskip-odr-check-in-gmf" "-fcxx-exceptions" "-fexceptions"
"-D__GCC_HAVE_DWARF2_CFI_ASM=1" "-o"
"/tmp/coderabbit-infer/ed6a96dcecd03c75/file.o" "-x" "c++"
"tests/fl/channels/channel_manager.cpp" "-O0" "-fno-builtin" "-include"
"/opt/infer-linux-x86_64-v1.2.0/lib/infer/infer/bin/../lib/clang_wrappers/global_defines.h"
"-Wno-everything"

tests/fl/font/truetype.cpp

tests/fl/font/truetype.cpp:1:10: fatal error: 'test.h' file not found
1 | #include "test.h"
| ^~~~~~~~
1 error generated.
Error: the following clang command did not run successfully:
/opt/infer-linux-x86_64-v1.2.0/lib/infer/facebook-clang-plugins/clang/install/bin/clang-18
@/tmp/coderabbit-infer/dc242d5cbc809d897b7e9d61b1ab871d6c673f3e-04daa21463fbcc09/tmp/clang_command_.tmp.bc468e.txt
++Contents of '/tmp/coderabbit-infer/dc242d5cbc809d897b7e9d61b1ab871d6c673f3e-04daa21463fbcc09/tmp/clang_command_.tmp.bc468e.txt':
"-cc1" "-load"
"/opt/infer-linux-x86_64-v1.2.0/lib/infer/infer/bin/../../facebook-clang-plugins/libtooling/build/FacebookClangPlugin.dylib"
"-add-plugin" "BiniouASTExporter" "-plugin-arg-BiniouASTExporter" "-"
"-plugin-arg-BiniouASTExporter" "PREPEND_CURRENT_DIR=1"
"-plugin-arg-BiniouASTExporter" "MAX_STRING_SIZE=65535" "-cc1" "-triple"
"x86_64-unknown-linux-gnu" "-emit-obj" "-mrelax-all" "-disable-free"
"-clear-ast-bef

... [truncated 1044 characters] ...

/install/lib/clang/18/include"
"-internal-isystem" "/usr/local/include" "-internal-isystem"
"/usr/lib/gcc/x86_64-linux-gnu/12/../../../../x86_64-linux-gnu/include"
"-internal-externc-isystem" "/usr/include/x86_64-linux-gnu"
"-internal-externc-isystem" "/include" "-internal-externc-isystem"
"/usr/include" "-Wno-ignored-optimization-argument" "-Wno-everything"
"-fdeprecated-macro" "-ferror-limit" "19" "-fgnuc-version=4.2.1"
"-fskip-odr-check-in-gmf" "-fcxx-exceptions" "-fexceptions"
"-D__GCC_HAVE_DWARF2_CFI_ASM=1" "-o"
"/tmp/coderabbit-infer/04daa21463fbcc09/file.o" "-x" "c++"
"tests/fl/font/truetype.cpp" "-O0" "-fno-builtin" "-include"
"/opt/infer-linux-x86_64-v1.2.0/lib/infer/infer/bin/../lib/clang_wrappers/global_defines.h"
"-Wno-everything"

tests/fl/stl/stdio.cpp

tests/fl/stl/stdio.cpp:1:10: fatal error: 'test.h' file not found
1 | #include "test.h"
| ^~~~~~~~
1 error generated.
Error: the following clang command did not run successfully:
/opt/infer-linux-x86_64-v1.2.0/lib/infer/facebook-clang-plugins/clang/install/bin/clang-18
@/tmp/coderabbit-infer/dc242d5cbc809d897b7e9d61b1ab871d6c673f3e-af6a589339fb82b2/tmp/clang_command_.tmp.36e1d2.txt
++Contents of '/tmp/coderabbit-infer/dc242d5cbc809d897b7e9d61b1ab871d6c673f3e-af6a589339fb82b2/tmp/clang_command_.tmp.36e1d2.txt':
"-cc1" "-load"
"/opt/infer-linux-x86_64-v1.2.0/lib/infer/infer/bin/../../facebook-clang-plugins/libtooling/build/FacebookClangPlugin.dylib"
"-add-plugin" "BiniouASTExporter" "-plugin-arg-BiniouASTExporter" "-"
"-plugin-arg-BiniouASTExporter" "PREPEND_CURRENT_DIR=1"
"-plugin-arg-BiniouASTExporter" "MAX_STRING_SIZE=65535" "-cc1" "-triple"
"x86_64-unknown-linux-gnu" "-emit-obj" "-mrelax-all" "-disable-free"
"-clear-ast-before-

... [truncated 1029 characters] ...

lang/install/lib/clang/18/include"
"-internal-isystem" "/usr/local/include" "-internal-isystem"
"/usr/lib/gcc/x86_64-linux-gnu/12/../../../../x86_64-linux-gnu/include"
"-internal-externc-isystem" "/usr/include/x86_64-linux-gnu"
"-internal-externc-isystem" "/include" "-internal-externc-isystem"
"/usr/include" "-Wno-ignored-optimization-argument" "-Wno-everything"
"-fdeprecated-macro" "-ferror-limit" "19" "-fgnuc-version=4.2.1"
"-fskip-odr-check-in-gmf" "-fcxx-exceptions" "-fexceptions"
"-D__GCC_HAVE_DWARF2_CFI_ASM=1" "-o"
"/tmp/coderabbit-infer/af6a589339fb82b2/file.o" "-x" "c++"
"tests/fl/stl/stdio.cpp" "-O0" "-fno-builtin" "-include"
"/opt/infer-linux-x86_64-v1.2.0/lib/infer/infer/bin/../lib/clang_wrappers/global_defines.h"
"-Wno-everything"

  • 1 others

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@zackees
zackees merged commit 1a347e9 into master Jun 2, 2026
4 of 7 checks passed
@fastled-project-sync fastled-project-sync Bot moved this to Triage in FastLED Tracker Jun 2, 2026
@fastled-project-sync fastled-project-sync Bot moved this from Triage to Done in FastLED Tracker Jun 2, 2026
zackees added a commit that referenced this pull request Jun 2, 2026
…2686)

PR #2685 removed the direct #include "fl/stl/cstdio.h" from
src/fl/remote/transport/serial.h based on a transitive-include chain
("strstream.h -> ostream.h -> cstdio.h") that does not exist —
strstream.h does NOT include ostream.h, so the symbols fl::available,
fl::read, fl::readLine, and fl::println are not in scope on any
non-PCH build.

CI symptom on the post-#2685 master sha (1a347e9), every teensy
variant fails on every example with:

  fl/remote/transport/serial.h:68:40: error: 'available' is not a
                                             member of 'fl'
  fl/remote/transport/serial.h:69:29: error: 'read'      is not a
                                             member of 'fl'
  fl/remote/transport/serial.h:80:16: error: 'readLine'  is not a
                                             member of 'fl'

The Windows PCH path-spelling dedup issue PR #2685 was working
around is already handled by the meson.build path-normalization
change that shipped in the same PR (replacing meson's `/` operator
with literal `'+ '/' +'` concatenation). Dropping the direct include
was an incorrect additional belt-and-suspenders that broke every
non-PCH build.

Verified locally on Windows:
  bash compile teensy41 --examples Apa102
  -> build succeeded in 129.6s
  -> SUCCESS: Apa102

Co-authored-by: Claude Opus 4.7 <[email protected]>
@zackees
zackees deleted the chore/fix-windows-pch-cstdio-redefinition branch August 21, 2026 19:15
zackees added a commit that referenced this pull request Oct 16, 2026
* docs(skills): add /pch-debug skill and pch_probe.py

A skill that auto-activates on PCH failures ('redefinition of',
'redefines default argument', 'modified since the precompiled header',
tests that pass only after --clean). It explains the identity model
(#pragma once fails early; include guards hide the double read), the two
mechanisms in FastLED's history (path-spelling drift: #2685/zccache#619,
#3813; stale PCH accepted: #4839, #4437, #2995/zccache#710), and a
probe-before-clean procedure.

pch_probe.py: 'inputs' dumps what the PCH recorded (falls back to scanning
the PCH bytes when clang refuses a stale PCH) and flags odd spellings,
duplicate spellings and stale inputs; 'tu' runs a real compile_commands
entry with -H (optionally through zccache) and lists project headers
re-opened from disk next to their PCH spelling.

* pch_probe: llvm-bcanalyzer input records; repo-root-based project-header check (#4860 review)

- inputs: read the PCH with llvm-bcanalyzer -dump when available (PATH or
  LLVM_BCANALYZER): exact recorded spelling, size and mtime per input,
  without clang's stale-PCH validation; stale = size/mtime differ from the
  record (clang's own check). Falls back to -module-file-info / byte scan.
- Project headers are now classified by resolving under the repo root
  (derived from the script location), not by matching /src/ or /tests/ in
  the raw spelling: relative recorded entries like tests/... count, and any
  --build-dir location works.

* pch_probe: resolve relative recorded inputs against the build dir (#4860 review)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant