diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2024-12-11 14:57:11 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-12-11 14:57:11 -0500 |
| commit | 3670910f20b56eda41a27ed7c4bb887f870cfc5d (patch) | |
| tree | 34e964ab79340005fe211292876fb8a0ec963b30 /src/Compilation.zig | |
| parent | 295c5a64f5746a10259b5fb0799415db023975c7 (diff) | |
| parent | 7ff42eff914e2e501f570bb8c530719bb3a2521a (diff) | |
| download | zig-3670910f20b56eda41a27ed7c4bb887f870cfc5d.tar.gz zig-3670910f20b56eda41a27ed7c4bb887f870cfc5d.zip | |
Merge pull request #22202 from ziglang/Cache.hit
std.Build.Cache.hit: more discipline in error handling
Diffstat (limited to 'src/Compilation.zig')
| -rw-r--r-- | src/Compilation.zig | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/src/Compilation.zig b/src/Compilation.zig index c198b5af82..5f4404ff99 100644 --- a/src/Compilation.zig +++ b/src/Compilation.zig @@ -2048,15 +2048,30 @@ pub fn update(comp: *Compilation, main_progress_node: std.Progress.Node) !void { whole.cache_manifest = &man; try addNonIncrementalStuffToCacheManifest(comp, arena, &man); - const is_hit = man.hit() catch |err| { - const i = man.failed_file_index orelse return err; - const pp = man.files.keys()[i].prefixed_path; - const prefix = man.cache.prefixes()[pp.prefix]; - return comp.setMiscFailure( + const is_hit = man.hit() catch |err| switch (err) { + error.CacheCheckFailed => switch (man.diagnostic) { + .none => unreachable, + .manifest_create, .manifest_read, .manifest_lock => |e| return comp.setMiscFailure( + .check_whole_cache, + "failed to check cache: {s} {s}", + .{ @tagName(man.diagnostic), @errorName(e) }, + ), + .file_open, .file_stat, .file_read, .file_hash => |op| { + const pp = man.files.keys()[op.file_index].prefixed_path; + const prefix = man.cache.prefixes()[pp.prefix]; + return comp.setMiscFailure( + .check_whole_cache, + "failed to check cache: '{}{s}' {s} {s}", + .{ prefix, pp.sub_path, @tagName(man.diagnostic), @errorName(op.err) }, + ); + }, + }, + error.OutOfMemory => return error.OutOfMemory, + error.InvalidFormat => return comp.setMiscFailure( .check_whole_cache, - "unable to check cache: stat file '{}{s}' failed: {s}", - .{ prefix, pp.sub_path, @errorName(err) }, - ); + "failed to check cache: invalid manifest file format", + .{}, + ), }; if (is_hit) { // In this case the cache hit contains the full set of file system inputs. Nice! |
