1
Fork 0

x86-64 hardfloat actually requires sse2

This commit is contained in:
Ralf Jung 2024-12-26 19:47:41 +01:00
parent 0a8cfc2f8f
commit eb527424a5
6 changed files with 54 additions and 15 deletions

View file

@ -129,12 +129,18 @@ pub(crate) fn global_gcc_features(sess: &Session, diagnostics: bool) -> Vec<Stri
}); });
} }
} else { } else {
if abi_enable_set.contains(feature) { // FIXME: we have to request implied features here since
sess.dcx().emit_warn(ForbiddenCTargetFeature { // negative features do not handle implied features above.
feature, #[allow(rustc::potential_query_instability)] // order does not matter
enabled: "disabled", for &required in abi_enable_set.iter() {
reason: "this feature is required by the target ABI", let implied = sess.target.implied_target_features(std::iter::once(required));
}); if implied.contains(feature) {
sess.dcx().emit_warn(ForbiddenCTargetFeature {
feature,
enabled: "disabled",
reason: "this feature is required by the target ABI",
});
}
} }
} }

View file

@ -753,12 +753,19 @@ pub(crate) fn global_llvm_features(
}); });
} }
} else { } else {
if abi_enable_set.contains(feature) { // FIXME: we have to request implied features here since
sess.dcx().emit_warn(ForbiddenCTargetFeature { // negative features do not handle implied features above.
feature, #[allow(rustc::potential_query_instability)] // order does not matter
enabled: "disabled", for &required in abi_enable_set.iter() {
reason: "this feature is required by the target ABI", let implied =
}); sess.target.implied_target_features(std::iter::once(required));
if implied.contains(feature) {
sess.dcx().emit_warn(ForbiddenCTargetFeature {
feature,
enabled: "disabled",
reason: "this feature is required by the target ABI",
});
}
} }
} }

View file

@ -753,7 +753,7 @@ impl Target {
// "forbidden" in the list above to ensure that there is a consistent answer to the // "forbidden" in the list above to ensure that there is a consistent answer to the
// questions "which ABI is used". // questions "which ABI is used".
match &*self.arch { match &*self.arch {
"x86" | "x86_64" => { "x86" => {
// We support 2 ABIs, hardfloat (default) and softfloat. // We support 2 ABIs, hardfloat (default) and softfloat.
if self.has_feature("soft-float") { if self.has_feature("soft-float") {
NOTHING NOTHING
@ -762,6 +762,15 @@ impl Target {
(&["x87"], &[]) (&["x87"], &[])
} }
} }
"x86_64" => {
// We support 2 ABIs, hardfloat (default) and softfloat.
if self.has_feature("soft-float") {
NOTHING
} else {
// Hardfloat ABI. x87 and SSE2 must be enabled.
(&["x87", "sse2"], &[])
}
}
"arm" => { "arm" => {
// We support 2 ABIs, hardfloat (default) and softfloat. // We support 2 ABIs, hardfloat (default) and softfloat.
if self.has_feature("soft-float") { if self.has_feature("soft-float") {

View file

@ -40,7 +40,7 @@ pub unsafe fn banana() -> u32 {
// CHECK: attributes [[APPLEATTRS]] // CHECK: attributes [[APPLEATTRS]]
// COMPAT-SAME: "target-features"="+avx,+avx2,{{.*}}" // COMPAT-SAME: "target-features"="+avx,+avx2,{{.*}}"
// INCOMPAT-SAME: "target-features"="-avx2,-avx,+avx,{{.*}}" // INCOMPAT-SAME: "target-features"="-avx2,-avx,+x87,+sse2,+avx,{{.*}}"
// CHECK: attributes [[BANANAATTRS]] // CHECK: attributes [[BANANAATTRS]]
// COMPAT-SAME: "target-features"="+avx,+avx2,{{.*}}" // COMPAT-SAME: "target-features"="+avx,+avx2,{{.*}}"
// INCOMPAT-SAME: "target-features"="-avx2,-avx" // INCOMPAT-SAME: "target-features"="-avx2,-avx,+x87,+sse2"

View file

@ -0,0 +1,10 @@
//@ compile-flags: --target=x86_64-unknown-linux-gnu --crate-type=lib
//@ needs-llvm-components: x86
//@ compile-flags: -Ctarget-feature=-sse
// For now this is just a warning.
//@ build-pass
#![feature(no_core, lang_items)]
#![no_core]
#[lang = "sized"]
pub trait Sized {}

View file

@ -0,0 +1,7 @@
warning: target feature `sse` cannot be disabled with `-Ctarget-feature`: this feature is required by the target 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>
warning: 1 warning emitted