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:35:27-07:00
log5b5097a22a380a93a0f205ba218e8290a42ad051
treef51497dde95e80d10625596b6f06879ce3bde61a
parent8d6eff5cb97488ad79eea938fe28f4c67fd8fd19

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
...@@ -708,7 +708,7 @@ pub fn create(gpa: *Allocator, options: InitOptions) !*Compilation {...@@ -708,7 +708,7 @@ pub fn create(gpa: *Allocator, options: InitOptions) !*Compilation {
708 cache.hash.add(options.link_libcpp);708 cache.hash.add(options.link_libcpp);
709 cache.hash.add(options.output_mode);709 cache.hash.add(options.output_mode);
710 cache.hash.add(options.machine_code_model);710 cache.hash.add(options.machine_code_model);
711 cache.hash.add(options.emit_bin != null);711 cache.hash.addOptionalEmitLoc(options.emit_bin);
712 cache.hash.addBytes(options.root_name);712 cache.hash.addBytes(options.root_name);
713 // TODO audit this and make sure everything is in it713 // TODO audit this and make sure everything is in it
714714
...@@ -2786,11 +2786,11 @@ fn updateStage1Module(comp: *Compilation, main_progress_node: *std.Progress.Node...@@ -2786,11 +2786,11 @@ fn updateStage1Module(comp: *Compilation, main_progress_node: *std.Progress.Node
2786 man.hash.add(comp.bin_file.options.function_sections);2786 man.hash.add(comp.bin_file.options.function_sections);
2787 man.hash.add(comp.bin_file.options.is_test);2787 man.hash.add(comp.bin_file.options.is_test);
2788 man.hash.add(comp.bin_file.options.emit != null);2788 man.hash.add(comp.bin_file.options.emit != null);
2789 man.hash.add(comp.emit_h != null);2789 man.hash.addOptionalEmitLoc(comp.emit_h);
2790 man.hash.add(comp.emit_asm != null);2790 man.hash.addOptionalEmitLoc(comp.emit_asm);
2791 man.hash.add(comp.emit_llvm_ir != null);2791 man.hash.addOptionalEmitLoc(comp.emit_llvm_ir);
2792 man.hash.add(comp.emit_analysis != null);2792 man.hash.addOptionalEmitLoc(comp.emit_analysis);
2793 man.hash.add(comp.emit_docs != null);2793 man.hash.addOptionalEmitLoc(comp.emit_docs);
2794 man.hash.addOptionalBytes(comp.test_filter);2794 man.hash.addOptionalBytes(comp.test_filter);
2795 man.hash.addOptionalBytes(comp.test_name_prefix);2795 man.hash.addOptionalBytes(comp.test_name_prefix);
27962796