feat: kiln-builtins crate — no_std staticlib for synth-compiled embedded targets#175
Merged
feat: kiln-builtins crate — no_std staticlib for synth-compiled embedded targets#175
Conversation
Phase 1 stub implementation of kiln-builtins — the C ABI bridge between synth-compiled ARM code and kiln's runtime services. Per RFC #46, this is the no_std execution path for embedded targets via gale/Zephyr. Three functions: - __meld_dispatch_import: routes import calls (stub returns 0) - __meld_get_memory_base: returns linear memory base from linker symbol - cabi_realloc: bump allocator for canonical ABI memory allocation Also: __kiln_builtins_init for heap initialization. Builds for thumbv7em-none-eabi (Cortex-M4) as libkiln_builtins.a. Zero dependencies, pure no_std. Trace: skip Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
🔍 Build Diagnostics ReportSummary
🎯 Impact AnalysisIssues in Files You Modified
Cascading Issues (Your Changes Breaking Other Files)
|
Tests: - cabi_realloc uninitialized returns 0 - cabi_realloc zero size returns 0 - cabi_realloc basic allocation and sequential bumping - cabi_realloc alignment (8-byte, 4-byte from misaligned start) - cabi_realloc overflow returns 0 (checked_add) - dispatch_import stub always returns 0 Kani proofs: - cabi_realloc_never_overflows: no u32 overflow in allocation - cabi_realloc_alignment_correct: result always respects alignment - dispatch_import_always_returns_zero: stub contract Also: use checked_add for overflow safety in cabi_realloc. Trace: skip Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…igration Add Platform struct — C-compatible function pointers for hardware/OS operations (write, clock, random, exit). This supports two coexisting paths: 1. C shim (today): callbacks call Zephyr C APIs directly via FFI 2. Verified Rust (gradual): swap individual callbacks to route through gale's formally verified kernel primitives, then to Zephyr C for HW The design mirrors Zephyr's device driver API pattern: a static struct of function pointers, registered at init, no generics, no vtable. Firmware init: __kiln_init(&PLATFORM, heap_start) Migration pattern: replace one callback at a time as gale modules become available, without changing kiln-builtins or synth. Tests: 9 unit tests + 3 Kani proofs. All pass. Trace: skip Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Phase 1 stub of kiln-builtins per RFC #46 toolchain architecture. This is the C ABI bridge between synth-compiled ARM ELF binaries and kiln's runtime services.
Functions
__meld_dispatch_import(import_index: u32) -> u32— stub, returns 0__meld_get_memory_base() -> *mut u8— returns linker-provided memory basecabi_realloc(old_ptr, old_size, align, new_size) -> u32— bump allocator__kiln_builtins_init(heap_start: u32)— initialize bump allocatorBuild
cargo build -p kiln-builtins --target thumbv7em-none-eabi --release # Produces: target/thumbv7em-none-eabi/release/libkiln_builtins.aProperties
no_std, zero dependencies--link --builtinsintegration