Skip to content

Commit f354d86

Browse files
committed
Auto merge of #133099 - RalfJung:forbidden-hardfloat-features, r=workingjubilee
forbid toggling x87 and fpregs on hard-float targets Part of rust-lang/rust#116344, follow-up to rust-lang/rust#129884: The `x87` target feature on x86 and the `fpregs` target feature on ARM must not be disabled on a hardfloat target, as that would change the float ABI. However, *enabling* `fpregs` on ARM is [explicitly requested](rust-lang/rust#130988) as it seems to be useful. Therefore, we need to refine the distinction of "forbidden" target features and "allowed" target features: all (un)stable target features can determine on a per-target basis whether they should be allowed to be toggled or not. `fpregs` then checks whether the current target has the `soft-float` feature, and if yes, `fpregs` is permitted -- otherwise, it is not. (Same for `x87` on x86). Also fixes rust-lang/rust#132351. Since `fpregs` and `x87` can be enabled on some builds and disabled on others, it would make sense that one can query it via `cfg`. Therefore, I made them behave in `cfg` like any other unstable target feature. The first commit prepares the infrastructure, but does not change behavior. The second commit then wires up `fpregs` and `x87` with that new infrastructure. r? `@workingjubilee`
2 parents 260e07e + fc9fe6d commit f354d86

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

src/lib.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,11 @@ impl CodegenBackend for CraneliftCodegenBackend {
175175
}
176176
}
177177

178-
fn target_features(&self, sess: &Session, _allow_unstable: bool) -> Vec<rustc_span::Symbol> {
178+
fn target_features_cfg(
179+
&self,
180+
sess: &Session,
181+
_allow_unstable: bool,
182+
) -> Vec<rustc_span::Symbol> {
179183
// FIXME return the actually used target features. this is necessary for #[cfg(target_feature)]
180184
if sess.target.arch == "x86_64" && sess.target.os != "none" {
181185
// x86_64 mandates SSE2 support

0 commit comments

Comments
 (0)