Skip to content

feat(cranelift,bex2): add Cranelift AOT backend, bex2 M:N runtime, and baml pack --native - #5850

Open
hellovai wants to merge 4 commits into
claude/cranelift-vendor-rebasedfrom
claude/cranelift-bex2-rebased
Open

hellovai wants to merge 4 commits into
claude/cranelift-vendor-rebasedfrom
claude/cranelift-bex2-rebased

Conversation

@hellovai

@hellovai hellovai commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Stack (on top of kai/mir-stack-rebased)

  1. bcu: add baml_bcu crate and move PackageInterface/BcuMeta out of TIR #5845 (claude/bcu-meta-rebased): baml_bcu crate + .bmeta
  2. bcu: add BcuModule (.bcu), parallel baml_mir_linker, and Salsa-free emit pipeline #5846 (claude/bcu-module-rebased): BcuModule (.bcu) + parallel baml_mir_linker + Salsa-free emit
  3. feat(lang,compiler,runtime): add //baml:in_class_only and baml.errors.Panic marker interface #5851 (feat/panic-interface): //baml:in_class_only and baml.errors.Panic marker interface
  4. feat(lang,compiler,runtime): migrate magic cleanup() to baml.Cleanup interface (BEP-093 Part 3) #5852 (feat/cleanup-interface): baml.Cleanup interface (BEP-093)
  5. refactor(stdlib,mir,vm): migrate pure stdlib builtins, Array callbacks, and ns_ops to pure BAML; simplify MIR builtins #5859 (feat/stdlib-pure-baml): Migrate pure stdlib builtins & Array callbacks to pure BAML
  6. feat(lang,compiler,runtime): rust items frontend (BEP-092 v4) #5863 (avery/rust-items): Rust items frontend (rust function, rust class, builtin function)
  7. feat(lang,bcu): add rust "<crate>" syntax and disjoint native metadata in BcuModule #5868 (feat/rust-crate-syntax): rust "<crate>" syntax + disjoint RustFnMeta/RustClassMeta in BcuModule
  8. feat(native): add baml_rust_workspace BEP-092 codegen and stub baml_native_rt crate #5869 (feat/native-codegen): baml_rust_workspace BEP-092 codegen + stub baml_native_rt + baml_bcu::mangle
  9. feat(cranelift): vendor cranelift-codegen 0.138 with AArch64 LSE2 + x86_64 AVX 128-bit atomics #5849 (claude/cranelift-vendor-rebased): Vendor cranelift-codegen 0.138 + LSE2/AVX 128-bit atomics
  10. feat(cranelift,bex2): add Cranelift AOT backend, bex2 M:N runtime, and baml pack --native #5850 (claude/cranelift-bex2-rebased): Cranelift AOT backend + bex2 M:N runtime + real BEP-092 C ABI + baml pack --native (this PR)

Squashed, rebased replacement for #5839, #5842, #5843, #5844 (non-vendor wiring), and #5847, stacked on top of #5849 (claude/cranelift-vendor-rebased -> #5846 claude/bcu-module-rebased -> #5845 claude/bcu-meta-rebased -> kai/mir-stack-rebased). Skips the superseded baml_runtime_abi / baml_runtime crates entirely.

What changes

  1. Clean-room bex2_* M:N runtime & GC (bex2_heap_types, bex2_heap, bex2_io, bex2_scheduler, bex2_runtime):
    • Native 128-bit atomic Value slots (no BUSY_BIT), seqlock maps, wait-free arrays, geometric Cheney semi-space copying GC with safepoint stack maps, and STW coordination.
    • M:N work-stealing scheduler (bex2_scheduler) with Chase-Lev deques, two-tier package initialization, cancellation DAGs, and direct-poll Tokio I/O (bex2_io).
    • Full runtime ops, JSON parse/stringify, and native CLI entry point (bex2_runtime).
  2. Cranelift AOT backend (baml_cranelift):
    • Lowers linked .bcu MIR (LinkedMirProgram) to native object files using the vendored cranelift-codegen 0.138 ([patch.crates-io]).
    • Pinned mutator register, CallConv::Tail + TCO, scalar call ABI, can_throw elision, safepoint prologue/backedge polls, and AArch64 LSE2 + x86_64 AVX 128-bit atomic lowering.
  3. CLI native packing & E2E suites (baml_cli, baml_db, baml_tests, stow.toml, nextest.toml):
    • Wires baml pack --native + native linking (native_link.rs, pack_command.rs, pack_native_e2e.rs, cranelift_e2e.rs).
    • Enforces crate boundaries for baml_cranelift and bex2_* in baml_language/stow.toml.

Rebase adaptations for kai/mir-stack-rebased / #5846

  • Adapted baml_cranelift/src/{lower,reach}.rs for Rvalue::LoadType { template, .. } and removed TyTemplate/RuntimeTy/RealizedTy::RustType variants.
  • Added rust_type: None to LocalClassDecl test fixtures in baml_cranelift/src/lib.rs.
  • Kept upstream kai/mir-stack-rebased catch-divergence handling in baml_compiler2_hir_ty/src/infer.rs (0 diff in baml_compiler2_hir_ty).
  • Added baml_fmt to the baml_base allowlist in baml_language/stow.toml.

Observable checks

  • cargo run --profile fasttest -p cargo-stow -- stow --check: 0 violations.
  • cargo fmt --all: clean.
  • Unit / integration tests:
  • cargo clippy --profile fasttest --no-deps --tests -p bex2_heap_types -p bex2_heap -p bex2_io -p bex2_scheduler -p bex2_runtime -p baml_cranelift -p baml_db -p baml_cli -- -D warnings: 0 warnings.

@vercel

vercel Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
developer-docs Ready Ready Preview Dec 4, 2026 7:16pm UTC

Request Review

@coderabbitai

coderabbitai Bot commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 7ea751fe-2dcc-4830-9c1c-bf4b0f0ee2a4

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@blacksmith-sh

blacksmith-sh Bot commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Found 18 test failures on Blacksmith runners:

Failures

Test View Logs
Anthropic Provider/Anthropic Provider should support anthropic shorthand View Logs
Anthropic Provider/
Anthropic Provider Streaming should support anthropic shorthand streaming
View Logs
AWS Provider/
AWS Provider Dynamic Client Registry Credential Resolution should handle session creden
tials correctly
View Logs
AWS Provider/
AWS Provider Dynamic Client Registry should throw error when using temporary credential
s without session token
View Logs
Azure Provider/
Azure Provider should support o1 model with explicit max_completion_tokens
View Logs
Collector Tests/Collector Tests should track cached input tokens for Anthropic caching View Logs
Experimental OnTick/
Experimental OnTick should fire onTick callbacks for async non-streaming function
View Logs
Experimental OnTick/
Experimental OnTick should fire onTick callbacks for streaming function
View Logs
Experimental OnTick/Experimental OnTick should handle onTick callback errors View Logs
Experimental OnTick/Experimental OnTick should not significantly impact performance View Logs

...and 8 more test failures. View all on Blacksmith

Fix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

…ped JSON errors, and @@rust_type slots

- Fix ARM64 (FEAT_LRCPC) Dekker lost-wakeup races in bex2_scheduler by
  upgrading wake_task, io_notified, CancelToken, Semaphore admission,
  AtomicLockTable, Future settlement, and AwaitAnyGroup paired atomic
  loads/stores/CASes to Ordering::SeqCst.
- Support uint8array (BytesObject) indexing in array_get, array_set
  (with low-8-bit masking and COW protection on shared Arc), and array_len.
- Decode uint8array.to_string() lossily as UTF-8 via baml_rt_bytes_to_string_lossy
  instead of returning debug '<uint8array len=N>'.
- Register and throw typed baml.json.{ParseError, DecodeError, SerializationError}
  instances with jq-style paths and reason tags from baml_rt_json_* entrypoints.
- Emit synthetic handle slot 0 for @@rust_type classes with zero BAML fields in
  rodata.rs and align Semaphore._admit/_admitted/_wait_permit with Permit handles.
- Add unit, Dekker stress, and Cranelift E2E regression tests (29/29 passing).
…tive_rt, baml_rust_workspace, and baml_cranelift

This branch was successfully deployed

1 active deployment
Preview – developer-docs — fb530c3c Deployed Dec 4, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant