-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
struct pass-by-value failing on SPARC #43894
Comments
Similar failures have been observed at some point due to mismatching ABI expectations between the two sides (e.g. rustc still passes by copying value onto stack/registers, C side expects a pointer). That would be my first shot if I were to debug this. |
In this particular case, the C side is expecting a value, not a pointer, and the C side doesn't appear to be the problem. That is, the value goes into the identity function and comes back out just as expected. What seems to be wrong is the IR rust is generating for the rust side for accessing the return value. A struct is passed into the C function and returned from the C function, but rust marks the function as returning an i16 instead, and when it goes to store the return value, it's attempting to store the lsb of the returned value instead of the msb. |
/cc @arielb1 |
Requesting an update from someone who has a SPARC machine (preferably made of hard silicon, not QEMU, to be precise): We are 5 years out from this being opened. A lot has changed, in both LLVM and Rust. Does this issue persist? If yes, updates on the recent shape of recent errors would be great. |
@binarycrusader and I have both moved on from Oracle. I don't know for sure about him, but I certainly don't have access to a SPARC machine anymore; I'm sorry. @alanc, I don't suppose there's any remaining internal need/support for Rust on SPARC, is there? |
We still require Rust on SPARC in order to build Python Cryptography, GNOME, & Firefox for Solaris. @psumbera is the current maintainer of the Rust packages in Oracle Solaris. |
The GCC Farm Project has some SPARC machines and I have access to them. I’ll keep the tab open and might get to verifying this. We had a some fixes to the SPARC ABI code recently, so chances that this might be fixed are quite significant. |
The extern-fn-struct-passing-abi test still fails with 1.59.0:
Unfortunately there are no nightly/beta/etc. builds of rustc for sparc, and I couldn’t be bothered enough to figure out how to crosscompile/get x.py work with the stable host rustc/if it would work at all. 1.59.0 sounds like a recent enough version to be a meaningful enough update for this issue though ^^ |
I'm getting this behavior on both SPARC and MIPS while trying to add struct definitions to the Both the SPARC and MIPS architectures are big endian, and they were the only two big endian architectures tested for the libc build. Not sure if that's just coincidence, but it could potentially be linked to the cause of this bug. These tests were ran and observed on qemu, not hard silicon. |
@rustbot label I-unsound |
I feel this is related to #115609 and rust-lang/compiler-team#672 @rustbot label -I-prioritize |
There are a handful of testsuite failures on SPARC that seem to be related, and they have to do with passing structs by value into C. Although in at least one case (
extern-fn-struct-passing-abi
), the C code isn't getting the right values (but there it's a floating-point value), in the integer case Shawn and I have dived into (extern-pass-TwoU8s
), that part appears to be correct. It's the retrieval of the struct's return value that seems to be wrong.The problem becomes a bit more apparent if we rebuild the test with
-g
instead of-O
. I can attach full files if necessary, but here is (what I think is the relevant part of) the IR for themain()
function:and the resulting assembly (more or less):
We believe the
sth
instruction after the call torust_dbg_extern_identity_TwoU8s
is where it goes wrong, implying something wrong with thestore
instruction in the IR.Here is the IR for the equivalent C function (albeit compiled by clang from a different version of LLVM):
Anyway, this was about as far as we got before we needed to take a break, but figured it was worth writing up and seeing if anyone here had any insights. This is all on the beta branch, at commit f38ffa8, though the failure happens on all versions of rust I've run the testsuite for.
@binarycrusader
The text was updated successfully, but these errors were encountered: