Stream: cranelift

Topic: ✔ What is the ABI of functions created with cranelift_jit?


view this post on Zulip Raekye (Feb 05 2023 at 01:40):

The JIT demo in the official repository transmutes the returned pointer to a rust function type. Wouldn't this mean cranelift's compiler backend produces the same ABI as the rust compiler? (And AFAIK Rust doesn't have a stable ABI.) I would have expected it to produce a Rust extern "C" function. I didn't do a thorough search, but I couldn't find documentation on it either. Could someone clarify? Thanks!

A fast and secure runtime for WebAssembly. Contribute to bytecodealliance/wasmtime development by creating an account on GitHub.

view this post on Zulip bjorn3 (Feb 05 2023 at 13:03):

That code is wrong. It should indeed be extern "C". While it is likely to work when only primitive types are passed, it definitively won't work as soon as more complex types are passed.

view this post on Zulip Raekye (Feb 07 2023 at 03:56):

I see, thanks for clarifying! Should someone/I submit a fix to the example? (I don't necessarily want to clutter PRs with trivial changes)

view this post on Zulip Notification Bot (Feb 07 2023 at 03:56):

Raekye has marked this topic as resolved.

view this post on Zulip bjorn3 (Feb 07 2023 at 07:56):

If you don't mind a PR is appreciated.


Last updated: Dec 23 2024 at 12:05 UTC