rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
98.54k stars 12.74k forks source link

Some `-Ctarget-feature`s must be restrained on RISCV #132618

Open workingjubilee opened 1 week ago

workingjubilee commented 1 week ago

refs:

in discussion of the target modifiers RFC^1, Ralf asks this question:

That's actually fine on most targets, e.g. on x86 if you set the soft-float target feature then you can enable x87 and SSE and whatnot and keep using the soft-float ABI. Only aarch64 https://github.com/llvm/llvm-project/issues/110632 (from the targets I checked so far).

The interesting question is what happens on RISC-V when I disable the FP instructions on a target that usually uses the hardfloat ABI. Sadly, what LLVM usually does in that case is silently fall back to the softfloat ABI. But I haven't checked for RISC-V.

cc @beetrees

beetrees commented 1 week ago

In summary:

Notes:

workingjubilee commented 1 week ago

cc @coastalwhite (as author of https://github.com/rust-lang/rust/pull/116485 which got scaled back due to precisely this question!)

beetrees commented 1 week ago

Just realised I missed the e feature from my summary; I've edited my comment above to include it.

beetrees commented 1 week ago

Also I haven't included above the cases where LLVM will emit an error itself due to feature incompatibility. Checking the features mentioned https://github.com/rust-lang/rust/pull/116485, those are:

In both these cases LLVM will already emit a fatal error, but it would definitely be better diagnostic UX for rustc to detect the problem and emit an error itself.

workingjubilee commented 6 days ago

Thanks for the summary! That seems pretty definite in terms of a "yes, we should", yeah.