authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-01-03 13:48:00-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-01-03 17:36:54-08:00
log2ac315c2457649570262693dc6d88d4832ef9f8b
tree960c83908e6d54c8c11925e6c343e10e284cd1f8
parentf64205b4456a81229886019e3621132ae150e053

compiler: fix build runner not added to cache hash

Closes #18438

1 files changed, 8 insertions(+), 2 deletions(-)

src/Compilation.zig+8-2
......@@ -1131,11 +1131,17 @@ fn addModuleTableToCacheHash(
11311131 arena: Allocator,
11321132 hash: *Cache.HashHelper,
11331133 root_mod: *Package.Module,
1134 main_mod: *Package.Module,
11341135 hash_type: union(enum) { path_bytes, files: *Cache.Manifest },
11351136) (error{OutOfMemory} || std.os.GetCwdError)!void {
11361137 var seen_table: std.AutoArrayHashMapUnmanaged(*Package.Module, void) = .{};
11371138 defer seen_table.deinit(gpa);
1139
1140 // root_mod and main_mod may be the same pointer. In fact they usually are.
1141 // However in the case of `zig test` or `zig build` they will be different,
1142 // and it's possible for one to not reference the other via the import table.
11381143 try seen_table.put(gpa, root_mod, {});
1144 try seen_table.put(gpa, main_mod, {});
11391145
11401146 const SortByName = struct {
11411147 names: []const []const u8,
......@@ -1612,7 +1618,7 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil
16121618 // do want to namespace different source file names because they are
16131619 // likely different compilations and therefore this would be likely to
16141620 // cause cache hits.
1615 try addModuleTableToCacheHash(gpa, arena, &hash, main_mod, .path_bytes);
1621 try addModuleTableToCacheHash(gpa, arena, &hash, options.root_mod, main_mod, .path_bytes);
16161622
16171623 // In the case of incremental cache mode, this `artifact_directory`
16181624 // is computed based on a hash of non-linker inputs, and it is where all
......@@ -2467,7 +2473,7 @@ fn addNonIncrementalStuffToCacheManifest(
24672473 if (comp.module) |mod| {
24682474 const main_zig_file = try mod.main_mod.root.joinString(arena, mod.main_mod.root_src_path);
24692475 _ = try man.addFile(main_zig_file, null);
2470 try addModuleTableToCacheHash(gpa, arena, &man.hash, mod.main_mod, .{ .files = man });
2476 try addModuleTableToCacheHash(gpa, arena, &man.hash, mod.root_mod, mod.main_mod, .{ .files = man });
24712477
24722478 // Synchronize with other matching comments: ZigOnlyHashStuff
24732479 man.hash.add(comp.config.test_evented_io);