| author | |
| committer | |
| log | 3416452d567e6725ef887252237e553f7d7be242 |
| tree | d715aa160d1ec67502ca61502a6b46607eaf83e9 |
| parent | ef92c156b5ce1fade3106fc0d79af36bb4409246 |
This was an unintentional regression in 23c8175 which meant that
backwards-incompatible ZIR changes would have caused compiler crashes if
old caches were present.3 files changed, 17 insertions(+), 11 deletions(-)
src/Compilation.zig+8-3| ... | ... | @@ -352,12 +352,17 @@ pub const Path = struct { |
| 352 | 352 | gpa.free(p.sub_path); |
| 353 | 353 | } |
| 354 | 354 | |
| 355 | /// The returned digest is relocatable across any compiler process using the same lib and cache | |
| 355 | /// The added data is relocatable across any compiler process using the same lib and cache | |
| 356 | 356 | /// directories; it does not depend on cwd. |
| 357 | pub fn digest(p: Path) Cache.BinDigest { | |
| 358 | var h = Cache.hasher_init; | |
| 357 | pub fn addToHasher(p: Path, h: *Cache.Hasher) void { | |
| 359 | 358 | h.update(&.{@intFromEnum(p.root)}); |
| 360 | 359 | h.update(p.sub_path); |
| 360 | } | |
| 361 | ||
| 362 | /// Small convenience wrapper around `addToHasher`. | |
| 363 | pub fn digest(p: Path) Cache.BinDigest { | |
| 364 | var h = Cache.hasher_init; | |
| 365 | p.addToHasher(&h); | |
| 361 | 366 | return h.finalResult(); |
| 362 | 367 | } |
| 363 | 368 |
src/Zcu.zig-7| ... | ... | @@ -4239,13 +4239,6 @@ pub fn setFileRootType(zcu: *Zcu, file_index: File.Index, root_type: InternPool. |
| 4239 | 4239 | files.view().items(.root_type)[file_index_unwrapped.index] = root_type; |
| 4240 | 4240 | } |
| 4241 | 4241 | |
| 4242 | pub fn filePathDigest(zcu: *const Zcu, file_index: File.Index) Cache.BinDigest { | |
| 4243 | const ip = &zcu.intern_pool; | |
| 4244 | const file_index_unwrapped = file_index.unwrap(ip); | |
| 4245 | const files = ip.getLocalShared(file_index_unwrapped.tid).files.acquire(); | |
| 4246 | return files.view().items(.bin_digest)[file_index_unwrapped.index]; | |
| 4247 | } | |
| 4248 | ||
| 4249 | 4242 | pub fn navSrcLoc(zcu: *const Zcu, nav_index: InternPool.Nav.Index) LazySrcLoc { |
| 4250 | 4243 | const ip = &zcu.intern_pool; |
| 4251 | 4244 | return .{ |
src/Zcu/PerThread.zig+9-1| ... | ... | @@ -101,7 +101,15 @@ pub fn updateFile( |
| 101 | 101 | .global_cache, .zig_lib => false, |
| 102 | 102 | }; |
| 103 | 103 | |
| 104 | const hex_digest = Cache.binToHex(file.path.digest()); | |
| 104 | const hex_digest: Cache.HexDigest = d: { | |
| 105 | var h: Cache.HashHelper = .{}; | |
| 106 | // As well as the file path, we also include the compiler version in case of backwards-incompatible ZIR changes. | |
| 107 | file.path.addToHasher(&h.hasher); | |
| 108 | h.addBytes(build_options.version); | |
| 109 | h.add(builtin.zig_backend); | |
| 110 | break :d h.final(); | |
| 111 | }; | |
| 112 | ||
| 105 | 113 | const cache_directory = if (want_local_cache) zcu.local_zir_cache else zcu.global_zir_cache; |
| 106 | 114 | const zir_dir = cache_directory.handle; |
| 107 | 115 |