authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-09-14 20:25:47-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-09-16 13:12:47-07:00
loge8882ffcf0d97cabfc974bdbc1c592f911832623
tree28125599834e248659e22beef92e21d7bf039519
parent514989908c897e9ecaf47402ea483dd573ba3b30

std.Build.Cache: fix compilation on 32-bit


4 files changed, 22 insertions(+), 9 deletions(-)

lib/compiler/Maker/Step.zig+3-2
......@@ -753,12 +753,13 @@ fn failWithCacheError(
753753 switch (err) {
754754 error.CacheCheckFailed => switch (man.diagnostic) {
755755 .none => unreachable,
756 .manifest_oversize => return s.fail(maker, "checking cache failed: {t}", .{man.diagnostic}),
756757 .manifest_create, .manifest_stat, .manifest_read, .manifest_lock => |e| {
757 return s.fail(maker, "failed checking cache: {t} {t}", .{ man.diagnostic, e });
758 return s.fail(maker, "checking cache failed: {t} {t}", .{ man.diagnostic, e });
758759 },
759760 .file_open, .file_stat, .file_read, .file_hash => |op| {
760761 const path = op.path(man);
761 return s.fail(maker, "failed checking cache: {f} {t} {t}", .{ path, man.diagnostic, op.err });
762 return s.fail(maker, "checking cache failed: {f} {t} {t}", .{ path, man.diagnostic, op.err });
762763 },
763764 },
764765 error.OutOfMemory, error.Canceled => |e| return e,
lib/std/Build/Cache.zig+4-1
......@@ -595,6 +595,7 @@ pub const Manifest = struct {
595595 none,
596596 manifest_create: Io.File.OpenError,
597597 manifest_stat: Io.File.StatError,
598 manifest_oversize,
598599 manifest_read: Io.File.ReadPositionalError,
599600 manifest_lock: Io.File.LockError,
600601 file_open: FileOp,
......@@ -1011,10 +1012,12 @@ pub const Manifest = struct {
10111012 const io = m.cache.io;
10121013 const manifest_file = m.manifest_file.?;
10131014
1014 const manifest_size = if (manifest_file.stat(io)) |stat| stat.size else |err| switch (err) {
1015 const manifest_stat = manifest_file.stat(io) catch |err| switch (err) {
10151016 error.Canceled => |e| return e,
10161017 else => |e| return fail(&m.diagnostic, .{ .manifest_stat = e }),
10171018 };
1019 const manifest_size = std.math.cast(u32, manifest_stat.size) orelse
1020 return fail(&m.diagnostic, .manifest_oversize);
10181021
10191022 if (manifest_size == 0 or manifest_size < m.contents.items.len) {
10201023 // Manifest file was never finalized.
src/Compilation.zig+11-6
......@@ -2817,13 +2817,18 @@ pub fn update(comp: *Compilation, main_progress_node: std.Progress.Node) UpdateE
28172817 error.Canceled, error.OutOfMemory => |e| return e,
28182818 error.CacheCheckFailed => switch (man.diagnostic) {
28192819 .none => unreachable,
2820 .manifest_create, .manifest_stat, .manifest_read, .manifest_lock => |e| return comp.setMiscFailure(
2821 .check_whole_cache,
2822 "failed to check cache: {t} {t}",
2823 .{ man.diagnostic, e },
2824 ),
2820 .manifest_oversize => {
2821 return comp.setMiscFailure(.check_whole_cache, "checking cache failed: {t}", .{
2822 man.diagnostic,
2823 });
2824 },
2825 .manifest_create, .manifest_stat, .manifest_read, .manifest_lock => |e| {
2826 return comp.setMiscFailure(.check_whole_cache, "checking cache failed: {t} {t}", .{
2827 man.diagnostic, e,
2828 });
2829 },
28252830 .file_open, .file_stat, .file_read, .file_hash => |op| {
2826 return comp.setMiscFailure(.check_whole_cache, "failed to check cache: {f} {t} {t}", .{
2831 return comp.setMiscFailure(.check_whole_cache, "checking cache failed: {f} {t} {t}", .{
28272832 op.path(&man), man.diagnostic, op.err,
28282833 });
28292834 },
src/libs/mingw.zig+4
......@@ -254,6 +254,10 @@ pub fn buildImportLib(comp: *Compilation, lib_name: []const u8, prog_node: std.P
254254 const status = man.check(prog_node) catch |err| switch (err) {
255255 error.CacheCheckFailed => switch (man.diagnostic) {
256256 .none => unreachable,
257 .manifest_oversize => {
258 comp.setMiscFailure(.windows_import_lib, "checking cache failed: {t}", .{man.diagnostic});
259 return error.AlreadyReported;
260 },
257261 .manifest_create, .manifest_stat, .manifest_read, .manifest_lock => |e| {
258262 comp.setMiscFailure(.windows_import_lib, "checking cache failed: {t} {t}", .{ man.diagnostic, e });
259263 return error.AlreadyReported;