Expand description
Stage 1.B — LTO co-compile backbone (closed-world CallNative).
GraalVM-style closed-world native dispatch: when the full host-fn
set is known at emit time (the build.rs / emit_object path,
not the open-world MCJIT / from_source path), the host Rust is
compiled to LLVM bitcode, linked into the same LLVM module as the
emitted Relon code, and run through LTO / inline so every
Op::CallNative collapses from a dynamic
relon_llvm_call_native helper hop into an inlined unit-internal
call — exactly what relon-codegen-cranelift’s static
cap_lookup -> fn_ptr arm does, but resolved fully at link time.
§Toolchain spike (the highest risk, validated first)
The host bitcode is produced by rustc’s bundled LLVM, while the
Relon module is built by the system LLVM 18.1.3 (inkwell’s
llvm18-1 feature). On this host rustc ships LLVM 22 — a 4-major
skew. Raw rustc --emit=llvm-bc embeds a ThinLTO module-summary
whose version (12) the LLVM-18 bitcode reader rejects
(Invalid summary version 12), so link_in_module cannot consume
it directly.
The bridge that works: emit textual IR (rustc --emit=llvm-ir)
and parse it in-process with inkwell’s LLVM-18 parser
(Context::create_module_from_ir). LLVM’s textual IR is
forward-compatible enough across this skew that the 18.1.3 parser
accepts rustc-22’s .ll, yielding an LLVM-18 module the inkwell
module links cleanly — no external llvm-as-18 binary required.
The host fn is then marked
alwaysinline so the O3 pipeline fully inlines it (the rustc
default attribute set — probe-stack / target-cpu — otherwise
makes the cost-model decline even a trivial single-use call).
Everything here is gated behind explicit calls; the open-world
MCJIT path (evaluator.rs) is untouched and remains the default.
Structs§
- Cocompiled
Module - Result of a closed-world co-compile: the post-O3 module IR text
(for inline-count assertions) plus a JIT execution engine kept
alive alongside its leaked
Contextso callers can run the entry.
Functions§
- cocompile_
legacy_ i64 - Co-compile a closed-world legacy-i64 IR module against a host shim crate.