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,
128128test_name_prefix: ?[]const u8,
129129test_evented_io: bool,
130130
131emit_h: ?EmitLoc,
132131emit_asm: ?EmitLoc,
133132emit_llvm_ir: ?EmitLoc,
134133emit_analysis: ?EmitLoc,
135134emit_docs: ?EmitLoc,
135
136136c_header: ?c_link.Header,
137137
138138pub const InnerError = Module.InnerError;
......@@ -973,8 +973,7 @@ pub fn create(gpa: *Allocator, options: InitOptions) !*Compilation {
973973 .local_cache_directory = options.local_cache_directory,
974974 .global_cache_directory = options.global_cache_directory,
975975 .bin_file = bin_file,
976 .emit_h = options.emit_h,
977 .c_header = if (!use_llvm and options.emit_h != null) c_link.Header.init(gpa) else null,
976 .c_header = if (!use_llvm and options.emit_h != null) c_link.Header.init(gpa, options.emit_h) else null,
978977 .emit_asm = options.emit_asm,
979978 .emit_llvm_ir = options.emit_llvm_ir,
980979 .emit_analysis = options.emit_analysis,
......@@ -1289,7 +1288,7 @@ pub fn update(self: *Compilation) !void {
12891288
12901289 // If we've chosen to emit a C header, flush the header to the disk.
12911290 if (self.c_header) |header| {
1292 const header_path = self.emit_h.?;
1291 const header_path = header.emit_loc.?;
12931292 // If a directory has been provided, write the header there. Otherwise, just write it to the
12941293 // cache directory.
12951294 const header_dir = if (header_path.directory) |dir|
......@@ -2952,7 +2951,7 @@ fn updateStage1Module(comp: *Compilation, main_progress_node: *std.Progress.Node
29522951 man.hash.add(comp.bin_file.options.function_sections);
29532952 man.hash.add(comp.bin_file.options.is_test);
29542953 man.hash.add(comp.bin_file.options.emit != null);
2955 man.hash.addOptionalEmitLoc(comp.emit_h);
2954 man.hash.add(comp.c_header != null);
29562955 man.hash.addOptionalEmitLoc(comp.emit_asm);
29572956 man.hash.addOptionalEmitLoc(comp.emit_llvm_ir);
29582957 man.hash.addOptionalEmitLoc(comp.emit_analysis);
......@@ -3051,10 +3050,10 @@ fn updateStage1Module(comp: *Compilation, main_progress_node: *std.Progress.Node
30513050 });
30523051 break :blk try directory.join(arena, &[_][]const u8{bin_basename});
30533052 } else "";
3054 if (comp.emit_h != null) {
3053 if (comp.c_header != null) {
30553054 log.warn("-femit-h is not available in the stage1 backend; no .h file will be produced", .{});
30563055 }
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);
30583057 const emit_asm_path = try stage1LocPath(arena, comp.emit_asm, directory);
30593058 const emit_llvm_ir_path = try stage1LocPath(arena, comp.emit_llvm_ir, directory);
30603059 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 {
1717 buf: std.ArrayList(u8),
1818 need_stddef: bool = false,
1919 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 {
2223 return .{
2324 .buf = std.ArrayList(u8).init(allocator),
25 .emit_loc = emit_loc,
2426 };
2527 }
2628
......@@ -81,7 +83,7 @@ pub fn openPath(allocator: *Allocator, sub_path: []const u8, options: link.Optio
8183 .allocator = allocator,
8284 },
8385 .main = std.ArrayList(u8).init(allocator),
84 .header = Header.init(allocator),
86 .header = Header.init(allocator, null),
8587 .constants = std.ArrayList(u8).init(allocator),
8688 .called = std.StringHashMap(void).init(allocator),
8789 };