Hand-written Cranelift calls bypass the shared ABI catalog and desynchronize JIT, AOT, and runtime extern "C-unwind" implementations.
FAQ and troubleshooting
Platform spec article
FAQ and troubleshooting
Spec standingStandard
-
Codegen must not invent alternate calling conventions for runtime builtins.
Context
Decision
Rule Detail Catalog BUILTIN_SPECSinbeskid_abi::builtinsis the sole source of Cranelift import signatures (ABI-002)Codegen declare_builtin_importsbuildsFuncIds only from specsDiverging builtins AbiReturnKind::Neverforpanicso unreachable blocks are correctParity Symbol strings in specs must match RUNTIME_EXPORT_SYMBOLSentries (ABI-001)Consequences
New builtins require spec,
BUILTIN_SPECS,symbols.rs, andbeskid_runtime::builtinsin one change set.Verification anchors
compiler/crates/beskid_codegen;compiler/crates/beskid_abi/src/builtins.rs. -
no_mangle extern C-unwind symbols implement the stable host surface.
Context
Generated code calls runtime entrypoints across JIT relink and AOT link. Rust panics across the boundary must use the platform unwind ABI expected by Cranelift
callsites.Decision
Rule Detail Export attribute Implementations use #[unsafe(no_mangle)] pub extern "C-unwind"inbeskid_runtime::builtinsRegistry RUNTIME_EXPORT_SYMBOLSlists every export the linker/JIT registersLayout types BeskidStr{ ptr, len }andBeskidArray{ ptr, len, cap }are normative payload headersFamilies Allocation, GC, fibers, channels, interop dispatch, IO, and panicshare one catalogConsequences
Host tooling resolves imports by symbol name +
BUILTIN_SPECSsignature, not Rust mangling.Verification anchors
compiler/crates/beskid_runtime/src/builtins/mod.rs;compiler/crates/beskid_runtime/src/lib.rsre-exports.
- Contracts and edge cases MUST rules for builtin signatures, return kinds, and export name stability.
- Design model BuiltinFnSpec catalog, runtime export symbols, and codegen import boundaries.
- Examples Reading BUILTIN_SPECS, mapping symbols to runtime modules, and typical call patterns.
- FAQ and troubleshooting Builtin symbol drift, signature mismatches, and codegen/runtime debugging.
- Flow and algorithm From lowering call sites through BUILTIN_SPECS to runtime C exports.
- Verification and traceability Crate paths and tests that pin builtin specs to runtime exports.
0 revisions (git unavailable at build; counts may be empty)
No commits recorded for this path.
| Section id | Required | Found |
|---|---|---|
what-this-feature-specifies | yes | yes |
implementation-anchors | yes | yes |
Full tree: run pnpm verify:platform-spec-layout (writes src/generated/platform-spec-layout-report.json).
Why separate BUILTIN_SPECS and RUNTIME_EXPORT_SYMBOLS?
Section titled “Why separate BUILTIN_SPECS and RUNTIME_EXPORT_SYMBOLS?”Names alone are insufficient for Cranelift: BuiltinFnSpec carries parameter and return kinds. The export list additionally includes symbols resolved without going through the spec table (for example version export) and documents the linker surface for AOT.
Can I add a builtin only in runtime?
Section titled “Can I add a builtin only in runtime?”No (BLT-001). Codegen will not declare the import; JIT fails at finalize or AOT fails at link.
What calling convention is used?
Section titled “What calling convention is used?”Generated code uses the Cranelift default for the host ISA; runtime exports use extern "C-unwind" so panics across the boundary remain defined for Rust host frames.
Do fiber builtins use Fiber<T> in the ABI?
Section titled “Do fiber builtins use Fiber<T> in the ABI?”No. ABI uses raw ids and pointers; generic Fiber<T> is a corelib surface. See Fiber scheduler.
Troubleshooting
Section titled “Troubleshooting”| Symptom | Likely fix |
|---|---|
MissingFunction for channel_receive | Call site uses old symbol; use channel_receive_status / channel_receive_value |
| CLIF verify failure on builtin call | Arity mismatch—update BUILTIN_SPECS and lowering together |
| GC heap corruption after new store | Missing gc_write_barrier in lowering for pointer write |
array_new always null data pointer | Build runtime with --features arrays_backing if tests need backing storage |