authorgravatar for ascottcameron@gmail.comAlex Cameron <ascottcameron@gmail.com> 2020-11-19 19:57:22+11:00
committergravatar for ascottcameron@gmail.comAlex Cameron <ascottcameron@gmail.com> 2020-12-23 01:14:35+11:00
logc87da2f45afedb33b5d1531ee0e4f67675aa9f78
treecf00a715064bfedbcb302393c8a7d7a776d1bc17
parentaba273d7313ece312cbf747ab5808063a6d8a1b4

Remove redundant emit_h member in Compilation struct.


2 files changed, 10 insertions(+), 9 deletions(-)

src/Compilation.zig+6-7
...@@ -128,11 +128,11 @@ test_filter: ?[]const u8,...@@ -128,11 +128,11 @@ test_filter: ?[]const u8,
128test_name_prefix: ?[]const u8,128test_name_prefix: ?[]const u8,
129test_evented_io: bool,129test_evented_io: bool,
130130
131emit_h: ?EmitLoc,
132emit_asm: ?EmitLoc,131emit_asm: ?EmitLoc,
133emit_llvm_ir: ?EmitLoc,132emit_llvm_ir: ?EmitLoc,
134emit_analysis: ?EmitLoc,133emit_analysis: ?EmitLoc,
135emit_docs: ?EmitLoc,134emit_docs: ?EmitLoc,
135
136c_header: ?c_link.Header,136c_header: ?c_link.Header,
137137
138pub const InnerError = Module.InnerError;138pub const InnerError = Module.InnerError;
...@@ -973,8 +973,7 @@ pub fn create(gpa: *Allocator, options: InitOptions) !*Compilation {...@@ -973,8 +973,7 @@ pub fn create(gpa: *Allocator, options: InitOptions) !*Compilation {
973 .local_cache_directory = options.local_cache_directory,973 .local_cache_directory = options.local_cache_directory,
974 .global_cache_directory = options.global_cache_directory,974 .global_cache_directory = options.global_cache_directory,
975 .bin_file = bin_file,975 .bin_file = bin_file,
976 .emit_h = options.emit_h,976 .c_header = if (!use_llvm and options.emit_h != null) c_link.Header.init(gpa, options.emit_h) else null,
977 .c_header = if (!use_llvm and options.emit_h != null) c_link.Header.init(gpa) else null,
978 .emit_asm = options.emit_asm,977 .emit_asm = options.emit_asm,
979 .emit_llvm_ir = options.emit_llvm_ir,978 .emit_llvm_ir = options.emit_llvm_ir,
980 .emit_analysis = options.emit_analysis,979 .emit_analysis = options.emit_analysis,
...@@ -1289,7 +1288,7 @@ pub fn update(self: *Compilation) !void {...@@ -1289,7 +1288,7 @@ pub fn update(self: *Compilation) !void {
12891288
1290 // If we've chosen to emit a C header, flush the header to the disk.1289 // If we've chosen to emit a C header, flush the header to the disk.
1291 if (self.c_header) |header| {1290 if (self.c_header) |header| {
1292 const header_path = self.emit_h.?;1291 const header_path = header.emit_loc.?;
1293 // If a directory has been provided, write the header there. Otherwise, just write it to the1292 // If a directory has been provided, write the header there. Otherwise, just write it to the
1294 // cache directory.1293 // cache directory.
1295 const header_dir = if (header_path.directory) |dir|1294 const header_dir = if (header_path.directory) |dir|
...@@ -2952,7 +2951,7 @@ fn updateStage1Module(comp: *Compilation, main_progress_node: *std.Progress.Node...@@ -2952,7 +2951,7 @@ fn updateStage1Module(comp: *Compilation, main_progress_node: *std.Progress.Node
2952 man.hash.add(comp.bin_file.options.function_sections);2951 man.hash.add(comp.bin_file.options.function_sections);
2953 man.hash.add(comp.bin_file.options.is_test);2952 man.hash.add(comp.bin_file.options.is_test);
2954 man.hash.add(comp.bin_file.options.emit != null);2953 man.hash.add(comp.bin_file.options.emit != null);
2955 man.hash.addOptionalEmitLoc(comp.emit_h);2954 man.hash.add(comp.c_header != null);
2956 man.hash.addOptionalEmitLoc(comp.emit_asm);2955 man.hash.addOptionalEmitLoc(comp.emit_asm);
2957 man.hash.addOptionalEmitLoc(comp.emit_llvm_ir);2956 man.hash.addOptionalEmitLoc(comp.emit_llvm_ir);
2958 man.hash.addOptionalEmitLoc(comp.emit_analysis);2957 man.hash.addOptionalEmitLoc(comp.emit_analysis);
...@@ -3051,10 +3050,10 @@ fn updateStage1Module(comp: *Compilation, main_progress_node: *std.Progress.Node...@@ -3051,10 +3050,10 @@ fn updateStage1Module(comp: *Compilation, main_progress_node: *std.Progress.Node
3051 });3050 });
3052 break :blk try directory.join(arena, &[_][]const u8{bin_basename});3051 break :blk try directory.join(arena, &[_][]const u8{bin_basename});
3053 } else "";3052 } else "";
3054 if (comp.emit_h != null) {3053 if (comp.c_header != null) {
3055 log.warn("-femit-h is not available in the stage1 backend; no .h file will be produced", .{});3054 log.warn("-femit-h is not available in the stage1 backend; no .h file will be produced", .{});
3056 }3055 }
3057 const emit_h_path = try stage1LocPath(arena, comp.emit_h, directory);3056 const emit_h_path = try stage1LocPath(arena, if (comp.c_header) |header| header.emit_loc else null, directory);
3058 const emit_asm_path = try stage1LocPath(arena, comp.emit_asm, directory);3057 const emit_asm_path = try stage1LocPath(arena, comp.emit_asm, directory);
3059 const emit_llvm_ir_path = try stage1LocPath(arena, comp.emit_llvm_ir, directory);3058 const emit_llvm_ir_path = try stage1LocPath(arena, comp.emit_llvm_ir, directory);
3060 const emit_analysis_path = try stage1LocPath(arena, comp.emit_analysis, directory);3059 const emit_analysis_path = try stage1LocPath(arena, comp.emit_analysis, directory);
src/link/C.zig+4-2
...@@ -17,10 +17,12 @@ pub const Header = struct {...@@ -17,10 +17,12 @@ pub const Header = struct {
17 buf: std.ArrayList(u8),17 buf: std.ArrayList(u8),
18 need_stddef: bool = false,18 need_stddef: bool = false,
19 need_stdint: bool = false,19 need_stdint: bool = false,
20 emit_loc: ?Compilation.EmitLoc,
2021
21 pub fn init(allocator: *Allocator) Header {22 pub fn init(allocator: *Allocator, emit_loc: ?Compilation.EmitLoc) Header {
22 return .{23 return .{
23 .buf = std.ArrayList(u8).init(allocator),24 .buf = std.ArrayList(u8).init(allocator),
25 .emit_loc = emit_loc,
24 };26 };
25 }27 }
2628
...@@ -81,7 +83,7 @@ pub fn openPath(allocator: *Allocator, sub_path: []const u8, options: link.Optio...@@ -81,7 +83,7 @@ pub fn openPath(allocator: *Allocator, sub_path: []const u8, options: link.Optio
81 .allocator = allocator,83 .allocator = allocator,
82 },84 },
83 .main = std.ArrayList(u8).init(allocator),85 .main = std.ArrayList(u8).init(allocator),
84 .header = Header.init(allocator),86 .header = Header.init(allocator, null),
85 .constants = std.ArrayList(u8).init(allocator),87 .constants = std.ArrayList(u8).init(allocator),
86 .called = std.StringHashMap(void).init(allocator),88 .called = std.StringHashMap(void).init(allocator),
87 };89 };