Skip to content

fbuild build -c creates a stray 0-byte file named -r in the CWD when zccache-fp is on PATH #1267

Closed

Description

@zackees

Summary

fbuild build -c creates a stray 0-byte file literally named -r in the process's current working directory. It appears only when zccache-fp is resolvable on PATH.

Reproduced deterministically with fbuild 2.5.14 and zccache 1.13.0 on Windows 10 / Git Bash.

Minimal reproduction — no FastLED Python involved

Run fbuild.exe directly from an arbitrary empty directory:

$ cd /some/empty/dir
$ rm -f -- ./-r
$ PATH="<venv>/Scripts;$PATH" fbuild.exe "<project-dir>" build -e teensy41 -c
build succeeded in 37.8s (flash: 72704 bytes, ram: 81984 bytes)
$ ls -la -- ./-r
-rw-r--r-- 1 ... 0 Aug  6 19:20 ./-r      # <-- stray

Now put only zccache.exe and zccache-daemon.exe on PATH (i.e. withhold zccache-fp.exe), everything else identical:

$ PATH="<dir with only zccache.exe + zccache-daemon.exe>;$PATH" fbuild.exe "<project-dir>" build -e teensy41 -c
build succeeded in 45.9s (flash: 72704 bytes, ram: 81984 bytes)
$ ls -la -- ./-r
ls: cannot access './-r': No such file or directory

Both runs did real work (37.8s / 45.9s, identical flash+ram output), so this is not a no-op-build artifact — I specifically re-ran with timings visible because a cached no-op build produces a false negative here.

Characterisation

  • Name: literally -r. The leading dash makes it hostile to clean up — rm -r is a very different command; you need rm -- -r.
  • Size: always 0 bytes.
  • Location: the process CWD, not the project dir. Running fbuild from a scratch directory drops it there instead.
  • Timing: created during the Linking firmware.elf stage (caught by polling a watcher at 20 ms and snapshotting the verbose log at that instant).
  • Trigger: only on builds that do real work. A no-op rebuild never produces it; -c reproduces every time.
  • Requires: zccache-fp.exe resolvable on PATH. With zccache.exe + zccache-daemon.exe alone it never appears.
  • Failure is swallowed: pre-creating a directory named -r blocks the write, and the build still succeeds with no diagnostic at all. Whatever creates it ignores the error.

Notes toward a root cause

  • Direct invocations of zccache-fp.exe (check, check --root ., check -r ., mark-success) do not create the file, so it does not look like zccache-fp writing it of its own accord.
  • zccache-fp check exposes --root with no -r short form, so a -r token in a generated command line would be a parse error rather than a path.
  • fbuild.exe contains embedded zccache fingerprint strings (embedded fingerprint check failed for, embedded fingerprint mark-success failed for, .zccache_fp.json, stamp_cache.json) and the project build dir gets a .project.zccache_fp.stamp_cache.json. So fbuild appears to use an embedded fingerprint path whose enablement is gated on zccache-fp being present on PATH.
  • fbuild.exe contains no --root / --ext / --exclude / --cache-type strings, so it does not appear to shell out to zccache-fp with those flags.
  • The 0-byte size plus swallowed error is consistent with a File::create() on a path variable that ended up holding the string -r — e.g. a flag token mistaken for a path while parsing a tool invocation. The ar operation string (-rcs / r) around archive creation, immediately before linking, is where I would look first, especially with lib_archive = true.

I could not confirm the exact call site from the stripped binary; the above is where the evidence points, not a diagnosis.

Impact

The CWD is typically the consuming repo's root, so every clean build dirties a clean working tree with an untracked -r. That breaks any workflow (human or agent) that asserts a clean tree before committing, and the leading dash makes accidental rm -r mistakes easy.

Downstream report: FastLED/FastLED#3867.

Acceptance criteria

  • A clean fbuild build -c with zccache-fp on PATH leaves the CWD unchanged.
  • Whatever performs the write either uses a correct path or fails loudly instead of silently swallowing the error.

Activity

  1. zackees commented on Aug 7, 2026

    @zackees
    MemberAuthor

    Root cause found — and a correction to this report

    Correction first: I filed this saying zccache-fp on PATH was the gate, based on it reproducing with all three zccache binaries present and not reproducing twice without zccache-fp.exe. That was a red herring. This bug is intermittent — as sweep_stray_dash_files' own comment in crates/fbuild-deploy/src/teensy/flash.rs already noted ("intermittently drop a 0-byte -r") — and two clean negatives were luck, not causation. zccache is not involved. Apologies for sending anyone down that path.

    Actual cause: crates/fbuild-build-arm/src/teensy/teensy_linker.rs passes None as the working directory to run_command, on both the response-file and direct-args branches. So arm-none-eabi-gcc — and the collect2 / lto-wrapper processes it spawns under -flto=auto -fuse-linker-plugin — run in the cwd the daemon inherited, normally the user's project root. Those helpers write scratch files relative to the process cwd.

    That explains every observation cleanly, including the ones that confused me:

    • CWD-relative — it follows wherever fbuild was invoked, not the project dir.
    • Exactly at Linking firmware.elf — caught with a 20 ms watcher snapshotting the verbose log.
    • Only on real work — no link, no stray.
    • Intermittent — which is what produced my false zccache-fp correlation.

    Notably flash.rs already fixed this exact thing for the deploy path, and its comment states the remedy plainly: "Run the loader in the firmware's own build directory rather than inheriting the daemon's working directory (which is typically the user's project/repo root)." The build path simply never got the same treatment. It also completes #261, which redirected the env-based LTO temp dir but left cwd inherited.

    Fix in #1268. Verified before/after on a real FastLED teensy41 clean build: control (2.5.14) drops ./-r in the repo root; with the fix the repo root stays clean and the stray lands at .fbuild/build/release/-r inside the gitignored tree, with byte-identical artifacts.

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

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions