Skip to content

Meta: flaky test-DLL load failures (error 126) — zccache ↔ clang-tool-chain post-link deployment gap #2329

Closed

Description

@zackees

Meta issue

This issue is a tracker — the real fixes are upstream. Linking them so FastLED's side of the fix lands in lockstep.

Symptom on FastLED

Under parallel quick-mode test runs on Windows, a small subset of test DLLs intermittently fail to load with:

Error: Failed to load C:\...\fl_math_lut.dll (error code: 126)
Error: Failed to load C:\...\fl_math_filter_filter.dll (error code: 32)
Error: Failed to load C:\...\fl_math_simd.dll (error code: 126)
Error: Failed to load C:\...\fl_math_screenmap.dll (error code: 126)
Error: Failed to load C:\...\fl_stl_fstream.dll (error code: 126)
  • Error 126 = STATUS_DLL_NOT_FOUND — a runtime dependency DLL was not on the search path when the loader resolved imports.
  • Error 32 = ERROR_SHARING_VIOLATION — file-lock contention, usually from another worker still holding the DLL.

All five pass when re-run individually in --debug mode. They are real tests with real logic; the failure is a load-time flake, not a test-logic bug.

Root cause

Two pieces interact:

  1. clang-tool-chain ships a MinGW/clang toolchain with runtime DLLs (libwinpthread-1.dll, libstdc++-6.dll, libclang_rt.asan_dynamic-x86_64.dll, …). The ctc-clang++ driver has a post-link deployment step that copies these DLLs next to the binary it just linked, so the binary loads on any machine without PATH gymnastics.

  2. zccache is a compile/link cache that wraps ctc-clang++. When a link is a cache hit, zccache writes the cached binary directly — the driver is bypassed. The deployment step never runs. The cached binary lands next to an empty directory.

FastLED's existing mitigation lives in ci/meson/native/meson.build (see the comment around runtime_dll_paths): we query clang-tool-chain for its runtime directories and prepend them to PATH before running tests. This works most of the time. Under 16-worker parallel load, the loader occasionally can't resolve a runtime DLL before another worker's test locks / releases it, producing intermittent 126/32 errors on the heaviest tests (fl_math_simd's AVX-512 runtime, fl_stl_fstream's libstdc++ chain).

Why it's a two-sided fix

The gap isn't fixable cleanly in FastLED alone:

  • zccache has no post-link hook — grep confirms no post_link / link_hook / after_link plumbing in the package. When a link cache hit serves, nothing runs against the output file.
  • clang-tool-chain-libdeploy exists and is exactly the tool we'd want to invoke — but it has no documented argv contract or --json manifest mode that a wrapper like zccache can lean on. Each wrapper would have to reverse-engineer the invocation.

Both sides need a small, well-scoped change:

Side Repo Issue Summary
Deployment tool zackees/clang-tool-chain #7 Make libdeploy wrapper-friendly: stable argv, --json / --dry-run / --if-missing
Cache wrapper zackees/zccache #33 Add post-link hook so cached link outputs invoke libdeploy

Both land → the integration wires through automatically: when zccache serves a cached link, its post-link hook calls clang-tool-chain-libdeploy <output>, and the runtime DLLs materialize in the output dir the way they would have on a fresh build. Flake disappears.

FastLED-side work (once upstream lands)

Minimal — this is a tracker, not an implementation issue:

  1. Bump pinned versions of zccache and clang-tool-chain in pyproject.toml / install scripts once both issues land.
  2. Opt into the hook — register clang-tool-chain-libdeploy as zccache's post-link command via whatever surface the fix exposes (CLI flag, config file, env var).
  3. Remove the PATH workaround in ci/meson/native/meson.build (runtime_dll_paths + test_env.prepend('PATH', ...)) — it becomes unnecessary once DLLs are co-located with binaries. Keep it as a belt-and-suspenders measure if review prefers.
  4. Delete the known-flake retry logic (if any exists for these five tests) — the flake should be gone.
  5. Lint: add a CI check that runs clang-tool-chain-libdeploy --json after the test build and fails if any test DLL has unresolved runtime deps in its sibling dir. Turns a silent regression into a build error.

Why keep this as a meta issue

  • Pinning the two upstream issues together so both teams can see the integration picture.
  • FastLED reviewers / future-agents seeing error 126 in CI can land here, see the two upstream links, and know exactly what's blocking vs what's fixed.
  • When both upstream issues close, this one closes with the version bump + workaround removal PR.

Repro

bash test --cpp --clean

under parallel load. Hits the flake roughly 1 in 3 runs on my box (Windows 10, 16 cores, zccache 1.2.11, clang-tool-chain 1.2.6). Re-running each failed test individually (bash test <name> --debug) always passes — confirms the issue is load-time, not logic.

Related

Activity

  1. zackees commented on Apr 18, 2026

    @zackees
    MemberAuthor

    Refined design: one fix, in zccache only

    Pivot on the upstream approach. The original plan paired a zccache post-link hook with a clang-tool-chain libdeploy --json contract, but the simpler and better design lives entirely in zccache:

    zccache caches the full artifact set (the -o output plus every sibling file the driver produced in the output directory), not just the named output.

    See zccache#33 refined proposal: forge-ci/zccache#33 (comment).

    Why this is better than the original pairing

    • No coordination between upstream repos. One change in zccache is sufficient.
    • Zero config for consumers. FastLED doesn't need to configure a post-link command anywhere.
    • Toolchain-agnostic. Same mechanism covers MinGW DLLs, sanitizer runtimes, .pdb debug files, WASM sidecars, future driver outputs we don't know about yet.
    • Deterministic. Cache captures the exact byte set the fresh link produced — immune to future toolchain policy shifts.
    • Self-healing. Manually delete a runtime DLL → next cache hit restores it.

    Updated status

    Upstream Issue Status Blocker for this meta?
    zackees/zccache #33 Pivoted to artifact bundling Yes — sole blocker
    zackees/clang-tool-chain #7 Downgraded to nice-to-have No

    FastLED-side close-out (revised)

    1. Bump pinned zccache version once the artifact-bundling fix lands.
    2. No config change required — zccache just starts caching full artifact sets automatically for link invocations.
    3. Remove the runtime_dll_paths / test_env.prepend('PATH', ...) workaround in ci/meson/native/meson.build — runtime DLLs will be co-located with every cached test DLL.
    4. Optional CI lint using clang-tool-chain-libdeploy --json (blocked on #7) to catch silent regressions — not required for the core fix.

    Close this meta when step 1–3 are done and CI is stable over ~10 consecutive full test runs.

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