-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Description
Extracted from #20580.
Zig version: 0.14.0-dev.283+1d20ff11d
Steps to reproduce:
In an empty directory:
$ zig init
info: created build.zig
info: created build.zig.zon
info: created src/main.zig
info: created src/root.zig
info: see `zig build --help` for a menu of options
$ zig build --watch
andy@bark ~/t/abc> zig build --watch
Build Summary: 5/5 steps succeeded
install success
├─ install abc success
│ └─ zig build-lib abc Debug native success 702ms MaxRSS:195M
└─ install abc success
└─ zig build-exe abc Debug native success 759ms MaxRSS:198M
Watching 21 Directories
Then go make a change to lib/zig/compiler_rt.zig in the lib directory corresponding to the zig compiler you are using.
The file is not being watched; no changes are picked up. Instead, changes to compiler_rt and other sub-compilations should be noticed and trigger a recompilation.
The mechanism behind this is in Compilation.update:
Line 2013 in 1d20ff1
| pub fn update(comp: *Compilation, main_progress_node: std.Progress.Node) !void { |
In this function:
- Pay attention to how
comp.file_system_inputsis modified - Note this comment:
Lines 2116 to 2121 in 1d20ff1
// From this point we add a preliminary set of file system inputs that // affects both incremental and whole cache mode. For incremental cache // mode, the long-lived compiler state will track additional file system // inputs discovered after this point. For whole cache mode, we rely on // these inputs to make it past AstGen, and once there, we can rely on // learning file system inputs from the Cache object. - Notice how the Cache Manifest object is the authority on file inputs, but only when using whole cache mode, and it is either a hit, or a successful compilation.
In a future enhancement, the build runner should pass in the set of modified file system inputs to the update() function directly, so that the fstat calls are avoided. That should be a follow-up issue when closing this one.