0
Fork 0
mirror of https://codeberg.org/ziglang/zig synced 2026-11-18 07:05:05 +00:00
zig/lib/std/Build
Matthew Lugg 989b6a1b93 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.
History 2026-05-07 19:45:37 +02:00
..
Cache std.Io.File: Remove deprecated option types 2026-05-05 04:12:52 +02:00
Step std: rename bit_set variants and deprecate the managed one. 2026-04-27 16:46:26 +02:00
Watch std.mem.Allocator: Remove dupeZ() in favor of dupeSentinel() 2026-05-03 21:42:16 +01:00
abi.zig std.meta: Remove Int in favor of @Int 2026-05-03 21:42:06 +01:00
Cache.zig Prefer <err> => |e| return e over <err> => return <err> 2026-04-20 18:03:14 -07:00
Fuzz.zig multiprocess fuzzing 2026-04-03 12:27:34 +02:00
Module.zig std.Build.Module: fix dangling slice in dynamic linker arg 2026-04-02 15:19:14 +02:00
Step.zig std.Build: clear step inputs when resetting the step 2026-05-07 19:45:37 +02:00
Watch.zig windows: use enums for boolean types 2026-03-20 02:25:16 +01:00
WebServer.zig Prefer <err> => |e| return e over <err> => return <err> 2026-04-20 18:03:14 -07:00