authorgravatar for timonkruiper@gmail.comTimon Kruiper <timonkruiper@gmail.com> 2020-12-21 10:21:30+01:00
committergravatar for timonkruiper@gmail.comTimon Kruiper <timonkruiper@gmail.com> 2020-12-28 21:20:49+01:00
log6b8d28312ccca56d652af32bad360e9a5394fb8e
treef68700b2da3329968bc6c17e24ec085a8598d65b
parentb059bb84b85ca7914d617cae7c4960a798412ea5

stage2: fix building self-hosted without llvm-backend enabled.


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

src/link/Coff.zig+8-10
......@@ -125,7 +125,7 @@ pub const SrcFn = void;
125125pub fn openPath(allocator: *Allocator, sub_path: []const u8, options: link.Options) !*Coff {
126126 assert(options.object_format == .coff);
127127
128 if (options.use_llvm) {
128 if (build_options.have_llvm and options.use_llvm) {
129129 const self = try createEmpty(allocator, options);
130130 errdefer self.base.destroy();
131131
......@@ -657,10 +657,8 @@ pub fn updateDecl(self: *Coff, module: *Module, decl: *Module.Decl) !void {
657657 const tracy = trace(@src());
658658 defer tracy.end();
659659
660 if (self.llvm_ir_module) |llvm_ir_module| {
661 try llvm_ir_module.updateDecl(module, decl);
662 return;
663 }
660 if (build_options.have_llvm)
661 if (self.llvm_ir_module) |llvm_ir_module| return try llvm_ir_module.updateDecl(module, decl);
664662
665663 var code_buffer = std.ArrayList(u8).init(self.base.allocator);
666664 defer code_buffer.deinit();
......@@ -760,10 +758,8 @@ pub fn flushModule(self: *Coff, comp: *Compilation) !void {
760758 const tracy = trace(@src());
761759 defer tracy.end();
762760
763 if (self.llvm_ir_module) |llvm_ir_module| {
764 try llvm_ir_module.flushModule(comp);
765 return;
766 }
761 if (build_options.have_llvm)
762 if (self.llvm_ir_module) |llvm_ir_module| return try llvm_ir_module.flushModule(comp);
767763
768764 if (self.text_section_size_dirty) {
769765 // Write the new raw size in the .text header
......@@ -1257,7 +1253,9 @@ pub fn updateDeclLineNumber(self: *Coff, module: *Module, decl: *Module.Decl) !v
12571253}
12581254
12591255pub fn deinit(self: *Coff) void {
1260 if (self.llvm_ir_module) |ir_module| ir_module.deinit(self.base.allocator);
1256 if (build_options.have_llvm)
1257 if (self.llvm_ir_module) |ir_module| ir_module.deinit(self.base.allocator);
1258
12611259 self.text_block_free_list.deinit(self.base.allocator);
12621260 self.offset_table.deinit(self.base.allocator);
12631261 self.offset_table_free_list.deinit(self.base.allocator);
src/link/Elf.zig+9-10
......@@ -228,7 +228,7 @@ pub const SrcFn = struct {
228228pub fn openPath(allocator: *Allocator, sub_path: []const u8, options: link.Options) !*Elf {
229229 assert(options.object_format == .elf);
230230
231 if (options.use_llvm) {
231 if (build_options.have_llvm and options.use_llvm) {
232232 const self = try createEmpty(allocator, options);
233233 errdefer self.base.destroy();
234234
......@@ -298,7 +298,10 @@ pub fn createEmpty(gpa: *Allocator, options: link.Options) !*Elf {
298298}
299299
300300pub fn deinit(self: *Elf) void {
301 if (self.llvm_ir_module) |ir_module| ir_module.deinit(self.base.allocator);
301 if (build_options.have_llvm)
302 if (self.llvm_ir_module) |ir_module|
303 ir_module.deinit(self.base.allocator);
304
302305 self.sections.deinit(self.base.allocator);
303306 self.program_headers.deinit(self.base.allocator);
304307 self.shstrtab.deinit(self.base.allocator);
......@@ -740,10 +743,8 @@ pub fn flushModule(self: *Elf, comp: *Compilation) !void {
740743 const tracy = trace(@src());
741744 defer tracy.end();
742745
743 if (self.llvm_ir_module) |llvm_ir_module| {
744 try llvm_ir_module.flushModule(comp);
745 return;
746 }
746 if (build_options.have_llvm)
747 if (self.llvm_ir_module) |llvm_ir_module| return try llvm_ir_module.flushModule(comp);
747748
748749 // TODO This linker code currently assumes there is only 1 compilation unit and it corresponds to the
749750 // Zig source code.
......@@ -2149,10 +2150,8 @@ pub fn updateDecl(self: *Elf, module: *Module, decl: *Module.Decl) !void {
21492150 const tracy = trace(@src());
21502151 defer tracy.end();
21512152
2152 if (self.llvm_ir_module) |llvm_ir_module| {
2153 try llvm_ir_module.updateDecl(module, decl);
2154 return;
2155 }
2153 if (build_options.have_llvm)
2154 if (self.llvm_ir_module) |llvm_ir_module| return try llvm_ir_module.updateDecl(module, decl);
21562155
21572156 var code_buffer = std.ArrayList(u8).init(self.base.allocator);
21582157 defer code_buffer.deinit();