-
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
Constants seem to be broken in nightly Rust on powerpc-unknown-linux-gnu #39061
Comments
Most likely the cause of this is i128 support (PR that implemented it: #38482). At least on windows (both x86_64 and i686), @nagisa and me have experienced the same issue (literal parsing being broken) when doing computations. Literal parsing is one of the areas i128 get used inside the compiler. It turned out to be an ABI mismatch between what LLVM thinks the ABI is, and our own ABI use. It got worked around until LLVM fixes it. Guess the segfault is also due to this. |
cc #35118 |
@est31’s analysis sounds plausible. No PPC to validate it on, though and qemu-ppc SIGSEGVs left and right. |
I could reproduce the issue, investigating. |
So, the ABI seems to be honoured. In the simplest case of const TEST_NUM_CONST: u128 = 123; two intrinsics are being called: 1st argument is passed in via registers r3:r4:r5:r6 (where 6 are LSB); 2nd argument is passed via r7:r8:r9:r10. Return value is stored in r3:r4:r5:r6 as well. Both caller (LLVM) and callee (rustc-generated code) honour these rules for trivial test cases I’ve constructed. These functions are called in this way:
I did not investigate in depth why this happens yet, but seems to be an issue within the multiplication intrinsic, rather than FFI layer. |
I may or may not suspect the byteorder assumptions. PPC are big-endian, which may be invalidating all the “black” magic going on within the intrinsics. EDIT: I will try to compile rustc with explicit conversion to and from low endian added in tomorrow and see if that fixes it. |
Oh, if its an endianness issue, it might be caused by this implementation: https://github.com/rust-lang/rust/blob/master/src/libcompiler_builtins/lib.rs#L407 You can try replacing it with a shift (and below in the |
@dusxmt can you re-try again with the newest nightly |
Closing as resolved! |
Good day, it appears that something is wrong with constants on the 32-bit powerpc linux flavor of nightly rustc, here's a simple example program:
What I expect it to output, and what it does indeed output on x86_64, is:
However, on PowerPC, rustc fails with:
If I comment out the numeric constant and its use, leaving the structure constant in, rustc reliably crashes due to memory corruption:
(link to full output: https://gist.github.com/dusxmt/1601ecd375e3092955ff8ec9c8a69456 )
$ rustc --version --verbose
rustc 1.16.0-nightly (1a2ed98 2017-01-13)
binary: rustc
commit-hash: 1a2ed98
commit-date: 2017-01-13
host: powerpc-unknown-linux-gnu
release: 1.16.0-nightly
LLVM version: 3.9
$ uname -a
Linux power-dooshki 4.4.39-gentoo #1 Fri Jan 6 23:47:44 CET 2017 ppc 7450, altivec supported PowerBook3,3 GNU/Linux
The text was updated successfully, but these errors were encountered: