authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-12-01 16:35:27-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-12-01 16:36:37-07:00
loga4c8bd8fd46585800c74b78c50a5073ccf877d21
treea07410ee6b794cc77178a818a06e171e9468f25a
parent7099dff7ea6ec4467d426e0955020b20f964e6e5

stage2: add -femit-foo=bar args to the cache hash

Closes #6979 Closes #7036

2 files changed, 17 insertions(+), 6 deletions(-)

src/Cache.zig+11
...@@ -60,6 +60,8 @@ pub const File = struct {...@@ -60,6 +60,8 @@ pub const File = struct {
60pub const HashHelper = struct {60pub const HashHelper = struct {
61 hasher: Hasher = hasher_init,61 hasher: Hasher = hasher_init,
6262
63 const EmitLoc = @import("Compilation.zig").EmitLoc;
64
63 /// Record a slice of bytes as an dependency of the process being cached65 /// Record a slice of bytes as an dependency of the process being cached
64 pub fn addBytes(hh: *HashHelper, bytes: []const u8) void {66 pub fn addBytes(hh: *HashHelper, bytes: []const u8) void {
65 hh.hasher.update(mem.asBytes(&bytes.len));67 hh.hasher.update(mem.asBytes(&bytes.len));
...@@ -71,6 +73,15 @@ pub const HashHelper = struct {...@@ -71,6 +73,15 @@ pub const HashHelper = struct {
71 hh.addBytes(optional_bytes orelse return);73 hh.addBytes(optional_bytes orelse return);
72 }74 }
7375
76 pub fn addEmitLoc(hh: *HashHelper, emit_loc: EmitLoc) void {
77 hh.addBytes(emit_loc.basename);
78 }
79
80 pub fn addOptionalEmitLoc(hh: *HashHelper, optional_emit_loc: ?EmitLoc) void {
81 hh.add(optional_emit_loc != null);
82 hh.addEmitLoc(optional_emit_loc orelse return);
83 }
84
74 pub fn addListOfBytes(hh: *HashHelper, list_of_bytes: []const []const u8) void {85 pub fn addListOfBytes(hh: *HashHelper, list_of_bytes: []const []const u8) void {
75 hh.add(list_of_bytes.len);86 hh.add(list_of_bytes.len);
76 for (list_of_bytes) |bytes| hh.addBytes(bytes);87 for (list_of_bytes) |bytes| hh.addBytes(bytes);
src/Compilation.zig+6-6
...@@ -690,7 +690,7 @@ pub fn create(gpa: *Allocator, options: InitOptions) !*Compilation {...@@ -690,7 +690,7 @@ pub fn create(gpa: *Allocator, options: InitOptions) !*Compilation {
690 cache.hash.add(options.link_libcpp);690 cache.hash.add(options.link_libcpp);
691 cache.hash.add(options.output_mode);691 cache.hash.add(options.output_mode);
692 cache.hash.add(options.machine_code_model);692 cache.hash.add(options.machine_code_model);
693 cache.hash.add(options.emit_bin != null);693 cache.hash.addOptionalEmitLoc(options.emit_bin);
694 cache.hash.addBytes(options.root_name);694 cache.hash.addBytes(options.root_name);
695 // TODO audit this and make sure everything is in it695 // TODO audit this and make sure everything is in it
696696
...@@ -2765,11 +2765,11 @@ fn updateStage1Module(comp: *Compilation, main_progress_node: *std.Progress.Node...@@ -2765,11 +2765,11 @@ fn updateStage1Module(comp: *Compilation, main_progress_node: *std.Progress.Node
2765 man.hash.add(comp.bin_file.options.function_sections);2765 man.hash.add(comp.bin_file.options.function_sections);
2766 man.hash.add(comp.bin_file.options.is_test);2766 man.hash.add(comp.bin_file.options.is_test);
2767 man.hash.add(comp.bin_file.options.emit != null);2767 man.hash.add(comp.bin_file.options.emit != null);
2768 man.hash.add(comp.emit_h != null);2768 man.hash.addOptionalEmitLoc(comp.emit_h);
2769 man.hash.add(comp.emit_asm != null);2769 man.hash.addOptionalEmitLoc(comp.emit_asm);
2770 man.hash.add(comp.emit_llvm_ir != null);2770 man.hash.addOptionalEmitLoc(comp.emit_llvm_ir);
2771 man.hash.add(comp.emit_analysis != null);2771 man.hash.addOptionalEmitLoc(comp.emit_analysis);
2772 man.hash.add(comp.emit_docs != null);2772 man.hash.addOptionalEmitLoc(comp.emit_docs);
2773 man.hash.addOptionalBytes(comp.test_filter);2773 man.hash.addOptionalBytes(comp.test_filter);
2774 man.hash.addOptionalBytes(comp.test_name_prefix);2774 man.hash.addOptionalBytes(comp.test_name_prefix);
27752775