authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-09-13 20:38:14-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-09-16 13:12:47-07:00
log79a7b7c0f033787215471beb9eab99264c1b7003
treec3eaff834225cde266a0d66a3c2cf09001a3c9e3
parent88f3896522fa5314fa4b19b06a2fd3675233ddc3

compiler: update to new std.Build.Cache API


3 files changed, 13 insertions(+), 22 deletions(-)

src/Compilation.zig+10-15
......@@ -2828,11 +2828,6 @@ pub fn update(comp: *Compilation, main_progress_node: std.Progress.Node) UpdateE
28282828 });
28292829 },
28302830 },
2831 error.InvalidFormat => return comp.setMiscFailure(
2832 .check_whole_cache,
2833 "failed to check cache: invalid manifest file format",
2834 .{},
2835 ),
28362831 };
28372832 if (status == .hit and !ignore_hit) {
28382833 // In this case the cache hit contains the full set of file system inputs. Nice!
......@@ -2845,7 +2840,7 @@ pub fn update(comp: *Compilation, main_progress_node: std.Progress.Node) UpdateE
28452840
28462841 comp.last_update_was_cache_hit = true;
28472842 log.debug("CacheMode.whole cache hit for {s}", .{comp.root_name});
2848 const bin_digest = man.finalBin();
2843 const bin_digest = man.hitDigest();
28492844
28502845 comp.digest = bin_digest;
28512846
......@@ -3054,7 +3049,7 @@ pub fn update(comp: *Compilation, main_progress_node: std.Progress.Node) UpdateE
30543049 try man.populateOtherManifest(pwc.manifest, pwc.prefix_map);
30553050 }
30563051
3057 const bin_digest = man.finalBin();
3052 const bin_digest = man.missDigest();
30583053 const hex_digest = Cache.binToHex(bin_digest);
30593054
30603055 // Work around windows `AccessDenied` if any files within this
......@@ -5125,9 +5120,9 @@ pub fn translateC(
51255120 var reader: std.Io.Reader = .fixed(stdout);
51265121 const MessageHeader = std.zig.Server.Message.Header;
51275122 const header = reader.takeStruct(MessageHeader, .little) catch |err|
5128 fatal("unable to read translate-c MessageHeader: {s}", .{@errorName(err)});
5123 fatal("unable to read translate-c MessageHeader: {t}", .{err});
51295124 const body = reader.take(header.bytes_len) catch |err|
5130 fatal("unable to read {}-byte translate-c message body: {s}", .{ header.bytes_len, @errorName(err) });
5125 fatal("unable to read {d}-byte translate-c message body: {t}", .{ header.bytes_len, err });
51315126 switch (header.tag) {
51325127 .error_bundle => {
51335128 const error_bundle = try std.zig.Server.allocErrorBundle(gpa, body);
......@@ -5137,11 +5132,11 @@ pub fn translateC(
51375132 .errors = error_bundle,
51385133 };
51395134 },
5140 else => fatal("unexpected message type received from translate-c: {s}", .{@tagName(header.tag)}),
5135 else => fatal("unexpected message type received from translate-c: {t}", .{header.tag}),
51415136 }
51425137 }
51435138
5144 const bin_digest = man.finalBin();
5139 const bin_digest = man.missDigest();
51455140 const hex_digest = Cache.binToHex(bin_digest);
51465141 const o_sub_path = "o" ++ fs.path.sep_str ++ hex_digest;
51475142
......@@ -5878,10 +5873,10 @@ fn updateWin32Resource(comp: *Compilation, win32_resource: *Win32Resource, win32
58785873 const rc_basename = try std.fmt.allocPrint(arena, "{s}.rc", .{src_basename});
58795874 const res_basename = try std.fmt.allocPrint(arena, "{s}.res", .{src_basename});
58805875
5881 const digest = if (.hit == try man.check(child_progress_node)) man.final() else blk: {
5876 const digest = if (.hit == try man.check(child_progress_node)) man.hitDigestHex() else blk: {
58825877 // The digest only depends on the .manifest file, so we can
58835878 // get the digest now and write the .res directly to the cache
5884 const digest = man.final();
5879 const digest = man.missDigestHex();
58855880
58865881 const o_sub_path = try fs.path.join(arena, &.{ "o", &digest });
58875882 var o_dir = try comp.dirs.local_cache.handle.createDirPathOpen(io, o_sub_path, .{});
......@@ -5970,7 +5965,7 @@ fn updateWin32Resource(comp: *Compilation, win32_resource: *Win32Resource, win32
59705965
59715966 const rc_basename_noext = src_basename[0 .. src_basename.len - fs.path.extension(src_basename).len];
59725967
5973 const digest = if (.hit == try man.check(child_progress_node)) man.final() else blk: {
5968 const digest = if (.hit == try man.check(child_progress_node)) man.hitDigestHex() else blk: {
59745969 var zig_cache_tmp_dir = try comp.dirs.local_cache.handle.createDirPathOpen(io, "tmp", .{});
59755970 defer zig_cache_tmp_dir.close(io);
59765971
......@@ -6042,7 +6037,7 @@ fn updateWin32Resource(comp: *Compilation, win32_resource: *Win32Resource, win32
60426037 }
60436038
60446039 // Rename into place.
6045 const digest = man.final();
6040 const digest = man.missDigestHex();
60466041 const o_sub_path = try fs.path.join(arena, &[_][]const u8{ "o", &digest });
60476042 var o_dir = try comp.dirs.local_cache.handle.createDirPathOpen(io, o_sub_path, .{});
60486043 defer o_dir.close(io);
src/libs/mingw.zig+2-6
......@@ -266,13 +266,9 @@ pub fn buildImportLib(comp: *Compilation, lib_name: []const u8, prog_node: std.P
266266 },
267267 },
268268 error.OutOfMemory, error.Canceled => |e| return e,
269 error.InvalidFormat => {
270 comp.setMiscFailure(.windows_import_lib, "checking cache failed: invalid manifest file format", .{});
271 return error.AlreadyReported;
272 },
273269 };
274270 if (status == .hit) {
275 const digest = man.final();
271 const digest = man.hitDigestHex();
276272 const sub_path = try std.fs.path.join(gpa, &.{ "o", &digest, final_lib_basename });
277273 errdefer gpa.free(sub_path);
278274
......@@ -291,7 +287,7 @@ pub fn buildImportLib(comp: *Compilation, lib_name: []const u8, prog_node: std.P
291287 return crt_file_path;
292288 }
293289
294 const digest = man.final();
290 const digest = man.missDigestHex();
295291 const o_sub_path = try std.fs.path.join(arena, &[_][]const u8{ "o", &digest });
296292 var o_dir = try comp.dirs.global_cache.handle.createDirPathOpen(io, o_sub_path, .{});
297293 defer o_dir.close(io);
src/main.zig+1-1
......@@ -4879,7 +4879,7 @@ fn cmdTranslateC(
48794879 fatal("unable to process {q}: {t}", .{ c_source_file.src_path, err });
48804880
48814881 const result: Compilation.TranslateCResult = if (.hit == try man.check(prog_node)) .{
4882 .digest = man.finalBin(),
4882 .digest = man.hitDigest(),
48834883 .cache_hit = true,
48844884 .errors = std.zig.ErrorBundle.empty,
48854885 } else result: {