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

Closes #6979
Closes #7036
master
Andrew Kelley 2020-12-01 16:35:27 -07:00
parent 8d6eff5cb9
commit 5b5097a22a
2 changed files with 17 additions and 6 deletions

View File

@ -60,6 +60,8 @@ pub const File = struct {
pub const HashHelper = struct {
hasher: Hasher = hasher_init,
const EmitLoc = @import("Compilation.zig").EmitLoc;
/// Record a slice of bytes as an dependency of the process being cached
pub fn addBytes(hh: *HashHelper, bytes: []const u8) void {
hh.hasher.update(mem.asBytes(&bytes.len));
@ -71,6 +73,15 @@ pub const HashHelper = struct {
hh.addBytes(optional_bytes orelse return);
}
pub fn addEmitLoc(hh: *HashHelper, emit_loc: EmitLoc) void {
hh.addBytes(emit_loc.basename);
}
pub fn addOptionalEmitLoc(hh: *HashHelper, optional_emit_loc: ?EmitLoc) void {
hh.add(optional_emit_loc != null);
hh.addEmitLoc(optional_emit_loc orelse return);
}
pub fn addListOfBytes(hh: *HashHelper, list_of_bytes: []const []const u8) void {
hh.add(list_of_bytes.len);
for (list_of_bytes) |bytes| hh.addBytes(bytes);

View File

@ -708,7 +708,7 @@ pub fn create(gpa: *Allocator, options: InitOptions) !*Compilation {
cache.hash.add(options.link_libcpp);
cache.hash.add(options.output_mode);
cache.hash.add(options.machine_code_model);
cache.hash.add(options.emit_bin != null);
cache.hash.addOptionalEmitLoc(options.emit_bin);
cache.hash.addBytes(options.root_name);
// TODO audit this and make sure everything is in it
@ -2786,11 +2786,11 @@ fn updateStage1Module(comp: *Compilation, main_progress_node: *std.Progress.Node
man.hash.add(comp.bin_file.options.function_sections);
man.hash.add(comp.bin_file.options.is_test);
man.hash.add(comp.bin_file.options.emit != null);
man.hash.add(comp.emit_h != null);
man.hash.add(comp.emit_asm != null);
man.hash.add(comp.emit_llvm_ir != null);
man.hash.add(comp.emit_analysis != null);
man.hash.add(comp.emit_docs != null);
man.hash.addOptionalEmitLoc(comp.emit_h);
man.hash.addOptionalEmitLoc(comp.emit_asm);
man.hash.addOptionalEmitLoc(comp.emit_llvm_ir);
man.hash.addOptionalEmitLoc(comp.emit_analysis);
man.hash.addOptionalEmitLoc(comp.emit_docs);
man.hash.addOptionalBytes(comp.test_filter);
man.hash.addOptionalBytes(comp.test_name_prefix);