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