-
Notifications
You must be signed in to change notification settings - Fork 13.3k
rustc 1.18.0 misaligned loads and stores on SPARC #43346
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
You're transmuting from a |
Perhaps I failed to trim down blake2b.rs correctly, but this is the same error I'm seeing in the compiler, out of https://github.com/rust-lang/rust/blob/master/src/librustc_data_structures/blake2b.rs Though there the loads are more complex:
(See the |
Ah, ok. That would have worked before the patch, of course. |
Yes. Or by using |
It doesn't look like I can use I reimplemented the I could, I suppose, build a patched 1.18.0 and use that for the bootstrap so that the above I'll leave this open until someone else wants to pick it up. If anyone thinks it'd be worthwhile for me to simply submit a PR with my slow code, and get it code-reviewed into existence as folks have time, I'm happy to do that. |
I think the simplest workaround would be to add |
Indeed, |
On SPARC, optimization fuel ends up emitting incorrect load and store instructions for the transmute() call in blake2b_compress(). If we force Blake2bCtx to be repr(C), the problem disappears. Fixes rust-lang#43346
Constrain the layout of Blake2bCtx for proper SPARC compilation On SPARC, optimization fuel ends up emitting incorrect load and store instructions for the transmute() call in blake2b_compress(). If we force Blake2bCtx to be repr(C), the problem disappears. Fixes rust-lang#43346
My apologies for not catching this sooner.
The struct alignment and packing that landed (well, was re-enabled) with 1.18.0 produces either improperly aligned structs or improperly aligned loads and stores (or both) on SPARC. The following test program demonstrates it (extracted from where I originally saw the compiler die):
The disassembly looks like this:
Note the
ldx
of[%i0 + 0x2]
. That would be valid if%i0
were itself misaligned, but it's not, andldx
requires an 8-byte alignment. I can attach the entire IR if necessary, but I believe these are the relevant bits:I don't see anything obviously wrong in the code, but my knowledge here is pretty slim, so if it's obvious to someone else, I'd love the help. Otherwise, I'm probably going to be putting debugging statements into
rustc::ty::layout::Struct::new
, hope I'm poking around in the right area, and doing a lot of recompiling.cc @binarycrusader
The text was updated successfully, but these errors were encountered: