add x86-sse2 (32bit) ABI that requires SSE2 target feature
This commit is contained in:
parent
bdc97d1046
commit
2eff2155e5
25 changed files with 96 additions and 20 deletions
|
@ -2,8 +2,8 @@ use std::borrow::Cow;
|
|||
use std::env;
|
||||
|
||||
use crate::spec::{
|
||||
Cc, DebuginfoKind, FloatAbi, FramePointer, LinkerFlavor, Lld, SplitDebuginfo, StackProbeType,
|
||||
StaticCow, TargetOptions, cvs,
|
||||
Cc, DebuginfoKind, FloatAbi, FramePointer, LinkerFlavor, Lld, RustcAbi, SplitDebuginfo,
|
||||
StackProbeType, StaticCow, TargetOptions, cvs,
|
||||
};
|
||||
|
||||
#[cfg(test)]
|
||||
|
@ -103,7 +103,7 @@ pub(crate) fn base(
|
|||
arch: Arch,
|
||||
abi: TargetAbi,
|
||||
) -> (TargetOptions, StaticCow<str>, StaticCow<str>) {
|
||||
let opts = TargetOptions {
|
||||
let mut opts = TargetOptions {
|
||||
abi: abi.target_abi().into(),
|
||||
llvm_floatabi: Some(FloatAbi::Hard),
|
||||
os: os.into(),
|
||||
|
@ -154,6 +154,10 @@ pub(crate) fn base(
|
|||
|
||||
..Default::default()
|
||||
};
|
||||
if matches!(arch, Arch::I386 | Arch::I686) {
|
||||
// All Apple x86-32 targets have SSE2.
|
||||
opts.rustc_abi = Some(RustcAbi::X86Sse2);
|
||||
}
|
||||
(opts, unversioned_llvm_target(os, arch, abi), arch.target_arch())
|
||||
}
|
||||
|
||||
|
|
|
@ -1109,6 +1109,8 @@ 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 only: make use of SSE and SSE2 for ABI purposes.
|
||||
X86Sse2,
|
||||
/// On x86-32/64 only: do not use any FPU or SIMD registers for the ABI.
|
||||
X86Softfloat,
|
||||
}
|
||||
|
@ -1118,6 +1120,7 @@ impl FromStr for RustcAbi {
|
|||
|
||||
fn from_str(s: &str) -> Result<RustcAbi, ()> {
|
||||
Ok(match s {
|
||||
"x86-sse2" => RustcAbi::X86Sse2,
|
||||
"x86-softfloat" => RustcAbi::X86Softfloat,
|
||||
_ => return Err(()),
|
||||
})
|
||||
|
@ -1127,6 +1130,7 @@ impl FromStr for RustcAbi {
|
|||
impl ToJson for RustcAbi {
|
||||
fn to_json(&self) -> Json {
|
||||
match *self {
|
||||
RustcAbi::X86Sse2 => "x86-sse2",
|
||||
RustcAbi::X86Softfloat => "x86-softfloat",
|
||||
}
|
||||
.to_json()
|
||||
|
@ -3264,6 +3268,11 @@ impl Target {
|
|||
// Check consistency of Rust ABI declaration.
|
||||
if let Some(rust_abi) = self.rustc_abi {
|
||||
match rust_abi {
|
||||
RustcAbi::X86Sse2 => check_matches!(
|
||||
&*self.arch,
|
||||
"x86",
|
||||
"`x86-sse2` ABI is only valid for x86-32 targets"
|
||||
),
|
||||
RustcAbi::X86Softfloat => check_matches!(
|
||||
&*self.arch,
|
||||
"x86" | "x86_64",
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use crate::spec::base::nto_qnx;
|
||||
use crate::spec::{StackProbeType, Target, TargetOptions, base};
|
||||
use crate::spec::{RustcAbi, StackProbeType, Target, TargetOptions, base};
|
||||
|
||||
pub(crate) fn target() -> Target {
|
||||
let mut meta = nto_qnx::meta();
|
||||
|
@ -14,6 +14,7 @@ pub(crate) fn target() -> Target {
|
|||
.into(),
|
||||
arch: "x86".into(),
|
||||
options: TargetOptions {
|
||||
rustc_abi: Some(RustcAbi::X86Sse2),
|
||||
cpu: "pentium4".into(),
|
||||
max_atomic_width: Some(64),
|
||||
pre_link_args: nto_qnx::pre_link_args(
|
||||
|
|
|
@ -2,6 +2,7 @@ use crate::spec::Target;
|
|||
|
||||
pub(crate) fn target() -> Target {
|
||||
let mut base = super::i686_unknown_linux_gnu::target();
|
||||
base.rustc_abi = None; // overwrite the SSE2 ABI set by the base target
|
||||
base.cpu = "pentium".into();
|
||||
base.llvm_target = "i586-unknown-linux-gnu".into();
|
||||
base
|
||||
|
|
|
@ -2,6 +2,7 @@ use crate::spec::Target;
|
|||
|
||||
pub(crate) fn target() -> Target {
|
||||
let mut base = super::i686_unknown_linux_musl::target();
|
||||
base.rustc_abi = None; // overwrite the SSE2 ABI set by the base target
|
||||
base.cpu = "pentium".into();
|
||||
base.llvm_target = "i586-unknown-linux-musl".into();
|
||||
// FIXME(compiler-team#422): musl targets should be dynamically linked by default.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use crate::spec::{SanitizerSet, StackProbeType, Target, TargetOptions, base};
|
||||
use crate::spec::{RustcAbi, SanitizerSet, StackProbeType, Target, TargetOptions, base};
|
||||
|
||||
// See https://developer.android.com/ndk/guides/abis.html#x86
|
||||
// for target ABI requirements.
|
||||
|
@ -8,6 +8,7 @@ pub(crate) fn target() -> Target {
|
|||
|
||||
base.max_atomic_width = Some(64);
|
||||
|
||||
base.rustc_abi = Some(RustcAbi::X86Sse2);
|
||||
// https://developer.android.com/ndk/guides/abis.html#x86
|
||||
base.cpu = "pentium4".into();
|
||||
base.features = "+mmx,+sse,+sse2,+sse3,+ssse3".into();
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
use crate::spec::{Cc, FramePointer, LinkerFlavor, Lld, Target, base};
|
||||
use crate::spec::{Cc, FramePointer, LinkerFlavor, Lld, RustcAbi, Target, base};
|
||||
|
||||
pub(crate) fn target() -> Target {
|
||||
let mut base = base::windows_gnu::opts();
|
||||
base.rustc_abi = Some(RustcAbi::X86Sse2);
|
||||
base.cpu = "pentium4".into();
|
||||
base.max_atomic_width = Some(64);
|
||||
base.frame_pointer = FramePointer::Always; // Required for backtraces
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
use crate::spec::{Cc, FramePointer, LinkerFlavor, Lld, Target, base};
|
||||
use crate::spec::{Cc, FramePointer, LinkerFlavor, Lld, RustcAbi, Target, base};
|
||||
|
||||
pub(crate) fn target() -> Target {
|
||||
let mut base = base::windows_gnullvm::opts();
|
||||
base.rustc_abi = Some(RustcAbi::X86Sse2);
|
||||
base.cpu = "pentium4".into();
|
||||
base.max_atomic_width = Some(64);
|
||||
base.frame_pointer = FramePointer::Always; // Required for backtraces
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
use crate::spec::{LinkerFlavor, Lld, SanitizerSet, Target, base};
|
||||
use crate::spec::{LinkerFlavor, Lld, RustcAbi, SanitizerSet, Target, base};
|
||||
|
||||
pub(crate) fn target() -> Target {
|
||||
let mut base = base::windows_msvc::opts();
|
||||
base.rustc_abi = Some(RustcAbi::X86Sse2);
|
||||
base.cpu = "pentium4".into();
|
||||
base.max_atomic_width = Some(64);
|
||||
base.supported_sanitizers = SanitizerSet::ADDRESS;
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
use crate::spec::{Cc, LinkerFlavor, Lld, StackProbeType, Target, base};
|
||||
use crate::spec::{Cc, LinkerFlavor, Lld, RustcAbi, StackProbeType, Target, base};
|
||||
|
||||
pub(crate) fn target() -> Target {
|
||||
let mut base = base::freebsd::opts();
|
||||
base.rustc_abi = Some(RustcAbi::X86Sse2);
|
||||
base.cpu = "pentium4".into();
|
||||
base.max_atomic_width = Some(64);
|
||||
base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m32", "-Wl,-znotext"]);
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
use crate::spec::{Cc, LinkerFlavor, Lld, StackProbeType, Target, base};
|
||||
use crate::spec::{Cc, LinkerFlavor, Lld, RustcAbi, StackProbeType, Target, base};
|
||||
|
||||
pub(crate) fn target() -> Target {
|
||||
let mut base = base::haiku::opts();
|
||||
base.rustc_abi = Some(RustcAbi::X86Sse2);
|
||||
base.cpu = "pentium4".into();
|
||||
base.max_atomic_width = Some(64);
|
||||
base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m32"]);
|
||||
|
|
|
@ -1,7 +1,19 @@
|
|||
use crate::spec::{Cc, LinkerFlavor, Lld, SanitizerSet, StackProbeType, Target, base};
|
||||
use crate::spec::{Cc, LinkerFlavor, Lld, RustcAbi, SanitizerSet, StackProbeType, Target, base};
|
||||
|
||||
pub(crate) fn target() -> Target {
|
||||
let mut base = base::linux_gnu::opts();
|
||||
base.rustc_abi = Some(RustcAbi::X86Sse2);
|
||||
// Dear distribution packager, if you are changing the base CPU model with the goal of removing
|
||||
// the SSE2 requirement, make sure to also set the `rustc_abi` to `None` above or else the compiler
|
||||
// will complain that the chosen ABI cannot be realized with the given CPU features.
|
||||
// Also note that x86 without SSE2 is *not* considered a Tier 1 target by the Rust project, and
|
||||
// it has some known floating-point correctness issues mostly caused by a lack of people caring
|
||||
// for LLVM's x87 support (double-rounding, value truncation; see
|
||||
// <https://github.com/rust-lang/rust/issues/114479> for details). This can lead to incorrect
|
||||
// math (Rust generally promises exact math, so this can break code in unexpected ways) and it
|
||||
// can lead to memory safety violations if floating-point values are used e.g. to access an
|
||||
// array. If users run into such issues and report bugs upstream and then it turns out that the
|
||||
// bugs are caused by distribution patches, that leads to confusion and frustration.
|
||||
base.cpu = "pentium4".into();
|
||||
base.max_atomic_width = Some(64);
|
||||
base.supported_sanitizers = SanitizerSet::ADDRESS;
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
use crate::spec::{Cc, FramePointer, LinkerFlavor, Lld, StackProbeType, Target, base};
|
||||
use crate::spec::{Cc, FramePointer, LinkerFlavor, Lld, RustcAbi, StackProbeType, Target, base};
|
||||
|
||||
pub(crate) fn target() -> Target {
|
||||
let mut base = base::linux_musl::opts();
|
||||
base.rustc_abi = Some(RustcAbi::X86Sse2);
|
||||
// If you want to change the base CPU, please see `i686_unknown_linux_gnu.rs`
|
||||
// for an important comment.
|
||||
base.cpu = "pentium4".into();
|
||||
base.max_atomic_width = Some(64);
|
||||
base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m32", "-Wl,-melf_i386"]);
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
use crate::spec::{Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetOptions, base};
|
||||
use crate::spec::{Cc, LinkerFlavor, Lld, RustcAbi, StackProbeType, Target, TargetOptions, base};
|
||||
|
||||
pub(crate) fn target() -> Target {
|
||||
let mut base = base::netbsd::opts();
|
||||
base.rustc_abi = Some(RustcAbi::X86Sse2);
|
||||
base.cpu = "pentium4".into();
|
||||
base.max_atomic_width = Some(64);
|
||||
base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m32"]);
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
use crate::spec::{Cc, LinkerFlavor, Lld, StackProbeType, Target, base};
|
||||
use crate::spec::{Cc, LinkerFlavor, Lld, RustcAbi, StackProbeType, Target, base};
|
||||
|
||||
pub(crate) fn target() -> Target {
|
||||
let mut base = base::openbsd::opts();
|
||||
base.rustc_abi = Some(RustcAbi::X86Sse2);
|
||||
base.cpu = "pentium4".into();
|
||||
base.max_atomic_width = Some(64);
|
||||
base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m32", "-fuse-ld=lld"]);
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
use crate::spec::{Cc, FramePointer, LinkerFlavor, Lld, Target, base};
|
||||
use crate::spec::{Cc, FramePointer, LinkerFlavor, Lld, RustcAbi, Target, base};
|
||||
|
||||
pub(crate) fn target() -> Target {
|
||||
let mut base = base::windows_uwp_gnu::opts();
|
||||
base.rustc_abi = Some(RustcAbi::X86Sse2);
|
||||
base.cpu = "pentium4".into();
|
||||
base.max_atomic_width = Some(64);
|
||||
base.frame_pointer = FramePointer::Always; // Required for backtraces
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
use crate::spec::{Target, base};
|
||||
use crate::spec::{RustcAbi, Target, base};
|
||||
|
||||
pub(crate) fn target() -> Target {
|
||||
let mut base = base::windows_uwp_msvc::opts();
|
||||
base.rustc_abi = Some(RustcAbi::X86Sse2);
|
||||
base.cpu = "pentium4".into();
|
||||
base.max_atomic_width = Some(64);
|
||||
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
use crate::spec::{Cc, FramePointer, LinkerFlavor, Lld, Target, base};
|
||||
use crate::spec::{Cc, FramePointer, LinkerFlavor, Lld, RustcAbi, Target, base};
|
||||
|
||||
pub(crate) fn target() -> Target {
|
||||
let mut base = base::windows_gnu::opts();
|
||||
base.vendor = "win7".into();
|
||||
base.rustc_abi = Some(RustcAbi::X86Sse2);
|
||||
base.cpu = "pentium4".into();
|
||||
base.max_atomic_width = Some(64);
|
||||
base.frame_pointer = FramePointer::Always; // Required for backtraces
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
use crate::spec::{LinkerFlavor, Lld, SanitizerSet, Target, base};
|
||||
use crate::spec::{LinkerFlavor, Lld, RustcAbi, SanitizerSet, Target, base};
|
||||
|
||||
pub(crate) fn target() -> Target {
|
||||
let mut base = base::windows_msvc::opts();
|
||||
base.vendor = "win7".into();
|
||||
base.rustc_abi = Some(RustcAbi::X86Sse2);
|
||||
base.cpu = "pentium4".into();
|
||||
base.max_atomic_width = Some(64);
|
||||
base.supported_sanitizers = SanitizerSet::ADDRESS;
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
use crate::spec::{Cc, LinkerFlavor, Lld, StackProbeType, Target, base};
|
||||
use crate::spec::{Cc, LinkerFlavor, Lld, RustcAbi, StackProbeType, Target, base};
|
||||
|
||||
pub(crate) fn target() -> Target {
|
||||
let mut base = base::vxworks::opts();
|
||||
base.rustc_abi = Some(RustcAbi::X86Sse2);
|
||||
base.cpu = "pentium4".into();
|
||||
base.max_atomic_width = Some(64);
|
||||
base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m32"]);
|
||||
|
|
|
@ -790,6 +790,13 @@ impl Target {
|
|||
// x87 must be enabled, soft-float must be disabled.
|
||||
FeatureConstraints { required: &["x87"], incompatible: &["soft-float"] }
|
||||
}
|
||||
Some(RustcAbi::X86Sse2) => {
|
||||
// Extended hardfloat ABI. x87 and SSE2 must be enabled, soft-float must be disabled.
|
||||
FeatureConstraints {
|
||||
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.
|
||||
|
@ -817,6 +824,7 @@ impl Target {
|
|||
// LLVM handles the rest.
|
||||
FeatureConstraints { required: &["soft-float"], incompatible: &[] }
|
||||
}
|
||||
Some(r) => panic!("invalid Rust ABI for x86_64: {r:?}"),
|
||||
}
|
||||
}
|
||||
"arm" => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue