• OctoMY API
  • OctoMY API Reference
  • C++ Classes
  • OctoMY
  • NativeCompiler
  • construct::native::NativeCompiler Class

    Compiles C++ source or LLVM IR to native code in-process, with the vendored LLVM. More...

    Header: #include <NativeCompiler>

    Public Functions

    construct::native::JitLlvmResult jitLlvmIr(const QString &irText, const QString &symbol)

    Detailed Description

    libeval's native lane, the construct editor, libfixo and libfirmware all compile through it. compile() builds C++ source into a shared library with in-process Clang and lld. compileLlvmIr() does the same for textual LLVM IR. jitLlvmIr() links LLVM IR into the running process with ORC and returns a callable entry point, with no file on disk.

    It needs nothing installed. The only toolchain is the LLVM vendored into the build. A build without it gets stub methods that fail with a message, and isAvailable() returns false, so a caller can hide the feature instead of offering it.

    Built libraries are cached by their source. A caller makes a NativeCompiler where it needs one; the result of jitLlvmIr() owns the linked code, and the entry point is valid only while that result lives.

    See also LLVMShadeRunTask.

    Member Function Documentation

    construct::native::JitLlvmResult NativeCompiler::jitLlvmIr(const QString &irText, const QString &symbol)

    `SUP-4` — ORC links the emitted code in this process.

    No object file, no `.so`, no `dlopen`. The IR is parsed and verified exactly as \ref compileLlvmIr does — the emitter gets the same two independent checks either way — and then handed to `LLJIT`, which compiles and links it into executable memory.

    **Why in memory, stated where it will be read**: Android tightened W^X, and a JIT that must write an executable file is one tightening away from not working. `SUR-7` is the finding; this is the mechanism that answers it.

    **The process symbol generator is not optional.** The emitted code calls `tanf`, `atan2f` and friends, and without a generator resolving against the host process those come back as "Symbols not found" — a message that reads like a defect in the emitter rather than a missing search path.