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(...@@ -1131,11 +1131,17 @@ fn addModuleTableToCacheHash(
1131 arena: Allocator,1131 arena: Allocator,
1132 hash: *Cache.HashHelper,1132 hash: *Cache.HashHelper,
1133 root_mod: *Package.Module,1133 root_mod: *Package.Module,
1134 main_mod: *Package.Module,
1134 hash_type: union(enum) { path_bytes, files: *Cache.Manifest },1135 hash_type: union(enum) { path_bytes, files: *Cache.Manifest },
1135) (error{OutOfMemory} || std.os.GetCwdError)!void {1136) (error{OutOfMemory} || std.os.GetCwdError)!void {
1136 var seen_table: std.AutoArrayHashMapUnmanaged(*Package.Module, void) = .{};1137 var seen_table: std.AutoArrayHashMapUnmanaged(*Package.Module, void) = .{};
1137 defer seen_table.deinit(gpa);1138 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.
1138 try seen_table.put(gpa, root_mod, {});1143 try seen_table.put(gpa, root_mod, {});
1144 try seen_table.put(gpa, main_mod, {});
11391145
1140 const SortByName = struct {1146 const SortByName = struct {
1141 names: []const []const u8,1147 names: []const []const u8,
...@@ -1612,7 +1618,7 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil...@@ -1612,7 +1618,7 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil
1612 // do want to namespace different source file names because they are1618 // do want to namespace different source file names because they are
1613 // likely different compilations and therefore this would be likely to1619 // likely different compilations and therefore this would be likely to
1614 // cause cache hits.1620 // 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
1617 // In the case of incremental cache mode, this `artifact_directory`1623 // In the case of incremental cache mode, this `artifact_directory`
1618 // is computed based on a hash of non-linker inputs, and it is where all1624 // is computed based on a hash of non-linker inputs, and it is where all
...@@ -2467,7 +2473,7 @@ fn addNonIncrementalStuffToCacheManifest(...@@ -2467,7 +2473,7 @@ fn addNonIncrementalStuffToCacheManifest(
2467 if (comp.module) |mod| {2473 if (comp.module) |mod| {
2468 const main_zig_file = try mod.main_mod.root.joinString(arena, mod.main_mod.root_src_path);2474 const main_zig_file = try mod.main_mod.root.joinString(arena, mod.main_mod.root_src_path);
2469 _ = try man.addFile(main_zig_file, null);2475 _ = 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
2472 // Synchronize with other matching comments: ZigOnlyHashStuff2478 // Synchronize with other matching comments: ZigOnlyHashStuff
2473 man.hash.add(comp.config.test_evented_io);2479 man.hash.add(comp.config.test_evented_io);