You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
std.Build.Step.WriteFile does not implement caching correctly for directories #20571
$ mkdir stuff
$ touch stuff/1
$ zig build
$ ls zig-out/1 bin lib
$ touch stuff/2
$ zig build
$ ls zig-out1 bin lib
Expected Behavior
When running zig build the second time, it should notice that a second file exists (2) and copy it to the WriteFile output directory, and then copy it to the installation prefix.
Diagnosis
This happens because the implementation only adds the directory name to the cache hash, instead of marking the file and directory itself as part of the cache input.
for (dir.options.exclude_extensions) |ext|man.hash.addBytes(ext);
if (dir.options.include_extensions) |incs|for (incs) |inc|man.hash.addBytes(inc);
}
This is insufficient and results in false positive cache hits. False positives in the cache system are not allowed; this must be fixed to work perfectly or the feature reverted.
Activity
std.Build.Step.WriteFile: fix handling of directories
bryanjhv commentedon Jul 11, 2024
I faced this issue today, as
addCopyDirectorydoes not handle changes in files either (as of0.13.0).Solving it temporarily by setting
options.exclude_extensionsto some cache-busting value, like so:std.Build.Step.WriteFile: fix handling of directories
std.Build.Step.WriteFile: fix handling of directories
std.Build.Step.WriteFile: fix handling of directories
docs: workaround buggy cache invalidation in build.zig