Hand-written Cranelift calls bypass the shared ABI catalog and desynchronize JIT, AOT, and runtime extern "C-unwind" implementations.
Examples
Platform spec article
Examples
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).
Locating a builtin implementation
Section titled “Locating a builtin implementation”Given CLIF calling fiber_yield:
- Find
SYM_FIBER_YIELD→"fiber_yield"insymbols.rs. - Locate
BuiltinFnSpecwithsymbol: SYM_FIBER_YIELDinbuiltins.rs. - Open
compiler/crates/beskid_runtime/src/builtins/fiber.rsfor behavior (park current fiber, requeue).
Corelib indirection
Section titled “Corelib indirection”User code calls Fiber.Yield() in corelib_concurrency; lowering must not embed scheduler details. The package emits a call to fiber_yield only—see Concurrency package.
Allocation + GC root scenario
Section titled “Allocation + GC root scenario”A global string cached from native code:
- Lowering calls
allocwith type descriptor pointer. - Host registers root via
gc_register_rootwhen exposing to foreign API. - On teardown,
gc_unregister_rootpairs with registration.
Missing unroot leaks until next collection; handles from gc_root_handle document temporary pinning.
Panic from bounds check
Section titled “Panic from bounds check”Lowering may emit:
call panic(message_ptr, message_len) -> neverRuntime formats output and terminates the process—no stack unwind through Beskid frames (error model legacy).
Inspecting JIT registration
Section titled “Inspecting JIT registration”In jit_module.rs, the declare_builtin_imports block maps each beskid_runtime function pointer to the symbol name Cranelift imports. A drift between Rust function export name and SYM_* constant breaks finalize with MissingFunction.
Related topics
Section titled “Related topics”- Verification and traceability
- Legacy symbol list: Runtime ABI (v0.1)