-
Notifications
You must be signed in to change notification settings - Fork 13k
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
aarch64-unknown-none-softfloat: ABI unsoundness when enabling "neon" feature #134375
Comments
I also skimmed the git history for the https://github.com/rust-lang/rust/blob/master/src/doc/rustc/src/platform-support.md but found nothing. I think it could make sense to demote the target if it's unmaintained. @RalfJung should I mention this question in the next compiler meeting? Another question: do you think the thanks EDIT: I feel this comment kind of answers my second question: IIUC the issue is only when the |
<#131058> was about various issues with the neon target feature; except for this one, they should all be resolved.
|
Cc @JamieCunliffe (currently, arm64 in the kernel uses |
Should we be using |
If you never need Probably, someone will have to add a |
@Darksonn @ojeda does Rust4Linux need to locally enable Right now the only way I can see to fix this issue is to just mark the |
I don't think the existing C users will be rewritten anytime soon, but who knows what out-of-tree may be doing. Let's see what Jamie says, and I have pinged the arm64 maintainers (Cc @ctmarinas). Alice et al. (Cc @maurer @samitolvanen) can confirm for Android. Also Cc @asahilina for Asahi and @Fabo in case they need it. If "being careful" (differently-compiled TUs) would still be doable like in C, then I guess it should be fine. |
I only use floats in const context (to transmute f32 to u32) and don't enable neon or anything like that. I didn't even realize Rust had an aarch64 softfloat target, I ended up implementing my own softfloat in pure integer Rust instead where I needed float math.
|
Android or Panthor does not currently need floats in kernel Rust code. |
#135160 proposes to make |
It is inevitable that some (perhaps third party / out of tree) Rust code will need to use NEON within the Linux kernel, in other kernels, and in similar situations. It is just a matter of time. In the same way that people are replacing C code with Rust code, people are also trying to replace out-of-line assembly with smaller bits of inline assembly and/or with auto-vectorized code, using patterns like this:
For people writing code like the above, we'd need to change our So, I don't think that disabling |
Did you intend the double negation? This sentence says you do think that it is a long-term solution... To be clear, I don't think this is a long-term solution. But it also makes no sense to pretend to support something which our primary backend does not support. Someone has to put in the work on the LLVM side before we can provide this feature (using the FPU on an otherwise softfloat aarch64 target) to our users. |
Enabling the "neon" target feature on the aarch64-unknown-none-softfloat target is taken by LLVM as a sign that we want to use the hardfloat ABI. That is unfortunate as it makes it UB to link such code against code built for aarch64-unknown-none-softfloat without the "neon" target feature.
For Rust-generated functions we work around this by forcing our own ABI, passing floats either indirectly or via integer registers (#133102). However, this does not help for LLVM-generated calls for builtins/intrinsics, as shown in this example by @beetrees.
We don't have target maintainers listed for this target, so maybe that means we can just demote it to tier 3? (See #113739)
LLVM issue: llvm/llvm-project#110632. So far LLVM maintainers seem to not agree that there is a problem here.
@Amanieu unfortunately your proposal for making floats work on that target doesn't quite suffice. :/ We do need some help from LLVM.
@nikic do you have any good ideas for what we could do here? It seems like rejecting enabling "neon" on aarch64-unknown-none-softfloat is the only sound option we have right now, but I worry that may make the Rust-for-Linux folks (among others) unhappy.
The text was updated successfully, but these errors were encountered: