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