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.
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
}
main :: IO ()
-main =
+main = do
+ loadLibraryPermanently (Just "stdlib.dylib")
withContext $ \ctx -> withHostTargetMachineDefault $ \tm ->
withExecutionSession $ \exSession ->
withSymbolResolver exSession (SymbolResolver symResolver) $ \symResolverPtr ->