-
Notifications
You must be signed in to change notification settings - Fork 13.3k
armhf code generation is broken #10482
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
http://pastebin.mozilla.org/3601836 is the asm output of compiling the above file with rustc -S source.rs |
Apparently it is the call to println with a floating point to blame. The following test case is enough to show the problem:
It inters oo loop after printing a=1 |
Are you able to get a stack trace when the program is infinite looping? Printing is actually a very large amount of machinery, so it may be helpful to reduce this down even further. |
Given the program:
The stack trace of the looping thread looks like oo recursion:
|
A variation of the example without format:
also leads to oo recursion:
It is |
More direct test case:
So something breaks code in the float_to_str_common implementation. |
I ran into this this very issue this evening (when rust-http tests were inexplicably not completing), and pinpointed the cause of failure more accurately. (I may say that after that, I was a little disappointed to find it had already been filed!)
This is as far as I have gone at present. I suggest that this be escalated to (at the least!) high priority. It also needs more tags added. Could someone please update this issue's title and main body to reflect the underlying problem? |
Nominating for 1.0. |
Hangs indefinitely, as expected.
Prints Any operations upon the result of 'i2f' are printed as NaN. This is using: rustc 0.9-pre (d5d5c50 2013-12-20 12:41:33 -0800) Any idea if this issue is related? @chris-morgan suggested f32 to not be impacted, but something's definitely wonky here. |
I got bored and wrote an implementation of ftoa in rust. It works fine on x86, fails miserably on armhf.
Prints |
This seems as if it ought to be high priority, with even fairly simple code failing to behave as expected. @luqmana - have you encountered any related floating point weirdness on ARM? Any insights? |
It looks like the call to the llvm intrinsics for log10 are at least partially culpable.
prints
prints |
Minimal test case:
With optimizations on, it prints 1000000000000000000000000000000 aka 2.0, as expected, as an intrinsic function of a constant is optimized to a constant. Without optimizations, it prints 0 (wrong) as expected. |
cc me |
Not knowing anything about LLVM, I've been embarking on a pretty thorough exploration of the IR for the simple test case above. It looks surprisingly OK - I've been copying possibly suspect pieces into the IR for a working C / clang analogue. I'm going to keep at the grind here, and will report back as soon as I have more information. |
One roadblock I've been fighting is going from rust LLVM bitcode to an executable. With a pointer from IRC, I have the following:
Unfortunately, this returns
Suggestions welcome! |
Few more observations.
returns On x86, this same code returns On ARMHF, in C, printf of a |
All calls to f64 intrinsics (tested log, log2, log10) seem to return 0x2200000000 / Any idea from where this constant could be originating? |
This is decimal 146028888064 - I checked OEIS, n_2^(2_n-1) looked possible, but didn't find anything especially compelling. |
Important, but we are not sure that armhf support need block 1.0 (and we are not sure how much of the android ecosystem we need to support for 1.0). Accepted for P-high. |
Spent eight days beating on this problem only to discover the following (partial) fix.
Freaking kidding me. LLVM IR looked fine because it was, llc just wasn't getting the right flag. I'll send a few bitcents to anyone who can explain why f64 intrinsics were returning 0x2200000000. |
I'll also send money to whoever writes the documentation for exactly what happens when you call |
Adding |
In a similar vein, It looks like the |
Huzzah!
Seems to resolve the problem completely. That said, this is not necessarily the most elegant of solutions. Comparing against I also considered modifying |
Tested on BeagleBone Black, Raspberry Pi, Allwinner A20, Allwinner A10, and RK3188 hardware and modern kernels. |
@alexcrichton looks like you fixed this in practice at 071ee96? |
I did? I was just shuffling things around in that commit, so I'm not sure that anything would have been fixed as part of that, but I could be wrong? Is the issue here just having some more |
Yeah, rustc previously didn't(?) have a viable way to add target_feature flags, and without a manual specification of vfp3, floating point ops failed on ARM. My patch automatically adds the flag on the right architectures, but yours is merged and ought to work. |
From what you discovered, should we be enabling |
Yes, we should. "Hardfloat" is pretty broken without it. |
Sounds good to me, would you like to submit a PR? I think you probably know more about it than I do! |
Latest from the frontlines:
Not entirely sure what's up here. I have a cross-compiler (x86_64 -> arm-unknown-linux-gnueabihf) working, but even -C target-feature=+vfp3 outputs an executable that hang ad nauseam. Guessing there's something broken with my toolchain? Related: ade-ma/A20Notes#5 @alexcrichton - on a similar note, target_feature=+v7 doesn't seem to disable __kernel_cmpxchg64. |
This enables the lowering of llvm 64b intrinsics to hardware ops, resolving issues around `__kernel_cmpxchg64` on older kernels on ARM devices, and also enables use of the hardware floating point unit, resolving #10482.
Do not propose to remove `async move` if variables are captured by ref Fixes rust-lang#10482 changelog: FP [`redundant_async_block`] Do not propose to remove `async move` if variables are captured by ref
I am using armhf build from http://luqman.ca/rust-builds/rust-0.9-pre-3b0d486-arm-unknown-linux-gnueabihf.zip released 2013-11-12. That generates broken code with the following program:
When running on armhf (Samsung ARM Chromebook) the program just goes into infinite loop instead of printing A 0.1.
The text was updated successfully, but these errors were encountered: