Auto merge of #136146 - RalfJung:x86-abi, r=workingjubilee
Explicitly choose x86 softfloat/hardfloat ABI Part of https://github.com/rust-lang/rust/pull/135408: Instead of choosing this based on the target features listed in the target spec, make that choice explicit. All built-in targets are being updated here; custom (JSON-defined) x86 (32bit and 64bit) softfloat targets need to explicitly set `rustc-abi` to `x86-softfloat`.
This commit is contained in:
commit
f027438f8b
22 changed files with 161 additions and 60 deletions
|
@ -128,6 +128,19 @@ impl Target {
|
||||||
Some(Ok(()))
|
Some(Ok(()))
|
||||||
})).unwrap_or(Ok(()))
|
})).unwrap_or(Ok(()))
|
||||||
} );
|
} );
|
||||||
|
($key_name:ident, RustcAbi) => ( {
|
||||||
|
let name = (stringify!($key_name)).replace("_", "-");
|
||||||
|
obj.remove(&name).and_then(|o| o.as_str().and_then(|s| {
|
||||||
|
match s.parse::<super::RustcAbi>() {
|
||||||
|
Ok(rustc_abi) => base.$key_name = Some(rustc_abi),
|
||||||
|
_ => return Some(Err(format!(
|
||||||
|
"'{s}' is not a valid value for rustc-abi. \
|
||||||
|
Use 'x86-softfloat' or leave the field unset."
|
||||||
|
))),
|
||||||
|
}
|
||||||
|
Some(Ok(()))
|
||||||
|
})).unwrap_or(Ok(()))
|
||||||
|
} );
|
||||||
($key_name:ident, RelocModel) => ( {
|
($key_name:ident, RelocModel) => ( {
|
||||||
let name = (stringify!($key_name)).replace("_", "-");
|
let name = (stringify!($key_name)).replace("_", "-");
|
||||||
obj.remove(&name).and_then(|o| o.as_str().and_then(|s| {
|
obj.remove(&name).and_then(|o| o.as_str().and_then(|s| {
|
||||||
|
@ -612,6 +625,7 @@ impl Target {
|
||||||
key!(llvm_mcount_intrinsic, optional);
|
key!(llvm_mcount_intrinsic, optional);
|
||||||
key!(llvm_abiname);
|
key!(llvm_abiname);
|
||||||
key!(llvm_floatabi, FloatAbi)?;
|
key!(llvm_floatabi, FloatAbi)?;
|
||||||
|
key!(rustc_abi, RustcAbi)?;
|
||||||
key!(relax_elf_relocations, bool);
|
key!(relax_elf_relocations, bool);
|
||||||
key!(llvm_args, list);
|
key!(llvm_args, list);
|
||||||
key!(use_ctors_section, bool);
|
key!(use_ctors_section, bool);
|
||||||
|
@ -788,6 +802,7 @@ impl ToJson for Target {
|
||||||
target_option_val!(llvm_mcount_intrinsic);
|
target_option_val!(llvm_mcount_intrinsic);
|
||||||
target_option_val!(llvm_abiname);
|
target_option_val!(llvm_abiname);
|
||||||
target_option_val!(llvm_floatabi);
|
target_option_val!(llvm_floatabi);
|
||||||
|
target_option_val!(rustc_abi);
|
||||||
target_option_val!(relax_elf_relocations);
|
target_option_val!(relax_elf_relocations);
|
||||||
target_option_val!(llvm_args);
|
target_option_val!(llvm_args);
|
||||||
target_option_val!(use_ctors_section);
|
target_option_val!(use_ctors_section);
|
||||||
|
|
|
@ -1114,6 +1114,33 @@ impl ToJson for FloatAbi {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The Rustc-specific variant of the ABI used for this target.
|
||||||
|
#[derive(Clone, Copy, PartialEq, Hash, Debug)]
|
||||||
|
pub enum RustcAbi {
|
||||||
|
/// On x86-32/64 only: do not use any FPU or SIMD registers for the ABI.
|
||||||
|
X86Softfloat,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl FromStr for RustcAbi {
|
||||||
|
type Err = ();
|
||||||
|
|
||||||
|
fn from_str(s: &str) -> Result<RustcAbi, ()> {
|
||||||
|
Ok(match s {
|
||||||
|
"x86-softfloat" => RustcAbi::X86Softfloat,
|
||||||
|
_ => return Err(()),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ToJson for RustcAbi {
|
||||||
|
fn to_json(&self) -> Json {
|
||||||
|
match *self {
|
||||||
|
RustcAbi::X86Softfloat => "x86-softfloat",
|
||||||
|
}
|
||||||
|
.to_json()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, PartialEq, Hash, Debug)]
|
#[derive(Clone, Copy, PartialEq, Hash, Debug)]
|
||||||
pub enum TlsModel {
|
pub enum TlsModel {
|
||||||
GeneralDynamic,
|
GeneralDynamic,
|
||||||
|
@ -2505,6 +2532,12 @@ pub struct TargetOptions {
|
||||||
/// If not provided, LLVM will infer the float ABI from the target triple (`llvm_target`).
|
/// If not provided, LLVM will infer the float ABI from the target triple (`llvm_target`).
|
||||||
pub llvm_floatabi: Option<FloatAbi>,
|
pub llvm_floatabi: Option<FloatAbi>,
|
||||||
|
|
||||||
|
/// Picks a specific ABI for this target. This is *not* just for "Rust" ABI functions,
|
||||||
|
/// it can also affect "C" ABI functions; the point is that this flag is interpreted by
|
||||||
|
/// rustc and not forwarded to LLVM.
|
||||||
|
/// So far, this is only used on x86.
|
||||||
|
pub rustc_abi: Option<RustcAbi>,
|
||||||
|
|
||||||
/// Whether or not RelaxElfRelocation flag will be passed to the linker
|
/// Whether or not RelaxElfRelocation flag will be passed to the linker
|
||||||
pub relax_elf_relocations: bool,
|
pub relax_elf_relocations: bool,
|
||||||
|
|
||||||
|
@ -2664,10 +2697,6 @@ impl TargetOptions {
|
||||||
.collect();
|
.collect();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn has_feature(&self, search_feature: &str) -> bool {
|
|
||||||
self.features.split(',').any(|f| f.strip_prefix('+').is_some_and(|f| f == search_feature))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for TargetOptions {
|
impl Default for TargetOptions {
|
||||||
|
@ -2774,6 +2803,7 @@ impl Default for TargetOptions {
|
||||||
llvm_mcount_intrinsic: None,
|
llvm_mcount_intrinsic: None,
|
||||||
llvm_abiname: "".into(),
|
llvm_abiname: "".into(),
|
||||||
llvm_floatabi: None,
|
llvm_floatabi: None,
|
||||||
|
rustc_abi: None,
|
||||||
relax_elf_relocations: false,
|
relax_elf_relocations: false,
|
||||||
llvm_args: cvs![],
|
llvm_args: cvs![],
|
||||||
use_ctors_section: false,
|
use_ctors_section: false,
|
||||||
|
@ -3240,6 +3270,17 @@ impl Target {
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check consistency of Rust ABI declaration.
|
||||||
|
if let Some(rust_abi) = self.rustc_abi {
|
||||||
|
match rust_abi {
|
||||||
|
RustcAbi::X86Softfloat => check_matches!(
|
||||||
|
&*self.arch,
|
||||||
|
"x86" | "x86_64",
|
||||||
|
"`x86-softfloat` ABI is only valid for x86 targets"
|
||||||
|
),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Check that the given target-features string makes some basic sense.
|
// Check that the given target-features string makes some basic sense.
|
||||||
if !self.features.is_empty() {
|
if !self.features.is_empty() {
|
||||||
let mut features_enabled = FxHashSet::default();
|
let mut features_enabled = FxHashSet::default();
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
// The cdecl ABI is used. It differs from the stdcall or fastcall ABI.
|
// The cdecl ABI is used. It differs from the stdcall or fastcall ABI.
|
||||||
// "i686-unknown-windows" is used to get the minimal subset of windows-specific features.
|
// "i686-unknown-windows" is used to get the minimal subset of windows-specific features.
|
||||||
|
|
||||||
use crate::spec::{Target, base};
|
use crate::spec::{RustcAbi, Target, base};
|
||||||
|
|
||||||
pub(crate) fn target() -> Target {
|
pub(crate) fn target() -> Target {
|
||||||
let mut base = base::uefi_msvc::opts();
|
let mut base = base::uefi_msvc::opts();
|
||||||
|
@ -22,6 +22,7 @@ pub(crate) fn target() -> Target {
|
||||||
// If you initialize FP units yourself, you can override these flags with custom linker
|
// If you initialize FP units yourself, you can override these flags with custom linker
|
||||||
// arguments, thus giving you access to full MMX/SSE acceleration.
|
// arguments, thus giving you access to full MMX/SSE acceleration.
|
||||||
base.features = "-mmx,-sse,+soft-float".into();
|
base.features = "-mmx,-sse,+soft-float".into();
|
||||||
|
base.rustc_abi = Some(RustcAbi::X86Softfloat);
|
||||||
|
|
||||||
// Use -GNU here, because of the reason below:
|
// Use -GNU here, because of the reason below:
|
||||||
// Background and Problem:
|
// Background and Problem:
|
||||||
|
|
|
@ -5,8 +5,8 @@
|
||||||
// features.
|
// features.
|
||||||
|
|
||||||
use crate::spec::{
|
use crate::spec::{
|
||||||
Cc, CodeModel, LinkerFlavor, Lld, PanicStrategy, RelroLevel, SanitizerSet, StackProbeType,
|
Cc, CodeModel, LinkerFlavor, Lld, PanicStrategy, RelroLevel, RustcAbi, SanitizerSet,
|
||||||
Target, TargetOptions,
|
StackProbeType, Target, TargetOptions,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub(crate) fn target() -> Target {
|
pub(crate) fn target() -> Target {
|
||||||
|
@ -20,6 +20,7 @@ pub(crate) fn target() -> Target {
|
||||||
relro_level: RelroLevel::Full,
|
relro_level: RelroLevel::Full,
|
||||||
linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes),
|
linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes),
|
||||||
linker: Some("rust-lld".into()),
|
linker: Some("rust-lld".into()),
|
||||||
|
rustc_abi: Some(RustcAbi::X86Softfloat),
|
||||||
features: "-mmx,-sse,-sse2,-sse3,-ssse3,-sse4.1,-sse4.2,-avx,-avx2,+soft-float".into(),
|
features: "-mmx,-sse,-sse2,-sse3,-ssse3,-sse4.1,-sse4.2,-avx,-avx2,+soft-float".into(),
|
||||||
supported_sanitizers: SanitizerSet::KCFI | SanitizerSet::KERNELADDRESS,
|
supported_sanitizers: SanitizerSet::KCFI | SanitizerSet::KERNELADDRESS,
|
||||||
disable_redzone: true,
|
disable_redzone: true,
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
// LLVM. "x86_64-unknown-windows" is used to get the minimal subset of windows-specific features.
|
// LLVM. "x86_64-unknown-windows" is used to get the minimal subset of windows-specific features.
|
||||||
|
|
||||||
use crate::abi::call::Conv;
|
use crate::abi::call::Conv;
|
||||||
use crate::spec::{Target, base};
|
use crate::spec::{RustcAbi, Target, base};
|
||||||
|
|
||||||
pub(crate) fn target() -> Target {
|
pub(crate) fn target() -> Target {
|
||||||
let mut base = base::uefi_msvc::opts();
|
let mut base = base::uefi_msvc::opts();
|
||||||
|
@ -26,6 +26,7 @@ pub(crate) fn target() -> Target {
|
||||||
// If you initialize FP units yourself, you can override these flags with custom linker
|
// If you initialize FP units yourself, you can override these flags with custom linker
|
||||||
// arguments, thus giving you access to full MMX/SSE acceleration.
|
// arguments, thus giving you access to full MMX/SSE acceleration.
|
||||||
base.features = "-mmx,-sse,+soft-float".into();
|
base.features = "-mmx,-sse,+soft-float".into();
|
||||||
|
base.rustc_abi = Some(RustcAbi::X86Softfloat);
|
||||||
|
|
||||||
Target {
|
Target {
|
||||||
llvm_target: "x86_64-unknown-windows".into(),
|
llvm_target: "x86_64-unknown-windows".into(),
|
||||||
|
|
|
@ -5,7 +5,7 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||||
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
|
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
|
||||||
use rustc_span::{Symbol, sym};
|
use rustc_span::{Symbol, sym};
|
||||||
|
|
||||||
use crate::spec::{FloatAbi, Target};
|
use crate::spec::{FloatAbi, RustcAbi, Target};
|
||||||
|
|
||||||
/// Features that control behaviour of rustc, rather than the codegen.
|
/// Features that control behaviour of rustc, rather than the codegen.
|
||||||
/// These exist globally and are not in the target-specific lists below.
|
/// These exist globally and are not in the target-specific lists below.
|
||||||
|
@ -422,7 +422,9 @@ const X86_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
|
||||||
("sha512", Unstable(sym::sha512_sm_x86), &["avx2"]),
|
("sha512", Unstable(sym::sha512_sm_x86), &["avx2"]),
|
||||||
("sm3", Unstable(sym::sha512_sm_x86), &["avx"]),
|
("sm3", Unstable(sym::sha512_sm_x86), &["avx"]),
|
||||||
("sm4", Unstable(sym::sha512_sm_x86), &["avx2"]),
|
("sm4", Unstable(sym::sha512_sm_x86), &["avx2"]),
|
||||||
("soft-float", Stability::Forbidden { reason: "unsound because it changes float ABI" }, &[]),
|
// This cannot actually be toggled, the ABI always fixes it, so it'd make little sense to
|
||||||
|
// stabilize. It must be in this list for the ABI check to be able to use it.
|
||||||
|
("soft-float", Stability::Unstable(sym::x87_target_feature), &[]),
|
||||||
("sse", Stable, &[]),
|
("sse", Stable, &[]),
|
||||||
("sse2", Stable, &["sse"]),
|
("sse2", Stable, &["sse"]),
|
||||||
("sse3", Stable, &["sse2"]),
|
("sse3", Stable, &["sse2"]),
|
||||||
|
@ -773,23 +775,41 @@ impl Target {
|
||||||
// questions "which ABI is used".
|
// questions "which ABI is used".
|
||||||
match &*self.arch {
|
match &*self.arch {
|
||||||
"x86" => {
|
"x86" => {
|
||||||
// We support 2 ABIs, hardfloat (default) and softfloat.
|
// We use our own ABI indicator here; LLVM does not have anything native.
|
||||||
// x86 has no sane ABI indicator so we have to use the target feature.
|
// Every case should require or forbid `soft-float`!
|
||||||
if self.has_feature("soft-float") {
|
match self.rustc_abi {
|
||||||
NOTHING
|
None => {
|
||||||
} else {
|
// Default hardfloat ABI.
|
||||||
// Hardfloat ABI. x87 must be enabled.
|
// x87 must be enabled, soft-float must be disabled.
|
||||||
FeatureConstraints { required: &["x87"], incompatible: &[] }
|
FeatureConstraints { required: &["x87"], incompatible: &["soft-float"] }
|
||||||
|
}
|
||||||
|
Some(RustcAbi::X86Softfloat) => {
|
||||||
|
// Softfloat ABI, requires corresponding target feature. That feature trumps
|
||||||
|
// `x87` and all other FPU features so those do not matter.
|
||||||
|
// Note that this one requirement is the entire implementation of the ABI!
|
||||||
|
// LLVM handles the rest.
|
||||||
|
FeatureConstraints { required: &["soft-float"], incompatible: &[] }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"x86_64" => {
|
"x86_64" => {
|
||||||
// We support 2 ABIs, hardfloat (default) and softfloat.
|
// We use our own ABI indicator here; LLVM does not have anything native.
|
||||||
// x86 has no sane ABI indicator so we have to use the target feature.
|
// Every case should require or forbid `soft-float`!
|
||||||
if self.has_feature("soft-float") {
|
match self.rustc_abi {
|
||||||
NOTHING
|
None => {
|
||||||
} else {
|
// Default hardfloat ABI. On x86-64, this always includes SSE2.
|
||||||
// Hardfloat ABI. x87 and SSE2 must be enabled.
|
FeatureConstraints {
|
||||||
FeatureConstraints { required: &["x87", "sse2"], incompatible: &[] }
|
required: &["x87", "sse2"],
|
||||||
|
incompatible: &["soft-float"],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Some(RustcAbi::X86Softfloat) => {
|
||||||
|
// Softfloat ABI, requires corresponding target feature. That feature trumps
|
||||||
|
// `x87` and all other FPU features so those do not matter.
|
||||||
|
// Note that this one requirement is the entire implementation of the ABI!
|
||||||
|
// LLVM handles the rest.
|
||||||
|
FeatureConstraints { required: &["soft-float"], incompatible: &[] }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"arm" => {
|
"arm" => {
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
LINUX_VERSION=v6.13-rc1
|
LINUX_VERSION=50e57739141b41f731ab31f8380821c7969f9dc4
|
||||||
|
|
||||||
# Build rustc, rustdoc, cargo, clippy-driver and rustfmt
|
# Build rustc, rustdoc, cargo, clippy-driver and rustfmt
|
||||||
../x.py build --stage 2 library rustdoc clippy rustfmt
|
../x.py build --stage 2 library rustdoc clippy rustfmt
|
||||||
|
@ -28,7 +28,7 @@ rm -rf linux || true
|
||||||
# Download Linux at a specific commit
|
# Download Linux at a specific commit
|
||||||
mkdir -p linux
|
mkdir -p linux
|
||||||
git -C linux init
|
git -C linux init
|
||||||
git -C linux remote add origin https://github.com/Rust-for-Linux/linux.git
|
git -C linux remote add origin https://github.com/Darksonn/linux.git
|
||||||
git -C linux fetch --depth 1 origin ${LINUX_VERSION}
|
git -C linux fetch --depth 1 origin ${LINUX_VERSION}
|
||||||
git -C linux checkout FETCH_HEAD
|
git -C linux checkout FETCH_HEAD
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
//! Ensure ABI-incompatible features cannot be enabled via `#[target_feature]`.
|
||||||
//@ compile-flags: --target=riscv32e-unknown-none-elf --crate-type=lib
|
//@ compile-flags: --target=riscv32e-unknown-none-elf --crate-type=lib
|
||||||
//@ needs-llvm-components: riscv
|
//@ needs-llvm-components: riscv
|
||||||
#![feature(no_core, lang_items, riscv_target_feature)]
|
#![feature(no_core, lang_items, riscv_target_feature)]
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
error: target feature `d` cannot be enabled with `#[target_feature]`: this feature is incompatible with the target ABI
|
error: target feature `d` cannot be enabled with `#[target_feature]`: this feature is incompatible with the target ABI
|
||||||
--> $DIR/forbidden-hardfloat-target-feature-attribute.rs:9:18
|
--> $DIR/forbidden-hardfloat-target-feature-attribute.rs:10:18
|
||||||
|
|
|
|
||||||
LL | #[target_feature(enable = "d")]
|
LL | #[target_feature(enable = "d")]
|
||||||
| ^^^^^^^^^^^^
|
| ^^^^^^^^^^^^
|
||||||
|
|
|
@ -1,14 +0,0 @@
|
||||||
//@ compile-flags: --target=x86_64-unknown-linux-gnu --crate-type=lib
|
|
||||||
//@ needs-llvm-components: x86
|
|
||||||
//@ check-pass
|
|
||||||
#![feature(no_core, lang_items)]
|
|
||||||
#![no_core]
|
|
||||||
#![allow(unexpected_cfgs)]
|
|
||||||
|
|
||||||
#[lang = "sized"]
|
|
||||||
pub trait Sized {}
|
|
||||||
|
|
||||||
// The compile_error macro does not exist, so if the `cfg` evaluates to `true` this
|
|
||||||
// complains about the missing macro rather than showing the error... but that's good enough.
|
|
||||||
#[cfg(not(target_feature = "x87"))]
|
|
||||||
compile_error!("the x87 feature *should* be exposed in `cfg`");
|
|
|
@ -1,8 +1,11 @@
|
||||||
|
//! Ensure that if disabling a target feature implies disabling an ABI-required target feature,
|
||||||
|
//! we complain.
|
||||||
//@ compile-flags: --target=x86_64-unknown-linux-gnu --crate-type=lib
|
//@ compile-flags: --target=x86_64-unknown-linux-gnu --crate-type=lib
|
||||||
//@ needs-llvm-components: x86
|
//@ needs-llvm-components: x86
|
||||||
//@ compile-flags: -Ctarget-feature=-sse
|
//@ compile-flags: -Ctarget-feature=-sse
|
||||||
// For now this is just a warning.
|
// For now this is just a warning.
|
||||||
//@ build-pass
|
//@ build-pass
|
||||||
|
//@error-pattern: must be enabled to ensure that the ABI
|
||||||
#![feature(no_core, lang_items)]
|
#![feature(no_core, lang_items)]
|
||||||
#![no_core]
|
#![no_core]
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
//@ compile-flags: -Ctarget-feature=-neon
|
//@ compile-flags: -Ctarget-feature=-neon
|
||||||
// For now this is just a warning.
|
// For now this is just a warning.
|
||||||
//@ build-pass
|
//@ build-pass
|
||||||
|
//@error-pattern: must be enabled to ensure that the ABI
|
||||||
#![feature(no_core, lang_items)]
|
#![feature(no_core, lang_items)]
|
||||||
#![no_core]
|
#![no_core]
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
|
//! Ensure ABI-required features cannot be disabled via `-Ctarget-feature`.
|
||||||
//@ compile-flags: --target=x86_64-unknown-linux-gnu --crate-type=lib
|
//@ compile-flags: --target=x86_64-unknown-linux-gnu --crate-type=lib
|
||||||
//@ needs-llvm-components: x86
|
//@ needs-llvm-components: x86
|
||||||
//@ compile-flags: -Ctarget-feature=-x87
|
//@ compile-flags: -Ctarget-feature=-x87
|
||||||
// For now this is just a warning.
|
// For now this is just a warning.
|
||||||
//@ build-pass
|
//@ build-pass
|
||||||
|
//@error-pattern: must be enabled to ensure that the ABI
|
||||||
#![feature(no_core, lang_items)]
|
#![feature(no_core, lang_items)]
|
||||||
#![no_core]
|
#![no_core]
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
//! Ensure ABI-incompatible features cannot be enabled via `-Ctarget-feature`.
|
||||||
|
//@ compile-flags: --target=x86_64-unknown-linux-gnu --crate-type=lib
|
||||||
|
//@ needs-llvm-components: x86
|
||||||
|
//@ compile-flags: -Ctarget-feature=+soft-float
|
||||||
|
// For now this is just a warning.
|
||||||
|
//@ build-pass
|
||||||
|
//@error-pattern: must be disabled to ensure that the ABI
|
||||||
|
#![feature(no_core, lang_items, riscv_target_feature)]
|
||||||
|
#![no_core]
|
||||||
|
|
||||||
|
#[lang = "sized"]
|
||||||
|
pub trait Sized {}
|
|
@ -0,0 +1,11 @@
|
||||||
|
warning: target feature `soft-float` must be disabled to ensure that the ABI of the current target can be implemented correctly
|
||||||
|
|
|
||||||
|
= 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: unstable feature specified for `-Ctarget-feature`: `soft-float`
|
||||||
|
|
|
||||||
|
= note: this feature is not stably supported; its behavior can change in the future
|
||||||
|
|
||||||
|
warning: 2 warnings emitted
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
//@ compile-flags: --target=x86_64-unknown-linux-gnu --crate-type=lib
|
//! Ensure "forbidden" target features cannot be enabled via `#[target_feature]`.
|
||||||
//@ needs-llvm-components: x86
|
//@ compile-flags: --target=riscv32e-unknown-none-elf --crate-type=lib
|
||||||
|
//@ needs-llvm-components: riscv
|
||||||
#![feature(no_core, lang_items)]
|
#![feature(no_core, lang_items)]
|
||||||
#![no_core]
|
#![no_core]
|
||||||
|
|
||||||
#[lang = "sized"]
|
#[lang = "sized"]
|
||||||
pub trait Sized {}
|
pub trait Sized {}
|
||||||
|
|
||||||
#[target_feature(enable = "soft-float")]
|
#[target_feature(enable = "forced-atomics")]
|
||||||
//~^ERROR: cannot be enabled with
|
//~^ERROR: cannot be enabled with
|
||||||
pub unsafe fn my_fun() {}
|
pub unsafe fn my_fun() {}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
error: target feature `soft-float` cannot be enabled with `#[target_feature]`: unsound because it changes float ABI
|
error: target feature `forced-atomics` cannot be enabled with `#[target_feature]`: unsound because it changes the ABI of atomic operations
|
||||||
--> $DIR/forbidden-target-feature-attribute.rs:9:18
|
--> $DIR/forbidden-target-feature-attribute.rs:10:18
|
||||||
|
|
|
|
||||||
LL | #[target_feature(enable = "soft-float")]
|
LL | #[target_feature(enable = "forced-atomics")]
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: aborting due to 1 previous error
|
error: aborting due to 1 previous error
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
//@ compile-flags: --target=x86_64-unknown-none --crate-type=lib
|
//! Ensure "forbidden" target features are not exposed via `cfg`.
|
||||||
//@ needs-llvm-components: x86
|
//@ compile-flags: --target=riscv32e-unknown-none-elf --crate-type=lib
|
||||||
|
//@ needs-llvm-components: riscv
|
||||||
//@ check-pass
|
//@ check-pass
|
||||||
#![feature(no_core, lang_items)]
|
#![feature(no_core, lang_items)]
|
||||||
#![no_core]
|
#![no_core]
|
||||||
|
@ -10,5 +11,5 @@ pub trait Sized {}
|
||||||
|
|
||||||
// The compile_error macro does not exist, so if the `cfg` evaluates to `true` this
|
// The compile_error macro does not exist, so if the `cfg` evaluates to `true` this
|
||||||
// complains about the missing macro rather than showing the error... but that's good enough.
|
// complains about the missing macro rather than showing the error... but that's good enough.
|
||||||
#[cfg(target_feature = "soft-float")]
|
#[cfg(target_feature = "forced-atomics")]
|
||||||
compile_error!("the soft-float feature should not be exposed in `cfg`");
|
compile_error!("the forced-atomics feature should not be exposed in `cfg`");
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
//@ compile-flags: --target=x86_64-unknown-linux-gnu --crate-type=lib
|
//! Ensure "forbidden" target features cannot be disabled via `-Ctarget-feature`.
|
||||||
//@ needs-llvm-components: x86
|
//@ compile-flags: --target=riscv32e-unknown-none-elf --crate-type=lib
|
||||||
//@ compile-flags: -Ctarget-feature=-soft-float
|
//@ needs-llvm-components: riscv
|
||||||
|
//@ compile-flags: -Ctarget-feature=-forced-atomics
|
||||||
// For now this is just a warning.
|
// For now this is just a warning.
|
||||||
//@ build-pass
|
//@ build-pass
|
||||||
|
//@error-pattern: unsound because it changes the ABI
|
||||||
#![feature(no_core, lang_items)]
|
#![feature(no_core, lang_items)]
|
||||||
#![no_core]
|
#![no_core]
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
warning: target feature `soft-float` cannot be disabled with `-Ctarget-feature`: unsound because it changes float ABI
|
warning: target feature `forced-atomics` cannot be disabled with `-Ctarget-feature`: unsound because it changes the ABI of atomic operations
|
||||||
|
|
|
|
||||||
= note: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
= 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>
|
= note: for more information, see issue #116344 <https://github.com/rust-lang/rust/issues/116344>
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
//@ compile-flags: --target=x86_64-unknown-linux-gnu --crate-type=lib
|
//! Ensure "forbidden" target features cannot be enabled via `-Ctarget-feature`.
|
||||||
//@ needs-llvm-components: x86
|
//@ compile-flags: --target=riscv32e-unknown-none-elf --crate-type=lib
|
||||||
//@ compile-flags: -Ctarget-feature=+soft-float
|
//@ needs-llvm-components: riscv
|
||||||
|
//@ compile-flags: -Ctarget-feature=+forced-atomics
|
||||||
// For now this is just a warning.
|
// For now this is just a warning.
|
||||||
//@ build-pass
|
//@ build-pass
|
||||||
|
//@error-pattern: unsound because it changes the ABI
|
||||||
#![feature(no_core, lang_items)]
|
#![feature(no_core, lang_items)]
|
||||||
#![no_core]
|
#![no_core]
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
warning: target feature `soft-float` cannot be enabled with `-Ctarget-feature`: unsound because it changes float ABI
|
warning: target feature `forced-atomics` cannot be enabled with `-Ctarget-feature`: unsound because it changes the ABI of atomic operations
|
||||||
|
|
|
|
||||||
= note: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
= 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>
|
= note: for more information, see issue #116344 <https://github.com/rust-lang/rust/issues/116344>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue