From c0262e071b9909756911c55339ba03c78d207332 Mon Sep 17 00:00:00 2001 From: Luke Lau Date: Sat, 9 Nov 2019 18:01:45 +0000 Subject: [PATCH] Load the standard library This is equivalent to dlopen(3), where it will load all the code and symbols from our standard library into our process. We need to do this so that later on we can call standard library functions whilst JITing. If you went down the statically linked route, you still need to call this with Nothing to expose the symbols to LLVM. --- Main.hs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Main.hs b/Main.hs index 97407fe..c2fff06 100644 --- a/Main.hs +++ b/Main.hs @@ -19,6 +19,7 @@ import LLVM.AST.Operand import LLVM.AST.Type as Type import LLVM.Context import LLVM.IRBuilder +import LLVM.Linking import LLVM.Module import LLVM.OrcJIT import LLVM.OrcJIT.CompileLayer @@ -38,7 +39,8 @@ data JITEnv = JITEnv } main :: IO () -main = +main = do + loadLibraryPermanently (Just "stdlib.dylib") withContext $ \ctx -> withHostTargetMachineDefault $ \tm -> withExecutionSession $ \exSession -> withSymbolResolver exSession (SymbolResolver symResolver) $ \symResolverPtr -> -- 2.30.2