Skip to content

Commit 17ba7f2

Browse files
authored
Rollup merge of rust-lang#151317 - RalfJung:x86-soft-float, r=workingjubilee
x86 soft-float feature: mark it as forbidden rather than unstable I am not sure why I made it "unstable" in rust-lang@f755f4c; I think at the time "forbidden" did not work for some reason. Making it "forbidden" instead has no significant effect on `-Ctarget-feature` use, it just changes the warning. It *does* have the effect that one cannot query this using `cfg(target_feature)` on nightly any more, but that seems fine to me. It only ever worked as an accidental side-effect of f755f4c anyway. r? @workingjubilee
2 parents 93d5b4f + fdc7cfd commit 17ba7f2

5 files changed

Lines changed: 24 additions & 7 deletions

File tree

compiler/rustc_target/src/target_features.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -466,9 +466,7 @@ static X86_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
466466
("sha512", Stable, &["avx2"]),
467467
("sm3", Stable, &["avx"]),
468468
("sm4", Stable, &["avx2"]),
469-
// This cannot actually be toggled, the ABI always fixes it, so it'd make little sense to
470-
// stabilize. It must be in this list for the ABI check to be able to use it.
471-
("soft-float", Stability::Unstable(sym::x87_target_feature), &[]),
469+
("soft-float", Stability::Forbidden { reason: "use a soft-float target instead" }, &[]),
472470
("sse", Stable, &[]),
473471
("sse2", Stable, &["sse"]),
474472
("sse3", Stable, &["sse2"]),

tests/ui/target-feature/abi-incompatible-target-feature-attribute.x86.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: target feature `soft-float` cannot be enabled with `#[target_feature]`: this feature is incompatible with the target ABI
1+
error: target feature `soft-float` cannot be enabled with `#[target_feature]`: use a soft-float target instead
22
--> $DIR/abi-incompatible-target-feature-attribute.rs:17:32
33
|
44
LL | #[cfg_attr(x86, target_feature(enable = "soft-float"))] #[cfg_attr(riscv, target_feature(enable = "d"))]

tests/ui/target-feature/abi-incompatible-target-feature-flag-enable.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,5 @@ extern crate minicore;
1919
use minicore::*;
2020

2121
//~? WARN must be disabled to ensure that the ABI of the current target can be implemented correctly
22-
//~? WARN unstable feature specified for `-Ctarget-feature`
22+
//[riscv]~? WARN unstable feature specified for `-Ctarget-feature`
23+
//[x86]~? WARN use a soft-float target instead

tests/ui/target-feature/abi-incompatible-target-feature-flag-enable.x86.stderr

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
warning: unstable feature specified for `-Ctarget-feature`: `soft-float`
1+
warning: target feature `soft-float` cannot be enabled with `-Ctarget-feature`: use a soft-float target instead
22
|
3-
= note: this feature is not stably supported; its behavior can change in the future
3+
= note: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
4+
= note: for more information, see issue #116344 <https://github.com/rust-lang/rust/issues/116344>
45

56
warning: target feature `soft-float` must be disabled to ensure that the ABI of the current target can be implemented correctly
67
|
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//! The soft-float target feature is *not* exposed as `cfg` on x86.
2+
//@ revisions: soft hard
3+
//@[hard] compile-flags: --target=x86_64-unknown-linux-gnu --crate-type=lib
4+
//@[hard] needs-llvm-components: x86
5+
//@[soft] compile-flags: --target=x86_64-unknown-none --crate-type=lib
6+
//@[soft] needs-llvm-components: x86
7+
//@ check-pass
8+
//@ ignore-backends: gcc
9+
//@ add-minicore
10+
#![feature(no_core)]
11+
#![no_core]
12+
#![allow(unexpected_cfgs)]
13+
14+
// The compile_error macro does not exist, so if the `cfg` evaluates to `true` this
15+
// complains about the missing macro rather than showing the error... but that's good enough.
16+
#[cfg(target_feature = "soft-float")]
17+
compile_error!("the soft-float feature should NOT be exposed in `cfg`");

0 commit comments

Comments
 (0)