| ... | @@ -1678,15 +1678,7 @@ pub const CreateOptions = struct { | ... | @@ -1678,15 +1678,7 @@ pub const CreateOptions = struct { |
| 1678 | }; | 1678 | }; |
| 1679 | }; | 1679 | }; |
| 1680 | | 1680 | |
| 1681 | fn addModuleTableToCacheHash( | 1681 | fn addModuleTableToCacheHash(zcu: *Zcu, hash: *Cache.HashHelper) error{ OutOfMemory, Unexpected }!void { |
| 1682 | zcu: *Zcu, | | |
| 1683 | arena: Allocator, | | |
| 1684 | hash: *Cache.HashHelper, | | |
| 1685 | hash_type: union(enum) { path_bytes, files: *Cache.Manifest }, | | |
| 1686 | ) error{ | | |
| 1687 | OutOfMemory, | | |
| 1688 | Unexpected, | | |
| 1689 | }!void { | | |
| 1690 | assert(zcu.module_roots.count() != 0); // module_roots is populated | 1682 | assert(zcu.module_roots.count() != 0); // module_roots is populated |
| 1691 | | 1683 | |
| 1692 | for (zcu.module_roots.keys(), zcu.module_roots.values()) |mod, opt_mod_root_file| { | 1684 | for (zcu.module_roots.keys(), zcu.module_roots.values()) |mod, opt_mod_root_file| { |
| ... | @@ -1695,17 +1687,9 @@ fn addModuleTableToCacheHash( | ... | @@ -1695,17 +1687,9 @@ fn addModuleTableToCacheHash( |
| 1695 | if (zcu.fileByIndex(mod_root_file).is_builtin) continue; // redundant | 1687 | if (zcu.fileByIndex(mod_root_file).is_builtin) continue; // redundant |
| 1696 | } | 1688 | } |
| 1697 | cache_helpers.addModule(hash, mod); | 1689 | cache_helpers.addModule(hash, mod); |
| 1698 | switch (hash_type) { | 1690 | hash.add(mod.root.root); |
| 1699 | .path_bytes => { | 1691 | hash.addBytes(mod.root.sub_path); |
| 1700 | hash.add(mod.root.root); | 1692 | hash.addBytes(mod.root_src_path); |
| 1701 | hash.addBytes(mod.root.sub_path); | | |
| 1702 | hash.addBytes(mod.root_src_path); | | |
| 1703 | }, | | |
| 1704 | .files => |man| if (mod.root_src_path.len != 0) { | | |
| 1705 | const root_src_path = try mod.root.toCachePath(zcu.comp.dirs).join(arena, mod.root_src_path); | | |
| 1706 | _ = try man.addFilePath(root_src_path, null); | | |
| 1707 | }, | | |
| 1708 | } | | |
| 1709 | hash.addListOfBytes(mod.deps.keys()); | 1693 | hash.addListOfBytes(mod.deps.keys()); |
| 1710 | } | 1694 | } |
| 1711 | } | 1695 | } |
| ... | @@ -2336,7 +2320,7 @@ pub fn create(gpa: Allocator, arena: Allocator, io: Io, diag: *CreateDiagnostic, | ... | @@ -2336,7 +2320,7 @@ pub fn create(gpa: Allocator, arena: Allocator, io: Io, diag: *CreateDiagnostic, |
| 2336 | // likely different compilations and therefore this would be likely to | 2320 | // likely different compilations and therefore this would be likely to |
| 2337 | // cause cache hits. | 2321 | // cause cache hits. |
| 2338 | if (comp.zcu) |zcu| { | 2322 | if (comp.zcu) |zcu| { |
| 2339 | try addModuleTableToCacheHash(zcu, arena, &hash, .path_bytes); | 2323 | try addModuleTableToCacheHash(zcu, &hash); |
| 2340 | } else { | 2324 | } else { |
| 2341 | cache_helpers.addModule(&hash, options.root_mod); | 2325 | cache_helpers.addModule(&hash, options.root_mod); |
| 2342 | } | 2326 | } |
| ... | @@ -3392,10 +3376,11 @@ fn addNonIncrementalStuffToCacheManifest(comp: *Compilation, man: *Cache.Manifes | ... | @@ -3392,10 +3376,11 @@ fn addNonIncrementalStuffToCacheManifest(comp: *Compilation, man: *Cache.Manifes |
| 3392 | comptime assert(link_hash_implementation_version == 14); | 3376 | comptime assert(link_hash_implementation_version == 14); |
| 3393 | | 3377 | |
| 3394 | if (comp.zcu) |zcu| { | 3378 | if (comp.zcu) |zcu| { |
| 3395 | // No need to call `addModuleTableToCacheHash` here because it is | 3379 | // No need to hash the actual file contents here because it is |
| 3396 | // redundant with the logic in `PerThread.update` which iterates over | 3380 | // redundant with the logic in `PerThread.update` which iterates over |
| 3397 | // `zcu.alive_files` and adds those files discovered via `@import` to | 3381 | // `zcu.alive_files` and adds those files discovered via `@import` to |
| 3398 | // the whole cache manifest. | 3382 | // the whole cache manifest. |
| | 3383 | try addModuleTableToCacheHash(zcu, &man.hash); |
| 3399 | | 3384 | |
| 3400 | // Synchronize with other matching comments: ZigOnlyHashStuff | 3385 | // Synchronize with other matching comments: ZigOnlyHashStuff |
| 3401 | man.hash.addListOfBytes(comp.test_filters); | 3386 | man.hash.addListOfBytes(comp.test_filters); |