-
Notifications
You must be signed in to change notification settings - Fork 106
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
i128 abi incompatibility with cg_llvm #1449
Comments
I can reproduce the crash with the following Cargo.toml: [package]
name = "crash_repro"
version = "0.1.0"
edition = "2021"
[dependencies]
bevy = "0.12.1"
[profile.dev.package."*"]
codegen-backend = "llvm"
opt-level = 3
[profile.dev]
codegen-backend = "cranelift" |
Found the issue: LLVM allows returning values in up to 3 registers, while Cranelift uses an implicit return value argument after the second register even when |
bytecodealliance/wasmtime#7770 should fix this. |
By the way thanks for providing the repro! It was really useful for figuring out the problem. |
The Cranelift PR has been accepted and backported to the branch that will be released in a little longer than a week. Once it has been released I will update cg_clif. |
Updated Cranelift in dc7ed16. Got a couple of other things I want to do first before syncing to the rust repo to get it on nightly. Will let you know when this is in a new nightly. |
Should be fixed on the latest nightly. |
Seems like it isn't fixed after all. |
Tried it again. Can't reproduce this crash anymore. abi-cafe does still show abi incompatibilities with cg_llvm for the i128 handling though, possibly because of https://blog.rust-lang.org/2024/03/30/i128-layout-update.html |
Will be fixed by bytecodealliance/wasmtime#8270 on x86_64-unknown-linux-gnu at least. |
With a cg_clif patched to use current Cranelift main (which contains bytecodealliance/wasmtime#8270) https://github.com/rust-lang/rustc_codegen_cranelift/actions/runs/8508177743 shows that abi-cafe now passes on x86_64-unknown-linux-gnu with the i128 test expectations updated to indicate that they are no longer broken. On x86_64-apple-darwin interoperability with cg_llvm works again too, but the clang used on GHA doesn't yet have the ABI fixes, so cg_clif <-> C is still broken for i128. |
Updated cranelift in 6ec27fe. Will sync it back to the rust repo tomorrow. |
This has been fixed on nightly now. |
Hi all,
I was informed a little over a week ago that it should be possible to mix
LLVM
and cranelift in the same rust target. I went about writing a game in bevy, and usingopt = 3
with LLVM for my dependencies. I used the following toml file to achieve this:I then added bevy as a dependency, and ran the simple example provided. All was well and the examples listed on their website run as expected. However, as soon as a
Plugin
is written in a cranelift context, and added to the LLVM emitted bevy code, a segmentation fault occurs. I suspect it might have to do with calling conventions, but my knowledge about LLVM and Cranelift is limited so I won't be much help here.Here is a minimal example that should illustrate the problem:
Compiling the following exclusively with LLVM or exclusively with Cranelift works as expected. Mixing the backends with the config provided earlier causes a segfault. I tried to investigate where exactly the segmentation fault occurs with lldb but was largely unsuccessful as it was not clear which code emitted was from cranelift and which was llvm.
Any help would be much appreciated, and I apologize I could not be more help here.
The text was updated successfully, but these errors were encountered: