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,7 +129,12 @@ pub(crate) fn global_gcc_features(sess: &Session, diagnostics: bool) -> Vec<Stri
});
}
} else {
if abi_enable_set.contains(feature) {
// FIXME: we have to request implied features here since
// negative features do not handle implied features above.
#[allow(rustc::potential_query_instability)] // order does not matter
for &required in abi_enable_set.iter() {
let implied = sess.target.implied_target_features(std::iter::once(required));
if implied.contains(feature) {
sess.dcx().emit_warn(ForbiddenCTargetFeature {
feature,
enabled: "disabled",
@ -137,6 +142,7 @@ pub(crate) fn global_gcc_features(sess: &Session, diagnostics: bool) -> Vec<Stri
});
}
}
}
// FIXME(nagisa): figure out how to not allocate a full hashset here.
featsmap.insert(feature, enable);

View file

@ -753,7 +753,13 @@ pub(crate) fn global_llvm_features(
});
}
} else {
if abi_enable_set.contains(feature) {
// FIXME: we have to request implied features here since
// negative features do not handle implied features above.
#[allow(rustc::potential_query_instability)] // order does not matter
for &required in abi_enable_set.iter() {
let implied =
sess.target.implied_target_features(std::iter::once(required));
if implied.contains(feature) {
sess.dcx().emit_warn(ForbiddenCTargetFeature {
feature,
enabled: "disabled",
@ -761,6 +767,7 @@ pub(crate) fn global_llvm_features(
});
}
}
}
// FIXME(nagisa): figure out how to not allocate a full hashset here.
featsmap.insert(feature, enable);

View file

@ -753,7 +753,7 @@ impl Target {
// "forbidden" in the list above to ensure that there is a consistent answer to the
// questions "which ABI is used".
match &*self.arch {
"x86" | "x86_64" => {
"x86" => {
// We support 2 ABIs, hardfloat (default) and softfloat.
if self.has_feature("soft-float") {
NOTHING
@ -762,6 +762,15 @@ impl Target {
(&["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" => {
// We support 2 ABIs, hardfloat (default) and softfloat.
if self.has_feature("soft-float") {

View file

@ -40,7 +40,7 @@ pub unsafe fn banana() -> u32 {
// CHECK: attributes [[APPLEATTRS]]
// 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]]
// 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