diff options
| author | Jacob Young <jacobly0@users.noreply.github.com> | 2023-10-18 18:43:48 -0400 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2023-10-19 16:51:11 -0400 |
| commit | 4d106076c3db840f786460e281aded056053ac35 (patch) | |
| tree | 34b1c1babde7ae4dfafbedf550f04a251927e4c7 /src/codegen | |
| parent | 530dc0405c9f48fa3b241f078cf815164e4448ab (diff) | |
| download | zig-4d106076c3db840f786460e281aded056053ac35.tar.gz zig-4d106076c3db840f786460e281aded056053ac35.zip | |
link: initialize llvm before calling the llvm API
Diffstat (limited to 'src/codegen')
| -rw-r--r-- | src/codegen/llvm/Builder.zig | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/codegen/llvm/Builder.zig b/src/codegen/llvm/Builder.zig index a4209da40a..5a9703af3d 100644 --- a/src/codegen/llvm/Builder.zig +++ b/src/codegen/llvm/Builder.zig @@ -7999,11 +7999,13 @@ pub fn init(options: Options) InitError!Builder { assert(try self.string("") == .empty); if (options.name.len > 0) self.source_filename = try self.string(options.name); - self.initializeLLVMTarget(options.target.cpu.arch); - if (self.useLibLlvm()) self.llvm.module = llvm.Module.createWithName( - (self.source_filename.slice(&self) orelse ""), - self.llvm.context, - ); + if (self.useLibLlvm()) { + initializeLLVMTarget(options.target.cpu.arch); + self.llvm.module = llvm.Module.createWithName( + (self.source_filename.slice(&self) orelse ""), + self.llvm.context, + ); + } if (options.triple.len > 0) { self.target_triple = try self.string(options.triple); @@ -8117,8 +8119,7 @@ pub fn deinit(self: *Builder) void { self.* = undefined; } -pub fn initializeLLVMTarget(self: *const Builder, arch: std.Target.Cpu.Arch) void { - if (!self.useLibLlvm()) return; +pub fn initializeLLVMTarget(arch: std.Target.Cpu.Arch) void { switch (arch) { .aarch64, .aarch64_be, .aarch64_32 => { llvm.LLVMInitializeAArch64Target(); |
