Skip to content

Commit 853cbd9

Browse files
committed
Link MCJIT when first JIT is created
1 parent 0f1c6d2 commit 853cbd9

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Sources/LLVM/JIT.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ public final class JIT {
3232
/// The underlying LLVMExecutionEngineRef backing this JIT.
3333
internal let llvm: LLVMExecutionEngineRef
3434

35+
private static var linkOnce: () = {
36+
return LLVMLinkInMCJIT()
37+
}()
38+
3539
/// Creates a Just In Time compiler that will compile the code in the
3640
/// provided `Module` to the architecture of the provided `TargetMachine`,
3741
/// and execute it.
@@ -41,6 +45,8 @@ public final class JIT {
4145
/// - machine: The target machine which you're compiling for
4246
/// - throws: JITError
4347
public init(module: Module, machine: TargetMachine) throws {
48+
_ = JIT.linkOnce
49+
4450
var jit: LLVMExecutionEngineRef?
4551
var error: UnsafeMutablePointer<Int8>?
4652
if LLVMCreateExecutionEngineForModule(&jit, module.llvm, &error) != 0 {

0 commit comments

Comments
 (0)