-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed
Labels
bugObserved behavior contradicts documented or intended behaviorObserved behavior contradicts documented or intended behaviorzig build systemstd.Build, the build runner, `zig build` subcommand, package managementstd.Build, the build runner, `zig build` subcommand, package management
Milestone
Description
Zig Version
0.14.0-dev.208+854e86c56
Steps to Reproduce and Observed Behavior
zig init
Add this code to build.zig
:
const wf = b.addWriteFiles();
b.installDirectory(.{
.source_dir = wf.addCopyDirectory(b.path("stuff"), "stuff", .{}),
.install_dir = .prefix,
.install_subdir = "",
});
$ mkdir stuff
$ touch stuff/1
$ zig build
$ ls zig-out/
1 bin lib
$ touch stuff/2
$ zig build
$ ls zig-out
1 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.
zig/lib/std/Build/Step/WriteFile.zig
Lines 271 to 276 in b3b923e
for (write_file.directories.items) |dir| { | |
man.hash.addBytes(dir.source.getPath2(b, step)); | |
man.hash.addBytes(dir.sub_path); | |
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.
bryanjhv
Metadata
Metadata
Assignees
Labels
bugObserved behavior contradicts documented or intended behaviorObserved behavior contradicts documented or intended behaviorzig build systemstd.Build, the build runner, `zig build` subcommand, package managementstd.Build, the build runner, `zig build` subcommand, package management