Installation
[]
= "0.2"
= "1"
You build the input functions with ir-lang, so it belongs alongside aot-lang. For a no_std build, disable default features: aot-lang = { version = "0.2", default-features = false }.
How it works
A compile is two stages, one per dependency it wires:
- Lower — each
ir_lang::Functionis validated and compiled to acodegen-langProgramof register bytecode. Only well-formed SSA is ever lowered. - Encode and link — each program is encoded into a
.textsection with a symbol at its start, andlinker-langplaces the objects at addresses, resolves the entry point, and produces the image.
A malformed function is rejected in the first stage as AotError::Codegen; a name collision or a missing entry point fails the second as AotError::Link.
Quick Start
Compile a single function into an image, with the function as the entry point:
use compile;
use ;
// fn square(x: int) -> int { x * x }
let mut b = new;
let x = b.block_params;
let sq = b.bin;
b.ret;
let image = compile.expect;
assert_eq!;
assert_eq!;
assert!;
Place several functions in one image with the Compiler builder, choosing the base address and entry point:
use Compiler;
use ;
// fn add(a: int, b: int) -> int { a + b }
let mut add = new;
let a = add.block_params;
let b = add.block_params;
let sum = add.bin;
add.ret;
// fn answer() -> int { 42 }
let mut answer = new;
let c = answer.iconst;
answer.ret;
let mut compiler = new;
compiler.base_address.entry;
compiler.add.unwrap;
compiler.add.unwrap;
let image = compiler.link.unwrap;
assert_eq!;
assert_eq!;
assert!;
API Overview
For a complete reference with examples for every item, see docs/API.md.
compile— ahead-of-time compile one function into an image, with it as the entry pointCompiler— a builder that accumulates functions and links them into one image, with a configurable base address and entry pointAotError— the failure type, distinguishing the code-generation stage from the link stageImage— the linked result: laid-out code, a resolved symbol table, and an entry point (re-exported fromlinker-lang)OutputSection— one laid-out section of an image (re-exported fromlinker-lang)
Highlights
- Small surface — one function, one builder, one error type. Nothing to configure that the task does not need.
- Two-stage pipeline — code generation and linking are separate, wired crates, and a failure names which stage it came from.
- Deterministic output — the object-code encoding is fixed little-endian, so recompiling the same IR yields byte-identical images across hosts.
no_std-ready — needs onlyalloc, performs no I/O, and forbidsunsafe. The whole pipeline drops the standard library together.- Cross-platform — Linux, macOS, and Windows on x86-64 and ARM64, verified in CI on all three operating systems and at the MSRV.
Contributing
See REPS.md for the engineering standards and the definition of done, and dev/ROADMAP.md for the plan to 1.0. Before a PR: cargo fmt --all, cargo clippy --all-targets --all-features -- -D warnings, and cargo test --all-features must be clean.