authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-12-27 10:42:32-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-01-01 19:49:07-07:00
log5b05e99dd48520c0efd5f624760b3218bc1311ec
tree0a7ffe3bcc62f7c3d3c71f5b01492a663e6ad92f
parent372b407740224ae20fad49647bbde56330b24967

Compilation: consolidate module hashing code


1 files changed, 21 insertions(+), 41 deletions(-)

src/Compilation.zig+21-41
......@@ -799,6 +799,24 @@ pub const EmitLoc = struct {
799799};
800800
801801pub const cache_helpers = struct {
802 pub fn addModule(hh: *Cache.HashHelper, mod: *const Package.Module) void {
803 addResolvedTarget(hh, mod.resolved_target);
804 hh.add(mod.optimize_mode);
805 hh.add(mod.code_model);
806 hh.add(mod.single_threaded);
807 hh.add(mod.error_tracing);
808 hh.add(mod.valgrind);
809 hh.add(mod.pic);
810 hh.add(mod.strip);
811 hh.add(mod.omit_frame_pointer);
812 hh.add(mod.stack_check);
813 hh.add(mod.red_zone);
814 hh.add(mod.sanitize_c);
815 hh.add(mod.sanitize_thread);
816 hh.add(mod.unwind_tables);
817 hh.add(mod.structured_cfg);
818 }
819
802820 pub fn addResolvedTarget(
803821 hh: *Cache.HashHelper,
804822 resolved_target: Package.Module.ResolvedTarget,
......@@ -1131,21 +1149,7 @@ fn addModuleTableToCacheHash(
11311149 continue;
11321150 }
11331151
1134 cache_helpers.addResolvedTarget(hash, mod.resolved_target);
1135 hash.add(mod.optimize_mode);
1136 hash.add(mod.code_model);
1137 hash.add(mod.single_threaded);
1138 hash.add(mod.error_tracing);
1139 hash.add(mod.valgrind);
1140 hash.add(mod.pic);
1141 hash.add(mod.strip);
1142 hash.add(mod.omit_frame_pointer);
1143 hash.add(mod.stack_check);
1144 hash.add(mod.red_zone);
1145 hash.add(mod.sanitize_c);
1146 hash.add(mod.sanitize_thread);
1147 hash.add(mod.unwind_tables);
1148 hash.add(mod.structured_cfg);
1152 cache_helpers.addModule(hash, mod);
11491153
11501154 switch (hash_type) {
11511155 .path_bytes => {
......@@ -2406,19 +2410,7 @@ fn addNonIncrementalStuffToCacheManifest(comp: *Compilation, man: *Cache.Manifes
24062410 man.hash.add(mod.emit_h != null);
24072411 man.hash.add(mod.error_limit);
24082412 } else {
2409 cache_helpers.addResolvedTarget(&man.hash, comp.root_mod.resolved_target);
2410 man.hash.add(comp.root_mod.optimize_mode);
2411 man.hash.add(comp.root_mod.code_model);
2412 man.hash.add(comp.root_mod.single_threaded);
2413 man.hash.add(comp.root_mod.error_tracing);
2414 man.hash.add(comp.root_mod.pic);
2415 man.hash.add(comp.root_mod.omit_frame_pointer);
2416 man.hash.add(comp.root_mod.stack_check);
2417 man.hash.add(comp.root_mod.red_zone);
2418 man.hash.add(comp.root_mod.sanitize_c);
2419 man.hash.add(comp.root_mod.sanitize_thread);
2420 man.hash.add(comp.root_mod.unwind_tables);
2421 man.hash.add(comp.root_mod.structured_cfg);
2413 cache_helpers.addModule(&man.hash, comp.root_mod);
24222414 }
24232415
24242416 for (comp.objects) |obj| {
......@@ -3855,19 +3847,7 @@ pub fn obtainCObjectCacheManifest(
38553847 // Only things that need to be added on top of the base hash, and only things
38563848 // that apply both to @cImport and compiling C objects. No linking stuff here!
38573849 // Also nothing that applies only to compiling .zig code.
3858 cache_helpers.addResolvedTarget(&man.hash, owner_mod.resolved_target);
3859 man.hash.add(owner_mod.optimize_mode);
3860 man.hash.add(owner_mod.code_model);
3861 man.hash.add(owner_mod.single_threaded);
3862 man.hash.add(owner_mod.error_tracing);
3863 man.hash.add(owner_mod.pic);
3864 man.hash.add(owner_mod.omit_frame_pointer);
3865 man.hash.add(owner_mod.stack_check);
3866 man.hash.add(owner_mod.red_zone);
3867 man.hash.add(owner_mod.sanitize_c);
3868 man.hash.add(owner_mod.sanitize_thread);
3869 man.hash.add(owner_mod.unwind_tables);
3870 man.hash.add(owner_mod.structured_cfg);
3850 cache_helpers.addModule(&man.hash, owner_mod);
38713851 man.hash.addListOfBytes(owner_mod.cc_argv);
38723852 man.hash.add(comp.config.link_libcpp);
38733853