This is a pre-RFC exploration. Presenting it to gather feedback before considering a formal RFC.
Problem
Rust 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:
- Bevy and other engines cannot distribute pre-compiled plugins as
.sofiles - Rust for Linux is constrained to isolated drivers with no deeper integration
- Any ecosystem requiring independently compiled binary modules hits this wall
The usual workaround is #[repr(C)], which is a lossy escape hatch β you lose Rust's type expressiveness and optimization potential.
Proposed concept: RACE (Rust Advanced Contract Enforcement)
Instead of freezing a fixed ABI at the language level, RACE proposes moving ABI resolution to link time via a semantic-aware linker.
1. .rcrate format
Compiled crates emit an intermediate .rcrate file containing:
- Polymorphic machine code
- A Semantic Type & Effects Graph (STEG) β rich type metadata beyond what DWARF provides
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.
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.
This 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.
What this would unlock
- Distributable pre-compiled Bevy plugins
- Deeper Rust integration in the Linux kernel
- Stable plugin ecosystems without WASM overhead
Open questions
- Is STEG expressible within or alongside existing MIR metadata?
- Are there soundness barriers to vtable remapping that make this approach unsafe?
- Has anything similar been explored β e.g. in Swift's ABI stability work?