Hello!
I'm wondering if anyone has gotten the Cranelift JIT backend working in Windows, and if there was anything special you had to do beyond a std::mem::transmute of the resulting bytes into a function and then calling it. At the moment, I'm running into a problem that smells like an ABI mismatch somewhere, where it could just be that there's some flag I need to pass to Cranelift to put it in some mode, or there may be some way I need to define the function in Rust to make the jump clean.
But, the meat of it is: I get a crash well after exiting my JITed code, because some Rust library is doing a write through RSI, and RSI has been clobbered by the Cranelift-generated code. Looking at ABI docs, RSI is used for an argument register in Linux, but looks like it's defined as callee-saved on Windows (reference). I don't see any generated code to save the register, which is what's making me wonder if there's an ABI mismatch, or possibly a bug in the definition of the register save semantics in Cranelift for Windows.
Any pointers?
-Adam
Which call conv do you use for the cranelift jitted function?
We correctly denote RSI as callee-saved in Fastcall, so I suspect the issue is that the CLIF body you're generating is marked as SysV or some other convention?
Chris Fallin said:
We correctly denote RSI as callee-saved in Fastcall, so I suspect the issue is that the CLIF body you're generating is marked as SysV or some other convention?
Ah-hah! You are correct. Thank you for reminding me of the search term; there was a stray, hard-coded CallConv::SystemV
in my code.
Last updated: Dec 23 2024 at 13:07 UTC