Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--watch does not pick up sub-Compilation file system inputs such as compiler_rt, glibc, or musl source files #20601

Open
andrewrk opened this issue Jul 13, 2024 · 0 comments
Labels
bug Observed behavior contradicts documented or intended behavior frontend Tokenization, parsing, AstGen, Sema, and Liveness.
Milestone

Comments

@andrewrk
Copy link
Member

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:

pub fn update(comp: *Compilation, main_progress_node: std.Progress.Node) !void {

In this function:

  • Pay attention to how comp.file_system_inputs is modified
  • Note this comment:

    zig/src/Compilation.zig

    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.

@andrewrk andrewrk added bug Observed behavior contradicts documented or intended behavior frontend Tokenization, parsing, AstGen, Sema, and Liveness. labels Jul 13, 2024
@andrewrk andrewrk added this to the 0.14.0 milestone Jul 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Observed behavior contradicts documented or intended behavior frontend Tokenization, parsing, AstGen, Sema, and Liveness.
Projects
None yet
Development

No branches or pull requests

1 participant