Hey, I ma writing my own compiler, not written in Rust and I wanted to use cranelift, does it have any C ABI I could use to dynamically link it to my project?
Unfortunately no. This is something we might be interested in taking PRs for, though -- the equivalent of the c-api crate for Wasmtime, but for cranelift-codegen + cranelift-frontend. It would be a nontrivial amount of work, though
There was another thread in this forum about how most of Cranelift was compiled down to WASM, so while not a C API, the interface to the WASM binary was probably spelled out very clearly. There they already had a JVM that could run WASM so they already had a host environment. Exception handling or traps still required some hand edits I think.
I think https://github.com/roastedroot/chicory-redline/blob/main/wasm-build/src/lib.rs is the rust side of their c api.
@andreaTP is on here and could probably shed more light on it
Last updated: May 03 2026 at 21:15 UTC