| author | |
| committer | |
| log | 6b8d28312ccca56d652af32bad360e9a5394fb8e |
| tree | f68700b2da3329968bc6c17e24ec085a8598d65b |
| parent | b059bb84b85ca7914d617cae7c4960a798412ea5 |
2 files changed, 17 insertions(+), 20 deletions(-)
src/link/Coff.zig+8-10| ... | ... | @@ -125,7 +125,7 @@ pub const SrcFn = void; |
| 125 | 125 | pub fn openPath(allocator: *Allocator, sub_path: []const u8, options: link.Options) !*Coff { |
| 126 | 126 | assert(options.object_format == .coff); |
| 127 | 127 | |
| 128 | if (options.use_llvm) { | |
| 128 | if (build_options.have_llvm and options.use_llvm) { | |
| 129 | 129 | const self = try createEmpty(allocator, options); |
| 130 | 130 | errdefer self.base.destroy(); |
| 131 | 131 | |
| ... | ... | @@ -657,10 +657,8 @@ pub fn updateDecl(self: *Coff, module: *Module, decl: *Module.Decl) !void { |
| 657 | 657 | const tracy = trace(@src()); |
| 658 | 658 | defer tracy.end(); |
| 659 | 659 | |
| 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); | |
| 664 | 662 | |
| 665 | 663 | var code_buffer = std.ArrayList(u8).init(self.base.allocator); |
| 666 | 664 | defer code_buffer.deinit(); |
| ... | ... | @@ -760,10 +758,8 @@ pub fn flushModule(self: *Coff, comp: *Compilation) !void { |
| 760 | 758 | const tracy = trace(@src()); |
| 761 | 759 | defer tracy.end(); |
| 762 | 760 | |
| 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); | |
| 767 | 763 | |
| 768 | 764 | if (self.text_section_size_dirty) { |
| 769 | 765 | // Write the new raw size in the .text header |
| ... | ... | @@ -1257,7 +1253,9 @@ pub fn updateDeclLineNumber(self: *Coff, module: *Module, decl: *Module.Decl) !v |
| 1257 | 1253 | } |
| 1258 | 1254 | |
| 1259 | 1255 | pub 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 | ||
| 1261 | 1259 | self.text_block_free_list.deinit(self.base.allocator); |
| 1262 | 1260 | self.offset_table.deinit(self.base.allocator); |
| 1263 | 1261 | self.offset_table_free_list.deinit(self.base.allocator); |
src/link/Elf.zig+9-10| ... | ... | @@ -228,7 +228,7 @@ pub const SrcFn = struct { |
| 228 | 228 | pub fn openPath(allocator: *Allocator, sub_path: []const u8, options: link.Options) !*Elf { |
| 229 | 229 | assert(options.object_format == .elf); |
| 230 | 230 | |
| 231 | if (options.use_llvm) { | |
| 231 | if (build_options.have_llvm and options.use_llvm) { | |
| 232 | 232 | const self = try createEmpty(allocator, options); |
| 233 | 233 | errdefer self.base.destroy(); |
| 234 | 234 | |
| ... | ... | @@ -298,7 +298,10 @@ pub fn createEmpty(gpa: *Allocator, options: link.Options) !*Elf { |
| 298 | 298 | } |
| 299 | 299 | |
| 300 | 300 | pub 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 | ||
| 302 | 305 | self.sections.deinit(self.base.allocator); |
| 303 | 306 | self.program_headers.deinit(self.base.allocator); |
| 304 | 307 | self.shstrtab.deinit(self.base.allocator); |
| ... | ... | @@ -740,10 +743,8 @@ pub fn flushModule(self: *Elf, comp: *Compilation) !void { |
| 740 | 743 | const tracy = trace(@src()); |
| 741 | 744 | defer tracy.end(); |
| 742 | 745 | |
| 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); | |
| 747 | 748 | |
| 748 | 749 | // TODO This linker code currently assumes there is only 1 compilation unit and it corresponds to the |
| 749 | 750 | // Zig source code. |
| ... | ... | @@ -2149,10 +2150,8 @@ pub fn updateDecl(self: *Elf, module: *Module, decl: *Module.Decl) !void { |
| 2149 | 2150 | const tracy = trace(@src()); |
| 2150 | 2151 | defer tracy.end(); |
| 2151 | 2152 | |
| 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); | |
| 2156 | 2155 | |
| 2157 | 2156 | var code_buffer = std.ArrayList(u8).init(self.base.allocator); |
| 2158 | 2157 | defer code_buffer.deinit(); |