Skip to main content

Abi

Trait Abi 

Source
pub trait Abi {
    // Required methods
    fn target_os(&self) -> TargetOperatingSystem;
    fn mangle_function_name(&self, name: &str) -> String;

    // Provided methods
    fn builtin_library(&self) -> BuiltinLibrary { ... }
    fn call_stub(&self, name: &str) -> Option<String> { ... }
}
Expand description

Trait defining the common interface for all ABI implementations.

This contract covers name mangling, builtin symbol mapping, and the minimal calling convention expectations shared by MIR backends.

§Calling Convention Assumptions

  • Arguments are passed using the platform C ABI register order, with overflow arguments spilled to the stack.
  • Integer arguments use 64-bit slots, even for narrower integer types.
  • Return values use the C ABI integer return register when present.

§Builtins

  • Builtins are resolved by call_stub, which can be overridden with the LAMINA_BUILTINS environment variable.
  • The builtin map recognizes every RuntimeSymbol.

§Naming

  • Backends must apply platform-specific symbol mangling, such as the underscore prefix on macOS.

Required Methods§

Source

fn target_os(&self) -> TargetOperatingSystem

Returns the target operating system for this ABI instance.

Source

fn mangle_function_name(&self, name: &str) -> String

Returns the mangled function name with platform-specific prefix.

This method handles platform-specific symbol naming conventions, such as the underscore prefix on macOS.

Provided Methods§

Source

fn builtin_library(&self) -> BuiltinLibrary

Source

fn call_stub(&self, name: &str) -> Option<String>

Maps well-known intrinsic/runtime names to platform symbol stubs.

Returns None if the name is not a known intrinsic that needs special handling. This lets backends map internal names (like “dealloc”) to platform-specific symbols (like “_free” on macOS).

Default implementation returns None for all names, meaning no special mapping is needed.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§