The ABI of float types can be changed by -Ctarget-feature
#116344
Description
A function that returns an f32
/f64
is not ABI-compatible with other functions that have the same signature on i686 when certain target features differ. It looks like one can disable the x87
feature or enable the soft-float
and then it will use different ways of passing floating-point arguments.
This is unsound as code calling methods from the standard library would now use the wrong registers to return results. In other words, setting -Ctarget-feature=-x87
or -Ctarget-feature=+soft-float
can introduce UB unless the standard library is rebuilt with the same flags. We therefore should reject these flags, to avoid the UB. This issue tracks that problem, and transitioning it to a hard error.
(SIMD types have a similar problem, but we are dealing with that differently. See #116558.)
Current status:
- It is a hard error to toggle some features with
#[target_feature]
(will be shipped in 1.84) -- not a breaking change since those features were not allowed in#[target_feature]
before either, only the error message changed - It is a warning to toggle them with
-Ctarget-feature
announcing that this will become a hard error in the future (will be shipped in 1.84) - Not all relevant features are properly detected yet, not even on tier 1 targets