Stream: cranelift

Topic: C ABI


view this post on Zulip PROMETHIA (May 22 2023 at 12:57):

I've noticed that it seems like cranelift is unable to produce or call C ABI functions. Are there any plans to be able to do so or am I missing something obvious?
I've also noticed that lots of examples, especially JIT ones, seem to use C ABI in rust to communicate with the jitted functions which are usually platform default ABI, such as fastcall/systemV. Given that rust can choose every ABI that cranelift supports, including the default system ABI, shouldn't these examples all use something like SystemV instead?

view this post on Zulip bjorn3 (May 22 2023 at 14:30):

extern "C" in rust is the platform default ABI, so SystemV on Unix and WindowsFastcall on Windows.

view this post on Zulip bjorn3 (May 22 2023 at 14:30):

Which examples are you referring to specifically?

view this post on Zulip PROMETHIA (May 22 2023 at 14:39):

For example, https://github.com/bytecodealliance/wasmtime/blob/main/cranelift/jit/examples/jit-minimal.rs transmutes the function pointer to an extern "C" pointer and then calls it, but it's declared (implicitly) with e.g. fastcall on windows.
And I thought extern "system" in rust was platform default, extern "C" is C ABI?

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

view this post on Zulip bjorn3 (May 22 2023 at 14:45):

make_signature() uses the C abi by default.

view this post on Zulip bjorn3 (May 22 2023 at 14:47):

On 32bit x86 Windows there is a difference between extern "system" which is used for system libraries and extern "C" which is used for the rest. On every other system there is no difference. I have been referring to extern "C" as platform default.

view this post on Zulip PROMETHIA (May 22 2023 at 14:52):

Ah, I see. I thought C ABI was referring to a concrete ABI such as cdecl, not referring to "whatever the system C compiler uses". That makes more sense. Thank you!


Last updated: Nov 22 2024 at 17:03 UTC