-
Notifications
You must be signed in to change notification settings - Fork 107
Link against libraries compiled by rustc #1092
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
There are a few abi incompatibilities of cg_clif with the SystemV abi (https://github.com/bjorn3/rustc_codegen_cranelift/issues/10). These mostly happen on non-scalar types that can still fit in two registers. In addition atomic operations are implemented using a glbal mutex as cranelift doesn't yet support atomic operations. (the new style backends do, bit those are still missing other things essential for cg_clif) For as long as you don't mix atomic operationa to the same location between cg_clif and cg_llvm this is not a problem. The goal is for both to eventually be compatible with each other. |
Makes sense. If this is a fixable issue with ABI compatibility, I'm happy to contribute. But I'm having trouble tracking down the precise cause of the bug. Specifically, I'm calling the JIT this way: https://github.com/willcrichton/crateton/blob/master/crates/crateton_scripts/src/lib.rs On this script at line 11: Specifically, a call to
|
I don't know where the ABI incompatibility here exactly is. The real fix would be using |
@bjorn3 the only issue with using cg_clif sysroot is that cg_clif can't bootstrap itself b/c it requires rustc_private. My game engine needs to call the cg_clif API to JIT compile code. So if I compile the game engine with cg_clif, then I get a " |
You could write a C wrapper around cg_clif and then compile cg_clif using cg_llvm, but everything else using cg_clif. In any case compiling cg_clif using cg_clif will be very bad for performance. You will want to alwaya compile it will all optimizations enabled. |
I'm experimenting with a project to use Rust as a scripting language for a Rust game engine. My goal is to compile the game engine (and stdlib) with rustc, then pass rustc-compiled data structures (eg Vec) directly to a JIT-compiled Rust script using Cranelift.
The specific issue I ran into: is it possible for Cranelift-compiled code to call rustc-compiled code? For example, I found that certain stdlib functions would segfault when called by Cranelift-compiled code due to (I believe) a violation of calling convention. I don't know how fundamental/unavoidable this issue is, so I wanted to double-check.
The text was updated successfully, but these errors were encountered: