Files
Matthew Lugg aead9ea2ac std.Build: clear step inputs when resetting the step
Previously, when using `zig build -fincremental --watch some-run-step`,
if the binary initially builds fine but a future update introduces a
compile error, the old file system inputs of the `Step.Run`---containing
the executable file itself---would remain. This is a bug, because that
file *has* changed since the input was registered (due to incremental
compilation), and yet the `Run` step is not out-of-date because it was
skipped due to a transitive failure.

A simple reproduction for this issue was:

  $ zig init
  $ zig build test --watch -fincremental

Then, in another terminal, introduce a compile error:

  $ sed -i 's/const/onst/' src/main.zig

Before this commit, this would cause the `zig build` command to repeat
updates forever, separated only by the 50ms debounce interval.

To fix this, when we reset a step with intent to re-run it, we should
clear its inputs immediately, so that if the step is skipped, it is
correctly marked as having no inputs.

This relates to a more general problem with the file system watching
logic which is that the set of inputs includes files in the cache which
are actually artifacts of other steps. Eventually, the build system
should learn to identify such files and exclude them from the set of
file system inputs. In other words, the fact that a `Run` step depends
on the executable generated by a `Compile` step should be modeled by a
dependency in the build step graph, *not* by a dependency on the path
where the `Compile` step happens to have emitted its executable file.
2026-05-06 09:15:01 +01:00
..
2026-04-26 19:26:16 +02:00