diff options
| author | Jacob Young <jacobly0@users.noreply.github.com> | 2023-08-09 00:24:17 -0400 |
|---|---|---|
| committer | Jacob Young <jacobly0@users.noreply.github.com> | 2023-08-09 05:47:13 -0400 |
| commit | c4848694d20c19b78657ee46f18028737290c829 (patch) | |
| tree | aca82d4ff8c67dd985dead2c09be2ba9a9f956cb /src/link/Coff.zig | |
| parent | 151c06cce40f33649fa96937d53926a7769491b9 (diff) | |
| download | zig-c4848694d20c19b78657ee46f18028737290c829.tar.gz zig-c4848694d20c19b78657ee46f18028737290c829.zip | |
llvm: enable even without libllvm linked
Diffstat (limited to 'src/link/Coff.zig')
| -rw-r--r-- | src/link/Coff.zig | 41 |
1 files changed, 14 insertions, 27 deletions
diff --git a/src/link/Coff.zig b/src/link/Coff.zig index f1b914c368..f86269fd52 100644 --- a/src/link/Coff.zig +++ b/src/link/Coff.zig @@ -225,7 +225,7 @@ pub const min_text_capacity = padToIdeal(minimum_text_block_size); pub fn openPath(allocator: Allocator, sub_path: []const u8, options: link.Options) !*Coff { assert(options.target.ofmt == .coff); - if (build_options.have_llvm and options.use_llvm) { + if (options.use_llvm) { return createEmpty(allocator, options); } @@ -267,8 +267,7 @@ pub fn createEmpty(gpa: Allocator, options: link.Options) !*Coff { .data_directories = comptime mem.zeroes([coff.IMAGE_NUMBEROF_DIRECTORY_ENTRIES]coff.ImageDataDirectory), }; - const use_llvm = build_options.have_llvm and options.use_llvm; - if (use_llvm) { + if (options.use_llvm) { self.llvm_object = try LlvmObject.create(gpa, options); } return self; @@ -277,9 +276,7 @@ pub fn createEmpty(gpa: Allocator, options: link.Options) !*Coff { pub fn deinit(self: *Coff) void { const gpa = self.base.allocator; - if (build_options.have_llvm) { - if (self.llvm_object) |llvm_object| llvm_object.destroy(gpa); - } + if (self.llvm_object) |llvm_object| llvm_object.destroy(gpa); for (self.objects.items) |*object| { object.deinit(gpa); @@ -1036,10 +1033,8 @@ pub fn updateFunc(self: *Coff, mod: *Module, func_index: InternPool.Index, air: if (build_options.skip_non_native and builtin.object_format != .coff) { @panic("Attempted to compile for object format that was disabled by build configuration"); } - if (build_options.have_llvm) { - if (self.llvm_object) |llvm_object| { - return llvm_object.updateFunc(mod, func_index, air, liveness); - } + if (self.llvm_object) |llvm_object| { + return llvm_object.updateFunc(mod, func_index, air, liveness); } const tracy = trace(@src()); defer tracy.end(); @@ -1147,9 +1142,7 @@ pub fn updateDecl( if (build_options.skip_non_native and builtin.object_format != .coff) { @panic("Attempted to compile for object format that was disabled by build configuration"); } - if (build_options.have_llvm) { - if (self.llvm_object) |llvm_object| return llvm_object.updateDecl(mod, decl_index); - } + if (self.llvm_object) |llvm_object| return llvm_object.updateDecl(mod, decl_index); const tracy = trace(@src()); defer tracy.end(); @@ -1390,9 +1383,7 @@ fn freeUnnamedConsts(self: *Coff, decl_index: Module.Decl.Index) void { } pub fn freeDecl(self: *Coff, decl_index: Module.Decl.Index) void { - if (build_options.have_llvm) { - if (self.llvm_object) |llvm_object| return llvm_object.freeDecl(decl_index); - } + if (self.llvm_object) |llvm_object| return llvm_object.freeDecl(decl_index); const mod = self.base.options.module.?; const decl = mod.declPtr(decl_index); @@ -1419,7 +1410,7 @@ pub fn updateDeclExports( const ip = &mod.intern_pool; - if (build_options.have_llvm) { + if (self.base.options.use_llvm) { // Even in the case of LLVM, we need to notice certain exported symbols in order to // detect the default subsystem. for (exports) |exp| { @@ -1448,10 +1439,10 @@ pub fn updateDeclExports( } } } - - if (self.llvm_object) |llvm_object| return llvm_object.updateDeclExports(mod, decl_index, exports); } + if (self.llvm_object) |llvm_object| return llvm_object.updateDeclExports(mod, decl_index, exports); + if (self.base.options.emit == null) return; const gpa = self.base.allocator; @@ -1583,10 +1574,8 @@ fn resolveGlobalSymbol(self: *Coff, current: SymbolWithLoc) !void { pub fn flush(self: *Coff, comp: *Compilation, prog_node: *std.Progress.Node) link.File.FlushError!void { if (self.base.options.emit == null) { - if (build_options.have_llvm) { - if (self.llvm_object) |llvm_object| { - return try llvm_object.flushModule(comp, prog_node); - } + if (self.llvm_object) |llvm_object| { + return try llvm_object.flushModule(comp, prog_node); } return; } @@ -1604,10 +1593,8 @@ pub fn flushModule(self: *Coff, comp: *Compilation, prog_node: *std.Progress.Nod const tracy = trace(@src()); defer tracy.end(); - if (build_options.have_llvm) { - if (self.llvm_object) |llvm_object| { - return try llvm_object.flushModule(comp, prog_node); - } + if (self.llvm_object) |llvm_object| { + return try llvm_object.flushModule(comp, prog_node); } var sub_prog_node = prog_node.start("COFF Flush", 0); |
