On Mon, 10 Feb 2025 at 17:38, Miguel Ojeda ojeda@kernel.org wrote:
Starting with Rust 1.85.0 (to be released 2025-02-20), `rustc` warns [1] about disabling neon in the aarch64 hardfloat target:
warning: target feature `neon` cannot be toggled with `-Ctarget-feature`: unsound on hard-float targets because it changes float ABI | = note: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #116344 <https://github.com/rust-lang/rust/issues/116344>
Thus, instead, use the softfloat target instead.
We have to carefully make the distinction here between codegen and ABI.
The arm64 C code in the kernel is built with -mgeneral-regs-only because FP/SIMD registers are not preserved/restored like GPRs, and so they must be used only in carefully controlled circumstances, i.e., in assembler code called under kernel_neon_begin()/kernel_neon_end() [modulo some exceptions related to NEON intrinsics]
This does not impact the ABI, which remains hard-float [this was the only arm64 calling convention that existed until about a year ago]. Any function that takes or returns floats or doubles (or NEON intrinsic types) is simply rejected by the compiler.
Changing this to softfloat for Rust modifies this calling convention, i.e., it will result in floats and doubles being accepted as function parameters and return values, but there is no code in the kernel that actually supports/implements that. Also, it should be clarified whether using a softfloat ABI permits the compiler to use FP/SIMD registers in codegen. We might still need -Ctarget-feature="-neon" here afaict.
Ideally, we'd have a target/target-feature combo that makes this more explicit: no FP/SIMD codegen at all, without affecting the ABI, therefore making float/double types in function prototypes illegal. AIUI, this change does something different.