aboutsummaryrefslogtreecommitdiff
path: root/src/Compilation.zig
diff options
context:
space:
mode:
authormlugg <mlugg@mlugg.co.uk>2025-05-20 19:34:27 +0100
committerMatthew Lugg <mlugg@mlugg.co.uk>2025-05-21 11:11:28 +0100
commit3416452d567e6725ef887252237e553f7d7be242 (patch)
treed715aa160d1ec67502ca61502a6b46607eaf83e9 /src/Compilation.zig
parentef92c156b5ce1fade3106fc0d79af36bb4409246 (diff)
downloadzig-3416452d567e6725ef887252237e553f7d7be242.tar.gz
zig-3416452d567e6725ef887252237e553f7d7be242.zip
compiler: fix ZIR hash not including compiler version
This was an unintentional regression in 23c8175 which meant that backwards-incompatible ZIR changes would have caused compiler crashes if old caches were present.
Diffstat (limited to 'src/Compilation.zig')
-rw-r--r--src/Compilation.zig11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/Compilation.zig b/src/Compilation.zig
index a9898e9226..6a546648b2 100644
--- a/src/Compilation.zig
+++ b/src/Compilation.zig
@@ -352,12 +352,17 @@ pub const Path = struct {
gpa.free(p.sub_path);
}
- /// The returned digest is relocatable across any compiler process using the same lib and cache
+ /// The added data is relocatable across any compiler process using the same lib and cache
/// directories; it does not depend on cwd.
- pub fn digest(p: Path) Cache.BinDigest {
- var h = Cache.hasher_init;
+ pub fn addToHasher(p: Path, h: *Cache.Hasher) void {
h.update(&.{@intFromEnum(p.root)});
h.update(p.sub_path);
+ }
+
+ /// Small convenience wrapper around `addToHasher`.
+ pub fn digest(p: Path) Cache.BinDigest {
+ var h = Cache.hasher_init;
+ p.addToHasher(&h);
return h.finalResult();
}