Skip to content

[meta] Build-system rebuild workarounds — fix-now list + zccache/meson upstream blockers #3129

Open

Description

@zackees

Goal

Audit and remove degenerate meson/ninja rebuild workarounds from the FastLED build orchestration. Several patches were added to dodge bugs in zccache (the upstream compiler cache, pinned >=1.12.7) or in older meson; some of those upstream fixes have shipped, and the local workarounds still pay their cost on every build. This issue catalogs the fix-now items, the items blocked on upstream zccache work, and the items blocked on upstream meson work, so we can land the cheap wins immediately and file targeted upstream PRs for the rest.

This is the deliverable from a 5-agent codebase audit; findings are cited with file:line and quoted evidence.


Section A — Fix-now (no upstream blocker)

These are workarounds for bugs that have already been fixed upstream OR for FastLED-local bugs that can be tightened today. Each is a small PR that should reduce build time on master without losing correctness.

A1. Drop cleanup_stale_meson_lockfile() — meson floor is now ≥ 1.11.0

  • Location: ci/meson/meson_markers.py:27-65; called from ci/meson/meson_setup_execute.py:631, 640, ci/wasm_build.py:484, 702, 733, ci/meson/sequential_runner.py.
  • What it does: On Windows, deletes meson-private/meson.lock before every meson setup.
  • Why it was added: Workaround for the pre-1.11.0 meson DirectoryLock crash. Comment at meson_markers.py:32-34 explicitly says "meson 1.11.0 fixed the crash itself".
  • Current floor: pyproject.toml pins meson >= 1.11.0. The crash cannot happen.
  • Fix: Remove the helper and its three call sites. ~80 LOC delta. Saves ~50-150 ms per bash test startup on Windows.

A2. Narrow STALE_BUILD_PATTERNS — stop nuking artifacts on plain "file not found"

  • Location: ci/meson/compile.py:55-74 defines the pattern list; recovery in ci/meson/runner_helpers.py:76-189 (_recover_stale_build), wired from ci/meson/streaming_runner.py:377-397 and ci/wasm_build.py:424-496.
  • Current trigger set: ["file not found", "no such file or directory", "missing and no known rule to make it", "does not exist", "has been modified since the precompiled header", "target not found"]. Any compile output containing one of these strings triggers a full cleanup_build_artifacts() (deletes all .obj/.a/.exe/.pch/.lib/.dll/.so/.dylib) plus forced meson setup --reconfigure.
  • Problem: "file not found", "target not found", and "does not exist" are routine substrings in legitimate compiler errors (user typo'd a header, missing include, etc.). Each false positive costs a ~20-30 s full artifact rebuild on the retry.
  • Fix: Require the line to start with ninja: error: or match a ninja-graph-specific phrase ("manifest contains a cycle", "FAILED: regen"). The narrow patterns still catch the legitimate stale-build cases; user typos no longer pay the artifact-wipe tax.

A3. Detach zccache version change from full artifact wipe

  • Location: ci/meson/build_config.py:254-300; cleanup at ci/meson/meson_cleanup.py:21-95.
  • What it does: When the detected zccache version string changes between builds, calls cleanup_build_artifacts() (wipes .obj/.a/.exe/.pch/.lib/.dll/.so/.dylib) and forces reconfigure.
  • Problem: zccache is a cache layer, not a codegen layer. A zccache version bump that doesn't change the cache-key format does not require nuking object files — zccache itself will just miss on the new version and recompile. Comment cites this as defense-in-depth from a prior era.
  • Fix: Drop the full wipe for zccache-only deltas. Keep the wipe for clang-version deltas (defensible — codegen can change). Saves a full rebuild every time uv sync pulls a patch-level zccache bump.

A4. Stop hashing .venv/ in WASM-build src-list invalidation

  • Location: ci/wasm_build.py:660-713 (ensure_meson_configured); sister logic in ci/meson/meson_setup_phases.py:359-385 (check_meson_build_modified).
  • What it does: Hashes the file list of src/** on every build and forces meson setup --reconfigure on any add/remove. Cost: 15-22 s reconfigure per source-file add/remove.
  • Problem: meson 1.11+ handles files() glob rescans transparently. The explicit reconfigure is belt-and-suspenders that bloats every "add one .cpp file" cycle into a 20 s tax.
  • Fix: Profile against meson 1.11.0's glob-rescan behavior; drop the explicit reconfigure unless it's still needed.

A5. Stop running _invalidate_stale_pchs + normalize_meson_private_include_paths on every compile

  • Location: ci/meson/compile.py:99-104, 165-189.
  • What it does: On every compile_meson() call (incremental builds included), walks build_dir.rglob("*.pch") and re-hashes each PCH depfile, then re-reads/rewrites build.ninja and compile_commands.json through the strict-path regex.
  • Cost per build: ~5-20 ms (small, but on every incremental).
  • Fix: Skip these passes when build.ninja mtime is unchanged since the last successful normalize. Track via a single sidecar marker. The cost itself is small but the principle matters — incremental "nothing changed" builds should do nothing.

A6. Remove redundant runtime DLL PATH injection if ZCCACHE_LINK_DEPLOY_CMD proves sufficient

  • Location: examples/meson.build:313, tests/meson.build:156-160, ci/meson/native/meson.build:506-512, ci/meson/get_runtime_dll_paths.py. Companion ZCCACHE_LINK_DEPLOY_CMD=clang-tool-chain-libdeploy set at ci/meson/runner_helpers.py:374-375.
  • What it does: Prepends clang-tool-chain runtime DLL dirs to test_env, plus sets the upstream-blessed ZCCACHE_LINK_DEPLOY_CMD (the zccache#33 fix). The commit message that added the env var explicitly says "runtime_dll_paths PATH workaround is kept as belt-and-suspenders."
  • Fix: Bench-test removing the PATH injection on a branch. If tests stay green for a week, drop ~30 LOC of meson glue.

A7. Probe-and-remove the Windows CI zccache stop step

A8. Re-evaluate clear_zccache_stats() — stale "1.0.3 doesn't support --zero-stats" comment

  • Location: ci/util/zccache_config.py:66-72.
  • What it does: No-op, with a comment citing "zccache 1.0.3 does not support --zero-stats."
  • Current floor: 1.12.7. The comment is from a much earlier era.
  • Fix: Confirm 1.12.7 supports the flag, then make the function actually clear stats so per-build numbers are accurate.

A9. Probe-and-remove ZCCACHE_PROBE_BYPASS=1 setdefault

  • Location: ci/meson/runner_helpers.py:377-383.
  • What it does: Bypasses zccache for sub-4 KiB try-compile probes (saves 7-10 s/configure when added).
  • Status: Possibly internalized in newer zccache. Verify against 1.12.7 with a no-bypass benchmark; remove if probe overhead is now low enough.

A10. Delete stale 2,500-line ci/util/meson_runner.py.backup

  • Location: ci/util/meson_runner.py.backup.
  • What it is: Backup of the old runner from a refactor. Pure housekeeping.
  • Fix: Delete.

A11. Drop depends: [fastled_lib] from test_pch custom_target

  • Location: tests/meson.build:38.
  • What it does: Declares the PCH custom_target as depending on fastled_lib. Comment says "Ensure library is built first (tests link against it)" — but the PCH compiles from headers; the test-link dependency is separate (tests/meson.build later) and doesn't gate the PCH.
  • Effect: Every relink of fastled.dll serializes ahead of test_pch.h.pch's staleness check, even though the PCH inputs are static headers. Ninja's restat=1 saves downstream test DLLs, but the wall-clock dependency still gates the graph for ~241 test DLLs.
  • Fix: Remove depends: [fastled_lib]. PCH inputs are headers; ninja's deps=gcc depfile already tracks them.

A12. Cache tests/profile/ source list — violates "NO Embedded Python Scripts" rule

  • Location: tests/profile/meson.build:14-30.
  • What it does: Inline python -c '...glob.glob(...)' at meson configure time. ~50-150 ms per reconfigure with no caching.
  • Rule violated: agents/docs/build-system.md:213 "NO Embedded Python Scripts".
  • Fix: Extract to tests/profile/discover_profile_tests.py and add a profile_metadata_cache.py mirror of the existing tests/test_metadata_cache.py pattern. Or inline the glob into the existing test_metadata_cache (both walk tests/).

A13. Fix .c file extension omission in FingerprintManager

  • Location: ci/util/test_types.py:455, 461, 519, 527 — globs are "**/*.h,**/*.cpp,**/*.hpp". ci/util/unified_test_cache.py:18-46 correctly includes .c. The two layers disagree.
  • Symptom: Editing a .c file in src/ does NOT change the cpp_test/examples fingerprint, so the test layer may incorrectly skip a run when a .c file is the only change.
  • Fix: Add **/*.c to all four glob strings. Pure FastLED-side bug, no upstream blocker.

Section B — Workarounds whose upstream fix shipped — verify and remove

These need a quick benchmark/audit pass before removal. The upstream fix is in the pinned version, but the local workaround may still be required as belt-and-suspenders or because the fix is partial.

B1. PCH path-spelling drift workarounds (zccache#619)

  • Local impact: 14 files carry "removed redundant #include "fl/stl/cstdio.h"" comments with zccache#619 citations. Files include tests/timeout_watchdog.h:30, src/fl/stl/istream.h:10, src/fl/system/engine_events.cpp.hpp:4, the src/fl/net/http/*.cpp.hpp family, and others.
  • Audit needed: Confirm zccache#619 is closed in 1.12.7. If yes, revert the explanatory comments and possibly re-add the previously-redundant includes (if the original include structure was correct and these were defensive removals).

B2. --backend=platformio pin for binary-size guards


Section C — Blocked on upstream zccache work

These require a fix in the upstream zackees/zccache repository before the FastLED-side workaround can be removed. Each item should produce a targeted upstream issue or PR; the local workaround stays until the fix ships and the floor is bumped.

C1. Restore link-output mtime to "now" on cache hit

  • Local workaround: ci/meson/mtime_stabilizer.py (entire 117-LOC file). Touches ~190 DLLs + runner exes after every compile because zccache restores cached link outputs with their ORIGINAL mtime; ninja then re-links the world every build.
  • Upstream request: ZCCACHE_RESTORE_MTIME={preserve,now} env var (default now for .dll/.exe/.so/.dylib), or implicit "current time" restore for executable artifacts.
  • Savings on removal: 1-2 s per build × every developer × every build. Deletes mtime_stabilizer.py.

C2. Exclude PCH artifacts from zccache meson configure snapshot (zccache#710)

  • Local workaround: ci/meson/meson_setup_execute.py:548-578 (_purge_restored_pch_artifacts). Walks the build dir and deletes every *.pch, *.pch.input_hash, *.d.cache after detecting [zccache-meson] hit.
  • Upstream status: zccache#710 partially fixed in 1.12.5 (native-file lifecycle), but PCH-content drift is still in tree.
  • Upstream request: zccache meson configure --snapshot-exclude "*.pch" --snapshot-exclude "*.input_hash" --snapshot-exclude "*.d.cache", or auto-classify .pch as non-snapshottable.
  • Savings on removal: 1-3 s PCH rebuild per meson-cache hit.

C3. Detach zccache wrappers from build-dir CWD on Windows

  • Local workaround: ci/meson/runner_helpers.py:206-237 (_kill_zombie_zccache). Walks every process via psutil, kills any zccache.exe whose CWD is inside the build dir. Sleeps 500 ms.
  • Why: zccache wrappers survive ninja interruption (they talk to a daemon, not parented to ninja) and hold a kernel handle on the build directory on Windows, blocking rmtree.
  • Upstream request: Wrapper should SetCurrentDirectory(GetTempPath()) (Windows) or chdir("/") (POSIX) immediately after forwarding compile args to the daemon.
  • Savings on removal: bash test --clean reliability on Windows; ~30 LOC of psutil-walking goes away.

C4. Canonicalize PCH path spellings (zccache#619 deeper fix)

  • Local workaround: Documented in B1 above (14 files with explanatory comments).
  • Symptom: C:/.../src\fl/stl/cstdio.h (mixed slashes) and the PCH-cached path don't dedupe, defeating #pragma once.
  • Upstream request: zccache should canonicalize all -I roots + relative include hits to a single spelling before hashing/PCH-keying. This is the underlying fix; B1 is just removing the FastLED-side defensive scrubbing.

C5. Make meson recognize zccache as a cache prefix

  • Local workaround: ci/meson/meson_markers.py:292-374 (inject_zccache_wrapping) + ci/meson/native_launchers.py:296-321. ~150 LOC of post-build.ninja-patching to wrap the 4 Ninja compile/link rules with zccache, because meson's BinaryTable.parse_entry only strips the literal "ccache"/"sccache" heads.
  • Upstream paths to fix: (a) Submit a meson PR to add "zccache" to the strip-list, OR (b) ship a sccache-named shim binary in the zccache wheel.
  • Savings on removal: ~150 LOC of build glue + eliminates the >90 s hang from the <cc> -xc++ -E -v - configure probe seeing full-path zccache.

C6. Verify per-version daemon namespacing (zccache#759/#760/#761/#762/#763)

  • Local workaround: ci/util/fbuild_runner.py:101-113. Prepends .venv/Scripts/ to PATH so a globally-installed zccache.exe cannot collide with the venv one (cross-version daemon corruption: 5 GB daemon balloons, locked named pipes).
  • Upstream status: 1.12.7 ships version-namespaced cache root (ESP32 crash after incorrect WiFi connection #763). Need to verify whether the daemon named pipe + lockfile are also version-namespaced. If yes, the PATH-prepend is removable.

C7. Restore PCH chain compatibility (currently disabled in test_pch.h)

  • Local workaround: tests/test_pch.h:8-11 includes FastLED.h directly rather than chaining the existing FastLED.h.pch. Comment: "zccache's PCH path could update FastLED.h.pch mtime after test_pch.h.pch was built, causing clang to reject the chain with 'module file has a different size or modification time than expected.'"
  • Upstream request: zccache needs to preserve PCH mtime semantics across chained PCH writes — restoring a cached PCH must not bump the mtime relative to a downstream chained PCH.
  • Cost of workaround: test_pch re-traverses all ~1,170 transitive headers from FastLED.h. Re-enabling the chain after the fix would cut test-PCH compile time substantially.

Section D — Blocked on upstream ninja / meson work

D1. Ninja recompact crash defuse (ninja-build/ninja#2787)

  • Local workaround: ci/meson/build_config.py:352-470 (perform_ninja_maintenance).
  • Upstream: open ninja issue. KEEP until resolved.

D2. Per-minor-version meson build-dir incompatibility

  • Local workaround: ci/meson/build_config.py:141-165. Compares meson version recorded in build_dir to current; mismatch → full artifact wipe + reconfigure.
  • Comment: "Meson 1.9.x and 1.10.x produce incompatible build directories."
  • Upstream: meson upstream should make build dirs forward-compatible across minor versions, OR document an allow-list of safe transitions so we can narrow the wipe trigger.

Section E — Couldn't tell / needs human eyes

  • E1. .intro_corruption_detected marker logic (ci/meson/meson_setup_phases.py:179-207) — needs root-cause investigation. Possibly related to zccache#710 PCH-snapshot drift.
  • E2. ZCCACHE_STRICT_PATHS=absolute setdefault — added gradually. Unclear from messages whether redundant given zccache#763's version-namespaced root.
  • E3. _start_zccache_session() heavy --stats/--log/--journal instrumentation — added during the daemon-flake debug push; may still be the diagnostic anchor or may be dead weight now.

Execution order (recommended)

  1. Section A fix-now items in PR-sized chunks — A1 (lockfile cleanup), A10 (backup deletion), A11 (test_pch dep), A13 (.c extension fix) are 30-minute PRs. Land first.
  2. Section A probe-and-remove items — A6, A7, A9 each need a "remove on branch, watch CI for a week, then merge or revert" cycle. Run in parallel.
  3. Section A architectural items — A2 (narrow stale patterns), A3 (decouple zccache version wipe), A4 (WASM glob rescan), A5 (skip-when-unchanged guards) need testing across modes (debug/quick/release) before landing.
  4. Section B verify items — confirm upstream state, then revert.
  5. Section C upstream issues — file each as a zackees/zccache issue (or PR) with the reproducer pulled directly from this audit. Tag this issue when each lands. Don't remove the FastLED-side workaround until the floor is bumped to the version containing the fix.
  6. Section D — keep workarounds; monitor upstream issues.

Acceptance criteria

  • All Section A items resolved (landed, reverted-after-probe, or explicitly deferred with a comment).
  • Section B items each have a follow-up issue OR are resolved with a revert PR.
  • Section C items each have a corresponding zackees/zccache upstream issue filed and linked back here.
  • Section D items remain in tree, documented inline with the upstream tracker URL.
  • One representative benchmark before/after the Section A cleanups: cold bash test --cpp and warm "no-op" bash test --cpp wall-clock on Windows.

Out of scope

cc: @zackees

Generated with Claude Code.

Activity

  1. added
    type: feature
    priority: medium
    area: ci
    on Jun 16, 2026
  2. zackees commented on Jun 17, 2026

    @zackees
    MemberAuthor

    Status update on Section A — 12 of 13 items handled.

    Merged so far (10): A1, A2, A3, A7, A8, A9, A10, A11, A12, A13.

    Currently open: A5 (#3206), A6 (#3205) — probe.

    Deferred with documented reason: A4 (Stop hashing .venv/ in WASM src-list invalidation).

    A4 deferral note

    The audit's title is imprecise — _compute_src_file_list_hash hashes the src/** file list, not .venv/. The audit's claim that "meson 1.11+ handles files() glob rescans transparently" doesn't hold in this codebase:

    • meson.build discovers sources via run_command(rglob_script, 'src', '*.cpp') and wraps the result in files(...).
    • files() tracks the specific paths handed to it; meson does not re-evaluate the run_command discovery on every build. Only meson setup re-runs the discovery.
    • meson setup is not auto-triggered by ninja when a source file is added — that's the gap the wasm-side hash currently fills (compute current file list, compare to marker, force meson setup --reconfigure on delta).

    Dropping the hash trigger would save 15–22 s per source-file add/remove cycle, but at the cost of the new file being silently absent from the build graph until the user manually runs bash compile wasm --clean. That trade-off is worse than the wall-clock saving for normal dev flow.

    The cleaner long-term fix is to switch meson.build source discovery from run_command to fs.glob('src/**/*.cpp'), which meson does re-evaluate on every build. That is a separate, larger change and is out of scope for the #3129 "fix-now" cleanup batch.

    Action: A4 closed as not-applicable-without-deeper-refactor. Filing a follow-up issue if desired.


    Section A acceptance status: 12/13 items resolved (10 merged + 1 in-flight + 1 deferred-with-reason).

    🤖 Generated with Claude Code

  3. zackees commented on Aug 20, 2026

    @zackees
    MemberAuthor

    Burn-down disposition: DEFER ? the bounded FastLED cleanups landed, but the remaining issue is an upstream coordination and measurement program.

    Current acceptance audit:

    Restart criteria:

    1. Re-audit each remaining workaround against the current zccache/fbuild/Meson/Ninja versions (the issue's original 1.12.7 floor is stale).
    2. File or map one upstream tracker per C1?C7 item, with a minimal reproducer and the exact FastLED workaround it would retire.
    3. Resolve B1 against current zccache FastLED.show() causes servo to twitch #619 behavior and remove only comments/workarounds proven unnecessary; record B2's fbuild Typos #297/WS2812B on ESP8266: LEDs 'leaking through' #309 disposition.
    4. Add explicit upstream URLs for both Section D guards and retain them until the corresponding versions are proven fixed.
    5. Capture reproducible Windows cold and warm/no-op benchmarks on the same SHA/toolchain/cache state and publish the result.
    6. Close this meta only when every row maps to a merge, an upstream tracker, or an explicit retained-workaround decision.

    The merged local PRs are valid wins, but they do not satisfy the meta's upstream and benchmark close gates.

  4. added
    deferred
    on Aug 20, 2026
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

    area: cideferredpriority: mediumtype: feature

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions