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?
extern "C"
in rust is the platform default ABI, so SystemV on Unix and WindowsFastcall on Windows.
Which examples are you referring to specifically?
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?
make_signature()
uses the C abi by default.
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.
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: Dec 23 2024 at 12:05 UTC