summaryrefslogtreecommitdiffstats
path: root/compiler/rustc_target
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--compiler/rustc_target/Cargo.toml3
-rw-r--r--compiler/rustc_target/src/abi/call/mod.rs5
-rw-r--r--compiler/rustc_target/src/abi/mod.rs70
-rw-r--r--compiler/rustc_target/src/lib.rs1
-rw-r--r--compiler/rustc_target/src/spec/aarch64_apple_ios_macabi.rs4
-rw-r--r--compiler/rustc_target/src/spec/aarch64_nintendo_switch_freestanding.rs4
-rw-r--r--compiler/rustc_target/src/spec/aarch64_unknown_none.rs4
-rw-r--r--compiler/rustc_target/src/spec/aarch64_unknown_none_softfloat.rs4
-rw-r--r--compiler/rustc_target/src/spec/aarch64_unknown_uefi.rs4
-rw-r--r--compiler/rustc_target/src/spec/abi.rs138
-rw-r--r--compiler/rustc_target/src/spec/android_base.rs4
-rw-r--r--compiler/rustc_target/src/spec/apple_base.rs22
-rw-r--r--compiler/rustc_target/src/spec/armebv7r_none_eabi.rs5
-rw-r--r--compiler/rustc_target/src/spec/armebv7r_none_eabihf.rs5
-rw-r--r--compiler/rustc_target/src/spec/armv4t_none_eabi.rs4
-rw-r--r--compiler/rustc_target/src/spec/armv5te_none_eabi.rs41
-rw-r--r--compiler/rustc_target/src/spec/armv6k_nintendo_3ds.rs5
-rw-r--r--compiler/rustc_target/src/spec/armv7_linux_androideabi.rs4
-rw-r--r--compiler/rustc_target/src/spec/armv7a_none_eabi.rs4
-rw-r--r--compiler/rustc_target/src/spec/armv7a_none_eabihf.rs4
-rw-r--r--compiler/rustc_target/src/spec/armv7r_none_eabi.rs5
-rw-r--r--compiler/rustc_target/src/spec/armv7r_none_eabihf.rs5
-rw-r--r--compiler/rustc_target/src/spec/avr_gnu_base.rs9
-rw-r--r--compiler/rustc_target/src/spec/fuchsia_base.rs6
-rw-r--r--compiler/rustc_target/src/spec/hermit_base.rs6
-rw-r--r--compiler/rustc_target/src/spec/hexagon_unknown_linux_musl.rs4
-rw-r--r--compiler/rustc_target/src/spec/i386_apple_ios.rs3
-rw-r--r--compiler/rustc_target/src/spec/i686_apple_darwin.rs7
-rw-r--r--compiler/rustc_target/src/spec/i686_linux_android.rs3
-rw-r--r--compiler/rustc_target/src/spec/i686_pc_windows_gnu.rs9
-rw-r--r--compiler/rustc_target/src/spec/i686_pc_windows_msvc.rs4
-rw-r--r--compiler/rustc_target/src/spec/i686_unknown_freebsd.rs7
-rw-r--r--compiler/rustc_target/src/spec/i686_unknown_haiku.rs7
-rw-r--r--compiler/rustc_target/src/spec/i686_unknown_linux_gnu.rs8
-rw-r--r--compiler/rustc_target/src/spec/i686_unknown_linux_musl.rs7
-rw-r--r--compiler/rustc_target/src/spec/i686_unknown_netbsd.rs7
-rw-r--r--compiler/rustc_target/src/spec/i686_unknown_openbsd.rs7
-rw-r--r--compiler/rustc_target/src/spec/i686_uwp_windows_gnu.rs9
-rw-r--r--compiler/rustc_target/src/spec/i686_wrs_vxworks.rs7
-rw-r--r--compiler/rustc_target/src/spec/illumos_base.rs6
-rw-r--r--compiler/rustc_target/src/spec/l4re_base.rs5
-rw-r--r--compiler/rustc_target/src/spec/linux_kernel_base.rs3
-rw-r--r--compiler/rustc_target/src/spec/mipsel_sony_psp.rs10
-rw-r--r--compiler/rustc_target/src/spec/mipsel_unknown_none.rs5
-rw-r--r--compiler/rustc_target/src/spec/mod.rs244
-rw-r--r--compiler/rustc_target/src/spec/msp430_none_elf.rs4
-rw-r--r--compiler/rustc_target/src/spec/msvc_base.rs8
-rw-r--r--compiler/rustc_target/src/spec/nvptx64_nvidia_cuda.rs1
-rw-r--r--compiler/rustc_target/src/spec/powerpc64_unknown_freebsd.rs5
-rw-r--r--compiler/rustc_target/src/spec/powerpc64_unknown_linux_gnu.rs9
-rw-r--r--compiler/rustc_target/src/spec/powerpc64_unknown_linux_musl.rs5
-rw-r--r--compiler/rustc_target/src/spec/powerpc64_unknown_openbsd.rs5
-rw-r--r--compiler/rustc_target/src/spec/powerpc64_wrs_vxworks.rs5
-rw-r--r--compiler/rustc_target/src/spec/powerpc64le_unknown_freebsd.rs5
-rw-r--r--compiler/rustc_target/src/spec/powerpc64le_unknown_linux_gnu.rs5
-rw-r--r--compiler/rustc_target/src/spec/powerpc64le_unknown_linux_musl.rs5
-rw-r--r--compiler/rustc_target/src/spec/powerpc_unknown_freebsd.rs8
-rw-r--r--compiler/rustc_target/src/spec/powerpc_unknown_linux_gnu.rs5
-rw-r--r--compiler/rustc_target/src/spec/powerpc_unknown_linux_gnuspe.rs5
-rw-r--r--compiler/rustc_target/src/spec/powerpc_unknown_linux_musl.rs5
-rw-r--r--compiler/rustc_target/src/spec/powerpc_unknown_netbsd.rs5
-rw-r--r--compiler/rustc_target/src/spec/powerpc_unknown_openbsd.rs3
-rw-r--r--compiler/rustc_target/src/spec/powerpc_wrs_vxworks.rs5
-rw-r--r--compiler/rustc_target/src/spec/powerpc_wrs_vxworks_spe.rs5
-rw-r--r--compiler/rustc_target/src/spec/riscv32i_unknown_none_elf.rs5
-rw-r--r--compiler/rustc_target/src/spec/riscv32im_unknown_none_elf.rs5
-rw-r--r--compiler/rustc_target/src/spec/riscv32imac_unknown_none_elf.rs5
-rw-r--r--compiler/rustc_target/src/spec/riscv32imac_unknown_xous_elf.rs5
-rw-r--r--compiler/rustc_target/src/spec/riscv32imc_esp_espidf.rs4
-rw-r--r--compiler/rustc_target/src/spec/riscv32imc_unknown_none_elf.rs5
-rw-r--r--compiler/rustc_target/src/spec/riscv64gc_unknown_none_elf.rs6
-rw-r--r--compiler/rustc_target/src/spec/riscv64imac_unknown_none_elf.rs6
-rw-r--r--compiler/rustc_target/src/spec/s390x_unknown_linux_gnu.rs11
-rw-r--r--compiler/rustc_target/src/spec/s390x_unknown_linux_musl.rs11
-rw-r--r--compiler/rustc_target/src/spec/solaris_base.rs4
-rw-r--r--compiler/rustc_target/src/spec/sparc64_unknown_netbsd.rs4
-rw-r--r--compiler/rustc_target/src/spec/sparc64_unknown_openbsd.rs4
-rw-r--r--compiler/rustc_target/src/spec/sparc_unknown_linux_gnu.rs4
-rw-r--r--compiler/rustc_target/src/spec/sparcv9_sun_solaris.rs4
-rw-r--r--compiler/rustc_target/src/spec/tests/tests_impl.rs85
-rw-r--r--compiler/rustc_target/src/spec/thumb_base.rs5
-rw-r--r--compiler/rustc_target/src/spec/thumbv4t_none_eabi.rs7
-rw-r--r--compiler/rustc_target/src/spec/thumbv5te_none_eabi.rs41
-rw-r--r--compiler/rustc_target/src/spec/thumbv7a_pc_windows_msvc.rs4
-rw-r--r--compiler/rustc_target/src/spec/thumbv7neon_linux_androideabi.rs4
-rw-r--r--compiler/rustc_target/src/spec/uefi_msvc_base.rs7
-rw-r--r--compiler/rustc_target/src/spec/wasm32_unknown_unknown.rs8
-rw-r--r--compiler/rustc_target/src/spec/wasm32_wasi.rs6
-rw-r--r--compiler/rustc_target/src/spec/wasm64_unknown_unknown.rs8
-rw-r--r--compiler/rustc_target/src/spec/wasm_base.rs9
-rw-r--r--compiler/rustc_target/src/spec/windows_gnu_base.rs28
-rw-r--r--compiler/rustc_target/src/spec/windows_gnullvm_base.rs10
-rw-r--r--compiler/rustc_target/src/spec/windows_uwp_gnu_base.rs7
-rw-r--r--compiler/rustc_target/src/spec/windows_uwp_msvc_base.rs4
-rw-r--r--compiler/rustc_target/src/spec/x86_64_apple_darwin.rs9
-rw-r--r--compiler/rustc_target/src/spec/x86_64_apple_ios.rs3
-rw-r--r--compiler/rustc_target/src/spec/x86_64_apple_ios_macabi.rs7
-rw-r--r--compiler/rustc_target/src/spec/x86_64_apple_tvos.rs3
-rw-r--r--compiler/rustc_target/src/spec/x86_64_apple_watchos_sim.rs3
-rw-r--r--compiler/rustc_target/src/spec/x86_64_fortanix_unknown_sgx.rs8
-rw-r--r--compiler/rustc_target/src/spec/x86_64_fuchsia.rs3
-rw-r--r--compiler/rustc_target/src/spec/x86_64_linux_android.rs7
-rw-r--r--compiler/rustc_target/src/spec/x86_64_pc_solaris.rs7
-rw-r--r--compiler/rustc_target/src/spec/x86_64_pc_windows_gnu.rs9
-rw-r--r--compiler/rustc_target/src/spec/x86_64_pc_windows_gnullvm.rs4
-rw-r--r--compiler/rustc_target/src/spec/x86_64_sun_solaris.rs7
-rw-r--r--compiler/rustc_target/src/spec/x86_64_unknown_dragonfly.rs7
-rw-r--r--compiler/rustc_target/src/spec/x86_64_unknown_freebsd.rs7
-rw-r--r--compiler/rustc_target/src/spec/x86_64_unknown_haiku.rs7
-rw-r--r--compiler/rustc_target/src/spec/x86_64_unknown_hermit.rs3
-rw-r--r--compiler/rustc_target/src/spec/x86_64_unknown_illumos.rs4
-rw-r--r--compiler/rustc_target/src/spec/x86_64_unknown_linux_gnu.rs7
-rw-r--r--compiler/rustc_target/src/spec/x86_64_unknown_linux_gnux32.rs7
-rw-r--r--compiler/rustc_target/src/spec/x86_64_unknown_linux_musl.rs7
-rw-r--r--compiler/rustc_target/src/spec/x86_64_unknown_netbsd.rs7
-rw-r--r--compiler/rustc_target/src/spec/x86_64_unknown_none.rs7
-rw-r--r--compiler/rustc_target/src/spec/x86_64_unknown_none_linuxkernel.rs4
-rw-r--r--compiler/rustc_target/src/spec/x86_64_unknown_openbsd.rs7
-rw-r--r--compiler/rustc_target/src/spec/x86_64_unknown_redox.rs7
-rw-r--r--compiler/rustc_target/src/spec/x86_64_uwp_windows_gnu.rs9
-rw-r--r--compiler/rustc_target/src/spec/x86_64_wrs_vxworks.rs7
121 files changed, 793 insertions, 516 deletions
diff --git a/compiler/rustc_target/Cargo.toml b/compiler/rustc_target/Cargo.toml
index 162376af4..fc37fdb1c 100644
--- a/compiler/rustc_target/Cargo.toml
+++ b/compiler/rustc_target/Cargo.toml
@@ -8,7 +8,8 @@ bitflags = "1.2.1"
tracing = "0.1"
serde_json = "1.0.59"
rustc_data_structures = { path = "../rustc_data_structures" }
+rustc_feature = { path = "../rustc_feature" }
+rustc_index = { path = "../rustc_index" }
rustc_macros = { path = "../rustc_macros" }
rustc_serialize = { path = "../rustc_serialize" }
rustc_span = { path = "../rustc_span" }
-rustc_index = { path = "../rustc_index" }
diff --git a/compiler/rustc_target/src/abi/call/mod.rs b/compiler/rustc_target/src/abi/call/mod.rs
index d2fb8c32f..9e5f0e4d1 100644
--- a/compiler/rustc_target/src/abi/call/mod.rs
+++ b/compiler/rustc_target/src/abi/call/mod.rs
@@ -47,7 +47,7 @@ pub enum PassMode {
/// Pass the argument indirectly via a hidden pointer.
/// The `extra_attrs` value, if any, is for the extra data (vtable or length)
/// which indicates that it refers to an unsized rvalue.
- /// `on_stack` defines that the the value should be passed at a fixed
+ /// `on_stack` defines that the value should be passed at a fixed
/// stack offset in accordance to the ABI rather than passed using a
/// pointer. This corresponds to the `byval` LLVM argument attribute.
Indirect { attrs: ArgAttributes, extra_attrs: Option<ArgAttributes>, on_stack: bool },
@@ -740,7 +740,8 @@ impl<'a, Ty> FnAbi<'a, Ty> {
mod size_asserts {
use super::*;
use rustc_data_structures::static_assert_size;
- // These are in alphabetical order, which is easy to maintain.
+ // tidy-alphabetical-start
static_assert_size!(ArgAbi<'_, usize>, 56);
static_assert_size!(FnAbi<'_, usize>, 80);
+ // tidy-alphabetical-end
}
diff --git a/compiler/rustc_target/src/abi/mod.rs b/compiler/rustc_target/src/abi/mod.rs
index ec334e588..7171ca7bf 100644
--- a/compiler/rustc_target/src/abi/mod.rs
+++ b/compiler/rustc_target/src/abi/mod.rs
@@ -1392,7 +1392,7 @@ pub struct PointeeInfo {
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub enum InitKind {
Zero,
- Uninit,
+ UninitMitigated0x01Fill,
}
/// Trait that needs to be implemented by the higher-level type representation
@@ -1498,72 +1498,4 @@ impl<'a, Ty> TyAndLayout<'a, Ty> {
Abi::Aggregate { sized } => sized && self.size.bytes() == 0,
}
}
-
- /// Determines if this type permits "raw" initialization by just transmuting some
- /// memory into an instance of `T`.
- ///
- /// `init_kind` indicates if the memory is zero-initialized or left uninitialized.
- ///
- /// This code is intentionally conservative, and will not detect
- /// * zero init of an enum whose 0 variant does not allow zero initialization
- /// * making uninitialized types who have a full valid range (ints, floats, raw pointers)
- /// * Any form of invalid value being made inside an array (unless the value is uninhabited)
- ///
- /// A strict form of these checks that uses const evaluation exists in
- /// `rustc_const_eval::might_permit_raw_init`, and a tracking issue for making these checks
- /// stricter is <https://github.com/rust-lang/rust/issues/66151>.
- ///
- /// FIXME: Once all the conservatism is removed from here, and the checks are ran by default,
- /// we can use the const evaluation checks always instead.
- pub fn might_permit_raw_init<C>(self, cx: &C, init_kind: InitKind) -> bool
- where
- Self: Copy,
- Ty: TyAbiInterface<'a, C>,
- C: HasDataLayout,
- {
- let scalar_allows_raw_init = move |s: Scalar| -> bool {
- match init_kind {
- InitKind::Zero => {
- // The range must contain 0.
- s.valid_range(cx).contains(0)
- }
- InitKind::Uninit => {
- // The range must include all values.
- s.is_always_valid(cx)
- }
- }
- };
-
- // Check the ABI.
- let valid = match self.abi {
- Abi::Uninhabited => false, // definitely UB
- Abi::Scalar(s) => scalar_allows_raw_init(s),
- Abi::ScalarPair(s1, s2) => scalar_allows_raw_init(s1) && scalar_allows_raw_init(s2),
- Abi::Vector { element: s, count } => count == 0 || scalar_allows_raw_init(s),
- Abi::Aggregate { .. } => true, // Fields are checked below.
- };
- if !valid {
- // This is definitely not okay.
- return false;
- }
-
- // If we have not found an error yet, we need to recursively descend into fields.
- match &self.fields {
- FieldsShape::Primitive | FieldsShape::Union { .. } => {}
- FieldsShape::Array { .. } => {
- // FIXME(#66151): For now, we are conservative and do not check arrays by default.
- }
- FieldsShape::Arbitrary { offsets, .. } => {
- for idx in 0..offsets.len() {
- if !self.field(cx, idx).might_permit_raw_init(cx, init_kind) {
- // We found a field that is unhappy with this kind of initialization.
- return false;
- }
- }
- }
- }
-
- // FIXME(#66151): For now, we are conservative and do not check `self.variants`.
- true
- }
}
diff --git a/compiler/rustc_target/src/lib.rs b/compiler/rustc_target/src/lib.rs
index a7deab9d2..aaba0d7f0 100644
--- a/compiler/rustc_target/src/lib.rs
+++ b/compiler/rustc_target/src/lib.rs
@@ -11,7 +11,6 @@
#![feature(assert_matches)]
#![feature(associated_type_bounds)]
#![feature(exhaustive_patterns)]
-#![cfg_attr(bootstrap, feature(let_else))]
#![feature(min_specialization)]
#![feature(never_type)]
#![feature(rustc_attrs)]
diff --git a/compiler/rustc_target/src/spec/aarch64_apple_ios_macabi.rs b/compiler/rustc_target/src/spec/aarch64_apple_ios_macabi.rs
index 1dad07a9a..2d2671549 100644
--- a/compiler/rustc_target/src/spec/aarch64_apple_ios_macabi.rs
+++ b/compiler/rustc_target/src/spec/aarch64_apple_ios_macabi.rs
@@ -1,11 +1,11 @@
use super::apple_sdk_base::{opts, Arch};
-use crate::spec::{FramePointer, LinkerFlavor, Target, TargetOptions};
+use crate::spec::{Cc, FramePointer, LinkerFlavor, Lld, Target, TargetOptions};
pub fn target() -> Target {
let llvm_target = "arm64-apple-ios14.0-macabi";
let mut base = opts("ios", Arch::Arm64_macabi);
- base.add_pre_link_args(LinkerFlavor::Gcc, &["-target", llvm_target]);
+ base.add_pre_link_args(LinkerFlavor::Darwin(Cc::Yes, Lld::No), &["-target", llvm_target]);
Target {
llvm_target: llvm_target.into(),
diff --git a/compiler/rustc_target/src/spec/aarch64_nintendo_switch_freestanding.rs b/compiler/rustc_target/src/spec/aarch64_nintendo_switch_freestanding.rs
index b301ce68a..529e98d2c 100644
--- a/compiler/rustc_target/src/spec/aarch64_nintendo_switch_freestanding.rs
+++ b/compiler/rustc_target/src/spec/aarch64_nintendo_switch_freestanding.rs
@@ -1,4 +1,4 @@
-use super::{LinkerFlavor, LldFlavor, PanicStrategy, RelroLevel, Target, TargetOptions};
+use super::{Cc, LinkerFlavor, Lld, PanicStrategy, RelroLevel, Target, TargetOptions};
const LINKER_SCRIPT: &str = include_str!("./aarch64_nintendo_switch_freestanding_linker_script.ld");
@@ -10,7 +10,7 @@ pub fn target() -> Target {
data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(),
arch: "aarch64".into(),
options: TargetOptions {
- linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
+ linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes),
linker: Some("rust-lld".into()),
link_script: Some(LINKER_SCRIPT.into()),
os: "horizon".into(),
diff --git a/compiler/rustc_target/src/spec/aarch64_unknown_none.rs b/compiler/rustc_target/src/spec/aarch64_unknown_none.rs
index d3fd7051a..4ae6d4120 100644
--- a/compiler/rustc_target/src/spec/aarch64_unknown_none.rs
+++ b/compiler/rustc_target/src/spec/aarch64_unknown_none.rs
@@ -6,11 +6,11 @@
//
// For example, `-C target-cpu=cortex-a53`.
-use super::{LinkerFlavor, LldFlavor, PanicStrategy, RelocModel, Target, TargetOptions};
+use super::{Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetOptions};
pub fn target() -> Target {
let opts = TargetOptions {
- linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
+ linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes),
linker: Some("rust-lld".into()),
features: "+strict-align,+neon,+fp-armv8".into(),
relocation_model: RelocModel::Static,
diff --git a/compiler/rustc_target/src/spec/aarch64_unknown_none_softfloat.rs b/compiler/rustc_target/src/spec/aarch64_unknown_none_softfloat.rs
index 6316abe1b..2385cb69a 100644
--- a/compiler/rustc_target/src/spec/aarch64_unknown_none_softfloat.rs
+++ b/compiler/rustc_target/src/spec/aarch64_unknown_none_softfloat.rs
@@ -6,12 +6,12 @@
//
// For example, `-C target-cpu=cortex-a53`.
-use super::{LinkerFlavor, LldFlavor, PanicStrategy, RelocModel, Target, TargetOptions};
+use super::{Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetOptions};
pub fn target() -> Target {
let opts = TargetOptions {
abi: "softfloat".into(),
- linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
+ linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes),
linker: Some("rust-lld".into()),
features: "+strict-align,-neon,-fp-armv8".into(),
relocation_model: RelocModel::Static,
diff --git a/compiler/rustc_target/src/spec/aarch64_unknown_uefi.rs b/compiler/rustc_target/src/spec/aarch64_unknown_uefi.rs
index 3ef04c676..817ff2422 100644
--- a/compiler/rustc_target/src/spec/aarch64_unknown_uefi.rs
+++ b/compiler/rustc_target/src/spec/aarch64_unknown_uefi.rs
@@ -2,13 +2,13 @@
// uefi-base module for generic UEFI options.
use super::uefi_msvc_base;
-use crate::spec::{LinkerFlavor, Target};
+use crate::spec::{LinkerFlavor, Lld, Target};
pub fn target() -> Target {
let mut base = uefi_msvc_base::opts();
base.max_atomic_width = Some(128);
- base.add_pre_link_args(LinkerFlavor::Msvc, &["/machine:arm64"]);
+ base.add_pre_link_args(LinkerFlavor::Msvc(Lld::No), &["/machine:arm64"]);
Target {
llvm_target: "aarch64-unknown-windows".into(),
diff --git a/compiler/rustc_target/src/spec/abi.rs b/compiler/rustc_target/src/spec/abi.rs
index 337554dc9..ce45fa139 100644
--- a/compiler/rustc_target/src/spec/abi.rs
+++ b/compiler/rustc_target/src/spec/abi.rs
@@ -1,6 +1,8 @@
use std::fmt;
use rustc_macros::HashStable_Generic;
+use rustc_span::symbol::sym;
+use rustc_span::{Span, Symbol};
#[cfg(test)]
mod tests;
@@ -94,6 +96,142 @@ pub fn all_names() -> Vec<&'static str> {
AbiDatas.iter().map(|d| d.name).collect()
}
+pub fn enabled_names(features: &rustc_feature::Features, span: Span) -> Vec<&'static str> {
+ AbiDatas
+ .iter()
+ .map(|d| d.name)
+ .filter(|name| is_enabled(features, span, name).is_ok())
+ .collect()
+}
+
+pub enum AbiDisabled {
+ Unstable { feature: Symbol, explain: &'static str },
+ Unrecognized,
+}
+
+pub fn is_enabled(
+ features: &rustc_feature::Features,
+ span: Span,
+ name: &str,
+) -> Result<(), AbiDisabled> {
+ let s = is_stable(name);
+ if let Err(AbiDisabled::Unstable { feature, .. }) = s {
+ if features.enabled(feature) || span.allows_unstable(feature) {
+ return Ok(());
+ }
+ }
+ s
+}
+
+pub fn is_stable(name: &str) -> Result<(), AbiDisabled> {
+ match name {
+ // Stable
+ "Rust" | "C" | "cdecl" | "stdcall" | "fastcall" | "aapcs" | "win64" | "sysv64"
+ | "system" => Ok(()),
+ "rust-intrinsic" => Err(AbiDisabled::Unstable {
+ feature: sym::intrinsics,
+ explain: "intrinsics are subject to change",
+ }),
+ "platform-intrinsic" => Err(AbiDisabled::Unstable {
+ feature: sym::platform_intrinsics,
+ explain: "platform intrinsics are experimental and possibly buggy",
+ }),
+ "vectorcall" => Err(AbiDisabled::Unstable {
+ feature: sym::abi_vectorcall,
+ explain: "vectorcall is experimental and subject to change",
+ }),
+ "thiscall" => Err(AbiDisabled::Unstable {
+ feature: sym::abi_thiscall,
+ explain: "thiscall is experimental and subject to change",
+ }),
+ "rust-call" => Err(AbiDisabled::Unstable {
+ feature: sym::unboxed_closures,
+ explain: "rust-call ABI is subject to change",
+ }),
+ "rust-cold" => Err(AbiDisabled::Unstable {
+ feature: sym::rust_cold_cc,
+ explain: "rust-cold is experimental and subject to change",
+ }),
+ "ptx-kernel" => Err(AbiDisabled::Unstable {
+ feature: sym::abi_ptx,
+ explain: "PTX ABIs are experimental and subject to change",
+ }),
+ "unadjusted" => Err(AbiDisabled::Unstable {
+ feature: sym::abi_unadjusted,
+ explain: "unadjusted ABI is an implementation detail and perma-unstable",
+ }),
+ "msp430-interrupt" => Err(AbiDisabled::Unstable {
+ feature: sym::abi_msp430_interrupt,
+ explain: "msp430-interrupt ABI is experimental and subject to change",
+ }),
+ "x86-interrupt" => Err(AbiDisabled::Unstable {
+ feature: sym::abi_x86_interrupt,
+ explain: "x86-interrupt ABI is experimental and subject to change",
+ }),
+ "amdgpu-kernel" => Err(AbiDisabled::Unstable {
+ feature: sym::abi_amdgpu_kernel,
+ explain: "amdgpu-kernel ABI is experimental and subject to change",
+ }),
+ "avr-interrupt" | "avr-non-blocking-interrupt" => Err(AbiDisabled::Unstable {
+ feature: sym::abi_avr_interrupt,
+ explain: "avr-interrupt and avr-non-blocking-interrupt ABIs are experimental and subject to change",
+ }),
+ "efiapi" => Err(AbiDisabled::Unstable {
+ feature: sym::abi_efiapi,
+ explain: "efiapi ABI is experimental and subject to change",
+ }),
+ "C-cmse-nonsecure-call" => Err(AbiDisabled::Unstable {
+ feature: sym::abi_c_cmse_nonsecure_call,
+ explain: "C-cmse-nonsecure-call ABI is experimental and subject to change",
+ }),
+ "C-unwind" => Err(AbiDisabled::Unstable {
+ feature: sym::c_unwind,
+ explain: "C-unwind ABI is experimental and subject to change",
+ }),
+ "stdcall-unwind" => Err(AbiDisabled::Unstable {
+ feature: sym::c_unwind,
+ explain: "stdcall-unwind ABI is experimental and subject to change",
+ }),
+ "system-unwind" => Err(AbiDisabled::Unstable {
+ feature: sym::c_unwind,
+ explain: "system-unwind ABI is experimental and subject to change",
+ }),
+ "thiscall-unwind" => Err(AbiDisabled::Unstable {
+ feature: sym::c_unwind,
+ explain: "thiscall-unwind ABI is experimental and subject to change",
+ }),
+ "cdecl-unwind" => Err(AbiDisabled::Unstable {
+ feature: sym::c_unwind,
+ explain: "cdecl-unwind ABI is experimental and subject to change",
+ }),
+ "fastcall-unwind" => Err(AbiDisabled::Unstable {
+ feature: sym::c_unwind,
+ explain: "fastcall-unwind ABI is experimental and subject to change",
+ }),
+ "vectorcall-unwind" => Err(AbiDisabled::Unstable {
+ feature: sym::c_unwind,
+ explain: "vectorcall-unwind ABI is experimental and subject to change",
+ }),
+ "aapcs-unwind" => Err(AbiDisabled::Unstable {
+ feature: sym::c_unwind,
+ explain: "aapcs-unwind ABI is experimental and subject to change",
+ }),
+ "win64-unwind" => Err(AbiDisabled::Unstable {
+ feature: sym::c_unwind,
+ explain: "win64-unwind ABI is experimental and subject to change",
+ }),
+ "sysv64-unwind" => Err(AbiDisabled::Unstable {
+ feature: sym::c_unwind,
+ explain: "sysv64-unwind ABI is experimental and subject to change",
+ }),
+ "wasm" => Err(AbiDisabled::Unstable {
+ feature: sym::wasm_abi,
+ explain: "wasm ABI is experimental and subject to change",
+ }),
+ _ => Err(AbiDisabled::Unrecognized),
+ }
+}
+
impl Abi {
/// Default ABI chosen for `extern fn` declarations without an explicit ABI.
pub const FALLBACK: Abi = Abi::C { unwind: false };
diff --git a/compiler/rustc_target/src/spec/android_base.rs b/compiler/rustc_target/src/spec/android_base.rs
index 9f3e0bd5e..9c1df1a06 100644
--- a/compiler/rustc_target/src/spec/android_base.rs
+++ b/compiler/rustc_target/src/spec/android_base.rs
@@ -1,10 +1,12 @@
-use crate::spec::TargetOptions;
+use crate::spec::{SanitizerSet, TargetOptions};
pub fn opts() -> TargetOptions {
let mut base = super::linux_base::opts();
base.os = "android".into();
+ base.is_like_android = true;
base.default_dwarf_version = 2;
base.has_thread_local = false;
+ base.supported_sanitizers = SanitizerSet::ADDRESS;
// This is for backward compatibility, see https://github.com/rust-lang/rust/issues/49867
// for context. (At that time, there was no `-C force-unwind-tables`, so the only solution
// was to always emit `uwtable`).
diff --git a/compiler/rustc_target/src/spec/apple_base.rs b/compiler/rustc_target/src/spec/apple_base.rs
index 2c72bf88a..40bc59ca1 100644
--- a/compiler/rustc_target/src/spec/apple_base.rs
+++ b/compiler/rustc_target/src/spec/apple_base.rs
@@ -1,7 +1,7 @@
use std::{borrow::Cow, env};
-use crate::spec::{cvs, DebuginfoKind, FramePointer, SplitDebuginfo, StaticCow, TargetOptions};
-use crate::spec::{LinkArgs, LinkerFlavor, LldFlavor};
+use crate::spec::{cvs, Cc, DebuginfoKind, FramePointer, LinkArgs};
+use crate::spec::{LinkerFlavor, Lld, SplitDebuginfo, StaticCow, TargetOptions};
fn pre_link_args(os: &'static str, arch: &'static str, abi: &'static str) -> LinkArgs {
let platform_name: StaticCow<str> = match abi {
@@ -20,17 +20,16 @@ fn pre_link_args(os: &'static str, arch: &'static str, abi: &'static str) -> Lin
.into();
let mut args = TargetOptions::link_args(
- LinkerFlavor::Lld(LldFlavor::Ld64),
+ LinkerFlavor::Darwin(Cc::No, Lld::No),
&["-arch", arch, "-platform_version"],
);
- // Manually add owned args unsupported by link arg building helpers.
- args.entry(LinkerFlavor::Lld(LldFlavor::Ld64)).or_default().extend([
- platform_name,
- platform_version.clone(),
- platform_version,
- ]);
+ super::add_link_args_iter(
+ &mut args,
+ LinkerFlavor::Darwin(Cc::No, Lld::No),
+ [platform_name, platform_version.clone(), platform_version].into_iter(),
+ );
if abi != "macabi" {
- super::add_link_args(&mut args, LinkerFlavor::Gcc, &["-arch", arch]);
+ super::add_link_args(&mut args, LinkerFlavor::Darwin(Cc::Yes, Lld::No), &["-arch", arch]);
}
args
@@ -55,11 +54,11 @@ pub fn opts(os: &'static str, arch: &'static str, abi: &'static str) -> TargetOp
TargetOptions {
os: os.into(),
vendor: "apple".into(),
+ linker_flavor: LinkerFlavor::Darwin(Cc::Yes, Lld::No),
// macOS has -dead_strip, which doesn't rely on function_sections
function_sections: false,
dynamic_linking: true,
pre_link_args: pre_link_args(os, arch, abi),
- linker_is_gnu: false,
families: cvs!["unix"],
is_like_osx: true,
default_dwarf_version: 2,
@@ -71,7 +70,6 @@ pub fn opts(os: &'static str, arch: &'static str, abi: &'static str) -> TargetOp
abi_return_struct_as_int: true,
emit_debug_gdb_scripts: false,
eh_frame_header: false,
- lld_flavor: LldFlavor::Ld64,
debuginfo_kind: DebuginfoKind::DwarfDsym,
// The historical default for macOS targets is to run `dsymutil` which
diff --git a/compiler/rustc_target/src/spec/armebv7r_none_eabi.rs b/compiler/rustc_target/src/spec/armebv7r_none_eabi.rs
index 511693abe..8c65d6afc 100644
--- a/compiler/rustc_target/src/spec/armebv7r_none_eabi.rs
+++ b/compiler/rustc_target/src/spec/armebv7r_none_eabi.rs
@@ -1,8 +1,7 @@
// Targets the Big endian Cortex-R4/R5 processor (ARMv7-R)
use crate::abi::Endian;
-use crate::spec::{LinkerFlavor, LldFlavor, PanicStrategy, RelocModel};
-use crate::spec::{Target, TargetOptions};
+use crate::spec::{Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetOptions};
pub fn target() -> Target {
Target {
@@ -13,7 +12,7 @@ pub fn target() -> Target {
options: TargetOptions {
abi: "eabi".into(),
endian: Endian::Big,
- linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
+ linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes),
linker: Some("rust-lld".into()),
relocation_model: RelocModel::Static,
panic_strategy: PanicStrategy::Abort,
diff --git a/compiler/rustc_target/src/spec/armebv7r_none_eabihf.rs b/compiler/rustc_target/src/spec/armebv7r_none_eabihf.rs
index 5df4a0a15..7013bc60d 100644
--- a/compiler/rustc_target/src/spec/armebv7r_none_eabihf.rs
+++ b/compiler/rustc_target/src/spec/armebv7r_none_eabihf.rs
@@ -1,8 +1,7 @@
// Targets the Cortex-R4F/R5F processor (ARMv7-R)
use crate::abi::Endian;
-use crate::spec::{LinkerFlavor, LldFlavor, PanicStrategy, RelocModel};
-use crate::spec::{Target, TargetOptions};
+use crate::spec::{Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetOptions};
pub fn target() -> Target {
Target {
@@ -13,7 +12,7 @@ pub fn target() -> Target {
options: TargetOptions {
abi: "eabihf".into(),
endian: Endian::Big,
- linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
+ linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes),
linker: Some("rust-lld".into()),
relocation_model: RelocModel::Static,
panic_strategy: PanicStrategy::Abort,
diff --git a/compiler/rustc_target/src/spec/armv4t_none_eabi.rs b/compiler/rustc_target/src/spec/armv4t_none_eabi.rs
index 797dfe52b..7ac1aab3b 100644
--- a/compiler/rustc_target/src/spec/armv4t_none_eabi.rs
+++ b/compiler/rustc_target/src/spec/armv4t_none_eabi.rs
@@ -16,7 +16,7 @@
//! The default link script is very likely wrong, so you should use
//! `-Clink-arg=-Tmy_script.ld` to override that with a correct linker script.
-use crate::spec::{cvs, LinkerFlavor, PanicStrategy, RelocModel, Target, TargetOptions};
+use crate::spec::{cvs, Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetOptions};
pub fn target() -> Target {
Target {
@@ -35,7 +35,7 @@ pub fn target() -> Target {
data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(),
options: TargetOptions {
abi: "eabi".into(),
- linker_flavor: LinkerFlavor::Ld,
+ linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::No),
linker: Some("arm-none-eabi-ld".into()),
asm_args: cvs!["-mthumb-interwork", "-march=armv4t", "-mlittle-endian",],
// Force-enable 32-bit atomics, which allows the use of atomic load/store only.
diff --git a/compiler/rustc_target/src/spec/armv5te_none_eabi.rs b/compiler/rustc_target/src/spec/armv5te_none_eabi.rs
new file mode 100644
index 000000000..dfd27b654
--- /dev/null
+++ b/compiler/rustc_target/src/spec/armv5te_none_eabi.rs
@@ -0,0 +1,41 @@
+//! Targets the ARMv5TE, with code as `a32` code by default.
+
+use crate::spec::{cvs, FramePointer, Target, TargetOptions};
+
+pub fn target() -> Target {
+ Target {
+ llvm_target: "armv5te-none-eabi".into(),
+ pointer_width: 32,
+ arch: "arm".into(),
+ /* Data layout args are '-' separated:
+ * little endian
+ * stack is 64-bit aligned (EABI)
+ * pointers are 32-bit
+ * i64 must be 64-bit aligned (EABI)
+ * mangle names with ELF style
+ * native integers are 32-bit
+ * All other elements are default
+ */
+ data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(),
+
+ options: TargetOptions {
+ abi: "eabi".into(),
+ // extra args passed to the external assembler (assuming `arm-none-eabi-as`):
+ // * activate t32/a32 interworking
+ // * use arch ARMv5TE
+ // * use little-endian
+ asm_args: cvs!["-mthumb-interwork", "-march=armv5te", "-mlittle-endian",],
+ // minimum extra features, these cannot be disabled via -C
+ // Also force-enable 32-bit atomics, which allows the use of atomic load/store only.
+ // The resulting atomics are ABI incompatible with atomics backed by libatomic.
+ features: "+soft-float,+strict-align,+atomics-32".into(),
+ frame_pointer: FramePointer::MayOmit,
+ main_needs_argc_argv: false,
+ // don't have atomic compare-and-swap
+ atomic_cas: false,
+ has_thumb_interworking: true,
+
+ ..super::thumb_base::opts()
+ },
+ }
+}
diff --git a/compiler/rustc_target/src/spec/armv6k_nintendo_3ds.rs b/compiler/rustc_target/src/spec/armv6k_nintendo_3ds.rs
index 1bba39393..40ec6f961 100644
--- a/compiler/rustc_target/src/spec/armv6k_nintendo_3ds.rs
+++ b/compiler/rustc_target/src/spec/armv6k_nintendo_3ds.rs
@@ -1,4 +1,4 @@
-use crate::spec::{cvs, LinkerFlavor, RelocModel, Target, TargetOptions};
+use crate::spec::{cvs, Cc, LinkerFlavor, Lld, RelocModel, Target, TargetOptions};
/// A base target for Nintendo 3DS devices using the devkitARM toolchain.
///
@@ -6,7 +6,7 @@ use crate::spec::{cvs, LinkerFlavor, RelocModel, Target, TargetOptions};
pub fn target() -> Target {
let pre_link_args = TargetOptions::link_args(
- LinkerFlavor::Gcc,
+ LinkerFlavor::Gnu(Cc::Yes, Lld::No),
&["-specs=3dsx.specs", "-mtune=mpcore", "-mfloat-abi=hard", "-mtp=soft"],
);
@@ -21,7 +21,6 @@ pub fn target() -> Target {
env: "newlib".into(),
vendor: "nintendo".into(),
abi: "eabihf".into(),
- linker_flavor: LinkerFlavor::Gcc,
cpu: "mpcore".into(),
families: cvs!["unix"],
linker: Some("arm-none-eabi-gcc".into()),
diff --git a/compiler/rustc_target/src/spec/armv7_linux_androideabi.rs b/compiler/rustc_target/src/spec/armv7_linux_androideabi.rs
index 38c117a49..402e0fd92 100644
--- a/compiler/rustc_target/src/spec/armv7_linux_androideabi.rs
+++ b/compiler/rustc_target/src/spec/armv7_linux_androideabi.rs
@@ -1,4 +1,4 @@
-use crate::spec::{LinkerFlavor, SanitizerSet, Target, TargetOptions};
+use crate::spec::{Cc, LinkerFlavor, Lld, SanitizerSet, Target, TargetOptions};
// This target if is for the baseline of the Android v7a ABI
// in thumb mode. It's named armv7-* instead of thumbv7-*
@@ -10,7 +10,7 @@ use crate::spec::{LinkerFlavor, SanitizerSet, Target, TargetOptions};
pub fn target() -> Target {
let mut base = super::android_base::opts();
- base.add_pre_link_args(LinkerFlavor::Gcc, &["-march=armv7-a"]);
+ base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-march=armv7-a"]);
Target {
llvm_target: "armv7-none-linux-android".into(),
pointer_width: 32,
diff --git a/compiler/rustc_target/src/spec/armv7a_none_eabi.rs b/compiler/rustc_target/src/spec/armv7a_none_eabi.rs
index cb5cbe158..4e20fb325 100644
--- a/compiler/rustc_target/src/spec/armv7a_none_eabi.rs
+++ b/compiler/rustc_target/src/spec/armv7a_none_eabi.rs
@@ -14,12 +14,12 @@
// - `relocation-model` set to `static`; also no PIE, no relro and no dynamic
// linking. rationale: matches `thumb` targets
-use super::{LinkerFlavor, LldFlavor, PanicStrategy, RelocModel, Target, TargetOptions};
+use super::{Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetOptions};
pub fn target() -> Target {
let opts = TargetOptions {
abi: "eabi".into(),
- linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
+ linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes),
linker: Some("rust-lld".into()),
features: "+v7,+thumb2,+soft-float,-neon,+strict-align".into(),
relocation_model: RelocModel::Static,
diff --git a/compiler/rustc_target/src/spec/armv7a_none_eabihf.rs b/compiler/rustc_target/src/spec/armv7a_none_eabihf.rs
index fb5dd2e75..ae70129ae 100644
--- a/compiler/rustc_target/src/spec/armv7a_none_eabihf.rs
+++ b/compiler/rustc_target/src/spec/armv7a_none_eabihf.rs
@@ -5,12 +5,12 @@
// changes (list in `armv7a_none_eabi.rs`) to bring it closer to the bare-metal
// `thumb` & `aarch64` targets.
-use super::{LinkerFlavor, LldFlavor, PanicStrategy, RelocModel, Target, TargetOptions};
+use super::{Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetOptions};
pub fn target() -> Target {
let opts = TargetOptions {
abi: "eabihf".into(),
- linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
+ linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes),
linker: Some("rust-lld".into()),
features: "+v7,+vfp3,-d32,+thumb2,-neon,+strict-align".into(),
relocation_model: RelocModel::Static,
diff --git a/compiler/rustc_target/src/spec/armv7r_none_eabi.rs b/compiler/rustc_target/src/spec/armv7r_none_eabi.rs
index 5f1da09b3..25f301ccc 100644
--- a/compiler/rustc_target/src/spec/armv7r_none_eabi.rs
+++ b/compiler/rustc_target/src/spec/armv7r_none_eabi.rs
@@ -1,7 +1,6 @@
// Targets the Little-endian Cortex-R4/R5 processor (ARMv7-R)
-use crate::spec::{LinkerFlavor, LldFlavor, PanicStrategy, RelocModel};
-use crate::spec::{Target, TargetOptions};
+use crate::spec::{Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetOptions};
pub fn target() -> Target {
Target {
@@ -12,7 +11,7 @@ pub fn target() -> Target {
options: TargetOptions {
abi: "eabi".into(),
- linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
+ linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes),
linker: Some("rust-lld".into()),
relocation_model: RelocModel::Static,
panic_strategy: PanicStrategy::Abort,
diff --git a/compiler/rustc_target/src/spec/armv7r_none_eabihf.rs b/compiler/rustc_target/src/spec/armv7r_none_eabihf.rs
index 0038ed0df..40449759d 100644
--- a/compiler/rustc_target/src/spec/armv7r_none_eabihf.rs
+++ b/compiler/rustc_target/src/spec/armv7r_none_eabihf.rs
@@ -1,7 +1,6 @@
// Targets the Little-endian Cortex-R4F/R5F processor (ARMv7-R)
-use crate::spec::{LinkerFlavor, LldFlavor, PanicStrategy, RelocModel};
-use crate::spec::{Target, TargetOptions};
+use crate::spec::{Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetOptions};
pub fn target() -> Target {
Target {
@@ -12,7 +11,7 @@ pub fn target() -> Target {
options: TargetOptions {
abi: "eabihf".into(),
- linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
+ linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes),
linker: Some("rust-lld".into()),
relocation_model: RelocModel::Static,
panic_strategy: PanicStrategy::Abort,
diff --git a/compiler/rustc_target/src/spec/avr_gnu_base.rs b/compiler/rustc_target/src/spec/avr_gnu_base.rs
index 8cca33cc4..9c3406b53 100644
--- a/compiler/rustc_target/src/spec/avr_gnu_base.rs
+++ b/compiler/rustc_target/src/spec/avr_gnu_base.rs
@@ -1,4 +1,4 @@
-use crate::spec::{LinkerFlavor, RelocModel, Target, TargetOptions};
+use crate::spec::{Cc, LinkerFlavor, Lld, RelocModel, Target, TargetOptions};
/// A base target for AVR devices using the GNU toolchain.
///
@@ -17,8 +17,11 @@ pub fn target(target_cpu: &'static str, mmcu: &'static str) -> Target {
linker: Some("avr-gcc".into()),
eh_frame_header: false,
- pre_link_args: TargetOptions::link_args(LinkerFlavor::Gcc, &[mmcu]),
- late_link_args: TargetOptions::link_args(LinkerFlavor::Gcc, &["-lgcc"]),
+ pre_link_args: TargetOptions::link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &[mmcu]),
+ late_link_args: TargetOptions::link_args(
+ LinkerFlavor::Gnu(Cc::Yes, Lld::No),
+ &["-lgcc"],
+ ),
max_atomic_width: Some(0),
atomic_cas: false,
relocation_model: RelocModel::Static,
diff --git a/compiler/rustc_target/src/spec/fuchsia_base.rs b/compiler/rustc_target/src/spec/fuchsia_base.rs
index 962ad0c66..4c2775850 100644
--- a/compiler/rustc_target/src/spec/fuchsia_base.rs
+++ b/compiler/rustc_target/src/spec/fuchsia_base.rs
@@ -1,4 +1,4 @@
-use crate::spec::{crt_objects, cvs, LinkOutputKind, LinkerFlavor, LldFlavor, TargetOptions};
+use crate::spec::{crt_objects, cvs, Cc, LinkOutputKind, LinkerFlavor, Lld, TargetOptions};
pub fn opts() -> TargetOptions {
// This mirrors the linker options provided by clang. We presume lld for
@@ -7,7 +7,7 @@ pub fn opts() -> TargetOptions {
//
// https://github.com/llvm/llvm-project/blob/db9322b2066c55254e7691efeab863f43bfcc084/clang/lib/Driver/ToolChains/Fuchsia.cpp#L31
let pre_link_args = TargetOptions::link_args(
- LinkerFlavor::Ld,
+ LinkerFlavor::Gnu(Cc::No, Lld::No),
&[
"--build-id",
"--hash-style=gnu",
@@ -25,7 +25,7 @@ pub fn opts() -> TargetOptions {
TargetOptions {
os: "fuchsia".into(),
- linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
+ linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes),
linker: Some("rust-lld".into()),
dynamic_linking: true,
families: cvs!["unix"],
diff --git a/compiler/rustc_target/src/spec/hermit_base.rs b/compiler/rustc_target/src/spec/hermit_base.rs
index 562ccef7e..dd9991381 100644
--- a/compiler/rustc_target/src/spec/hermit_base.rs
+++ b/compiler/rustc_target/src/spec/hermit_base.rs
@@ -1,14 +1,14 @@
-use crate::spec::{LinkerFlavor, LldFlavor, PanicStrategy, TargetOptions, TlsModel};
+use crate::spec::{Cc, LinkerFlavor, Lld, PanicStrategy, TargetOptions, TlsModel};
pub fn opts() -> TargetOptions {
let pre_link_args = TargetOptions::link_args(
- LinkerFlavor::Ld,
+ LinkerFlavor::Gnu(Cc::No, Lld::No),
&["--build-id", "--hash-style=gnu", "--Bstatic"],
);
TargetOptions {
os: "hermit".into(),
- linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
+ linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes),
linker: Some("rust-lld".into()),
has_thread_local: true,
pre_link_args,
diff --git a/compiler/rustc_target/src/spec/hexagon_unknown_linux_musl.rs b/compiler/rustc_target/src/spec/hexagon_unknown_linux_musl.rs
index 2a24e4459..3aad05eb2 100644
--- a/compiler/rustc_target/src/spec/hexagon_unknown_linux_musl.rs
+++ b/compiler/rustc_target/src/spec/hexagon_unknown_linux_musl.rs
@@ -1,4 +1,4 @@
-use crate::spec::Target;
+use crate::spec::{Cc, LinkerFlavor, Target};
pub fn target() -> Target {
let mut base = super::linux_musl_base::opts();
@@ -9,7 +9,7 @@ pub fn target() -> Target {
base.crt_static_default = false;
base.has_rpath = true;
- base.linker_is_gnu = false;
+ base.linker_flavor = LinkerFlavor::Unix(Cc::Yes);
base.c_enum_min_bits = 8;
diff --git a/compiler/rustc_target/src/spec/i386_apple_ios.rs b/compiler/rustc_target/src/spec/i386_apple_ios.rs
index 8b6266c58..b85214a9c 100644
--- a/compiler/rustc_target/src/spec/i386_apple_ios.rs
+++ b/compiler/rustc_target/src/spec/i386_apple_ios.rs
@@ -14,8 +14,7 @@ pub fn target() -> Target {
arch: "x86".into(),
options: TargetOptions {
max_atomic_width: Some(64),
- // don't use probe-stack=inline-asm until rust#83139 and rust#84667 are resolved
- stack_probes: StackProbeType::Call,
+ stack_probes: StackProbeType::X86,
..base
},
}
diff --git a/compiler/rustc_target/src/spec/i686_apple_darwin.rs b/compiler/rustc_target/src/spec/i686_apple_darwin.rs
index 5e9ceb844..15607c12e 100644
--- a/compiler/rustc_target/src/spec/i686_apple_darwin.rs
+++ b/compiler/rustc_target/src/spec/i686_apple_darwin.rs
@@ -1,14 +1,13 @@
-use crate::spec::{FramePointer, LinkerFlavor, StackProbeType, Target, TargetOptions};
+use crate::spec::{Cc, FramePointer, LinkerFlavor, Lld, StackProbeType, Target, TargetOptions};
pub fn target() -> Target {
// ld64 only understand i386 and not i686
let mut base = super::apple_base::opts("macos", "i386", "");
base.cpu = "yonah".into();
base.max_atomic_width = Some(64);
- base.add_pre_link_args(LinkerFlavor::Gcc, &["-m32"]);
+ base.add_pre_link_args(LinkerFlavor::Darwin(Cc::Yes, Lld::No), &["-m32"]);
base.link_env_remove.to_mut().extend(super::apple_base::macos_link_env_remove());
- // don't use probe-stack=inline-asm until rust#83139 and rust#84667 are resolved
- base.stack_probes = StackProbeType::Call;
+ base.stack_probes = StackProbeType::X86;
base.frame_pointer = FramePointer::Always;
// Clang automatically chooses a more specific target based on
diff --git a/compiler/rustc_target/src/spec/i686_linux_android.rs b/compiler/rustc_target/src/spec/i686_linux_android.rs
index bdaf5c990..c7c30c239 100644
--- a/compiler/rustc_target/src/spec/i686_linux_android.rs
+++ b/compiler/rustc_target/src/spec/i686_linux_android.rs
@@ -11,8 +11,7 @@ pub fn target() -> Target {
// https://developer.android.com/ndk/guides/abis.html#x86
base.cpu = "pentiumpro".into();
base.features = "+mmx,+sse,+sse2,+sse3,+ssse3".into();
- // don't use probe-stack=inline-asm until rust#83139 and rust#84667 are resolved
- base.stack_probes = StackProbeType::Call;
+ base.stack_probes = StackProbeType::X86;
Target {
llvm_target: "i686-linux-android".into(),
diff --git a/compiler/rustc_target/src/spec/i686_pc_windows_gnu.rs b/compiler/rustc_target/src/spec/i686_pc_windows_gnu.rs
index 631865439..7a1113875 100644
--- a/compiler/rustc_target/src/spec/i686_pc_windows_gnu.rs
+++ b/compiler/rustc_target/src/spec/i686_pc_windows_gnu.rs
@@ -1,4 +1,4 @@
-use crate::spec::{FramePointer, LinkerFlavor, Target};
+use crate::spec::{Cc, FramePointer, LinkerFlavor, Lld, Target};
pub fn target() -> Target {
let mut base = super::windows_gnu_base::opts();
@@ -9,8 +9,11 @@ pub fn target() -> Target {
// Mark all dynamic libraries and executables as compatible with the larger 4GiB address
// space available to x86 Windows binaries on x86_64.
- base.add_pre_link_args(LinkerFlavor::Ld, &["-m", "i386pe", "--large-address-aware"]);
- base.add_pre_link_args(LinkerFlavor::Gcc, &["-Wl,--large-address-aware"]);
+ base.add_pre_link_args(
+ LinkerFlavor::Gnu(Cc::No, Lld::No),
+ &["-m", "i386pe", "--large-address-aware"],
+ );
+ base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-Wl,--large-address-aware"]);
Target {
llvm_target: "i686-pc-windows-gnu".into(),
diff --git a/compiler/rustc_target/src/spec/i686_pc_windows_msvc.rs b/compiler/rustc_target/src/spec/i686_pc_windows_msvc.rs
index f4ceaa1ca..db4c00dc6 100644
--- a/compiler/rustc_target/src/spec/i686_pc_windows_msvc.rs
+++ b/compiler/rustc_target/src/spec/i686_pc_windows_msvc.rs
@@ -1,4 +1,4 @@
-use crate::spec::{LinkerFlavor, Target};
+use crate::spec::{LinkerFlavor, Lld, Target};
pub fn target() -> Target {
let mut base = super::windows_msvc_base::opts();
@@ -6,7 +6,7 @@ pub fn target() -> Target {
base.max_atomic_width = Some(64);
base.add_pre_link_args(
- LinkerFlavor::Msvc,
+ LinkerFlavor::Msvc(Lld::No),
&[
// Mark all dynamic libraries and executables as compatible with the larger 4GiB address
// space available to x86 Windows binaries on x86_64.
diff --git a/compiler/rustc_target/src/spec/i686_unknown_freebsd.rs b/compiler/rustc_target/src/spec/i686_unknown_freebsd.rs
index aff284bf2..35ca78034 100644
--- a/compiler/rustc_target/src/spec/i686_unknown_freebsd.rs
+++ b/compiler/rustc_target/src/spec/i686_unknown_freebsd.rs
@@ -1,12 +1,11 @@
-use crate::spec::{LinkerFlavor, StackProbeType, Target};
+use crate::spec::{Cc, LinkerFlavor, Lld, StackProbeType, Target};
pub fn target() -> Target {
let mut base = super::freebsd_base::opts();
base.cpu = "pentium4".into();
base.max_atomic_width = Some(64);
- base.add_pre_link_args(LinkerFlavor::Gcc, &["-m32", "-Wl,-znotext"]);
- // don't use probe-stack=inline-asm until rust#83139 and rust#84667 are resolved
- base.stack_probes = StackProbeType::Call;
+ base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m32", "-Wl,-znotext"]);
+ base.stack_probes = StackProbeType::X86;
Target {
llvm_target: "i686-unknown-freebsd".into(),
diff --git a/compiler/rustc_target/src/spec/i686_unknown_haiku.rs b/compiler/rustc_target/src/spec/i686_unknown_haiku.rs
index 87aa74e40..e6b72336c 100644
--- a/compiler/rustc_target/src/spec/i686_unknown_haiku.rs
+++ b/compiler/rustc_target/src/spec/i686_unknown_haiku.rs
@@ -1,12 +1,11 @@
-use crate::spec::{LinkerFlavor, StackProbeType, Target};
+use crate::spec::{Cc, LinkerFlavor, Lld, StackProbeType, Target};
pub fn target() -> Target {
let mut base = super::haiku_base::opts();
base.cpu = "pentium4".into();
base.max_atomic_width = Some(64);
- base.add_pre_link_args(LinkerFlavor::Gcc, &["-m32"]);
- // don't use probe-stack=inline-asm until rust#83139 and rust#84667 are resolved
- base.stack_probes = StackProbeType::Call;
+ base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m32"]);
+ base.stack_probes = StackProbeType::X86;
Target {
llvm_target: "i686-unknown-haiku".into(),
diff --git a/compiler/rustc_target/src/spec/i686_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/i686_unknown_linux_gnu.rs
index 765803d16..73e536a7e 100644
--- a/compiler/rustc_target/src/spec/i686_unknown_linux_gnu.rs
+++ b/compiler/rustc_target/src/spec/i686_unknown_linux_gnu.rs
@@ -1,12 +1,12 @@
-use crate::spec::{LinkerFlavor, StackProbeType, Target};
+use crate::spec::{Cc, LinkerFlavor, Lld, SanitizerSet, StackProbeType, Target};
pub fn target() -> Target {
let mut base = super::linux_gnu_base::opts();
base.cpu = "pentium4".into();
base.max_atomic_width = Some(64);
- base.add_pre_link_args(LinkerFlavor::Gcc, &["-m32"]);
- // don't use probe-stack=inline-asm until rust#83139 and rust#84667 are resolved
- base.stack_probes = StackProbeType::Call;
+ base.supported_sanitizers = SanitizerSet::ADDRESS;
+ base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m32"]);
+ base.stack_probes = StackProbeType::X86;
Target {
llvm_target: "i686-unknown-linux-gnu".into(),
diff --git a/compiler/rustc_target/src/spec/i686_unknown_linux_musl.rs b/compiler/rustc_target/src/spec/i686_unknown_linux_musl.rs
index d94928043..3825082ba 100644
--- a/compiler/rustc_target/src/spec/i686_unknown_linux_musl.rs
+++ b/compiler/rustc_target/src/spec/i686_unknown_linux_musl.rs
@@ -1,12 +1,11 @@
-use crate::spec::{FramePointer, LinkerFlavor, StackProbeType, Target};
+use crate::spec::{Cc, FramePointer, LinkerFlavor, Lld, StackProbeType, Target};
pub fn target() -> Target {
let mut base = super::linux_musl_base::opts();
base.cpu = "pentium4".into();
base.max_atomic_width = Some(64);
- base.add_pre_link_args(LinkerFlavor::Gcc, &["-m32", "-Wl,-melf_i386"]);
- // don't use probe-stack=inline-asm until rust#83139 and rust#84667 are resolved
- base.stack_probes = StackProbeType::Call;
+ base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m32", "-Wl,-melf_i386"]);
+ base.stack_probes = StackProbeType::X86;
// The unwinder used by i686-unknown-linux-musl, the LLVM libunwind
// implementation, apparently relies on frame pointers existing... somehow.
diff --git a/compiler/rustc_target/src/spec/i686_unknown_netbsd.rs b/compiler/rustc_target/src/spec/i686_unknown_netbsd.rs
index 8de698b51..b191996c7 100644
--- a/compiler/rustc_target/src/spec/i686_unknown_netbsd.rs
+++ b/compiler/rustc_target/src/spec/i686_unknown_netbsd.rs
@@ -1,12 +1,11 @@
-use crate::spec::{LinkerFlavor, StackProbeType, Target, TargetOptions};
+use crate::spec::{Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetOptions};
pub fn target() -> Target {
let mut base = super::netbsd_base::opts();
base.cpu = "pentium4".into();
base.max_atomic_width = Some(64);
- base.add_pre_link_args(LinkerFlavor::Gcc, &["-m32"]);
- // don't use probe-stack=inline-asm until rust#83139 and rust#84667 are resolved
- base.stack_probes = StackProbeType::Call;
+ base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m32"]);
+ base.stack_probes = StackProbeType::X86;
Target {
llvm_target: "i686-unknown-netbsdelf".into(),
diff --git a/compiler/rustc_target/src/spec/i686_unknown_openbsd.rs b/compiler/rustc_target/src/spec/i686_unknown_openbsd.rs
index 7f25a1a16..8babe5597 100644
--- a/compiler/rustc_target/src/spec/i686_unknown_openbsd.rs
+++ b/compiler/rustc_target/src/spec/i686_unknown_openbsd.rs
@@ -1,12 +1,11 @@
-use crate::spec::{LinkerFlavor, StackProbeType, Target};
+use crate::spec::{Cc, LinkerFlavor, Lld, StackProbeType, Target};
pub fn target() -> Target {
let mut base = super::openbsd_base::opts();
base.cpu = "pentium4".into();
base.max_atomic_width = Some(64);
- base.add_pre_link_args(LinkerFlavor::Gcc, &["-m32", "-fuse-ld=lld"]);
- // don't use probe-stack=inline-asm until rust#83139 and rust#84667 are resolved
- base.stack_probes = StackProbeType::Call;
+ base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m32", "-fuse-ld=lld"]);
+ base.stack_probes = StackProbeType::X86;
Target {
llvm_target: "i686-unknown-openbsd".into(),
diff --git a/compiler/rustc_target/src/spec/i686_uwp_windows_gnu.rs b/compiler/rustc_target/src/spec/i686_uwp_windows_gnu.rs
index d52810d2f..a3e325698 100644
--- a/compiler/rustc_target/src/spec/i686_uwp_windows_gnu.rs
+++ b/compiler/rustc_target/src/spec/i686_uwp_windows_gnu.rs
@@ -1,4 +1,4 @@
-use crate::spec::{FramePointer, LinkerFlavor, Target};
+use crate::spec::{Cc, FramePointer, LinkerFlavor, Lld, Target};
pub fn target() -> Target {
let mut base = super::windows_uwp_gnu_base::opts();
@@ -8,8 +8,11 @@ pub fn target() -> Target {
// Mark all dynamic libraries and executables as compatible with the larger 4GiB address
// space available to x86 Windows binaries on x86_64.
- base.add_pre_link_args(LinkerFlavor::Ld, &["-m", "i386pe", "--large-address-aware"]);
- base.add_pre_link_args(LinkerFlavor::Gcc, &["-Wl,--large-address-aware"]);
+ base.add_pre_link_args(
+ LinkerFlavor::Gnu(Cc::No, Lld::No),
+ &["-m", "i386pe", "--large-address-aware"],
+ );
+ base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-Wl,--large-address-aware"]);
Target {
llvm_target: "i686-pc-windows-gnu".into(),
diff --git a/compiler/rustc_target/src/spec/i686_wrs_vxworks.rs b/compiler/rustc_target/src/spec/i686_wrs_vxworks.rs
index f62404e82..b5cfdfceb 100644
--- a/compiler/rustc_target/src/spec/i686_wrs_vxworks.rs
+++ b/compiler/rustc_target/src/spec/i686_wrs_vxworks.rs
@@ -1,12 +1,11 @@
-use crate::spec::{LinkerFlavor, StackProbeType, Target};
+use crate::spec::{Cc, LinkerFlavor, Lld, StackProbeType, Target};
pub fn target() -> Target {
let mut base = super::vxworks_base::opts();
base.cpu = "pentium4".into();
base.max_atomic_width = Some(64);
- base.add_pre_link_args(LinkerFlavor::Gcc, &["-m32"]);
- // don't use probe-stack=inline-asm until rust#83139 and rust#84667 are resolved
- base.stack_probes = StackProbeType::Call;
+ base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m32"]);
+ base.stack_probes = StackProbeType::X86;
Target {
llvm_target: "i686-unknown-linux-gnu".into(),
diff --git a/compiler/rustc_target/src/spec/illumos_base.rs b/compiler/rustc_target/src/spec/illumos_base.rs
index 77e000474..8ac351584 100644
--- a/compiler/rustc_target/src/spec/illumos_base.rs
+++ b/compiler/rustc_target/src/spec/illumos_base.rs
@@ -1,8 +1,8 @@
-use crate::spec::{cvs, FramePointer, LinkerFlavor, TargetOptions};
+use crate::spec::{cvs, Cc, FramePointer, LinkerFlavor, TargetOptions};
pub fn opts() -> TargetOptions {
let late_link_args = TargetOptions::link_args(
- LinkerFlavor::Gcc,
+ LinkerFlavor::Unix(Cc::Yes),
&[
// The illumos libc contains a stack unwinding implementation, as
// does libgcc_s. The latter implementation includes several
@@ -30,7 +30,7 @@ pub fn opts() -> TargetOptions {
has_rpath: true,
families: cvs!["unix"],
is_like_solaris: true,
- linker_is_gnu: false,
+ linker_flavor: LinkerFlavor::Unix(Cc::Yes),
limit_rdylib_exports: false, // Linker doesn't support this
frame_pointer: FramePointer::Always,
eh_frame_header: false,
diff --git a/compiler/rustc_target/src/spec/l4re_base.rs b/compiler/rustc_target/src/spec/l4re_base.rs
index b7bc1072b..3a4d83fad 100644
--- a/compiler/rustc_target/src/spec/l4re_base.rs
+++ b/compiler/rustc_target/src/spec/l4re_base.rs
@@ -1,13 +1,12 @@
-use crate::spec::{cvs, LinkerFlavor, PanicStrategy, RelocModel, TargetOptions};
+use crate::spec::{cvs, Cc, LinkerFlavor, PanicStrategy, RelocModel, TargetOptions};
pub fn opts() -> TargetOptions {
TargetOptions {
os: "l4re".into(),
env: "uclibc".into(),
- linker_flavor: LinkerFlavor::Ld,
+ linker_flavor: LinkerFlavor::Unix(Cc::No),
panic_strategy: PanicStrategy::Abort,
linker: Some("l4-bender".into()),
- linker_is_gnu: false,
families: cvs!["unix"],
relocation_model: RelocModel::Static,
..Default::default()
diff --git a/compiler/rustc_target/src/spec/linux_kernel_base.rs b/compiler/rustc_target/src/spec/linux_kernel_base.rs
index 0f5d85205..f41533a95 100644
--- a/compiler/rustc_target/src/spec/linux_kernel_base.rs
+++ b/compiler/rustc_target/src/spec/linux_kernel_base.rs
@@ -6,8 +6,7 @@ pub fn opts() -> TargetOptions {
env: "gnu".into(),
disable_redzone: true,
panic_strategy: PanicStrategy::Abort,
- // don't use probe-stack=inline-asm until rust#83139 and rust#84667 are resolved
- stack_probes: StackProbeType::Call,
+ stack_probes: StackProbeType::X86,
frame_pointer: FramePointer::Always,
position_independent_executables: true,
needs_plt: true,
diff --git a/compiler/rustc_target/src/spec/mipsel_sony_psp.rs b/compiler/rustc_target/src/spec/mipsel_sony_psp.rs
index cfc8ec21c..75beb91b1 100644
--- a/compiler/rustc_target/src/spec/mipsel_sony_psp.rs
+++ b/compiler/rustc_target/src/spec/mipsel_sony_psp.rs
@@ -1,11 +1,13 @@
-use crate::spec::{cvs, Target, TargetOptions};
-use crate::spec::{LinkerFlavor, LldFlavor, RelocModel};
+use crate::spec::{cvs, Cc, LinkerFlavor, Lld, RelocModel, Target, TargetOptions};
// The PSP has custom linker requirements.
const LINKER_SCRIPT: &str = include_str!("./mipsel_sony_psp_linker_script.ld");
pub fn target() -> Target {
- let pre_link_args = TargetOptions::link_args(LinkerFlavor::Ld, &["--emit-relocs", "--nmagic"]);
+ let pre_link_args = TargetOptions::link_args(
+ LinkerFlavor::Gnu(Cc::No, Lld::No),
+ &["--emit-relocs", "--nmagic"],
+ );
Target {
llvm_target: "mipsel-sony-psp".into(),
@@ -16,7 +18,7 @@ pub fn target() -> Target {
options: TargetOptions {
os: "psp".into(),
vendor: "sony".into(),
- linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
+ linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes),
cpu: "mips2".into(),
linker: Some("rust-lld".into()),
relocation_model: RelocModel::Static,
diff --git a/compiler/rustc_target/src/spec/mipsel_unknown_none.rs b/compiler/rustc_target/src/spec/mipsel_unknown_none.rs
index fe2aa2de8..43b01e7a0 100644
--- a/compiler/rustc_target/src/spec/mipsel_unknown_none.rs
+++ b/compiler/rustc_target/src/spec/mipsel_unknown_none.rs
@@ -2,8 +2,7 @@
//!
//! Can be used for MIPS M4K core (e.g. on PIC32MX devices)
-use crate::spec::{LinkerFlavor, LldFlavor, RelocModel};
-use crate::spec::{PanicStrategy, Target, TargetOptions};
+use crate::spec::{Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetOptions};
pub fn target() -> Target {
Target {
@@ -13,7 +12,7 @@ pub fn target() -> Target {
arch: "mips".into(),
options: TargetOptions {
- linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
+ linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes),
cpu: "mips32r2".into(),
features: "+mips32r2,+soft-float,+noabicalls".into(),
max_atomic_width: Some(32),
diff --git a/compiler/rustc_target/src/spec/mod.rs b/compiler/rustc_target/src/spec/mod.rs
index dc16739bd..8909cf33a 100644
--- a/compiler/rustc_target/src/spec/mod.rs
+++ b/compiler/rustc_target/src/spec/mod.rs
@@ -90,17 +90,73 @@ mod windows_msvc_base;
mod windows_uwp_gnu_base;
mod windows_uwp_msvc_base;
+/// Linker is called through a C/C++ compiler.
+#[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd)]
+pub enum Cc {
+ Yes,
+ No,
+}
+
+/// Linker is LLD.
+#[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd)]
+pub enum Lld {
+ Yes,
+ No,
+}
+
+/// All linkers have some kinds of command line interfaces and rustc needs to know which commands
+/// to use with each of them. So we cluster all such interfaces into a (somewhat arbitrary) number
+/// of classes that we call "linker flavors".
+///
+/// Technically, it's not even necessary, we can nearly always infer the flavor from linker name
+/// and target properties like `is_like_windows`/`is_like_osx`/etc. However, the PRs originally
+/// introducing `-Clinker-flavor` (#40018 and friends) were aiming to reduce this kind of inference
+/// and provide something certain and explicitly specified instead, and that design goal is still
+/// relevant now.
+///
+/// The second goal is to keep the number of flavors to the minimum if possible.
+/// LLD somewhat forces our hand here because that linker is self-sufficent only if its executable
+/// (`argv[0]`) is named in specific way, otherwise it doesn't work and requires a
+/// `-flavor LLD_FLAVOR` argument to choose which logic to use. Our shipped `rust-lld` in
+/// particular is not named in such specific way, so it needs the flavor option, so we make our
+/// linker flavors sufficiently fine-grained to satisfy LLD without inferring its flavor from other
+/// target properties, in accordance with the first design goal.
+///
+/// The first component of the flavor is tightly coupled with the compilation target,
+/// while the `Cc` and `Lld` flags can vary withing the same target.
#[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd)]
pub enum LinkerFlavor {
- Gcc,
- Ld,
- Lld(LldFlavor),
- Msvc,
+ /// Unix-like linker with GNU extensions (both naked and compiler-wrapped forms).
+ /// Besides similar "default" Linux/BSD linkers this also includes Windows/GNU linker,
+ /// which is somewhat different because it doesn't produce ELFs.
+ Gnu(Cc, Lld),
+ /// Unix-like linker for Apple targets (both naked and compiler-wrapped forms).
+ /// Extracted from the "umbrella" `Unix` flavor due to its corresponding LLD flavor.
+ Darwin(Cc, Lld),
+ /// Unix-like linker for Wasm targets (both naked and compiler-wrapped forms).
+ /// Extracted from the "umbrella" `Unix` flavor due to its corresponding LLD flavor.
+ /// Non-LLD version does not exist, so the lld flag is currently hardcoded here.
+ WasmLld(Cc),
+ /// Basic Unix-like linker for "any other Unix" targets (Solaris/illumos, L4Re, MSP430, etc),
+ /// possibly with non-GNU extensions (both naked and compiler-wrapped forms).
+ /// LLD doesn't support any of these.
+ Unix(Cc),
+ /// MSVC-style linker for Windows and UEFI, LLD supports it.
+ Msvc(Lld),
+ /// Emscripten Compiler Frontend, a wrapper around `WasmLld(Cc::Yes)` that has a different
+ /// interface and produces some additional JavaScript output.
EmCc,
+ // Below: other linker-like tools with unique interfaces for exotic targets.
+ /// Linker tool for BPF.
Bpf,
+ /// Linker tool for Nvidia PTX.
Ptx,
}
+/// Linker flavors available externally through command line (`-Clinker-flavor`)
+/// or json target specifications.
+/// FIXME: This set has accumulated historically, bring it more in line with the internal
+/// linker flavors (`LinkerFlavor`).
#[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd)]
pub enum LinkerFlavorCli {
Gcc,
@@ -148,12 +204,32 @@ impl ToJson for LldFlavor {
}
impl LinkerFlavor {
- pub fn from_cli(cli: LinkerFlavorCli) -> LinkerFlavor {
+ pub fn from_cli(cli: LinkerFlavorCli, target: &TargetOptions) -> LinkerFlavor {
+ Self::from_cli_impl(cli, target.linker_flavor.lld_flavor(), target.linker_flavor.is_gnu())
+ }
+
+ /// The passed CLI flavor is preferred over other args coming from the default target spec,
+ /// so this function can produce a flavor that is incompatible with the current target.
+ /// FIXME: Produce errors when `-Clinker-flavor` is set to something incompatible
+ /// with the current target.
+ fn from_cli_impl(cli: LinkerFlavorCli, lld_flavor: LldFlavor, is_gnu: bool) -> LinkerFlavor {
match cli {
- LinkerFlavorCli::Gcc => LinkerFlavor::Gcc,
- LinkerFlavorCli::Ld => LinkerFlavor::Ld,
- LinkerFlavorCli::Lld(lld_flavor) => LinkerFlavor::Lld(lld_flavor),
- LinkerFlavorCli::Msvc => LinkerFlavor::Msvc,
+ LinkerFlavorCli::Gcc => match lld_flavor {
+ LldFlavor::Ld if is_gnu => LinkerFlavor::Gnu(Cc::Yes, Lld::No),
+ LldFlavor::Ld64 => LinkerFlavor::Darwin(Cc::Yes, Lld::No),
+ LldFlavor::Wasm => LinkerFlavor::WasmLld(Cc::Yes),
+ LldFlavor::Ld | LldFlavor::Link => LinkerFlavor::Unix(Cc::Yes),
+ },
+ LinkerFlavorCli::Ld => match lld_flavor {
+ LldFlavor::Ld if is_gnu => LinkerFlavor::Gnu(Cc::No, Lld::No),
+ LldFlavor::Ld64 => LinkerFlavor::Darwin(Cc::No, Lld::No),
+ LldFlavor::Ld | LldFlavor::Wasm | LldFlavor::Link => LinkerFlavor::Unix(Cc::No),
+ },
+ LinkerFlavorCli::Lld(LldFlavor::Ld) => LinkerFlavor::Gnu(Cc::No, Lld::Yes),
+ LinkerFlavorCli::Lld(LldFlavor::Ld64) => LinkerFlavor::Darwin(Cc::No, Lld::Yes),
+ LinkerFlavorCli::Lld(LldFlavor::Wasm) => LinkerFlavor::WasmLld(Cc::No),
+ LinkerFlavorCli::Lld(LldFlavor::Link) => LinkerFlavor::Msvc(Lld::Yes),
+ LinkerFlavorCli::Msvc => LinkerFlavor::Msvc(Lld::No),
LinkerFlavorCli::Em => LinkerFlavor::EmCc,
LinkerFlavorCli::BpfLinker => LinkerFlavor::Bpf,
LinkerFlavorCli::PtxLinker => LinkerFlavor::Ptx,
@@ -162,15 +238,40 @@ impl LinkerFlavor {
fn to_cli(self) -> LinkerFlavorCli {
match self {
- LinkerFlavor::Gcc => LinkerFlavorCli::Gcc,
- LinkerFlavor::Ld => LinkerFlavorCli::Ld,
- LinkerFlavor::Lld(lld_flavor) => LinkerFlavorCli::Lld(lld_flavor),
- LinkerFlavor::Msvc => LinkerFlavorCli::Msvc,
+ LinkerFlavor::Gnu(Cc::Yes, _)
+ | LinkerFlavor::Darwin(Cc::Yes, _)
+ | LinkerFlavor::WasmLld(Cc::Yes)
+ | LinkerFlavor::Unix(Cc::Yes) => LinkerFlavorCli::Gcc,
+ LinkerFlavor::Gnu(_, Lld::Yes) => LinkerFlavorCli::Lld(LldFlavor::Ld),
+ LinkerFlavor::Darwin(_, Lld::Yes) => LinkerFlavorCli::Lld(LldFlavor::Ld64),
+ LinkerFlavor::WasmLld(..) => LinkerFlavorCli::Lld(LldFlavor::Wasm),
+ LinkerFlavor::Gnu(..) | LinkerFlavor::Darwin(..) | LinkerFlavor::Unix(..) => {
+ LinkerFlavorCli::Ld
+ }
+ LinkerFlavor::Msvc(Lld::Yes) => LinkerFlavorCli::Lld(LldFlavor::Link),
+ LinkerFlavor::Msvc(..) => LinkerFlavorCli::Msvc,
LinkerFlavor::EmCc => LinkerFlavorCli::Em,
LinkerFlavor::Bpf => LinkerFlavorCli::BpfLinker,
LinkerFlavor::Ptx => LinkerFlavorCli::PtxLinker,
}
}
+
+ pub fn lld_flavor(self) -> LldFlavor {
+ match self {
+ LinkerFlavor::Gnu(..)
+ | LinkerFlavor::Unix(..)
+ | LinkerFlavor::EmCc
+ | LinkerFlavor::Bpf
+ | LinkerFlavor::Ptx => LldFlavor::Ld,
+ LinkerFlavor::Darwin(..) => LldFlavor::Ld64,
+ LinkerFlavor::WasmLld(..) => LldFlavor::Wasm,
+ LinkerFlavor::Msvc(..) => LldFlavor::Link,
+ }
+ }
+
+ pub fn is_gnu(self) -> bool {
+ matches!(self, LinkerFlavor::Gnu(..))
+ }
}
macro_rules! linker_flavor_cli_impls {
@@ -635,6 +736,10 @@ pub enum StackProbeType {
}
impl StackProbeType {
+ // LLVM X86 targets (ix86 and x86_64) can use inline-asm stack probes starting with LLVM 16.
+ // Notable past issues were rust#83139 (fixed in 14) and rust#84667 (fixed in 16).
+ const X86: Self = Self::InlineOrCall { min_llvm_version_for_inline: (16, 0, 0) };
+
fn from_json(json: &Json) -> Result<Self, String> {
let object = json.as_object().ok_or_else(|| "expected a JSON object")?;
let kind = object
@@ -1120,6 +1225,8 @@ supported_targets! {
("mipsel-unknown-none", mipsel_unknown_none),
("thumbv4t-none-eabi", thumbv4t_none_eabi),
("armv4t-none-eabi", armv4t_none_eabi),
+ ("thumbv5te-none-eabi", thumbv5te_none_eabi),
+ ("armv5te-none-eabi", armv5te_none_eabi),
("aarch64_be-unknown-linux-gnu", aarch64_be_unknown_linux_gnu),
("aarch64-unknown-linux-gnu_ilp32", aarch64_unknown_linux_gnu_ilp32),
@@ -1252,16 +1359,11 @@ pub struct TargetOptions {
/// Linker to invoke
pub linker: Option<StaticCow<str>>,
/// Default linker flavor used if `-C linker-flavor` or `-C linker` are not passed
- /// on the command line. Defaults to `LinkerFlavor::Gcc`.
+ /// on the command line. Defaults to `LinkerFlavor::Gnu(Cc::Yes, Lld::No)`.
pub linker_flavor: LinkerFlavor,
linker_flavor_json: LinkerFlavorCli,
- /// LLD flavor used if `lld` (or `rust-lld`) is specified as a linker
- /// without clarifying its flavor in any way.
- /// FIXME: Merge this into `LinkerFlavor`.
- pub lld_flavor: LldFlavor,
- /// Whether the linker support GNU-like arguments such as -O. Defaults to true.
- /// FIXME: Merge this into `LinkerFlavor`.
- pub linker_is_gnu: bool,
+ lld_flavor_json: LldFlavor,
+ linker_is_gnu_json: bool,
/// Objects to link before and after all other object code.
pub pre_link_objects: CrtObjects,
@@ -1294,7 +1396,7 @@ pub struct TargetOptions {
/// Optional link script applied to `dylib` and `executable` crate types.
/// This is a string containing the script, not a path. Can only be applied
- /// to linkers where `linker_is_gnu` is true.
+ /// to linkers where linker flavor matches `LinkerFlavor::Gnu(..)`.
pub link_script: Option<StaticCow<str>>,
/// Environment variables to be set for the linker invocation.
pub link_env: StaticCow<[(StaticCow<str>, StaticCow<str>)]>,
@@ -1379,6 +1481,8 @@ pub struct TargetOptions {
pub is_like_msvc: bool,
/// Whether a target toolchain is like WASM.
pub is_like_wasm: bool,
+ /// Whether a target toolchain is like Android, implying a Linux kernel and a Bionic libc
+ pub is_like_android: bool,
/// Default supported version of DWARF on this platform.
/// Useful because some platforms (osx, bsd) only want up to DWARF2.
pub default_dwarf_version: u32,
@@ -1567,22 +1671,38 @@ pub struct TargetOptions {
/// Add arguments for the given flavor and also for its "twin" flavors
/// that have a compatible command line interface.
-fn add_link_args(link_args: &mut LinkArgs, flavor: LinkerFlavor, args: &[&'static str]) {
- let mut insert = |flavor| {
- link_args.entry(flavor).or_default().extend(args.iter().copied().map(Cow::Borrowed))
- };
+fn add_link_args_iter(
+ link_args: &mut LinkArgs,
+ flavor: LinkerFlavor,
+ args: impl Iterator<Item = StaticCow<str>> + Clone,
+) {
+ let mut insert = |flavor| link_args.entry(flavor).or_default().extend(args.clone());
insert(flavor);
match flavor {
- LinkerFlavor::Ld => insert(LinkerFlavor::Lld(LldFlavor::Ld)),
- LinkerFlavor::Msvc => insert(LinkerFlavor::Lld(LldFlavor::Link)),
- LinkerFlavor::Lld(LldFlavor::Ld64) | LinkerFlavor::Lld(LldFlavor::Wasm) => {}
- LinkerFlavor::Lld(lld_flavor) => {
- panic!("add_link_args: use non-LLD flavor for {:?}", lld_flavor)
+ LinkerFlavor::Gnu(cc, lld) => {
+ assert_eq!(lld, Lld::No);
+ insert(LinkerFlavor::Gnu(cc, Lld::Yes));
+ }
+ LinkerFlavor::Darwin(cc, lld) => {
+ assert_eq!(lld, Lld::No);
+ insert(LinkerFlavor::Darwin(cc, Lld::Yes));
}
- LinkerFlavor::Gcc | LinkerFlavor::EmCc | LinkerFlavor::Bpf | LinkerFlavor::Ptx => {}
+ LinkerFlavor::Msvc(lld) => {
+ assert_eq!(lld, Lld::No);
+ insert(LinkerFlavor::Msvc(Lld::Yes));
+ }
+ LinkerFlavor::WasmLld(..)
+ | LinkerFlavor::Unix(..)
+ | LinkerFlavor::EmCc
+ | LinkerFlavor::Bpf
+ | LinkerFlavor::Ptx => {}
}
}
+fn add_link_args(link_args: &mut LinkArgs, flavor: LinkerFlavor, args: &[&'static str]) {
+ add_link_args_iter(link_args, flavor, args.iter().copied().map(Cow::Borrowed))
+}
+
impl TargetOptions {
fn link_args(flavor: LinkerFlavor, args: &[&'static str]) -> LinkArgs {
let mut link_args = LinkArgs::new();
@@ -1599,7 +1719,11 @@ impl TargetOptions {
}
fn update_from_cli(&mut self) {
- self.linker_flavor = LinkerFlavor::from_cli(self.linker_flavor_json);
+ self.linker_flavor = LinkerFlavor::from_cli_impl(
+ self.linker_flavor_json,
+ self.lld_flavor_json,
+ self.linker_is_gnu_json,
+ );
for (args, args_json) in [
(&mut self.pre_link_args, &self.pre_link_args_json),
(&mut self.late_link_args, &self.late_link_args_json),
@@ -1607,15 +1731,32 @@ impl TargetOptions {
(&mut self.late_link_args_static, &self.late_link_args_static_json),
(&mut self.post_link_args, &self.post_link_args_json),
] {
- *args = args_json
- .iter()
- .map(|(flavor, args)| (LinkerFlavor::from_cli(*flavor), args.clone()))
- .collect();
+ args.clear();
+ for (flavor, args_json) in args_json {
+ // Cannot use `from_cli` due to borrow checker.
+ let linker_flavor = LinkerFlavor::from_cli_impl(
+ *flavor,
+ self.lld_flavor_json,
+ self.linker_is_gnu_json,
+ );
+ // Normalize to no lld to avoid asserts.
+ let linker_flavor = match linker_flavor {
+ LinkerFlavor::Gnu(cc, _) => LinkerFlavor::Gnu(cc, Lld::No),
+ LinkerFlavor::Darwin(cc, _) => LinkerFlavor::Darwin(cc, Lld::No),
+ LinkerFlavor::Msvc(_) => LinkerFlavor::Msvc(Lld::No),
+ _ => linker_flavor,
+ };
+ if !args.contains_key(&linker_flavor) {
+ add_link_args_iter(args, linker_flavor, args_json.iter().cloned());
+ }
+ }
}
}
fn update_to_cli(&mut self) {
self.linker_flavor_json = self.linker_flavor.to_cli();
+ self.lld_flavor_json = self.linker_flavor.lld_flavor();
+ self.linker_is_gnu_json = self.linker_flavor.is_gnu();
for (args, args_json) in [
(&self.pre_link_args, &mut self.pre_link_args_json),
(&self.late_link_args, &mut self.late_link_args_json),
@@ -1642,10 +1783,10 @@ impl Default for TargetOptions {
abi: "".into(),
vendor: "unknown".into(),
linker: option_env!("CFG_DEFAULT_LINKER").map(|s| s.into()),
- linker_flavor: LinkerFlavor::Gcc,
+ linker_flavor: LinkerFlavor::Gnu(Cc::Yes, Lld::No),
linker_flavor_json: LinkerFlavorCli::Gcc,
- lld_flavor: LldFlavor::Ld,
- linker_is_gnu: true,
+ lld_flavor_json: LldFlavor::Ld,
+ linker_is_gnu_json: true,
link_script: None,
asm_args: cvs![],
cpu: "generic".into(),
@@ -1671,6 +1812,7 @@ impl Default for TargetOptions {
is_like_windows: false,
is_like_msvc: false,
is_like_wasm: false,
+ is_like_android: false,
default_dwarf_version: 4,
allows_weak_linkage: true,
has_rpath: false,
@@ -1913,6 +2055,12 @@ impl Target {
base.$key_name = s;
}
} );
+ ($key_name:ident = $json_name:expr, bool) => ( {
+ let name = $json_name;
+ if let Some(s) = obj.remove(name).and_then(|b| b.as_bool()) {
+ base.$key_name = s;
+ }
+ } );
($key_name:ident, u64) => ( {
let name = (stringify!($key_name)).replace("_", "-");
if let Some(s) = obj.remove(&name).and_then(|j| Json::as_u64(&j)) {
@@ -2084,9 +2232,9 @@ impl Target {
.map(|s| s.to_string().into());
}
} );
- ($key_name:ident, LldFlavor) => ( {
- let name = (stringify!($key_name)).replace("_", "-");
- obj.remove(&name).and_then(|o| o.as_str().and_then(|s| {
+ ($key_name:ident = $json_name:expr, LldFlavor) => ( {
+ let name = $json_name;
+ obj.remove(name).and_then(|o| o.as_str().and_then(|s| {
if let Some(flavor) = LldFlavor::from_str(&s) {
base.$key_name = flavor;
} else {
@@ -2280,8 +2428,8 @@ impl Target {
key!(vendor);
key!(linker, optional);
key!(linker_flavor_json = "linker-flavor", LinkerFlavor)?;
- key!(lld_flavor, LldFlavor)?;
- key!(linker_is_gnu, bool);
+ key!(lld_flavor_json = "lld-flavor", LldFlavor)?;
+ key!(linker_is_gnu_json = "linker-is-gnu", bool);
key!(pre_link_objects = "pre-link-objects", link_objects);
key!(post_link_objects = "post-link-objects", link_objects);
key!(pre_link_objects_self_contained = "pre-link-objects-fallback", link_objects);
@@ -2318,6 +2466,7 @@ impl Target {
key!(is_like_windows, bool);
key!(is_like_msvc, bool);
key!(is_like_wasm, bool);
+ key!(is_like_android, bool);
key!(default_dwarf_version, u32);
key!(allows_weak_linkage, bool);
key!(has_rpath, bool);
@@ -2529,8 +2678,8 @@ impl ToJson for Target {
target_option_val!(vendor);
target_option_val!(linker);
target_option_val!(linker_flavor_json, "linker-flavor");
- target_option_val!(lld_flavor);
- target_option_val!(linker_is_gnu);
+ target_option_val!(lld_flavor_json, "lld-flavor");
+ target_option_val!(linker_is_gnu_json, "linker-is-gnu");
target_option_val!(pre_link_objects);
target_option_val!(post_link_objects);
target_option_val!(pre_link_objects_self_contained, "pre-link-objects-fallback");
@@ -2568,6 +2717,7 @@ impl ToJson for Target {
target_option_val!(is_like_windows);
target_option_val!(is_like_msvc);
target_option_val!(is_like_wasm);
+ target_option_val!(is_like_android);
target_option_val!(default_dwarf_version);
target_option_val!(allows_weak_linkage);
target_option_val!(has_rpath);
diff --git a/compiler/rustc_target/src/spec/msp430_none_elf.rs b/compiler/rustc_target/src/spec/msp430_none_elf.rs
index 6b09386ae..251fd2a0a 100644
--- a/compiler/rustc_target/src/spec/msp430_none_elf.rs
+++ b/compiler/rustc_target/src/spec/msp430_none_elf.rs
@@ -1,4 +1,4 @@
-use crate::spec::{cvs, PanicStrategy, RelocModel, Target, TargetOptions};
+use crate::spec::{cvs, Cc, LinkerFlavor, PanicStrategy, RelocModel, Target, TargetOptions};
pub fn target() -> Target {
Target {
@@ -16,7 +16,7 @@ pub fn target() -> Target {
// dependency on this specific gcc.
asm_args: cvs!["-mcpu=msp430"],
linker: Some("msp430-elf-gcc".into()),
- linker_is_gnu: false,
+ linker_flavor: LinkerFlavor::Unix(Cc::Yes),
// There are no atomic CAS instructions available in the MSP430
// instruction set, and the LLVM backend doesn't currently support
diff --git a/compiler/rustc_target/src/spec/msvc_base.rs b/compiler/rustc_target/src/spec/msvc_base.rs
index b3cd38a6e..1dad9133e 100644
--- a/compiler/rustc_target/src/spec/msvc_base.rs
+++ b/compiler/rustc_target/src/spec/msvc_base.rs
@@ -1,17 +1,15 @@
-use crate::spec::{DebuginfoKind, LinkerFlavor, LldFlavor, SplitDebuginfo, TargetOptions};
+use crate::spec::{DebuginfoKind, LinkerFlavor, Lld, SplitDebuginfo, TargetOptions};
use std::borrow::Cow;
pub fn opts() -> TargetOptions {
// Suppress the verbose logo and authorship debugging output, which would needlessly
// clog any log files.
- let pre_link_args = TargetOptions::link_args(LinkerFlavor::Msvc, &["/NOLOGO"]);
+ let pre_link_args = TargetOptions::link_args(LinkerFlavor::Msvc(Lld::No), &["/NOLOGO"]);
TargetOptions {
- linker_flavor: LinkerFlavor::Msvc,
+ linker_flavor: LinkerFlavor::Msvc(Lld::No),
is_like_windows: true,
is_like_msvc: true,
- lld_flavor: LldFlavor::Link,
- linker_is_gnu: false,
pre_link_args,
abi_return_struct_as_int: true,
emit_debug_gdb_scripts: false,
diff --git a/compiler/rustc_target/src/spec/nvptx64_nvidia_cuda.rs b/compiler/rustc_target/src/spec/nvptx64_nvidia_cuda.rs
index 6ab3a8b7e..b0582b235 100644
--- a/compiler/rustc_target/src/spec/nvptx64_nvidia_cuda.rs
+++ b/compiler/rustc_target/src/spec/nvptx64_nvidia_cuda.rs
@@ -13,7 +13,6 @@ pub fn target() -> Target {
linker_flavor: LinkerFlavor::Ptx,
// The linker can be installed from `crates.io`.
linker: Some("rust-ptx-linker".into()),
- linker_is_gnu: false,
// With `ptx-linker` approach, it can be later overridden via link flags.
cpu: "sm_30".into(),
diff --git a/compiler/rustc_target/src/spec/powerpc64_unknown_freebsd.rs b/compiler/rustc_target/src/spec/powerpc64_unknown_freebsd.rs
index 803453c4a..08b273207 100644
--- a/compiler/rustc_target/src/spec/powerpc64_unknown_freebsd.rs
+++ b/compiler/rustc_target/src/spec/powerpc64_unknown_freebsd.rs
@@ -1,11 +1,12 @@
use crate::abi::Endian;
-use crate::spec::{LinkerFlavor, Target, TargetOptions};
+use crate::spec::{Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetOptions};
pub fn target() -> Target {
let mut base = super::freebsd_base::opts();
base.cpu = "ppc64".into();
- base.add_pre_link_args(LinkerFlavor::Gcc, &["-m64"]);
+ base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64"]);
base.max_atomic_width = Some(64);
+ base.stack_probes = StackProbeType::Inline;
Target {
llvm_target: "powerpc64-unknown-freebsd".into(),
diff --git a/compiler/rustc_target/src/spec/powerpc64_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/powerpc64_unknown_linux_gnu.rs
index 5413c4f33..ce64de861 100644
--- a/compiler/rustc_target/src/spec/powerpc64_unknown_linux_gnu.rs
+++ b/compiler/rustc_target/src/spec/powerpc64_unknown_linux_gnu.rs
@@ -1,15 +1,12 @@
use crate::abi::Endian;
-use crate::spec::{LinkerFlavor, RelroLevel, Target, TargetOptions};
+use crate::spec::{Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetOptions};
pub fn target() -> Target {
let mut base = super::linux_gnu_base::opts();
base.cpu = "ppc64".into();
- base.add_pre_link_args(LinkerFlavor::Gcc, &["-m64"]);
+ base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64"]);
base.max_atomic_width = Some(64);
-
- // ld.so in at least RHEL6 on ppc64 has a bug related to BIND_NOW, so only enable partial RELRO
- // for now. https://github.com/rust-lang/rust/pull/43170#issuecomment-315411474
- base.relro_level = RelroLevel::Partial;
+ base.stack_probes = StackProbeType::Inline;
Target {
llvm_target: "powerpc64-unknown-linux-gnu".into(),
diff --git a/compiler/rustc_target/src/spec/powerpc64_unknown_linux_musl.rs b/compiler/rustc_target/src/spec/powerpc64_unknown_linux_musl.rs
index 159335eb6..81286a668 100644
--- a/compiler/rustc_target/src/spec/powerpc64_unknown_linux_musl.rs
+++ b/compiler/rustc_target/src/spec/powerpc64_unknown_linux_musl.rs
@@ -1,11 +1,12 @@
use crate::abi::Endian;
-use crate::spec::{LinkerFlavor, Target, TargetOptions};
+use crate::spec::{Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetOptions};
pub fn target() -> Target {
let mut base = super::linux_musl_base::opts();
base.cpu = "ppc64".into();
- base.add_pre_link_args(LinkerFlavor::Gcc, &["-m64"]);
+ base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64"]);
base.max_atomic_width = Some(64);
+ base.stack_probes = StackProbeType::Inline;
Target {
llvm_target: "powerpc64-unknown-linux-musl".into(),
diff --git a/compiler/rustc_target/src/spec/powerpc64_unknown_openbsd.rs b/compiler/rustc_target/src/spec/powerpc64_unknown_openbsd.rs
index 9cb3a67dc..7232dce3e 100644
--- a/compiler/rustc_target/src/spec/powerpc64_unknown_openbsd.rs
+++ b/compiler/rustc_target/src/spec/powerpc64_unknown_openbsd.rs
@@ -1,11 +1,12 @@
use crate::abi::Endian;
-use crate::spec::{LinkerFlavor, Target, TargetOptions};
+use crate::spec::{Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetOptions};
pub fn target() -> Target {
let mut base = super::openbsd_base::opts();
base.cpu = "ppc64".into();
- base.add_pre_link_args(LinkerFlavor::Gcc, &["-m64"]);
+ base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64"]);
base.max_atomic_width = Some(64);
+ base.stack_probes = StackProbeType::Inline;
Target {
llvm_target: "powerpc64-unknown-openbsd".into(),
diff --git a/compiler/rustc_target/src/spec/powerpc64_wrs_vxworks.rs b/compiler/rustc_target/src/spec/powerpc64_wrs_vxworks.rs
index b7420d232..10da7872c 100644
--- a/compiler/rustc_target/src/spec/powerpc64_wrs_vxworks.rs
+++ b/compiler/rustc_target/src/spec/powerpc64_wrs_vxworks.rs
@@ -1,11 +1,12 @@
use crate::abi::Endian;
-use crate::spec::{LinkerFlavor, Target, TargetOptions};
+use crate::spec::{Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetOptions};
pub fn target() -> Target {
let mut base = super::vxworks_base::opts();
base.cpu = "ppc64".into();
- base.add_pre_link_args(LinkerFlavor::Gcc, &["-m64"]);
+ base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64"]);
base.max_atomic_width = Some(64);
+ base.stack_probes = StackProbeType::Inline;
Target {
llvm_target: "powerpc64-unknown-linux-gnu".into(),
diff --git a/compiler/rustc_target/src/spec/powerpc64le_unknown_freebsd.rs b/compiler/rustc_target/src/spec/powerpc64le_unknown_freebsd.rs
index a3d180043..8c941e106 100644
--- a/compiler/rustc_target/src/spec/powerpc64le_unknown_freebsd.rs
+++ b/compiler/rustc_target/src/spec/powerpc64le_unknown_freebsd.rs
@@ -1,10 +1,11 @@
-use crate::spec::{LinkerFlavor, Target, TargetOptions};
+use crate::spec::{Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetOptions};
pub fn target() -> Target {
let mut base = super::freebsd_base::opts();
base.cpu = "ppc64le".into();
- base.add_pre_link_args(LinkerFlavor::Gcc, &["-m64"]);
+ base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64"]);
base.max_atomic_width = Some(64);
+ base.stack_probes = StackProbeType::Inline;
Target {
llvm_target: "powerpc64le-unknown-freebsd".into(),
diff --git a/compiler/rustc_target/src/spec/powerpc64le_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/powerpc64le_unknown_linux_gnu.rs
index e18ff3be4..fd896e086 100644
--- a/compiler/rustc_target/src/spec/powerpc64le_unknown_linux_gnu.rs
+++ b/compiler/rustc_target/src/spec/powerpc64le_unknown_linux_gnu.rs
@@ -1,10 +1,11 @@
-use crate::spec::{LinkerFlavor, Target, TargetOptions};
+use crate::spec::{Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetOptions};
pub fn target() -> Target {
let mut base = super::linux_gnu_base::opts();
base.cpu = "ppc64le".into();
- base.add_pre_link_args(LinkerFlavor::Gcc, &["-m64"]);
+ base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64"]);
base.max_atomic_width = Some(64);
+ base.stack_probes = StackProbeType::Inline;
Target {
llvm_target: "powerpc64le-unknown-linux-gnu".into(),
diff --git a/compiler/rustc_target/src/spec/powerpc64le_unknown_linux_musl.rs b/compiler/rustc_target/src/spec/powerpc64le_unknown_linux_musl.rs
index b84943d23..3cffcf497 100644
--- a/compiler/rustc_target/src/spec/powerpc64le_unknown_linux_musl.rs
+++ b/compiler/rustc_target/src/spec/powerpc64le_unknown_linux_musl.rs
@@ -1,10 +1,11 @@
-use crate::spec::{LinkerFlavor, Target, TargetOptions};
+use crate::spec::{Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetOptions};
pub fn target() -> Target {
let mut base = super::linux_musl_base::opts();
base.cpu = "ppc64le".into();
- base.add_pre_link_args(LinkerFlavor::Gcc, &["-m64"]);
+ base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64"]);
base.max_atomic_width = Some(64);
+ base.stack_probes = StackProbeType::Inline;
Target {
llvm_target: "powerpc64le-unknown-linux-musl".into(),
diff --git a/compiler/rustc_target/src/spec/powerpc_unknown_freebsd.rs b/compiler/rustc_target/src/spec/powerpc_unknown_freebsd.rs
index 75ac66c27..342f321bd 100644
--- a/compiler/rustc_target/src/spec/powerpc_unknown_freebsd.rs
+++ b/compiler/rustc_target/src/spec/powerpc_unknown_freebsd.rs
@@ -1,11 +1,15 @@
use crate::abi::Endian;
-use crate::spec::{LinkerFlavor, Target, TargetOptions};
+use crate::spec::{Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetOptions};
pub fn target() -> Target {
let mut base = super::freebsd_base::opts();
// Extra hint to linker that we are generating secure-PLT code.
- base.add_pre_link_args(LinkerFlavor::Gcc, &["-m32", "--target=powerpc-unknown-freebsd13.0"]);
+ base.add_pre_link_args(
+ LinkerFlavor::Gnu(Cc::Yes, Lld::No),
+ &["-m32", "--target=powerpc-unknown-freebsd13.0"],
+ );
base.max_atomic_width = Some(32);
+ base.stack_probes = StackProbeType::Inline;
Target {
llvm_target: "powerpc-unknown-freebsd13.0".into(),
diff --git a/compiler/rustc_target/src/spec/powerpc_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/powerpc_unknown_linux_gnu.rs
index 6686a0bbf..c8c61dc46 100644
--- a/compiler/rustc_target/src/spec/powerpc_unknown_linux_gnu.rs
+++ b/compiler/rustc_target/src/spec/powerpc_unknown_linux_gnu.rs
@@ -1,10 +1,11 @@
use crate::abi::Endian;
-use crate::spec::{LinkerFlavor, Target, TargetOptions};
+use crate::spec::{Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetOptions};
pub fn target() -> Target {
let mut base = super::linux_gnu_base::opts();
- base.add_pre_link_args(LinkerFlavor::Gcc, &["-m32"]);
+ base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m32"]);
base.max_atomic_width = Some(32);
+ base.stack_probes = StackProbeType::Inline;
Target {
llvm_target: "powerpc-unknown-linux-gnu".into(),
diff --git a/compiler/rustc_target/src/spec/powerpc_unknown_linux_gnuspe.rs b/compiler/rustc_target/src/spec/powerpc_unknown_linux_gnuspe.rs
index 6a250f4b5..5c51ec91f 100644
--- a/compiler/rustc_target/src/spec/powerpc_unknown_linux_gnuspe.rs
+++ b/compiler/rustc_target/src/spec/powerpc_unknown_linux_gnuspe.rs
@@ -1,10 +1,11 @@
use crate::abi::Endian;
-use crate::spec::{LinkerFlavor, Target, TargetOptions};
+use crate::spec::{Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetOptions};
pub fn target() -> Target {
let mut base = super::linux_gnu_base::opts();
- base.add_pre_link_args(LinkerFlavor::Gcc, &["-mspe"]);
+ base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-mspe"]);
base.max_atomic_width = Some(32);
+ base.stack_probes = StackProbeType::Inline;
Target {
llvm_target: "powerpc-unknown-linux-gnuspe".into(),
diff --git a/compiler/rustc_target/src/spec/powerpc_unknown_linux_musl.rs b/compiler/rustc_target/src/spec/powerpc_unknown_linux_musl.rs
index 34200c679..fc7d802cb 100644
--- a/compiler/rustc_target/src/spec/powerpc_unknown_linux_musl.rs
+++ b/compiler/rustc_target/src/spec/powerpc_unknown_linux_musl.rs
@@ -1,10 +1,11 @@
use crate::abi::Endian;
-use crate::spec::{LinkerFlavor, Target, TargetOptions};
+use crate::spec::{Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetOptions};
pub fn target() -> Target {
let mut base = super::linux_musl_base::opts();
- base.add_pre_link_args(LinkerFlavor::Gcc, &["-m32"]);
+ base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m32"]);
base.max_atomic_width = Some(32);
+ base.stack_probes = StackProbeType::Inline;
Target {
llvm_target: "powerpc-unknown-linux-musl".into(),
diff --git a/compiler/rustc_target/src/spec/powerpc_unknown_netbsd.rs b/compiler/rustc_target/src/spec/powerpc_unknown_netbsd.rs
index 60661ef9b..912149c79 100644
--- a/compiler/rustc_target/src/spec/powerpc_unknown_netbsd.rs
+++ b/compiler/rustc_target/src/spec/powerpc_unknown_netbsd.rs
@@ -1,10 +1,11 @@
use crate::abi::Endian;
-use crate::spec::{LinkerFlavor, Target, TargetOptions};
+use crate::spec::{Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetOptions};
pub fn target() -> Target {
let mut base = super::netbsd_base::opts();
- base.add_pre_link_args(LinkerFlavor::Gcc, &["-m32"]);
+ base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m32"]);
base.max_atomic_width = Some(32);
+ base.stack_probes = StackProbeType::Inline;
Target {
llvm_target: "powerpc-unknown-netbsd".into(),
diff --git a/compiler/rustc_target/src/spec/powerpc_unknown_openbsd.rs b/compiler/rustc_target/src/spec/powerpc_unknown_openbsd.rs
index ad2c3d40f..dec85f996 100644
--- a/compiler/rustc_target/src/spec/powerpc_unknown_openbsd.rs
+++ b/compiler/rustc_target/src/spec/powerpc_unknown_openbsd.rs
@@ -1,10 +1,11 @@
use crate::abi::Endian;
-use crate::spec::Target;
+use crate::spec::{StackProbeType, Target};
pub fn target() -> Target {
let mut base = super::openbsd_base::opts();
base.endian = Endian::Big;
base.max_atomic_width = Some(32);
+ base.stack_probes = StackProbeType::Inline;
Target {
llvm_target: "powerpc-unknown-openbsd".into(),
diff --git a/compiler/rustc_target/src/spec/powerpc_wrs_vxworks.rs b/compiler/rustc_target/src/spec/powerpc_wrs_vxworks.rs
index 3f24966e0..a8c1c2a61 100644
--- a/compiler/rustc_target/src/spec/powerpc_wrs_vxworks.rs
+++ b/compiler/rustc_target/src/spec/powerpc_wrs_vxworks.rs
@@ -1,10 +1,11 @@
use crate::abi::Endian;
-use crate::spec::{LinkerFlavor, Target, TargetOptions};
+use crate::spec::{Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetOptions};
pub fn target() -> Target {
let mut base = super::vxworks_base::opts();
- base.add_pre_link_args(LinkerFlavor::Gcc, &["-m32", "--secure-plt"]);
+ base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m32", "--secure-plt"]);
base.max_atomic_width = Some(32);
+ base.stack_probes = StackProbeType::Inline;
Target {
llvm_target: "powerpc-unknown-linux-gnu".into(),
diff --git a/compiler/rustc_target/src/spec/powerpc_wrs_vxworks_spe.rs b/compiler/rustc_target/src/spec/powerpc_wrs_vxworks_spe.rs
index 0f04f41f9..abb8d13da 100644
--- a/compiler/rustc_target/src/spec/powerpc_wrs_vxworks_spe.rs
+++ b/compiler/rustc_target/src/spec/powerpc_wrs_vxworks_spe.rs
@@ -1,10 +1,11 @@
use crate::abi::Endian;
-use crate::spec::{LinkerFlavor, Target, TargetOptions};
+use crate::spec::{Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetOptions};
pub fn target() -> Target {
let mut base = super::vxworks_base::opts();
- base.add_pre_link_args(LinkerFlavor::Gcc, &["-mspe", "--secure-plt"]);
+ base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-mspe", "--secure-plt"]);
base.max_atomic_width = Some(32);
+ base.stack_probes = StackProbeType::Inline;
Target {
llvm_target: "powerpc-unknown-linux-gnuspe".into(),
diff --git a/compiler/rustc_target/src/spec/riscv32i_unknown_none_elf.rs b/compiler/rustc_target/src/spec/riscv32i_unknown_none_elf.rs
index 232139db6..75a65a268 100644
--- a/compiler/rustc_target/src/spec/riscv32i_unknown_none_elf.rs
+++ b/compiler/rustc_target/src/spec/riscv32i_unknown_none_elf.rs
@@ -1,5 +1,4 @@
-use crate::spec::{LinkerFlavor, LldFlavor, PanicStrategy, RelocModel};
-use crate::spec::{Target, TargetOptions};
+use crate::spec::{Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetOptions};
pub fn target() -> Target {
Target {
@@ -9,7 +8,7 @@ pub fn target() -> Target {
arch: "riscv32".into(),
options: TargetOptions {
- linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
+ linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes),
linker: Some("rust-lld".into()),
cpu: "generic-rv32".into(),
max_atomic_width: Some(0),
diff --git a/compiler/rustc_target/src/spec/riscv32im_unknown_none_elf.rs b/compiler/rustc_target/src/spec/riscv32im_unknown_none_elf.rs
index 3e5d2887f..f2242bbe0 100644
--- a/compiler/rustc_target/src/spec/riscv32im_unknown_none_elf.rs
+++ b/compiler/rustc_target/src/spec/riscv32im_unknown_none_elf.rs
@@ -1,5 +1,4 @@
-use crate::spec::{LinkerFlavor, LldFlavor, PanicStrategy, RelocModel};
-use crate::spec::{Target, TargetOptions};
+use crate::spec::{Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetOptions};
pub fn target() -> Target {
Target {
@@ -9,7 +8,7 @@ pub fn target() -> Target {
arch: "riscv32".into(),
options: TargetOptions {
- linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
+ linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes),
linker: Some("rust-lld".into()),
cpu: "generic-rv32".into(),
max_atomic_width: Some(0),
diff --git a/compiler/rustc_target/src/spec/riscv32imac_unknown_none_elf.rs b/compiler/rustc_target/src/spec/riscv32imac_unknown_none_elf.rs
index 99317b9f1..55c6e4d16 100644
--- a/compiler/rustc_target/src/spec/riscv32imac_unknown_none_elf.rs
+++ b/compiler/rustc_target/src/spec/riscv32imac_unknown_none_elf.rs
@@ -1,5 +1,4 @@
-use crate::spec::{LinkerFlavor, LldFlavor, PanicStrategy, RelocModel};
-use crate::spec::{Target, TargetOptions};
+use crate::spec::{Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetOptions};
pub fn target() -> Target {
Target {
@@ -9,7 +8,7 @@ pub fn target() -> Target {
arch: "riscv32".into(),
options: TargetOptions {
- linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
+ linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes),
linker: Some("rust-lld".into()),
cpu: "generic-rv32".into(),
max_atomic_width: Some(32),
diff --git a/compiler/rustc_target/src/spec/riscv32imac_unknown_xous_elf.rs b/compiler/rustc_target/src/spec/riscv32imac_unknown_xous_elf.rs
index a5de645c9..a263e5d5c 100644
--- a/compiler/rustc_target/src/spec/riscv32imac_unknown_xous_elf.rs
+++ b/compiler/rustc_target/src/spec/riscv32imac_unknown_xous_elf.rs
@@ -1,5 +1,4 @@
-use crate::spec::{LinkerFlavor, LldFlavor, PanicStrategy, RelocModel};
-use crate::spec::{Target, TargetOptions};
+use crate::spec::{Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetOptions};
pub fn target() -> Target {
Target {
@@ -10,7 +9,7 @@ pub fn target() -> Target {
options: TargetOptions {
os: "xous".into(),
- linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
+ linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes),
linker: Some("rust-lld".into()),
cpu: "generic-rv32".into(),
max_atomic_width: Some(32),
diff --git a/compiler/rustc_target/src/spec/riscv32imc_esp_espidf.rs b/compiler/rustc_target/src/spec/riscv32imc_esp_espidf.rs
index 03baef65c..25638a092 100644
--- a/compiler/rustc_target/src/spec/riscv32imc_esp_espidf.rs
+++ b/compiler/rustc_target/src/spec/riscv32imc_esp_espidf.rs
@@ -1,5 +1,4 @@
-use crate::spec::{cvs, Target, TargetOptions};
-use crate::spec::{LinkerFlavor, PanicStrategy, RelocModel};
+use crate::spec::{cvs, PanicStrategy, RelocModel, Target, TargetOptions};
pub fn target() -> Target {
Target {
@@ -13,7 +12,6 @@ pub fn target() -> Target {
os: "espidf".into(),
env: "newlib".into(),
vendor: "espressif".into(),
- linker_flavor: LinkerFlavor::Gcc,
linker: Some("riscv32-esp-elf-gcc".into()),
cpu: "generic-rv32".into(),
diff --git a/compiler/rustc_target/src/spec/riscv32imc_unknown_none_elf.rs b/compiler/rustc_target/src/spec/riscv32imc_unknown_none_elf.rs
index bf510d204..01e773fae 100644
--- a/compiler/rustc_target/src/spec/riscv32imc_unknown_none_elf.rs
+++ b/compiler/rustc_target/src/spec/riscv32imc_unknown_none_elf.rs
@@ -1,5 +1,4 @@
-use crate::spec::{LinkerFlavor, LldFlavor, PanicStrategy, RelocModel};
-use crate::spec::{Target, TargetOptions};
+use crate::spec::{Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetOptions};
pub fn target() -> Target {
Target {
@@ -9,7 +8,7 @@ pub fn target() -> Target {
arch: "riscv32".into(),
options: TargetOptions {
- linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
+ linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes),
linker: Some("rust-lld".into()),
cpu: "generic-rv32".into(),
max_atomic_width: Some(0),
diff --git a/compiler/rustc_target/src/spec/riscv64gc_unknown_none_elf.rs b/compiler/rustc_target/src/spec/riscv64gc_unknown_none_elf.rs
index 03b3cfd1e..67806d578 100644
--- a/compiler/rustc_target/src/spec/riscv64gc_unknown_none_elf.rs
+++ b/compiler/rustc_target/src/spec/riscv64gc_unknown_none_elf.rs
@@ -1,5 +1,5 @@
-use crate::spec::{CodeModel, LinkerFlavor, LldFlavor, PanicStrategy, RelocModel};
-use crate::spec::{Target, TargetOptions};
+use crate::spec::{Cc, CodeModel, LinkerFlavor, Lld, PanicStrategy};
+use crate::spec::{RelocModel, Target, TargetOptions};
pub fn target() -> Target {
Target {
@@ -9,7 +9,7 @@ pub fn target() -> Target {
arch: "riscv64".into(),
options: TargetOptions {
- linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
+ linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes),
linker: Some("rust-lld".into()),
llvm_abiname: "lp64d".into(),
cpu: "generic-rv64".into(),
diff --git a/compiler/rustc_target/src/spec/riscv64imac_unknown_none_elf.rs b/compiler/rustc_target/src/spec/riscv64imac_unknown_none_elf.rs
index 2a94c9dd2..f371e09be 100644
--- a/compiler/rustc_target/src/spec/riscv64imac_unknown_none_elf.rs
+++ b/compiler/rustc_target/src/spec/riscv64imac_unknown_none_elf.rs
@@ -1,5 +1,5 @@
-use crate::spec::{CodeModel, Target, TargetOptions};
-use crate::spec::{LinkerFlavor, LldFlavor, PanicStrategy, RelocModel};
+use crate::spec::{Cc, CodeModel, LinkerFlavor, Lld, PanicStrategy};
+use crate::spec::{RelocModel, Target, TargetOptions};
pub fn target() -> Target {
Target {
@@ -9,7 +9,7 @@ pub fn target() -> Target {
arch: "riscv64".into(),
options: TargetOptions {
- linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
+ linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes),
linker: Some("rust-lld".into()),
cpu: "generic-rv64".into(),
max_atomic_width: Some(64),
diff --git a/compiler/rustc_target/src/spec/s390x_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/s390x_unknown_linux_gnu.rs
index 8757bbed8..cda88de0e 100644
--- a/compiler/rustc_target/src/spec/s390x_unknown_linux_gnu.rs
+++ b/compiler/rustc_target/src/spec/s390x_unknown_linux_gnu.rs
@@ -1,22 +1,23 @@
use crate::abi::Endian;
-use crate::spec::Target;
+use crate::spec::{StackProbeType, Target};
pub fn target() -> Target {
let mut base = super::linux_gnu_base::opts();
base.endian = Endian::Big;
// z10 is the oldest CPU supported by LLVM
base.cpu = "z10".into();
- // FIXME: The data_layout string below and the ABI implementation in
- // cabi_s390x.rs are for now hard-coded to assume the no-vector ABI.
- // Pass the -vector feature string to LLVM to respect this assumption.
+ // FIXME: The ABI implementation in cabi_s390x.rs is for now hard-coded to assume the no-vector
+ // ABI. Pass the -vector feature string to LLVM to respect this assumption. On LLVM < 16, we
+ // also strip v128 from the data_layout below to match the older LLVM's expectation.
base.features = "-vector".into();
base.max_atomic_width = Some(64);
base.min_global_align = Some(16);
+ base.stack_probes = StackProbeType::Inline;
Target {
llvm_target: "s390x-unknown-linux-gnu".into(),
pointer_width: 64,
- data_layout: "E-m:e-i1:8:16-i8:8:16-i64:64-f128:64-a:8:16-n32:64".into(),
+ data_layout: "E-m:e-i1:8:16-i8:8:16-i64:64-f128:64-v128:64-a:8:16-n32:64".into(),
arch: "s390x".into(),
options: base,
}
diff --git a/compiler/rustc_target/src/spec/s390x_unknown_linux_musl.rs b/compiler/rustc_target/src/spec/s390x_unknown_linux_musl.rs
index 4c855271a..91e63aee5 100644
--- a/compiler/rustc_target/src/spec/s390x_unknown_linux_musl.rs
+++ b/compiler/rustc_target/src/spec/s390x_unknown_linux_musl.rs
@@ -1,23 +1,24 @@
use crate::abi::Endian;
-use crate::spec::Target;
+use crate::spec::{StackProbeType, Target};
pub fn target() -> Target {
let mut base = super::linux_musl_base::opts();
base.endian = Endian::Big;
// z10 is the oldest CPU supported by LLVM
base.cpu = "z10".into();
- // FIXME: The data_layout string below and the ABI implementation in
- // cabi_s390x.rs are for now hard-coded to assume the no-vector ABI.
- // Pass the -vector feature string to LLVM to respect this assumption.
+ // FIXME: The ABI implementation in cabi_s390x.rs is for now hard-coded to assume the no-vector
+ // ABI. Pass the -vector feature string to LLVM to respect this assumption. On LLVM < 16, we
+ // also strip v128 from the data_layout below to match the older LLVM's expectation.
base.features = "-vector".into();
base.max_atomic_width = Some(64);
base.min_global_align = Some(16);
base.static_position_independent_executables = true;
+ base.stack_probes = StackProbeType::Inline;
Target {
llvm_target: "s390x-unknown-linux-musl".into(),
pointer_width: 64,
- data_layout: "E-m:e-i1:8:16-i8:8:16-i64:64-f128:64-a:8:16-n32:64".into(),
+ data_layout: "E-m:e-i1:8:16-i8:8:16-i64:64-f128:64-v128:64-a:8:16-n32:64".into(),
arch: "s390x".into(),
options: base,
}
diff --git a/compiler/rustc_target/src/spec/solaris_base.rs b/compiler/rustc_target/src/spec/solaris_base.rs
index b7e8e8cf7..f97cdb4fb 100644
--- a/compiler/rustc_target/src/spec/solaris_base.rs
+++ b/compiler/rustc_target/src/spec/solaris_base.rs
@@ -1,4 +1,4 @@
-use crate::spec::{cvs, TargetOptions};
+use crate::spec::{cvs, Cc, LinkerFlavor, TargetOptions};
pub fn opts() -> TargetOptions {
TargetOptions {
@@ -7,7 +7,7 @@ pub fn opts() -> TargetOptions {
has_rpath: true,
families: cvs!["unix"],
is_like_solaris: true,
- linker_is_gnu: false,
+ linker_flavor: LinkerFlavor::Unix(Cc::Yes),
limit_rdylib_exports: false, // Linker doesn't support this
eh_frame_header: false,
diff --git a/compiler/rustc_target/src/spec/sparc64_unknown_netbsd.rs b/compiler/rustc_target/src/spec/sparc64_unknown_netbsd.rs
index 836ab0e37..38ab066b0 100644
--- a/compiler/rustc_target/src/spec/sparc64_unknown_netbsd.rs
+++ b/compiler/rustc_target/src/spec/sparc64_unknown_netbsd.rs
@@ -1,10 +1,10 @@
use crate::abi::Endian;
-use crate::spec::{LinkerFlavor, Target, TargetOptions};
+use crate::spec::{Cc, LinkerFlavor, Lld, Target, TargetOptions};
pub fn target() -> Target {
let mut base = super::netbsd_base::opts();
base.cpu = "v9".into();
- base.add_pre_link_args(LinkerFlavor::Gcc, &["-m64"]);
+ base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64"]);
base.max_atomic_width = Some(64);
Target {
diff --git a/compiler/rustc_target/src/spec/sparc64_unknown_openbsd.rs b/compiler/rustc_target/src/spec/sparc64_unknown_openbsd.rs
index 4a192df39..06a5f782a 100644
--- a/compiler/rustc_target/src/spec/sparc64_unknown_openbsd.rs
+++ b/compiler/rustc_target/src/spec/sparc64_unknown_openbsd.rs
@@ -1,11 +1,11 @@
use crate::abi::Endian;
-use crate::spec::{LinkerFlavor, Target};
+use crate::spec::{Cc, LinkerFlavor, Lld, Target};
pub fn target() -> Target {
let mut base = super::openbsd_base::opts();
base.endian = Endian::Big;
base.cpu = "v9".into();
- base.add_pre_link_args(LinkerFlavor::Gcc, &["-m64"]);
+ base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64"]);
base.max_atomic_width = Some(64);
Target {
diff --git a/compiler/rustc_target/src/spec/sparc_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/sparc_unknown_linux_gnu.rs
index ea4fafa4b..12968abda 100644
--- a/compiler/rustc_target/src/spec/sparc_unknown_linux_gnu.rs
+++ b/compiler/rustc_target/src/spec/sparc_unknown_linux_gnu.rs
@@ -1,12 +1,12 @@
use crate::abi::Endian;
-use crate::spec::{LinkerFlavor, Target};
+use crate::spec::{Cc, LinkerFlavor, Lld, Target};
pub fn target() -> Target {
let mut base = super::linux_gnu_base::opts();
base.endian = Endian::Big;
base.cpu = "v9".into();
base.max_atomic_width = Some(64);
- base.add_pre_link_args(LinkerFlavor::Gcc, &["-mv8plus"]);
+ base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-mv8plus"]);
Target {
llvm_target: "sparc-unknown-linux-gnu".into(),
diff --git a/compiler/rustc_target/src/spec/sparcv9_sun_solaris.rs b/compiler/rustc_target/src/spec/sparcv9_sun_solaris.rs
index aac09181a..440194ef2 100644
--- a/compiler/rustc_target/src/spec/sparcv9_sun_solaris.rs
+++ b/compiler/rustc_target/src/spec/sparcv9_sun_solaris.rs
@@ -1,10 +1,10 @@
use crate::abi::Endian;
-use crate::spec::{LinkerFlavor, Target};
+use crate::spec::{Cc, LinkerFlavor, Target};
pub fn target() -> Target {
let mut base = super::solaris_base::opts();
base.endian = Endian::Big;
- base.add_pre_link_args(LinkerFlavor::Gcc, &["-m64"]);
+ base.add_pre_link_args(LinkerFlavor::Unix(Cc::Yes), &["-m64"]);
// llvm calls this "v9"
base.cpu = "v9".into();
base.vendor = "sun".into();
diff --git a/compiler/rustc_target/src/spec/tests/tests_impl.rs b/compiler/rustc_target/src/spec/tests/tests_impl.rs
index 0af599916..172da0ed5 100644
--- a/compiler/rustc_target/src/spec/tests/tests_impl.rs
+++ b/compiler/rustc_target/src/spec/tests/tests_impl.rs
@@ -19,11 +19,13 @@ impl Target {
assert!(self.is_like_windows);
}
- // Check that default linker flavor and lld flavor are compatible
- // with some other key properties.
- assert_eq!(self.is_like_osx, matches!(self.lld_flavor, LldFlavor::Ld64));
- assert_eq!(self.is_like_msvc, matches!(self.lld_flavor, LldFlavor::Link));
- assert_eq!(self.is_like_wasm, matches!(self.lld_flavor, LldFlavor::Wasm));
+ // Check that default linker flavor is compatible with some other key properties.
+ assert_eq!(self.is_like_osx, matches!(self.linker_flavor, LinkerFlavor::Darwin(..)));
+ assert_eq!(self.is_like_msvc, matches!(self.linker_flavor, LinkerFlavor::Msvc(..)));
+ assert_eq!(
+ self.is_like_wasm && self.os != "emscripten",
+ matches!(self.linker_flavor, LinkerFlavor::WasmLld(..))
+ );
assert_eq!(self.os == "emscripten", matches!(self.linker_flavor, LinkerFlavor::EmCc));
assert_eq!(self.arch == "bpf", matches!(self.linker_flavor, LinkerFlavor::Bpf));
assert_eq!(self.arch == "nvptx64", matches!(self.linker_flavor, LinkerFlavor::Ptx));
@@ -38,44 +40,25 @@ impl Target {
for (&flavor, flavor_args) in args {
assert!(!flavor_args.is_empty());
// Check that flavors mentioned in link args are compatible with the default flavor.
- match (self.linker_flavor, self.lld_flavor) {
- (
- LinkerFlavor::Ld | LinkerFlavor::Lld(LldFlavor::Ld) | LinkerFlavor::Gcc,
- LldFlavor::Ld,
- ) => {
- assert_matches!(
- flavor,
- LinkerFlavor::Ld | LinkerFlavor::Lld(LldFlavor::Ld) | LinkerFlavor::Gcc
- )
- }
- (LinkerFlavor::Gcc, LldFlavor::Ld64) => {
- assert_matches!(
- flavor,
- LinkerFlavor::Lld(LldFlavor::Ld64) | LinkerFlavor::Gcc
- )
+ match self.linker_flavor {
+ LinkerFlavor::Gnu(..) => {
+ assert_matches!(flavor, LinkerFlavor::Gnu(..));
}
- (LinkerFlavor::Msvc | LinkerFlavor::Lld(LldFlavor::Link), LldFlavor::Link) => {
- assert_matches!(
- flavor,
- LinkerFlavor::Msvc | LinkerFlavor::Lld(LldFlavor::Link)
- )
+ LinkerFlavor::Darwin(..) => {
+ assert_matches!(flavor, LinkerFlavor::Darwin(..))
}
- (LinkerFlavor::Lld(LldFlavor::Wasm) | LinkerFlavor::Gcc, LldFlavor::Wasm) => {
- assert_matches!(
- flavor,
- LinkerFlavor::Lld(LldFlavor::Wasm) | LinkerFlavor::Gcc
- )
+ LinkerFlavor::WasmLld(..) => {
+ assert_matches!(flavor, LinkerFlavor::WasmLld(..))
}
- (LinkerFlavor::EmCc, LldFlavor::Wasm) => {
- assert_matches!(flavor, LinkerFlavor::EmCc)
+ LinkerFlavor::Unix(..) => {
+ assert_matches!(flavor, LinkerFlavor::Unix(..));
}
- (LinkerFlavor::Bpf, LldFlavor::Ld) => {
- assert_matches!(flavor, LinkerFlavor::Bpf)
+ LinkerFlavor::Msvc(..) => {
+ assert_matches!(flavor, LinkerFlavor::Msvc(..))
}
- (LinkerFlavor::Ptx, LldFlavor::Ld) => {
- assert_matches!(flavor, LinkerFlavor::Ptx)
+ LinkerFlavor::EmCc | LinkerFlavor::Bpf | LinkerFlavor::Ptx => {
+ assert_eq!(flavor, self.linker_flavor)
}
- flavors => unreachable!("unexpected flavor combination: {:?}", flavors),
}
// Check that link args for cc and non-cc versions of flavors are consistent.
@@ -88,25 +71,29 @@ impl Target {
}
}
};
+
match self.linker_flavor {
- LinkerFlavor::Gcc => match self.lld_flavor {
- LldFlavor::Ld => {
- check_noncc(LinkerFlavor::Ld);
- check_noncc(LinkerFlavor::Lld(LldFlavor::Ld));
- }
- LldFlavor::Ld64 => check_noncc(LinkerFlavor::Lld(LldFlavor::Ld64)),
- LldFlavor::Wasm => check_noncc(LinkerFlavor::Lld(LldFlavor::Wasm)),
- LldFlavor::Link => {}
- },
+ LinkerFlavor::Gnu(Cc::Yes, lld) => check_noncc(LinkerFlavor::Gnu(Cc::No, lld)),
+ LinkerFlavor::WasmLld(Cc::Yes) => check_noncc(LinkerFlavor::WasmLld(Cc::No)),
+ LinkerFlavor::Unix(Cc::Yes) => check_noncc(LinkerFlavor::Unix(Cc::No)),
_ => {}
}
}
// Check that link args for lld and non-lld versions of flavors are consistent.
- assert_eq!(args.get(&LinkerFlavor::Ld), args.get(&LinkerFlavor::Lld(LldFlavor::Ld)));
+ for cc in [Cc::No, Cc::Yes] {
+ assert_eq!(
+ args.get(&LinkerFlavor::Gnu(cc, Lld::No)),
+ args.get(&LinkerFlavor::Gnu(cc, Lld::Yes)),
+ );
+ assert_eq!(
+ args.get(&LinkerFlavor::Darwin(cc, Lld::No)),
+ args.get(&LinkerFlavor::Darwin(cc, Lld::Yes)),
+ );
+ }
assert_eq!(
- args.get(&LinkerFlavor::Msvc),
- args.get(&LinkerFlavor::Lld(LldFlavor::Link)),
+ args.get(&LinkerFlavor::Msvc(Lld::No)),
+ args.get(&LinkerFlavor::Msvc(Lld::Yes)),
);
}
diff --git a/compiler/rustc_target/src/spec/thumb_base.rs b/compiler/rustc_target/src/spec/thumb_base.rs
index 049142b89..000766c57 100644
--- a/compiler/rustc_target/src/spec/thumb_base.rs
+++ b/compiler/rustc_target/src/spec/thumb_base.rs
@@ -27,13 +27,12 @@
// differentiate these targets from our other `arm(v7)-*-*-gnueabi(hf)` targets in the context of
// build scripts / gcc flags.
-use crate::spec::TargetOptions;
-use crate::spec::{FramePointer, LinkerFlavor, LldFlavor, PanicStrategy, RelocModel};
+use crate::spec::{Cc, FramePointer, LinkerFlavor, Lld, PanicStrategy, RelocModel, TargetOptions};
pub fn opts() -> TargetOptions {
// See rust-lang/rfcs#1645 for a discussion about these defaults
TargetOptions {
- linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
+ linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes),
// In most cases, LLD is good enough
linker: Some("rust-lld".into()),
// Because these devices have very little resources having an unwinder is too onerous so we
diff --git a/compiler/rustc_target/src/spec/thumbv4t_none_eabi.rs b/compiler/rustc_target/src/spec/thumbv4t_none_eabi.rs
index bdaaed8b5..5a3e4c88d 100644
--- a/compiler/rustc_target/src/spec/thumbv4t_none_eabi.rs
+++ b/compiler/rustc_target/src/spec/thumbv4t_none_eabi.rs
@@ -16,9 +16,8 @@
//! The default link script is very likely wrong, so you should use
//! `-Clink-arg=-Tmy_script.ld` to override that with a correct linker script.
-use crate::spec::{
- cvs, FramePointer, LinkerFlavor, PanicStrategy, RelocModel, Target, TargetOptions,
-};
+use crate::spec::{cvs, Cc, FramePointer, LinkerFlavor, Lld};
+use crate::spec::{PanicStrategy, RelocModel, Target, TargetOptions};
pub fn target() -> Target {
Target {
@@ -37,7 +36,7 @@ pub fn target() -> Target {
data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(),
options: TargetOptions {
abi: "eabi".into(),
- linker_flavor: LinkerFlavor::Ld,
+ linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::No),
linker: Some("arm-none-eabi-ld".into()),
// extra args passed to the external assembler (assuming `arm-none-eabi-as`):
diff --git a/compiler/rustc_target/src/spec/thumbv5te_none_eabi.rs b/compiler/rustc_target/src/spec/thumbv5te_none_eabi.rs
new file mode 100644
index 000000000..021b0e0eb
--- /dev/null
+++ b/compiler/rustc_target/src/spec/thumbv5te_none_eabi.rs
@@ -0,0 +1,41 @@
+//! Targets the ARMv5TE, with code as `t32` code by default.
+
+use crate::spec::{cvs, FramePointer, Target, TargetOptions};
+
+pub fn target() -> Target {
+ Target {
+ llvm_target: "thumbv5te-none-eabi".into(),
+ pointer_width: 32,
+ arch: "arm".into(),
+ /* Data layout args are '-' separated:
+ * little endian
+ * stack is 64-bit aligned (EABI)
+ * pointers are 32-bit
+ * i64 must be 64-bit aligned (EABI)
+ * mangle names with ELF style
+ * native integers are 32-bit
+ * All other elements are default
+ */
+ data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(),
+
+ options: TargetOptions {
+ abi: "eabi".into(),
+ // extra args passed to the external assembler (assuming `arm-none-eabi-as`):
+ // * activate t32/a32 interworking
+ // * use arch ARMv5TE
+ // * use little-endian
+ asm_args: cvs!["-mthumb-interwork", "-march=armv5te", "-mlittle-endian",],
+ // minimum extra features, these cannot be disabled via -C
+ // Also force-enable 32-bit atomics, which allows the use of atomic load/store only.
+ // The resulting atomics are ABI incompatible with atomics backed by libatomic.
+ features: "+soft-float,+strict-align,+atomics-32".into(),
+ frame_pointer: FramePointer::MayOmit,
+ main_needs_argc_argv: false,
+ // don't have atomic compare-and-swap
+ atomic_cas: false,
+ has_thumb_interworking: true,
+
+ ..super::thumb_base::opts()
+ },
+ }
+}
diff --git a/compiler/rustc_target/src/spec/thumbv7a_pc_windows_msvc.rs b/compiler/rustc_target/src/spec/thumbv7a_pc_windows_msvc.rs
index 4d09d3a4d..f1be274f0 100644
--- a/compiler/rustc_target/src/spec/thumbv7a_pc_windows_msvc.rs
+++ b/compiler/rustc_target/src/spec/thumbv7a_pc_windows_msvc.rs
@@ -1,4 +1,4 @@
-use crate::spec::{LinkerFlavor, PanicStrategy, Target, TargetOptions};
+use crate::spec::{LinkerFlavor, Lld, PanicStrategy, Target, TargetOptions};
pub fn target() -> Target {
let mut base = super::windows_msvc_base::opts();
@@ -9,7 +9,7 @@ pub fn target() -> Target {
// should be smart enough to insert branch islands only
// where necessary, but this is not the observed behavior.
// Disabling the LBR optimization works around the issue.
- base.add_pre_link_args(LinkerFlavor::Msvc, &["/OPT:NOLBR"]);
+ base.add_pre_link_args(LinkerFlavor::Msvc(Lld::No), &["/OPT:NOLBR"]);
Target {
llvm_target: "thumbv7a-pc-windows-msvc".into(),
diff --git a/compiler/rustc_target/src/spec/thumbv7neon_linux_androideabi.rs b/compiler/rustc_target/src/spec/thumbv7neon_linux_androideabi.rs
index 4cad9e183..8d80fcd5f 100644
--- a/compiler/rustc_target/src/spec/thumbv7neon_linux_androideabi.rs
+++ b/compiler/rustc_target/src/spec/thumbv7neon_linux_androideabi.rs
@@ -1,4 +1,4 @@
-use crate::spec::{LinkerFlavor, Target, TargetOptions};
+use crate::spec::{Cc, LinkerFlavor, Lld, Target, TargetOptions};
// This target if is for the Android v7a ABI in thumb mode with
// NEON unconditionally enabled and, therefore, with 32 FPU registers
@@ -10,7 +10,7 @@ use crate::spec::{LinkerFlavor, Target, TargetOptions};
pub fn target() -> Target {
let mut base = super::android_base::opts();
- base.add_pre_link_args(LinkerFlavor::Gcc, &["-march=armv7-a"]);
+ base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-march=armv7-a"]);
Target {
llvm_target: "armv7-none-linux-android".into(),
pointer_width: 32,
diff --git a/compiler/rustc_target/src/spec/uefi_msvc_base.rs b/compiler/rustc_target/src/spec/uefi_msvc_base.rs
index 99af7d85e..8968d3c8f 100644
--- a/compiler/rustc_target/src/spec/uefi_msvc_base.rs
+++ b/compiler/rustc_target/src/spec/uefi_msvc_base.rs
@@ -9,14 +9,13 @@
// the timer-interrupt. Device-drivers are required to use polling-based models. Furthermore, all
// code runs in the same environment, no process separation is supported.
-use crate::spec::{LinkerFlavor, LldFlavor, PanicStrategy};
-use crate::spec::{StackProbeType, TargetOptions};
+use crate::spec::{LinkerFlavor, Lld, PanicStrategy, StackProbeType, TargetOptions};
pub fn opts() -> TargetOptions {
let mut base = super::msvc_base::opts();
base.add_pre_link_args(
- LinkerFlavor::Msvc,
+ LinkerFlavor::Msvc(Lld::No),
&[
// Non-standard subsystems have no default entry-point in PE+ files. We have to define
// one. "efi_main" seems to be a common choice amongst other implementations and the
@@ -37,7 +36,7 @@ pub fn opts() -> TargetOptions {
TargetOptions {
os: "uefi".into(),
- linker_flavor: LinkerFlavor::Lld(LldFlavor::Link),
+ linker_flavor: LinkerFlavor::Msvc(Lld::Yes),
disable_redzone: true,
exe_suffix: ".efi".into(),
allows_weak_linkage: false,
diff --git a/compiler/rustc_target/src/spec/wasm32_unknown_unknown.rs b/compiler/rustc_target/src/spec/wasm32_unknown_unknown.rs
index 4e2927dd9..8dad941b5 100644
--- a/compiler/rustc_target/src/spec/wasm32_unknown_unknown.rs
+++ b/compiler/rustc_target/src/spec/wasm32_unknown_unknown.rs
@@ -10,14 +10,12 @@
//! This target is more or less managed by the Rust and WebAssembly Working
//! Group nowadays at <https://github.com/rustwasm>.
-use super::wasm_base;
-use super::{LinkerFlavor, LldFlavor, Target};
+use super::{wasm_base, Cc, LinkerFlavor, Target};
use crate::spec::abi::Abi;
pub fn target() -> Target {
let mut options = wasm_base::options();
options.os = "unknown".into();
- options.linker_flavor = LinkerFlavor::Lld(LldFlavor::Wasm);
// This is a default for backwards-compatibility with the original
// definition of this target oh-so-long-ago. Once the "wasm" ABI is
@@ -30,7 +28,7 @@ pub fn target() -> Target {
options.default_adjusted_cabi = Some(Abi::Wasm);
options.add_pre_link_args(
- LinkerFlavor::Lld(LldFlavor::Wasm),
+ LinkerFlavor::WasmLld(Cc::No),
&[
// For now this target just never has an entry symbol no matter the output
// type, so unconditionally pass this.
@@ -44,7 +42,7 @@ pub fn target() -> Target {
],
);
options.add_pre_link_args(
- LinkerFlavor::Gcc,
+ LinkerFlavor::WasmLld(Cc::Yes),
&[
// Make sure clang uses LLD as its linker and is configured appropriately
// otherwise
diff --git a/compiler/rustc_target/src/spec/wasm32_wasi.rs b/compiler/rustc_target/src/spec/wasm32_wasi.rs
index 9c30487f4..93a956403 100644
--- a/compiler/rustc_target/src/spec/wasm32_wasi.rs
+++ b/compiler/rustc_target/src/spec/wasm32_wasi.rs
@@ -72,15 +72,13 @@
//! best we can with this target. Don't start relying on too much here unless
//! you know what you're getting in to!
-use super::wasm_base;
-use super::{crt_objects, LinkerFlavor, LldFlavor, Target};
+use super::{crt_objects, wasm_base, Cc, LinkerFlavor, Target};
pub fn target() -> Target {
let mut options = wasm_base::options();
options.os = "wasi".into();
- options.linker_flavor = LinkerFlavor::Lld(LldFlavor::Wasm);
- options.add_pre_link_args(LinkerFlavor::Gcc, &["--target=wasm32-wasi"]);
+ options.add_pre_link_args(LinkerFlavor::WasmLld(Cc::Yes), &["--target=wasm32-wasi"]);
options.pre_link_objects_self_contained = crt_objects::pre_wasi_self_contained();
options.post_link_objects_self_contained = crt_objects::post_wasi_self_contained();
diff --git a/compiler/rustc_target/src/spec/wasm64_unknown_unknown.rs b/compiler/rustc_target/src/spec/wasm64_unknown_unknown.rs
index 5211f7707..3fda398d2 100644
--- a/compiler/rustc_target/src/spec/wasm64_unknown_unknown.rs
+++ b/compiler/rustc_target/src/spec/wasm64_unknown_unknown.rs
@@ -7,16 +7,14 @@
//! the standard library is available, most of it returns an error immediately
//! (e.g. trying to create a TCP stream or something like that).
-use super::wasm_base;
-use super::{LinkerFlavor, LldFlavor, Target};
+use super::{wasm_base, Cc, LinkerFlavor, Target};
pub fn target() -> Target {
let mut options = wasm_base::options();
options.os = "unknown".into();
- options.linker_flavor = LinkerFlavor::Lld(LldFlavor::Wasm);
options.add_pre_link_args(
- LinkerFlavor::Lld(LldFlavor::Wasm),
+ LinkerFlavor::WasmLld(Cc::No),
&[
// For now this target just never has an entry symbol no matter the output
// type, so unconditionally pass this.
@@ -25,7 +23,7 @@ pub fn target() -> Target {
],
);
options.add_pre_link_args(
- LinkerFlavor::Gcc,
+ LinkerFlavor::WasmLld(Cc::Yes),
&[
// Make sure clang uses LLD as its linker and is configured appropriately
// otherwise
diff --git a/compiler/rustc_target/src/spec/wasm_base.rs b/compiler/rustc_target/src/spec/wasm_base.rs
index 28a07701e..528a84a8b 100644
--- a/compiler/rustc_target/src/spec/wasm_base.rs
+++ b/compiler/rustc_target/src/spec/wasm_base.rs
@@ -1,5 +1,5 @@
use super::crt_objects::LinkSelfContainedDefault;
-use super::{cvs, LinkerFlavor, LldFlavor, PanicStrategy, RelocModel, TargetOptions, TlsModel};
+use super::{cvs, Cc, LinkerFlavor, PanicStrategy, RelocModel, TargetOptions, TlsModel};
pub fn options() -> TargetOptions {
macro_rules! args {
@@ -49,8 +49,8 @@ pub fn options() -> TargetOptions {
};
}
- let mut pre_link_args = TargetOptions::link_args(LinkerFlavor::Lld(LldFlavor::Wasm), args!(""));
- super::add_link_args(&mut pre_link_args, LinkerFlavor::Gcc, args!("-Wl,"));
+ let mut pre_link_args = TargetOptions::link_args(LinkerFlavor::WasmLld(Cc::No), args!(""));
+ super::add_link_args(&mut pre_link_args, LinkerFlavor::WasmLld(Cc::Yes), args!("-Wl,"));
TargetOptions {
is_like_wasm: true,
@@ -91,8 +91,7 @@ pub fn options() -> TargetOptions {
// we use the LLD shipped with the Rust toolchain by default
linker: Some("rust-lld".into()),
- lld_flavor: LldFlavor::Wasm,
- linker_is_gnu: false,
+ linker_flavor: LinkerFlavor::WasmLld(Cc::No),
pre_link_args,
diff --git a/compiler/rustc_target/src/spec/windows_gnu_base.rs b/compiler/rustc_target/src/spec/windows_gnu_base.rs
index 81d44a963..a32ca469b 100644
--- a/compiler/rustc_target/src/spec/windows_gnu_base.rs
+++ b/compiler/rustc_target/src/spec/windows_gnu_base.rs
@@ -1,10 +1,10 @@
use crate::spec::crt_objects::{self, LinkSelfContainedDefault};
-use crate::spec::{cvs, DebuginfoKind, LinkerFlavor, SplitDebuginfo, TargetOptions};
+use crate::spec::{cvs, Cc, DebuginfoKind, LinkerFlavor, Lld, SplitDebuginfo, TargetOptions};
use std::borrow::Cow;
pub fn opts() -> TargetOptions {
let mut pre_link_args = TargetOptions::link_args(
- LinkerFlavor::Ld,
+ LinkerFlavor::Gnu(Cc::No, Lld::No),
&[
// Enable ASLR
"--dynamicbase",
@@ -14,7 +14,7 @@ pub fn opts() -> TargetOptions {
);
super::add_link_args(
&mut pre_link_args,
- LinkerFlavor::Gcc,
+ LinkerFlavor::Gnu(Cc::Yes, Lld::No),
&[
// Tell GCC to avoid linker plugins, because we are not bundling
// them with Windows installer, and Rust does its own LTO anyways.
@@ -42,23 +42,33 @@ pub fn opts() -> TargetOptions {
"-luser32",
"-lkernel32",
];
- let mut late_link_args = TargetOptions::link_args(LinkerFlavor::Ld, mingw_libs);
- super::add_link_args(&mut late_link_args, LinkerFlavor::Gcc, mingw_libs);
+ let mut late_link_args =
+ TargetOptions::link_args(LinkerFlavor::Gnu(Cc::No, Lld::No), mingw_libs);
+ super::add_link_args(&mut late_link_args, LinkerFlavor::Gnu(Cc::Yes, Lld::No), mingw_libs);
// If any of our crates are dynamically linked then we need to use
// the shared libgcc_s-dw2-1.dll. This is required to support
// unwinding across DLL boundaries.
let dynamic_unwind_libs = &["-lgcc_s"];
let mut late_link_args_dynamic =
- TargetOptions::link_args(LinkerFlavor::Ld, dynamic_unwind_libs);
- super::add_link_args(&mut late_link_args_dynamic, LinkerFlavor::Gcc, dynamic_unwind_libs);
+ TargetOptions::link_args(LinkerFlavor::Gnu(Cc::No, Lld::No), dynamic_unwind_libs);
+ super::add_link_args(
+ &mut late_link_args_dynamic,
+ LinkerFlavor::Gnu(Cc::Yes, Lld::No),
+ dynamic_unwind_libs,
+ );
// If all of our crates are statically linked then we can get away
// with statically linking the libgcc unwinding code. This allows
// binaries to be redistributed without the libgcc_s-dw2-1.dll
// dependency, but unfortunately break unwinding across DLL
// boundaries when unwinding across FFI boundaries.
let static_unwind_libs = &["-lgcc_eh", "-l:libpthread.a"];
- let mut late_link_args_static = TargetOptions::link_args(LinkerFlavor::Ld, static_unwind_libs);
- super::add_link_args(&mut late_link_args_static, LinkerFlavor::Gcc, static_unwind_libs);
+ let mut late_link_args_static =
+ TargetOptions::link_args(LinkerFlavor::Gnu(Cc::No, Lld::No), static_unwind_libs);
+ super::add_link_args(
+ &mut late_link_args_static,
+ LinkerFlavor::Gnu(Cc::Yes, Lld::No),
+ static_unwind_libs,
+ );
TargetOptions {
os: "windows".into(),
diff --git a/compiler/rustc_target/src/spec/windows_gnullvm_base.rs b/compiler/rustc_target/src/spec/windows_gnullvm_base.rs
index f30be2549..58210c75a 100644
--- a/compiler/rustc_target/src/spec/windows_gnullvm_base.rs
+++ b/compiler/rustc_target/src/spec/windows_gnullvm_base.rs
@@ -1,15 +1,17 @@
-use crate::spec::{cvs, LinkerFlavor, TargetOptions};
+use crate::spec::{cvs, Cc, LinkerFlavor, Lld, TargetOptions};
pub fn opts() -> TargetOptions {
// We cannot use `-nodefaultlibs` because compiler-rt has to be passed
// as a path since it's not added to linker search path by the default.
// There were attempts to make it behave like libgcc (so one can just use -l<name>)
// but LLVM maintainers rejected it: https://reviews.llvm.org/D51440
- let pre_link_args =
- TargetOptions::link_args(LinkerFlavor::Gcc, &["-nolibc", "--unwindlib=none"]);
+ let pre_link_args = TargetOptions::link_args(
+ LinkerFlavor::Gnu(Cc::Yes, Lld::No),
+ &["-nolibc", "--unwindlib=none"],
+ );
// Order of `late_link_args*` does not matter with LLD.
let late_link_args = TargetOptions::link_args(
- LinkerFlavor::Gcc,
+ LinkerFlavor::Gnu(Cc::Yes, Lld::No),
&["-lmingw32", "-lmingwex", "-lmsvcrt", "-lkernel32", "-luser32"],
);
diff --git a/compiler/rustc_target/src/spec/windows_uwp_gnu_base.rs b/compiler/rustc_target/src/spec/windows_uwp_gnu_base.rs
index fa69b919c..f30c33d99 100644
--- a/compiler/rustc_target/src/spec/windows_uwp_gnu_base.rs
+++ b/compiler/rustc_target/src/spec/windows_uwp_gnu_base.rs
@@ -1,4 +1,4 @@
-use crate::spec::{LinkArgs, LinkerFlavor, TargetOptions};
+use crate::spec::{Cc, LinkArgs, LinkerFlavor, Lld, TargetOptions};
pub fn opts() -> TargetOptions {
let base = super::windows_gnu_base::opts();
@@ -15,8 +15,9 @@ pub fn opts() -> TargetOptions {
"-lmingwex",
"-lmingw32",
];
- let mut late_link_args = TargetOptions::link_args(LinkerFlavor::Ld, mingw_libs);
- super::add_link_args(&mut late_link_args, LinkerFlavor::Gcc, mingw_libs);
+ let mut late_link_args =
+ TargetOptions::link_args(LinkerFlavor::Gnu(Cc::No, Lld::No), mingw_libs);
+ super::add_link_args(&mut late_link_args, LinkerFlavor::Gnu(Cc::Yes, Lld::No), mingw_libs);
// Reset the flags back to empty until the FIXME above is addressed.
let late_link_args_dynamic = LinkArgs::new();
let late_link_args_static = LinkArgs::new();
diff --git a/compiler/rustc_target/src/spec/windows_uwp_msvc_base.rs b/compiler/rustc_target/src/spec/windows_uwp_msvc_base.rs
index f2573fc2d..8c942c59d 100644
--- a/compiler/rustc_target/src/spec/windows_uwp_msvc_base.rs
+++ b/compiler/rustc_target/src/spec/windows_uwp_msvc_base.rs
@@ -1,11 +1,11 @@
-use crate::spec::{LinkerFlavor, TargetOptions};
+use crate::spec::{LinkerFlavor, Lld, TargetOptions};
pub fn opts() -> TargetOptions {
let mut opts = super::windows_msvc_base::opts();
opts.abi = "uwp".into();
opts.vendor = "uwp".into();
- opts.add_pre_link_args(LinkerFlavor::Msvc, &["/APPCONTAINER", "mincore.lib"]);
+ opts.add_pre_link_args(LinkerFlavor::Msvc(Lld::No), &["/APPCONTAINER", "mincore.lib"]);
opts
}
diff --git a/compiler/rustc_target/src/spec/x86_64_apple_darwin.rs b/compiler/rustc_target/src/spec/x86_64_apple_darwin.rs
index 176c9dd6b..087be1b95 100644
--- a/compiler/rustc_target/src/spec/x86_64_apple_darwin.rs
+++ b/compiler/rustc_target/src/spec/x86_64_apple_darwin.rs
@@ -1,5 +1,5 @@
-use crate::spec::TargetOptions;
-use crate::spec::{FramePointer, LinkerFlavor, SanitizerSet, StackProbeType, Target};
+use crate::spec::{Cc, FramePointer, LinkerFlavor, Lld, SanitizerSet};
+use crate::spec::{StackProbeType, Target, TargetOptions};
pub fn target() -> Target {
let arch = "x86_64";
@@ -7,10 +7,9 @@ pub fn target() -> Target {
base.cpu = "core2".into();
base.max_atomic_width = Some(128); // core2 support cmpxchg16b
base.frame_pointer = FramePointer::Always;
- base.add_pre_link_args(LinkerFlavor::Gcc, &["-m64"]);
+ base.add_pre_link_args(LinkerFlavor::Darwin(Cc::Yes, Lld::No), &["-m64"]);
base.link_env_remove.to_mut().extend(super::apple_base::macos_link_env_remove());
- // don't use probe-stack=inline-asm until rust#83139 and rust#84667 are resolved
- base.stack_probes = StackProbeType::Call;
+ base.stack_probes = StackProbeType::X86;
base.supported_sanitizers =
SanitizerSet::ADDRESS | SanitizerSet::CFI | SanitizerSet::LEAK | SanitizerSet::THREAD;
diff --git a/compiler/rustc_target/src/spec/x86_64_apple_ios.rs b/compiler/rustc_target/src/spec/x86_64_apple_ios.rs
index 5e64ed0cf..e6143025d 100644
--- a/compiler/rustc_target/src/spec/x86_64_apple_ios.rs
+++ b/compiler/rustc_target/src/spec/x86_64_apple_ios.rs
@@ -13,8 +13,7 @@ pub fn target() -> Target {
arch: "x86_64".into(),
options: TargetOptions {
max_atomic_width: Some(64),
- // don't use probe-stack=inline-asm until rust#83139 and rust#84667 are resolved
- stack_probes: StackProbeType::Call,
+ stack_probes: StackProbeType::X86,
..base
},
}
diff --git a/compiler/rustc_target/src/spec/x86_64_apple_ios_macabi.rs b/compiler/rustc_target/src/spec/x86_64_apple_ios_macabi.rs
index 2122bcd37..13259205a 100644
--- a/compiler/rustc_target/src/spec/x86_64_apple_ios_macabi.rs
+++ b/compiler/rustc_target/src/spec/x86_64_apple_ios_macabi.rs
@@ -1,11 +1,11 @@
use super::apple_sdk_base::{opts, Arch};
-use crate::spec::{LinkerFlavor, StackProbeType, Target, TargetOptions};
+use crate::spec::{Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetOptions};
pub fn target() -> Target {
let llvm_target = "x86_64-apple-ios13.0-macabi";
let mut base = opts("ios", Arch::X86_64_macabi);
- base.add_pre_link_args(LinkerFlavor::Gcc, &["-target", llvm_target]);
+ base.add_pre_link_args(LinkerFlavor::Darwin(Cc::Yes, Lld::No), &["-target", llvm_target]);
Target {
llvm_target: llvm_target.into(),
@@ -15,8 +15,7 @@ pub fn target() -> Target {
arch: "x86_64".into(),
options: TargetOptions {
max_atomic_width: Some(64),
- // don't use probe-stack=inline-asm until rust#83139 and rust#84667 are resolved
- stack_probes: StackProbeType::Call,
+ stack_probes: StackProbeType::X86,
..base
},
}
diff --git a/compiler/rustc_target/src/spec/x86_64_apple_tvos.rs b/compiler/rustc_target/src/spec/x86_64_apple_tvos.rs
index a848c5a0a..3d54da086 100644
--- a/compiler/rustc_target/src/spec/x86_64_apple_tvos.rs
+++ b/compiler/rustc_target/src/spec/x86_64_apple_tvos.rs
@@ -10,8 +10,7 @@ pub fn target() -> Target {
arch: "x86_64".into(),
options: TargetOptions {
max_atomic_width: Some(64),
- // don't use probe-stack=inline-asm until rust#83139 and rust#84667 are resolved
- stack_probes: StackProbeType::Call,
+ stack_probes: StackProbeType::X86,
..base
},
}
diff --git a/compiler/rustc_target/src/spec/x86_64_apple_watchos_sim.rs b/compiler/rustc_target/src/spec/x86_64_apple_watchos_sim.rs
index 4dff3c2f2..e499b1985 100644
--- a/compiler/rustc_target/src/spec/x86_64_apple_watchos_sim.rs
+++ b/compiler/rustc_target/src/spec/x86_64_apple_watchos_sim.rs
@@ -15,8 +15,7 @@ pub fn target() -> Target {
arch: "x86_64".into(),
options: TargetOptions {
max_atomic_width: Some(64),
- // don't use probe-stack=inline-asm until rust#83139 and rust#84667 are resolved
- stack_probes: StackProbeType::Call,
+ stack_probes: StackProbeType::X86,
forces_embed_bitcode: true,
// Taken from a clang build on Xcode 11.4.1.
// These arguments are not actually invoked - they just have
diff --git a/compiler/rustc_target/src/spec/x86_64_fortanix_unknown_sgx.rs b/compiler/rustc_target/src/spec/x86_64_fortanix_unknown_sgx.rs
index 9d597ea2e..cba6fda19 100644
--- a/compiler/rustc_target/src/spec/x86_64_fortanix_unknown_sgx.rs
+++ b/compiler/rustc_target/src/spec/x86_64_fortanix_unknown_sgx.rs
@@ -1,12 +1,10 @@
use std::borrow::Cow;
-use crate::spec::cvs;
-
-use super::{LinkerFlavor, LldFlavor, Target, TargetOptions};
+use super::{cvs, Cc, LinkerFlavor, Lld, Target, TargetOptions};
pub fn target() -> Target {
let pre_link_args = TargetOptions::link_args(
- LinkerFlavor::Ld,
+ LinkerFlavor::Gnu(Cc::No, Lld::No),
&[
"-e",
"elf_entry",
@@ -61,7 +59,7 @@ pub fn target() -> Target {
env: "sgx".into(),
vendor: "fortanix".into(),
abi: "fortanix".into(),
- linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
+ linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes),
linker: Some("rust-lld".into()),
max_atomic_width: Some(64),
cpu: "x86-64".into(),
diff --git a/compiler/rustc_target/src/spec/x86_64_fuchsia.rs b/compiler/rustc_target/src/spec/x86_64_fuchsia.rs
index 4f88fc350..532dd6d07 100644
--- a/compiler/rustc_target/src/spec/x86_64_fuchsia.rs
+++ b/compiler/rustc_target/src/spec/x86_64_fuchsia.rs
@@ -4,8 +4,7 @@ pub fn target() -> Target {
let mut base = super::fuchsia_base::opts();
base.cpu = "x86-64".into();
base.max_atomic_width = Some(64);
- // don't use probe-stack=inline-asm until rust#83139 and rust#84667 are resolved
- base.stack_probes = StackProbeType::Call;
+ base.stack_probes = StackProbeType::X86;
base.supported_sanitizers = SanitizerSet::ADDRESS | SanitizerSet::CFI;
Target {
diff --git a/compiler/rustc_target/src/spec/x86_64_linux_android.rs b/compiler/rustc_target/src/spec/x86_64_linux_android.rs
index 6d19cf265..9c9137848 100644
--- a/compiler/rustc_target/src/spec/x86_64_linux_android.rs
+++ b/compiler/rustc_target/src/spec/x86_64_linux_android.rs
@@ -1,4 +1,4 @@
-use crate::spec::{LinkerFlavor, SanitizerSet, StackProbeType, Target, TargetOptions};
+use crate::spec::{Cc, LinkerFlavor, Lld, SanitizerSet, StackProbeType, Target, TargetOptions};
pub fn target() -> Target {
let mut base = super::android_base::opts();
@@ -6,9 +6,8 @@ pub fn target() -> Target {
// https://developer.android.com/ndk/guides/abis.html#86-64
base.features = "+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+popcnt".into();
base.max_atomic_width = Some(64);
- base.add_pre_link_args(LinkerFlavor::Gcc, &["-m64"]);
- // don't use probe-stack=inline-asm until rust#83139 and rust#84667 are resolved
- base.stack_probes = StackProbeType::Call;
+ base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64"]);
+ base.stack_probes = StackProbeType::X86;
Target {
llvm_target: "x86_64-linux-android".into(),
diff --git a/compiler/rustc_target/src/spec/x86_64_pc_solaris.rs b/compiler/rustc_target/src/spec/x86_64_pc_solaris.rs
index 0550b221f..cb62a8173 100644
--- a/compiler/rustc_target/src/spec/x86_64_pc_solaris.rs
+++ b/compiler/rustc_target/src/spec/x86_64_pc_solaris.rs
@@ -1,13 +1,12 @@
-use crate::spec::{LinkerFlavor, SanitizerSet, StackProbeType, Target};
+use crate::spec::{Cc, LinkerFlavor, SanitizerSet, StackProbeType, Target};
pub fn target() -> Target {
let mut base = super::solaris_base::opts();
- base.add_pre_link_args(LinkerFlavor::Gcc, &["-m64"]);
+ base.add_pre_link_args(LinkerFlavor::Unix(Cc::Yes), &["-m64"]);
base.cpu = "x86-64".into();
base.vendor = "pc".into();
base.max_atomic_width = Some(64);
- // don't use probe-stack=inline-asm until rust#83139 and rust#84667 are resolved
- base.stack_probes = StackProbeType::Call;
+ base.stack_probes = StackProbeType::X86;
base.supported_sanitizers = SanitizerSet::ADDRESS | SanitizerSet::CFI;
Target {
diff --git a/compiler/rustc_target/src/spec/x86_64_pc_windows_gnu.rs b/compiler/rustc_target/src/spec/x86_64_pc_windows_gnu.rs
index 59a8cffca..37feaa9db 100644
--- a/compiler/rustc_target/src/spec/x86_64_pc_windows_gnu.rs
+++ b/compiler/rustc_target/src/spec/x86_64_pc_windows_gnu.rs
@@ -1,11 +1,14 @@
-use crate::spec::{LinkerFlavor, Target};
+use crate::spec::{Cc, LinkerFlavor, Lld, Target};
pub fn target() -> Target {
let mut base = super::windows_gnu_base::opts();
base.cpu = "x86-64".into();
// Use high-entropy 64 bit address space for ASLR
- base.add_pre_link_args(LinkerFlavor::Ld, &["-m", "i386pep", "--high-entropy-va"]);
- base.add_pre_link_args(LinkerFlavor::Gcc, &["-m64", "-Wl,--high-entropy-va"]);
+ base.add_pre_link_args(
+ LinkerFlavor::Gnu(Cc::No, Lld::No),
+ &["-m", "i386pep", "--high-entropy-va"],
+ );
+ base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64", "-Wl,--high-entropy-va"]);
base.max_atomic_width = Some(64);
base.linker = Some("x86_64-w64-mingw32-gcc".into());
diff --git a/compiler/rustc_target/src/spec/x86_64_pc_windows_gnullvm.rs b/compiler/rustc_target/src/spec/x86_64_pc_windows_gnullvm.rs
index d3909b389..039bc2bd2 100644
--- a/compiler/rustc_target/src/spec/x86_64_pc_windows_gnullvm.rs
+++ b/compiler/rustc_target/src/spec/x86_64_pc_windows_gnullvm.rs
@@ -1,9 +1,9 @@
-use crate::spec::{LinkerFlavor, Target};
+use crate::spec::{Cc, LinkerFlavor, Lld, Target};
pub fn target() -> Target {
let mut base = super::windows_gnullvm_base::opts();
base.cpu = "x86-64".into();
- base.add_pre_link_args(LinkerFlavor::Gcc, &["-m64"]);
+ base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64"]);
base.max_atomic_width = Some(64);
base.linker = Some("x86_64-w64-mingw32-clang".into());
diff --git a/compiler/rustc_target/src/spec/x86_64_sun_solaris.rs b/compiler/rustc_target/src/spec/x86_64_sun_solaris.rs
index cbe87589a..0f31ea86b 100644
--- a/compiler/rustc_target/src/spec/x86_64_sun_solaris.rs
+++ b/compiler/rustc_target/src/spec/x86_64_sun_solaris.rs
@@ -1,13 +1,12 @@
-use crate::spec::{LinkerFlavor, StackProbeType, Target};
+use crate::spec::{Cc, LinkerFlavor, StackProbeType, Target};
pub fn target() -> Target {
let mut base = super::solaris_base::opts();
- base.add_pre_link_args(LinkerFlavor::Gcc, &["-m64"]);
+ base.add_pre_link_args(LinkerFlavor::Unix(Cc::Yes), &["-m64"]);
base.cpu = "x86-64".into();
base.vendor = "sun".into();
base.max_atomic_width = Some(64);
- // don't use probe-stack=inline-asm until rust#83139 and rust#84667 are resolved
- base.stack_probes = StackProbeType::Call;
+ base.stack_probes = StackProbeType::X86;
Target {
llvm_target: "x86_64-pc-solaris".into(),
diff --git a/compiler/rustc_target/src/spec/x86_64_unknown_dragonfly.rs b/compiler/rustc_target/src/spec/x86_64_unknown_dragonfly.rs
index 746f64781..67ce3768d 100644
--- a/compiler/rustc_target/src/spec/x86_64_unknown_dragonfly.rs
+++ b/compiler/rustc_target/src/spec/x86_64_unknown_dragonfly.rs
@@ -1,12 +1,11 @@
-use crate::spec::{LinkerFlavor, StackProbeType, Target};
+use crate::spec::{Cc, LinkerFlavor, Lld, StackProbeType, Target};
pub fn target() -> Target {
let mut base = super::dragonfly_base::opts();
base.cpu = "x86-64".into();
base.max_atomic_width = Some(64);
- base.add_pre_link_args(LinkerFlavor::Gcc, &["-m64"]);
- // don't use probe-stack=inline-asm until rust#83139 and rust#84667 are resolved
- base.stack_probes = StackProbeType::Call;
+ base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64"]);
+ base.stack_probes = StackProbeType::X86;
Target {
llvm_target: "x86_64-unknown-dragonfly".into(),
diff --git a/compiler/rustc_target/src/spec/x86_64_unknown_freebsd.rs b/compiler/rustc_target/src/spec/x86_64_unknown_freebsd.rs
index b30784ed6..98988ab35 100644
--- a/compiler/rustc_target/src/spec/x86_64_unknown_freebsd.rs
+++ b/compiler/rustc_target/src/spec/x86_64_unknown_freebsd.rs
@@ -1,12 +1,11 @@
-use crate::spec::{LinkerFlavor, SanitizerSet, StackProbeType, Target};
+use crate::spec::{Cc, LinkerFlavor, Lld, SanitizerSet, StackProbeType, Target};
pub fn target() -> Target {
let mut base = super::freebsd_base::opts();
base.cpu = "x86-64".into();
base.max_atomic_width = Some(64);
- base.add_pre_link_args(LinkerFlavor::Gcc, &["-m64"]);
- // don't use probe-stack=inline-asm until rust#83139 and rust#84667 are resolved
- base.stack_probes = StackProbeType::Call;
+ base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64"]);
+ base.stack_probes = StackProbeType::X86;
base.supported_sanitizers =
SanitizerSet::ADDRESS | SanitizerSet::CFI | SanitizerSet::MEMORY | SanitizerSet::THREAD;
diff --git a/compiler/rustc_target/src/spec/x86_64_unknown_haiku.rs b/compiler/rustc_target/src/spec/x86_64_unknown_haiku.rs
index d6d033629..9a7a3b501 100644
--- a/compiler/rustc_target/src/spec/x86_64_unknown_haiku.rs
+++ b/compiler/rustc_target/src/spec/x86_64_unknown_haiku.rs
@@ -1,12 +1,11 @@
-use crate::spec::{LinkerFlavor, StackProbeType, Target};
+use crate::spec::{Cc, LinkerFlavor, Lld, StackProbeType, Target};
pub fn target() -> Target {
let mut base = super::haiku_base::opts();
base.cpu = "x86-64".into();
base.max_atomic_width = Some(64);
- base.add_pre_link_args(LinkerFlavor::Gcc, &["-m64"]);
- // don't use probe-stack=inline-asm until rust#83139 and rust#84667 are resolved
- base.stack_probes = StackProbeType::Call;
+ base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64"]);
+ base.stack_probes = StackProbeType::X86;
// This option is required to build executables on Haiku x86_64
base.position_independent_executables = true;
diff --git a/compiler/rustc_target/src/spec/x86_64_unknown_hermit.rs b/compiler/rustc_target/src/spec/x86_64_unknown_hermit.rs
index d31530161..fb1af33f8 100644
--- a/compiler/rustc_target/src/spec/x86_64_unknown_hermit.rs
+++ b/compiler/rustc_target/src/spec/x86_64_unknown_hermit.rs
@@ -5,8 +5,7 @@ pub fn target() -> Target {
base.cpu = "x86-64".into();
base.max_atomic_width = Some(64);
base.features = "+rdrnd,+rdseed".into();
- // don't use probe-stack=inline-asm until rust#83139 and rust#84667 are resolved
- base.stack_probes = StackProbeType::Call;
+ base.stack_probes = StackProbeType::X86;
Target {
llvm_target: "x86_64-unknown-hermit".into(),
diff --git a/compiler/rustc_target/src/spec/x86_64_unknown_illumos.rs b/compiler/rustc_target/src/spec/x86_64_unknown_illumos.rs
index 9f19c3a2b..04a12a7bf 100644
--- a/compiler/rustc_target/src/spec/x86_64_unknown_illumos.rs
+++ b/compiler/rustc_target/src/spec/x86_64_unknown_illumos.rs
@@ -1,8 +1,8 @@
-use crate::spec::{LinkerFlavor, SanitizerSet, Target};
+use crate::spec::{Cc, LinkerFlavor, SanitizerSet, Target};
pub fn target() -> Target {
let mut base = super::illumos_base::opts();
- base.add_pre_link_args(LinkerFlavor::Gcc, &["-m64", "-std=c99"]);
+ base.add_pre_link_args(LinkerFlavor::Unix(Cc::Yes), &["-m64", "-std=c99"]);
base.cpu = "x86-64".into();
base.max_atomic_width = Some(64);
base.supported_sanitizers = SanitizerSet::ADDRESS | SanitizerSet::CFI;
diff --git a/compiler/rustc_target/src/spec/x86_64_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/x86_64_unknown_linux_gnu.rs
index 956be0353..a91ab365b 100644
--- a/compiler/rustc_target/src/spec/x86_64_unknown_linux_gnu.rs
+++ b/compiler/rustc_target/src/spec/x86_64_unknown_linux_gnu.rs
@@ -1,12 +1,11 @@
-use crate::spec::{LinkerFlavor, SanitizerSet, StackProbeType, Target};
+use crate::spec::{Cc, LinkerFlavor, Lld, SanitizerSet, StackProbeType, Target};
pub fn target() -> Target {
let mut base = super::linux_gnu_base::opts();
base.cpu = "x86-64".into();
base.max_atomic_width = Some(64);
- base.add_pre_link_args(LinkerFlavor::Gcc, &["-m64"]);
- // don't use probe-stack=inline-asm until rust#83139 and rust#84667 are resolved
- base.stack_probes = StackProbeType::Call;
+ base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64"]);
+ base.stack_probes = StackProbeType::X86;
base.static_position_independent_executables = true;
base.supported_sanitizers = SanitizerSet::ADDRESS
| SanitizerSet::CFI
diff --git a/compiler/rustc_target/src/spec/x86_64_unknown_linux_gnux32.rs b/compiler/rustc_target/src/spec/x86_64_unknown_linux_gnux32.rs
index 140882747..626d5b480 100644
--- a/compiler/rustc_target/src/spec/x86_64_unknown_linux_gnux32.rs
+++ b/compiler/rustc_target/src/spec/x86_64_unknown_linux_gnux32.rs
@@ -1,13 +1,12 @@
-use crate::spec::{LinkerFlavor, StackProbeType, Target};
+use crate::spec::{Cc, LinkerFlavor, Lld, StackProbeType, Target};
pub fn target() -> Target {
let mut base = super::linux_gnu_base::opts();
base.cpu = "x86-64".into();
base.abi = "x32".into();
base.max_atomic_width = Some(64);
- base.add_pre_link_args(LinkerFlavor::Gcc, &["-mx32"]);
- // don't use probe-stack=inline-asm until rust#83139 and rust#84667 are resolved
- base.stack_probes = StackProbeType::Call;
+ base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-mx32"]);
+ base.stack_probes = StackProbeType::X86;
base.has_thread_local = false;
// BUG(GabrielMajeri): disabling the PLT on x86_64 Linux with x32 ABI
// breaks code gen. See LLVM bug 36743
diff --git a/compiler/rustc_target/src/spec/x86_64_unknown_linux_musl.rs b/compiler/rustc_target/src/spec/x86_64_unknown_linux_musl.rs
index 87e7784d1..9087dc3df 100644
--- a/compiler/rustc_target/src/spec/x86_64_unknown_linux_musl.rs
+++ b/compiler/rustc_target/src/spec/x86_64_unknown_linux_musl.rs
@@ -1,12 +1,11 @@
-use crate::spec::{LinkerFlavor, SanitizerSet, StackProbeType, Target};
+use crate::spec::{Cc, LinkerFlavor, Lld, SanitizerSet, StackProbeType, Target};
pub fn target() -> Target {
let mut base = super::linux_musl_base::opts();
base.cpu = "x86-64".into();
base.max_atomic_width = Some(64);
- base.add_pre_link_args(LinkerFlavor::Gcc, &["-m64"]);
- // don't use probe-stack=inline-asm until rust#83139 and rust#84667 are resolved
- base.stack_probes = StackProbeType::Call;
+ base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64"]);
+ base.stack_probes = StackProbeType::X86;
base.static_position_independent_executables = true;
base.supported_sanitizers = SanitizerSet::ADDRESS
| SanitizerSet::CFI
diff --git a/compiler/rustc_target/src/spec/x86_64_unknown_netbsd.rs b/compiler/rustc_target/src/spec/x86_64_unknown_netbsd.rs
index d3a67619a..64ae425d8 100644
--- a/compiler/rustc_target/src/spec/x86_64_unknown_netbsd.rs
+++ b/compiler/rustc_target/src/spec/x86_64_unknown_netbsd.rs
@@ -1,12 +1,11 @@
-use crate::spec::{LinkerFlavor, SanitizerSet, StackProbeType, Target, TargetOptions};
+use crate::spec::{Cc, LinkerFlavor, Lld, SanitizerSet, StackProbeType, Target, TargetOptions};
pub fn target() -> Target {
let mut base = super::netbsd_base::opts();
base.cpu = "x86-64".into();
base.max_atomic_width = Some(64);
- base.add_pre_link_args(LinkerFlavor::Gcc, &["-m64"]);
- // don't use probe-stack=inline-asm until rust#83139 and rust#84667 are resolved
- base.stack_probes = StackProbeType::Call;
+ base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64"]);
+ base.stack_probes = StackProbeType::X86;
base.supported_sanitizers = SanitizerSet::ADDRESS
| SanitizerSet::CFI
| SanitizerSet::LEAK
diff --git a/compiler/rustc_target/src/spec/x86_64_unknown_none.rs b/compiler/rustc_target/src/spec/x86_64_unknown_none.rs
index b9a345127..e4d33c2b8 100644
--- a/compiler/rustc_target/src/spec/x86_64_unknown_none.rs
+++ b/compiler/rustc_target/src/spec/x86_64_unknown_none.rs
@@ -4,19 +4,18 @@
// `target-cpu` compiler flags to opt-in more hardware-specific
// features.
-use super::{CodeModel, LinkerFlavor, LldFlavor, PanicStrategy};
+use super::{Cc, CodeModel, LinkerFlavor, Lld, PanicStrategy};
use super::{RelroLevel, StackProbeType, Target, TargetOptions};
pub fn target() -> Target {
let opts = TargetOptions {
cpu: "x86-64".into(),
max_atomic_width: Some(64),
- // don't use probe-stack=inline-asm until rust#83139 and rust#84667 are resolved
- stack_probes: StackProbeType::Call,
+ stack_probes: StackProbeType::X86,
position_independent_executables: true,
static_position_independent_executables: true,
relro_level: RelroLevel::Full,
- linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
+ linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes),
linker: Some("rust-lld".into()),
features:
"-mmx,-sse,-sse2,-sse3,-ssse3,-sse4.1,-sse4.2,-3dnow,-3dnowa,-avx,-avx2,+soft-float"
diff --git a/compiler/rustc_target/src/spec/x86_64_unknown_none_linuxkernel.rs b/compiler/rustc_target/src/spec/x86_64_unknown_none_linuxkernel.rs
index 593345a5f..ebd9636ff 100644
--- a/compiler/rustc_target/src/spec/x86_64_unknown_none_linuxkernel.rs
+++ b/compiler/rustc_target/src/spec/x86_64_unknown_none_linuxkernel.rs
@@ -1,7 +1,7 @@
// This defines the amd64 target for the Linux Kernel. See the linux-kernel-base module for
// generic Linux kernel options.
-use crate::spec::{CodeModel, LinkerFlavor, Target};
+use crate::spec::{Cc, CodeModel, LinkerFlavor, Lld, Target};
pub fn target() -> Target {
let mut base = super::linux_kernel_base::opts();
@@ -10,7 +10,7 @@ pub fn target() -> Target {
base.features =
"-mmx,-sse,-sse2,-sse3,-ssse3,-sse4.1,-sse4.2,-3dnow,-3dnowa,-avx,-avx2,+soft-float".into();
base.code_model = Some(CodeModel::Kernel);
- base.add_pre_link_args(LinkerFlavor::Gcc, &["-m64"]);
+ base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64"]);
Target {
// FIXME: Some dispute, the linux-on-clang folks think this should use
diff --git a/compiler/rustc_target/src/spec/x86_64_unknown_openbsd.rs b/compiler/rustc_target/src/spec/x86_64_unknown_openbsd.rs
index f50c6bcee..66b8e2022 100644
--- a/compiler/rustc_target/src/spec/x86_64_unknown_openbsd.rs
+++ b/compiler/rustc_target/src/spec/x86_64_unknown_openbsd.rs
@@ -1,12 +1,11 @@
-use crate::spec::{LinkerFlavor, StackProbeType, Target};
+use crate::spec::{Cc, LinkerFlavor, Lld, StackProbeType, Target};
pub fn target() -> Target {
let mut base = super::openbsd_base::opts();
base.cpu = "x86-64".into();
base.max_atomic_width = Some(64);
- base.add_pre_link_args(LinkerFlavor::Gcc, &["-m64"]);
- // don't use probe-stack=inline-asm until rust#83139 and rust#84667 are resolved
- base.stack_probes = StackProbeType::Call;
+ base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64"]);
+ base.stack_probes = StackProbeType::X86;
Target {
llvm_target: "x86_64-unknown-openbsd".into(),
diff --git a/compiler/rustc_target/src/spec/x86_64_unknown_redox.rs b/compiler/rustc_target/src/spec/x86_64_unknown_redox.rs
index 668ae9054..b47f15cf5 100644
--- a/compiler/rustc_target/src/spec/x86_64_unknown_redox.rs
+++ b/compiler/rustc_target/src/spec/x86_64_unknown_redox.rs
@@ -1,12 +1,11 @@
-use crate::spec::{LinkerFlavor, StackProbeType, Target};
+use crate::spec::{Cc, LinkerFlavor, Lld, StackProbeType, Target};
pub fn target() -> Target {
let mut base = super::redox_base::opts();
base.cpu = "x86-64".into();
base.max_atomic_width = Some(64);
- base.add_pre_link_args(LinkerFlavor::Gcc, &["-m64"]);
- // don't use probe-stack=inline-asm until rust#83139 and rust#84667 are resolved
- base.stack_probes = StackProbeType::Call;
+ base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64"]);
+ base.stack_probes = StackProbeType::X86;
Target {
llvm_target: "x86_64-unknown-redox".into(),
diff --git a/compiler/rustc_target/src/spec/x86_64_uwp_windows_gnu.rs b/compiler/rustc_target/src/spec/x86_64_uwp_windows_gnu.rs
index 76d2013cf..c3eaa6939 100644
--- a/compiler/rustc_target/src/spec/x86_64_uwp_windows_gnu.rs
+++ b/compiler/rustc_target/src/spec/x86_64_uwp_windows_gnu.rs
@@ -1,11 +1,14 @@
-use crate::spec::{LinkerFlavor, Target};
+use crate::spec::{Cc, LinkerFlavor, Lld, Target};
pub fn target() -> Target {
let mut base = super::windows_uwp_gnu_base::opts();
base.cpu = "x86-64".into();
// Use high-entropy 64 bit address space for ASLR
- base.add_pre_link_args(LinkerFlavor::Ld, &["-m", "i386pep", "--high-entropy-va"]);
- base.add_pre_link_args(LinkerFlavor::Gcc, &["-m64", "-Wl,--high-entropy-va"]);
+ base.add_pre_link_args(
+ LinkerFlavor::Gnu(Cc::No, Lld::No),
+ &["-m", "i386pep", "--high-entropy-va"],
+ );
+ base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64", "-Wl,--high-entropy-va"]);
base.max_atomic_width = Some(64);
Target {
diff --git a/compiler/rustc_target/src/spec/x86_64_wrs_vxworks.rs b/compiler/rustc_target/src/spec/x86_64_wrs_vxworks.rs
index 129897495..365ade6bc 100644
--- a/compiler/rustc_target/src/spec/x86_64_wrs_vxworks.rs
+++ b/compiler/rustc_target/src/spec/x86_64_wrs_vxworks.rs
@@ -1,12 +1,11 @@
-use crate::spec::{LinkerFlavor, StackProbeType, Target};
+use crate::spec::{Cc, LinkerFlavor, Lld, StackProbeType, Target};
pub fn target() -> Target {
let mut base = super::vxworks_base::opts();
base.cpu = "x86-64".into();
base.max_atomic_width = Some(64);
- base.add_pre_link_args(LinkerFlavor::Gcc, &["-m64"]);
- // don't use probe-stack=inline-asm until rust#83139 and rust#84667 are resolved
- base.stack_probes = StackProbeType::Call;
+ base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64"]);
+ base.stack_probes = StackProbeType::X86;
base.disable_redzone = true;
Target {