aboutsummaryrefslogtreecommitdiff
path: root/src/Compilation.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2024-01-03 13:48:00 -0700
committerAndrew Kelley <andrew@ziglang.org>2024-01-03 17:36:54 -0800
commit2ac315c2457649570262693dc6d88d4832ef9f8b (patch)
tree960c83908e6d54c8c11925e6c343e10e284cd1f8 /src/Compilation.zig
parentf64205b4456a81229886019e3621132ae150e053 (diff)
downloadzig-2ac315c2457649570262693dc6d88d4832ef9f8b.tar.gz
zig-2ac315c2457649570262693dc6d88d4832ef9f8b.zip
compiler: fix build runner not added to cache hash
Closes #18438
Diffstat (limited to 'src/Compilation.zig')
-rw-r--r--src/Compilation.zig10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/Compilation.zig b/src/Compilation.zig
index 6c7f1d0d83..9347644381 100644
--- a/src/Compilation.zig
+++ b/src/Compilation.zig
@@ -1131,11 +1131,17 @@ fn addModuleTableToCacheHash(
arena: Allocator,
hash: *Cache.HashHelper,
root_mod: *Package.Module,
+ main_mod: *Package.Module,
hash_type: union(enum) { path_bytes, files: *Cache.Manifest },
) (error{OutOfMemory} || std.os.GetCwdError)!void {
var seen_table: std.AutoArrayHashMapUnmanaged(*Package.Module, void) = .{};
defer seen_table.deinit(gpa);
+
+ // root_mod and main_mod may be the same pointer. In fact they usually are.
+ // However in the case of `zig test` or `zig build` they will be different,
+ // and it's possible for one to not reference the other via the import table.
try seen_table.put(gpa, root_mod, {});
+ try seen_table.put(gpa, main_mod, {});
const SortByName = struct {
names: []const []const u8,
@@ -1612,7 +1618,7 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil
// do want to namespace different source file names because they are
// likely different compilations and therefore this would be likely to
// cause cache hits.
- try addModuleTableToCacheHash(gpa, arena, &hash, main_mod, .path_bytes);
+ try addModuleTableToCacheHash(gpa, arena, &hash, options.root_mod, main_mod, .path_bytes);
// In the case of incremental cache mode, this `artifact_directory`
// is computed based on a hash of non-linker inputs, and it is where all
@@ -2467,7 +2473,7 @@ fn addNonIncrementalStuffToCacheManifest(
if (comp.module) |mod| {
const main_zig_file = try mod.main_mod.root.joinString(arena, mod.main_mod.root_src_path);
_ = try man.addFile(main_zig_file, null);
- try addModuleTableToCacheHash(gpa, arena, &man.hash, mod.main_mod, .{ .files = man });
+ try addModuleTableToCacheHash(gpa, arena, &man.hash, mod.root_mod, mod.main_mod, .{ .files = man });
// Synchronize with other matching comments: ZigOnlyHashStuff
man.hash.add(comp.config.test_evented_io);