{
"$type": "site.standard.document",
"bskyPostRef": {
"cid": "bafyreifq4mei2ckoc75k3xeln2qy3pnj6ng5wcyporveggrsa2nwk6gcxm",
"uri": "at://did:plc:ivbknywyskln22er3nkssdhl/app.bsky.feed.post/3mndkh7xtcaj2"
},
"path": "/t/race-semantic-linker-approach-to-stable-cross-crate-abi-without-runtime-overhead/24369#post_1",
"publishedAt": "2026-06-02T21:20:19.000Z",
"site": "https://internals.rust-lang.org",
"textContent": "_This is a pre-RFC exploration. Presenting it to gather feedback before considering a formal RFC._\n\n* * *\n\n**Problem**\n\nRust currently has no stable ABI. This is a deliberate and reasonable decision — it allows the compiler to optimize freely. However, it creates a hard barrier in several real-world scenarios:\n\n * Bevy and other engines cannot distribute pre-compiled plugins as `.so` files\n * Rust for Linux is constrained to isolated drivers with no deeper integration\n * Any ecosystem requiring independently compiled binary modules hits this wall\n\n\n\nThe usual workaround is `#[repr(C)]`, which is a lossy escape hatch — you lose Rust's type expressiveness and optimization potential.\n\n* * *\n\n**Proposed concept: RACE (Rust Advanced Contract Enforcement)**\n\nInstead of freezing a fixed ABI at the language level, RACE proposes moving ABI resolution to link time via a semantic-aware linker.\n\n**1.`.rcrate` format** Compiled crates emit an intermediate `.rcrate` file containing:\n\n * Polymorphic machine code\n * A Semantic Type & Effects Graph (STEG) — rich type metadata beyond what DWARF provides\n\n\n\n**2. Symbolic Layout Offsets** Field offsets are not baked into instructions at compile time. Instead, the final linker resolves and patches them as computed constants — zero runtime cost, no temporary allocations.\n\n**3. vtable layout synthesis** `dyn Trait` vtables are a core ABI concern — reordering methods breaks call sites. RACE proposes vtable remapping at link time: the linker matches methods by identity and type metadata, synthesizing an adapted vtable layout to satisfy the caller's expectations.\n\nThis moves ownership/lifetime/type contract validation entirely to compile+link time, producing a fully monolithic binary with no runtime abstraction layers — suitable for `no_std` and hard real-time environments.\n\n* * *\n\n**What this would unlock**\n\n * Distributable pre-compiled Bevy plugins\n * Deeper Rust integration in the Linux kernel\n * Stable plugin ecosystems without WASM overhead\n\n\n\n* * *\n\n**Open questions**\n\n * Is STEG expressible within or alongside existing MIR metadata?\n * Are there soundness barriers to vtable remapping that make this approach unsafe?\n * Has anything similar been explored — e.g. in Swift's ABI stability work?\n\n",
"title": "RACE: Semantic-linker approach to stable cross-crate ABI without runtime overhead"
}