Step 03 · LLJITBuilder & initialisation
llvm::InitializeNativeTarget();
llvm::InitializeNativeTargetAsmPrinter();
llvm::InitializeNativeTargetAsmParser();
These pull the host backend (X86 / AArch64 / …) into the binary.
Without them LLJIT::create() fails with "No available targets".
We wrap the three calls behind std::call_once so it's safe to call
jit::runMain from anywhere.
Building the JIT
auto jitOrErr = llvm::orc::LLJITBuilder().create();
if (!jitOrErr) /* report toString(takeError()) */;
auto jit = std::move(*jitOrErr);
LLJITBuilder exposes knobs (setNumCompileThreads,
setDataLayout, setObjectLinkingLayerCreator, …) for advanced
setups. We accept defaults.
The DataLayout
LLJIT derives the data layout from the JIT's TargetMachine and sets
it on every module added later. That's why we can build the
Module in cp-11 without specifying a DataLayout up front — LLJIT
patches it before compilation.