Skip to content

Commit c221672

Browse files
committed
x86-64 hardfloat actually requires sse2
1 parent 3065831 commit c221672

File tree

6 files changed

+54
-15
lines changed

6 files changed

+54
-15
lines changed

Diff for: compiler/rustc_codegen_gcc/src/gcc_util.rs

+12-6
Original file line numberDiff line numberDiff line change
@@ -129,12 +129,18 @@ pub(crate) fn global_gcc_features(sess: &Session, diagnostics: bool) -> Vec<Stri
129129
});
130130
}
131131
} else {
132-
if abi_enable_set.contains(feature) {
133-
sess.dcx().emit_warn(ForbiddenCTargetFeature {
134-
feature,
135-
enabled: "disabled",
136-
reason: "this feature is required by the target ABI",
137-
});
132+
// FIXME: we have to request implied features here since
133+
// negative features do not handle implied features above.
134+
#[allow(rustc::potential_query_instability)] // order does not matter
135+
for &required in abi_enable_set.iter() {
136+
let implied = sess.target.implied_target_features(std::iter::once(required));
137+
if implied.contains(feature) {
138+
sess.dcx().emit_warn(ForbiddenCTargetFeature {
139+
feature,
140+
enabled: "disabled",
141+
reason: "this feature is required by the target ABI",
142+
});
143+
}
138144
}
139145
}
140146

Diff for: compiler/rustc_codegen_llvm/src/llvm_util.rs

+13-6
Original file line numberDiff line numberDiff line change
@@ -753,12 +753,19 @@ pub(crate) fn global_llvm_features(
753753
});
754754
}
755755
} else {
756-
if abi_enable_set.contains(feature) {
757-
sess.dcx().emit_warn(ForbiddenCTargetFeature {
758-
feature,
759-
enabled: "disabled",
760-
reason: "this feature is required by the target ABI",
761-
});
756+
// FIXME: we have to request implied features here since
757+
// negative features do not handle implied features above.
758+
#[allow(rustc::potential_query_instability)] // order does not matter
759+
for &required in abi_enable_set.iter() {
760+
let implied =
761+
sess.target.implied_target_features(std::iter::once(required));
762+
if implied.contains(feature) {
763+
sess.dcx().emit_warn(ForbiddenCTargetFeature {
764+
feature,
765+
enabled: "disabled",
766+
reason: "this feature is required by the target ABI",
767+
});
768+
}
762769
}
763770
}
764771

Diff for: compiler/rustc_target/src/target_features.rs

+10-1
Original file line numberDiff line numberDiff line change
@@ -754,7 +754,7 @@ impl Target {
754754
// "forbidden" in the list above to ensure that there is a consistent answer to the
755755
// questions "which ABI is used".
756756
match &*self.arch {
757-
"x86" | "x86_64" => {
757+
"x86" => {
758758
// We support 2 ABIs, hardfloat (default) and softfloat.
759759
if self.has_feature("soft-float") {
760760
NOTHING
@@ -763,6 +763,15 @@ impl Target {
763763
(&["x87"], &[])
764764
}
765765
}
766+
"x86_64" => {
767+
// We support 2 ABIs, hardfloat (default) and softfloat.
768+
if self.has_feature("soft-float") {
769+
NOTHING
770+
} else {
771+
// Hardfloat ABI. x87 and SSE2 must be enabled.
772+
(&["x87", "sse2"], &[])
773+
}
774+
}
766775
"arm" => {
767776
// We support 2 ABIs, hardfloat (default) and softfloat.
768777
if self.has_feature("soft-float") {

Diff for: tests/codegen/target-feature-overrides.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ pub unsafe fn banana() -> u32 {
4040

4141
// CHECK: attributes [[APPLEATTRS]]
4242
// COMPAT-SAME: "target-features"="+avx,+avx2,{{.*}}"
43-
// INCOMPAT-SAME: "target-features"="-avx2,-avx,+avx,{{.*}}"
43+
// INCOMPAT-SAME: "target-features"="-avx2,-avx,+x87,+sse2,+avx,{{.*}}"
4444
// CHECK: attributes [[BANANAATTRS]]
4545
// COMPAT-SAME: "target-features"="+avx,+avx2,{{.*}}"
46-
// INCOMPAT-SAME: "target-features"="-avx2,-avx"
46+
// INCOMPAT-SAME: "target-features"="-avx2,-avx,+x87,+sse2"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
//@ compile-flags: --target=x86_64-unknown-linux-gnu --crate-type=lib
2+
//@ needs-llvm-components: x86
3+
//@ compile-flags: -Ctarget-feature=-sse
4+
// For now this is just a warning.
5+
//@ build-pass
6+
#![feature(no_core, lang_items)]
7+
#![no_core]
8+
9+
#[lang = "sized"]
10+
pub trait Sized {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
warning: target feature `sse` cannot be disabled with `-Ctarget-feature`: this feature is required by the target ABI
2+
|
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>
5+
6+
warning: 1 warning emitted
7+

0 commit comments

Comments
 (0)