diff --git a/include/xo/jit/Jit.hpp b/include/xo/jit/Jit.hpp index 26c81e05..57e8cf9e 100644 --- a/include/xo/jit/Jit.hpp +++ b/include/xo/jit/Jit.hpp @@ -97,6 +97,9 @@ namespace xo { #endif ); + /* iniitialize native builder (i.e. for platform we're running on) */ + static void init_once(); + private: // ----- this part adapted from LLVM 19.0 KaleidoscopeJIT.hpp [wip] ----- diff --git a/src/jit/Jit.cpp b/src/jit/Jit.cpp index 66412b67..6a2d43a5 100644 --- a/src/jit/Jit.cpp +++ b/src/jit/Jit.cpp @@ -15,6 +15,18 @@ namespace xo { using std::endl; namespace jit { + void + Jit::init_once() { + static bool s_init_once = false; + + if (!s_init_once) { + s_init_once = true; + + llvm::InitializeNativeTarget(); + llvm::InitializeNativeTargetAsmPrinter(); + llvm::InitializeNativeTargetAsmParser(); + } + } /*init_once*/ /* tracking KaleidoscopeJIT::Create() here.. * @@ -29,6 +41,8 @@ namespace xo { llvm::Expected> Jit::make_aux() { + Jit::init_once(); + #ifdef NOT_USING /* 'executor process control' */ auto epc = llvm::orc::SelfExecutorProcessControl::Create();