-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
[beta] librand unreachable pattern on armv7-unknown-linux-gnueabihf #37630
Comments
This could be related to #37559 and it's fix (rust-lang/compiler-rt#25), now maybe the opposite situation (if the compiler uses some of the builtins during the unreachability checking). cc @japaric |
@cuviper: Just to check:
|
|
Mh, no I think 1.12.1 was not affected by that bug, so using the upstream binaries wouldn't help, I think. |
If you want, you could try with rust-lang/compiler-rt@592717e reverted, although I'm not really sure how much that will help, the code responsible for pattern checking does not seem to need any builtins from a quick glance. |
I started a build with that reverted, if you care to watch paint dry... However, assuming your fix was correct, there are two more places with explicit "aapcs": Of course the ABI of each |
Then that is probably the real problem.
I just looked around a bit in I expected the |
Yes, it's hard float, but not NEON if that matters to your point. Actually, I have another build going without that #36933 patch, in case NEON does make a difference. |
Alright, so parsing floats seems to be broken (printing constants works fine): Test program: use std::io::{self, BufRead};
fn main() {
let inp = io::stdin();
let mut inp = inp.lock();
let mut line = String::new();
inp.read_line(&mut line).unwrap();
println!("{}", line.trim().parse::<f64>().unwrap());
} For input So the comparisons / match checking are probably fine but the parsed floats are bad. Edit: This was compiled with the official rust beta binaries. |
Edit: forget that, I must have confused something, I cannot reproduce on either of those nightlies. |
The NEON build (withholding #36933) still failed in the same way. The build with reverted rust-lang/compiler-rt@592717e is still going, but it just got past that failure point of librand |
Alright, so with the test program above, the current beta, running on an RPi 2 with armv7-unknown-linux-gnu, I observer the following:
|
So, this is ... interesting. According to this bug, for eabihf ("hard float") target, libgcc calls floating point intrinsics, like "floatundidf", using the hard float convention (argument passing over FPU registers (s0, d0, etc.)) (FWIW, this seems consistent to me, it respects the global calling convention, the "hf" in gnueabihf) whereas clang/llvm calls them using the soft float convention (argument passing over "general purpose" registers (r0, r1)). It seems that llvm does that because libgcc used to do it that way but libgcc (apparently) broke its ABI and changed from soft float to the current hard float ABI. So, what to do. For gnueabihf, we should compile these floating point intrinsics using the soft float convention because that's how LLVM call these intrinsics. Except for the powisf2 intrinsic, that should be compiled using the hard float convention to avoid re-introducing #37559. It's weird that LLVM calls some floating point intrinsics using the soft float convention but others with the hard float one ... but we have to do what LLVM dictates. |
Is that really LLVM's doing? I see the That makes me wonder if perhaps LLVM is internally using consistent soft float for these, when they are implicitly added, whereas the calls generated for intrinsics by Rust are using the default hard float ABI. Maybe there's some attribute missing on Rust's declarations to get the right code generation out of it. |
Yeah, that seems to be the case.
You mean to call powi using the soft float convention? IMO, all the intrinsics should use hard float because that's the global setting. It'd be better if we could make that work. |
I have found new discreps in stable vs beta in #37559 |
IIRC you can tag a Hm... I'm not so sure any more. Compiling this: double a(double b, int c) {
return __builtin_powi(b, c);
} with clang yields:
That is, nothing weird with calling conventions here. What's going on?! |
I think we should be consistent. Going fully hard float would be ideal, but we'd have to figure out how to influence the LLVM internal calls, as well as fork all the asm implementations in |
This is a beta regression that will be on stable Thursday. |
This update of compiler-rt includes rust-lang/compiler-rt#26 which provides a targeted fix to the powisf2 intrinsics to keep rust-lang#37559 fixed but also address the new issue of rust-lang#37630. I've also [written up my thoughts][1] on why it appears that this is the correct fix for now (hoepfully at least). Closes rust-lang#37630 [1]: rust-lang/compiler-rt#26 (comment)
Ok I've done some investigation and believe @TimNN's patch ironically fixes everything, and I've submitted a PR to update to that compiler-rt. |
std: Update compiler-rt for more ABI fixes This update of compiler-rt includes rust-lang/compiler-rt#26 which provides a targeted fix to the powisf2 intrinsics to keep #37559 fixed but also address the new issue of #37630. I've also [written up my thoughts][1] on why it appears that this is the correct fix for now (hoepfully at least). Closes #37630 [1]: rust-lang/compiler-rt#26 (comment)
Note that since the official Rust builds were not fixed, those armhf 1.13.0 binaries won't be usable as a host stage0 to build 1.14.0. I just tried such a build for the new beta, and it failed right away, segfault compiling libcore. Using Fedora's own 1.13.0 binary (patched with rust-lang/compiler-rt#26) does appear to work so far as stage0 for the beta. |
to pick up the fixes for rust-lang/rust#37559 and rust-lang/rust#37630
update the compiler-rt submodule to pick up the fixes for rust-lang/rust#37559 and rust-lang/rust#37630 r? @alexcrichton cc @TimNN
This update of compiler-rt includes rust-lang/compiler-rt#26 which provides a targeted fix to the powisf2 intrinsics to keep rust-lang#37559 fixed but also address the new issue of rust-lang#37630. I've also [written up my thoughts][1] on why it appears that this is the correct fix for now (hoepfully at least). Closes rust-lang#37630 [1]: rust-lang/compiler-rt#26 (comment)
I just tried builds of 1.13.0-beta.3 on Fedora 24 and Rawhide (with LLVM 3.8 and 3.9 respectively), and both builds failed only on armv7hl, in the exact same place:
That full function is:
This particular code hasn't changed in over a year, and my i686, x86_64, and aarch64 builds were fine with it. Only armv7hl has the error, and note even then it wasn't until
--cfg stage2
.I had no problem with armv7hl on prior releases, so this appears to be a beta regression. I do have one patch applied from #36933 to disable NEON, but I also had that on 1.12.1 and it went fine. I'm baffled what else could be specific to armv7hl to cause this...
The text was updated successfully, but these errors were encountered: