diff --git a/lib/compiler/Maker/Step.zig b/lib/compiler/Maker/Step.zig index c3ff8962b0d5cd940a766c7b4e6aef9ed7faeb9c..117e9c9df53e3626f0c4cfd259cd41bb41878779 100644 --- a/lib/compiler/Maker/Step.zig +++ b/lib/compiler/Maker/Step.zig @@ -753,12 +753,13 @@ fn failWithCacheError( switch (err) { error.CacheCheckFailed => switch (man.diagnostic) { .none => unreachable, + .manifest_oversize => return s.fail(maker, "checking cache failed: {t}", .{man.diagnostic}), .manifest_create, .manifest_stat, .manifest_read, .manifest_lock => |e| { - return s.fail(maker, "failed checking cache: {t} {t}", .{ man.diagnostic, e }); + return s.fail(maker, "checking cache failed: {t} {t}", .{ man.diagnostic, e }); }, .file_open, .file_stat, .file_read, .file_hash => |op| { const path = op.path(man); - return s.fail(maker, "failed checking cache: {f} {t} {t}", .{ path, man.diagnostic, op.err }); + return s.fail(maker, "checking cache failed: {f} {t} {t}", .{ path, man.diagnostic, op.err }); }, }, error.OutOfMemory, error.Canceled => |e| return e, diff --git a/lib/std/Build/Cache.zig b/lib/std/Build/Cache.zig index 8d00a3384607eb684fb3860754bfe821618dc1b5..973488702c729c2e246b18db00db4daea831e8df 100644 --- a/lib/std/Build/Cache.zig +++ b/lib/std/Build/Cache.zig @@ -595,6 +595,7 @@ pub const Manifest = struct { none, manifest_create: Io.File.OpenError, manifest_stat: Io.File.StatError, + manifest_oversize, manifest_read: Io.File.ReadPositionalError, manifest_lock: Io.File.LockError, file_open: FileOp, @@ -1011,10 +1012,12 @@ pub const Manifest = struct { const io = m.cache.io; const manifest_file = m.manifest_file.?; - const manifest_size = if (manifest_file.stat(io)) |stat| stat.size else |err| switch (err) { + const manifest_stat = manifest_file.stat(io) catch |err| switch (err) { error.Canceled => |e| return e, else => |e| return fail(&m.diagnostic, .{ .manifest_stat = e }), }; + const manifest_size = std.math.cast(u32, manifest_stat.size) orelse + return fail(&m.diagnostic, .manifest_oversize); if (manifest_size == 0 or manifest_size < m.contents.items.len) { // Manifest file was never finalized. diff --git a/src/Compilation.zig b/src/Compilation.zig index fb4d0653f25f385a0d82e5a72ae73ac5f1805ab6..68c76dfd83bce307a45af5d0ed0c35f126316c64 100644 --- a/src/Compilation.zig +++ b/src/Compilation.zig @@ -2817,13 +2817,18 @@ pub fn update(comp: *Compilation, main_progress_node: std.Progress.Node) UpdateE error.Canceled, error.OutOfMemory => |e| return e, error.CacheCheckFailed => switch (man.diagnostic) { .none => unreachable, - .manifest_create, .manifest_stat, .manifest_read, .manifest_lock => |e| return comp.setMiscFailure( - .check_whole_cache, - "failed to check cache: {t} {t}", - .{ man.diagnostic, e }, - ), + .manifest_oversize => { + return comp.setMiscFailure(.check_whole_cache, "checking cache failed: {t}", .{ + man.diagnostic, + }); + }, + .manifest_create, .manifest_stat, .manifest_read, .manifest_lock => |e| { + return comp.setMiscFailure(.check_whole_cache, "checking cache failed: {t} {t}", .{ + man.diagnostic, e, + }); + }, .file_open, .file_stat, .file_read, .file_hash => |op| { - return comp.setMiscFailure(.check_whole_cache, "failed to check cache: {f} {t} {t}", .{ + return comp.setMiscFailure(.check_whole_cache, "checking cache failed: {f} {t} {t}", .{ op.path(&man), man.diagnostic, op.err, }); }, diff --git a/src/libs/mingw.zig b/src/libs/mingw.zig index 24a6ac4e12e4fe0749dde875bf88f8b8a574e4e0..59d99a783af2af8053dcfb629ce1c48ee672f262 100644 --- a/src/libs/mingw.zig +++ b/src/libs/mingw.zig @@ -254,6 +254,10 @@ pub fn buildImportLib(comp: *Compilation, lib_name: []const u8, prog_node: std.P const status = man.check(prog_node) catch |err| switch (err) { error.CacheCheckFailed => switch (man.diagnostic) { .none => unreachable, + .manifest_oversize => { + comp.setMiscFailure(.windows_import_lib, "checking cache failed: {t}", .{man.diagnostic}); + return error.AlreadyReported; + }, .manifest_create, .manifest_stat, .manifest_read, .manifest_lock => |e| { comp.setMiscFailure(.windows_import_lib, "checking cache failed: {t} {t}", .{ man.diagnostic, e }); return error.AlreadyReported;