From e8a2297ac0c705375a95db9ca50e404e25c336de Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sat, 15 Jun 2024 15:11:59 -0400 Subject: [PATCH] xo-jit: need global initialization as per kaleidoscope4 --- include/xo/jit/Jit.hpp | 3 +++ src/jit/Jit.cpp | 14 ++++++++++++++ 2 files changed, 17 insertions(+) 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();