Merge remote-tracking branch 'upstream/master' into impl-16351-nightly
Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
commit
f9d390d14a
4238 changed files with 96221 additions and 81870 deletions
|
@ -18,8 +18,7 @@ mod riscv;
|
|||
mod s390x;
|
||||
mod sparc;
|
||||
mod sparc64;
|
||||
mod wasm32;
|
||||
mod wasm32_bindgen_compat;
|
||||
mod wasm;
|
||||
mod x86;
|
||||
mod x86_64;
|
||||
mod x86_win64;
|
||||
|
@ -65,14 +64,17 @@ mod attr_impl {
|
|||
const NoCapture = 1 << 2;
|
||||
const NonNull = 1 << 3;
|
||||
const ReadOnly = 1 << 4;
|
||||
const InReg = 1 << 8;
|
||||
const InReg = 1 << 5;
|
||||
// NoAlias on &mut arguments can only be used with LLVM >= 12 due to miscompiles
|
||||
// in earlier versions. FIXME: Remove this distinction once possible.
|
||||
const NoAliasMutRef = 1 << 6;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Sometimes an ABI requires small integers to be extended to a full or partial register. This enum
|
||||
/// defines if this extension should be zero-extension or sign-extension when necssary. When it is
|
||||
/// not necesary to extend the argument, this enum is ignored.
|
||||
/// defines if this extension should be zero-extension or sign-extension when necessary. When it is
|
||||
/// not necessary to extend the argument, this enum is ignored.
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
|
||||
pub enum ArgExtension {
|
||||
None,
|
||||
|
@ -644,11 +646,14 @@ impl<'a, Ty> FnAbi<'a, Ty> {
|
|||
"nvptx64" => nvptx64::compute_abi_info(self),
|
||||
"hexagon" => hexagon::compute_abi_info(self),
|
||||
"riscv32" | "riscv64" => riscv::compute_abi_info(cx, self),
|
||||
"wasm32" => match cx.target_spec().os.as_str() {
|
||||
"emscripten" | "wasi" => wasm32::compute_abi_info(cx, self),
|
||||
_ => wasm32_bindgen_compat::compute_abi_info(self),
|
||||
},
|
||||
"asmjs" => wasm32::compute_abi_info(cx, self),
|
||||
"wasm32" | "wasm64" => {
|
||||
if cx.target_spec().adjust_abi(abi) == spec::abi::Abi::Wasm {
|
||||
wasm::compute_wasm_abi_info(self)
|
||||
} else {
|
||||
wasm::compute_c_abi_info(cx, self)
|
||||
}
|
||||
}
|
||||
"asmjs" => wasm::compute_c_abi_info(cx, self),
|
||||
a => return Err(format!("unrecognized arch \"{}\" in target specification", a)),
|
||||
}
|
||||
|
||||
|
|
|
@ -40,7 +40,8 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
pub fn compute_abi_info<'a, Ty, C>(cx: &C, fn_abi: &mut FnAbi<'a, Ty>)
|
||||
/// The purpose of this ABI is to match the C ABI (aka clang) exactly.
|
||||
pub fn compute_c_abi_info<'a, Ty, C>(cx: &C, fn_abi: &mut FnAbi<'a, Ty>)
|
||||
where
|
||||
Ty: TyAndLayoutMethods<'a, C> + Copy,
|
||||
C: LayoutOf<Ty = Ty, TyAndLayout = TyAndLayout<'a, Ty>> + HasDataLayout,
|
||||
|
@ -56,3 +57,27 @@ where
|
|||
classify_arg(cx, arg);
|
||||
}
|
||||
}
|
||||
|
||||
/// The purpose of this ABI is for matching the WebAssembly standard. This
|
||||
/// intentionally diverges from the C ABI and is specifically crafted to take
|
||||
/// advantage of LLVM's support of multiple returns in WebAssembly.
|
||||
pub fn compute_wasm_abi_info<Ty>(fn_abi: &mut FnAbi<'_, Ty>) {
|
||||
if !fn_abi.ret.is_ignore() {
|
||||
classify_ret(&mut fn_abi.ret);
|
||||
}
|
||||
|
||||
for arg in &mut fn_abi.args {
|
||||
if arg.is_ignore() {
|
||||
continue;
|
||||
}
|
||||
classify_arg(arg);
|
||||
}
|
||||
|
||||
fn classify_ret<Ty>(ret: &mut ArgAbi<'_, Ty>) {
|
||||
ret.extend_integer_width_to(32);
|
||||
}
|
||||
|
||||
fn classify_arg<Ty>(arg: &mut ArgAbi<'_, Ty>) {
|
||||
arg.extend_integer_width_to(32);
|
||||
}
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
// This is not and has never been a correct C ABI for WebAssembly, but
|
||||
// for a long time this was the C ABI that Rust used. wasm-bindgen
|
||||
// depends on ABI details for this ABI and is incompatible with the
|
||||
// correct C ABI, so this ABI is being kept around until wasm-bindgen
|
||||
// can be fixed to work with the correct ABI. See #63649 for further
|
||||
// discussion.
|
||||
|
||||
use crate::abi::call::{ArgAbi, FnAbi};
|
||||
|
||||
fn classify_ret<Ty>(ret: &mut ArgAbi<'_, Ty>) {
|
||||
ret.extend_integer_width_to(32);
|
||||
}
|
||||
|
||||
fn classify_arg<Ty>(arg: &mut ArgAbi<'_, Ty>) {
|
||||
arg.extend_integer_width_to(32);
|
||||
}
|
||||
|
||||
pub fn compute_abi_info<Ty>(fn_abi: &mut FnAbi<'_, Ty>) {
|
||||
if !fn_abi.ret.is_ignore() {
|
||||
classify_ret(&mut fn_abi.ret);
|
||||
}
|
||||
|
||||
for arg in &mut fn_abi.args {
|
||||
if arg.is_ignore() {
|
||||
continue;
|
||||
}
|
||||
classify_arg(arg);
|
||||
}
|
||||
}
|
|
@ -1112,7 +1112,7 @@ pub enum PointerKind {
|
|||
/// `&T` where `T` contains no `UnsafeCell`, is `noalias` and `readonly`.
|
||||
Frozen,
|
||||
|
||||
/// `&mut T`, when we know `noalias` is safe for LLVM.
|
||||
/// `&mut T` which is `noalias` but not `readonly`.
|
||||
UniqueBorrowed,
|
||||
|
||||
/// `Box<T>`, unlike `UniqueBorrowed`, it also has `noalias` on returns.
|
||||
|
|
|
@ -68,7 +68,6 @@ fn frame_pointer_r11(
|
|||
_arch: InlineAsmArch,
|
||||
has_feature: impl FnMut(&str) -> bool,
|
||||
target: &Target,
|
||||
_allocating: bool,
|
||||
) -> Result<(), &'static str> {
|
||||
if !frame_pointer_is_r7(has_feature, target) {
|
||||
Err("the frame pointer (r11) cannot be used as an operand for inline asm")
|
||||
|
@ -81,7 +80,6 @@ fn frame_pointer_r7(
|
|||
_arch: InlineAsmArch,
|
||||
has_feature: impl FnMut(&str) -> bool,
|
||||
target: &Target,
|
||||
_allocating: bool,
|
||||
) -> Result<(), &'static str> {
|
||||
if frame_pointer_is_r7(has_feature, target) {
|
||||
Err("the frame pointer (r7) cannot be used as an operand for inline asm")
|
||||
|
|
|
@ -90,7 +90,7 @@ macro_rules! def_regs {
|
|||
match name {
|
||||
$(
|
||||
$($alias)|* | $reg_name => {
|
||||
$($filter(_arch, &mut _has_feature, _target, false)?;)?
|
||||
$($filter(_arch, &mut _has_feature, _target)?;)?
|
||||
Ok(Self::$reg)
|
||||
}
|
||||
)*
|
||||
|
@ -114,7 +114,7 @@ macro_rules! def_regs {
|
|||
#[allow(unused_imports)]
|
||||
use super::{InlineAsmReg, InlineAsmRegClass};
|
||||
$(
|
||||
if $($filter(_arch, &mut _has_feature, _target, true).is_ok() &&)? true {
|
||||
if $($filter(_arch, &mut _has_feature, _target).is_ok() &&)? true {
|
||||
if let Some(set) = _map.get_mut(&InlineAsmRegClass::$arch($arch_regclass::$class)) {
|
||||
set.insert(InlineAsmReg::$arch($arch_reg::$reg));
|
||||
}
|
||||
|
@ -229,6 +229,8 @@ pub enum InlineAsmReg {
|
|||
Mips(MipsInlineAsmReg),
|
||||
SpirV(SpirVInlineAsmReg),
|
||||
Wasm(WasmInlineAsmReg),
|
||||
// Placeholder for invalid register constraints for the current target
|
||||
Err,
|
||||
}
|
||||
|
||||
impl InlineAsmReg {
|
||||
|
@ -240,6 +242,7 @@ impl InlineAsmReg {
|
|||
Self::RiscV(r) => r.name(),
|
||||
Self::Hexagon(r) => r.name(),
|
||||
Self::Mips(r) => r.name(),
|
||||
Self::Err => "<reg>",
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -251,6 +254,7 @@ impl InlineAsmReg {
|
|||
Self::RiscV(r) => InlineAsmRegClass::RiscV(r.reg_class()),
|
||||
Self::Hexagon(r) => InlineAsmRegClass::Hexagon(r.reg_class()),
|
||||
Self::Mips(r) => InlineAsmRegClass::Mips(r.reg_class()),
|
||||
Self::Err => InlineAsmRegClass::Err,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -309,6 +313,7 @@ impl InlineAsmReg {
|
|||
Self::RiscV(r) => r.emit(out, arch, modifier),
|
||||
Self::Hexagon(r) => r.emit(out, arch, modifier),
|
||||
Self::Mips(r) => r.emit(out, arch, modifier),
|
||||
Self::Err => unreachable!("Use of InlineAsmReg::Err"),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -320,6 +325,7 @@ impl InlineAsmReg {
|
|||
Self::RiscV(_) => cb(self),
|
||||
Self::Hexagon(r) => r.overlapping_regs(|r| cb(Self::Hexagon(r))),
|
||||
Self::Mips(_) => cb(self),
|
||||
Self::Err => unreachable!("Use of InlineAsmReg::Err"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -346,6 +352,8 @@ pub enum InlineAsmRegClass {
|
|||
Mips(MipsInlineAsmRegClass),
|
||||
SpirV(SpirVInlineAsmRegClass),
|
||||
Wasm(WasmInlineAsmRegClass),
|
||||
// Placeholder for invalid register constraints for the current target
|
||||
Err,
|
||||
}
|
||||
|
||||
impl InlineAsmRegClass {
|
||||
|
@ -360,6 +368,7 @@ impl InlineAsmRegClass {
|
|||
Self::Mips(r) => r.name(),
|
||||
Self::SpirV(r) => r.name(),
|
||||
Self::Wasm(r) => r.name(),
|
||||
Self::Err => rustc_span::symbol::sym::reg,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -377,6 +386,7 @@ impl InlineAsmRegClass {
|
|||
Self::Mips(r) => r.suggest_class(arch, ty).map(InlineAsmRegClass::Mips),
|
||||
Self::SpirV(r) => r.suggest_class(arch, ty).map(InlineAsmRegClass::SpirV),
|
||||
Self::Wasm(r) => r.suggest_class(arch, ty).map(InlineAsmRegClass::Wasm),
|
||||
Self::Err => unreachable!("Use of InlineAsmRegClass::Err"),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -401,6 +411,7 @@ impl InlineAsmRegClass {
|
|||
Self::Mips(r) => r.suggest_modifier(arch, ty),
|
||||
Self::SpirV(r) => r.suggest_modifier(arch, ty),
|
||||
Self::Wasm(r) => r.suggest_modifier(arch, ty),
|
||||
Self::Err => unreachable!("Use of InlineAsmRegClass::Err"),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -421,6 +432,7 @@ impl InlineAsmRegClass {
|
|||
Self::Mips(r) => r.default_modifier(arch),
|
||||
Self::SpirV(r) => r.default_modifier(arch),
|
||||
Self::Wasm(r) => r.default_modifier(arch),
|
||||
Self::Err => unreachable!("Use of InlineAsmRegClass::Err"),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -440,6 +452,7 @@ impl InlineAsmRegClass {
|
|||
Self::Mips(r) => r.supported_types(arch),
|
||||
Self::SpirV(r) => r.supported_types(arch),
|
||||
Self::Wasm(r) => r.supported_types(arch),
|
||||
Self::Err => unreachable!("Use of InlineAsmRegClass::Err"),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -476,6 +489,7 @@ impl InlineAsmRegClass {
|
|||
Self::Mips(r) => r.valid_modifiers(arch),
|
||||
Self::SpirV(r) => r.valid_modifiers(arch),
|
||||
Self::Wasm(r) => r.valid_modifiers(arch),
|
||||
Self::Err => unreachable!("Use of InlineAsmRegClass::Err"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,7 +52,6 @@ fn not_e(
|
|||
_arch: InlineAsmArch,
|
||||
mut has_feature: impl FnMut(&str) -> bool,
|
||||
_target: &Target,
|
||||
_allocating: bool,
|
||||
) -> Result<(), &'static str> {
|
||||
if has_feature("e") {
|
||||
Err("register can't be used with the `e` target feature")
|
||||
|
|
|
@ -133,7 +133,6 @@ fn x86_64_only(
|
|||
arch: InlineAsmArch,
|
||||
_has_feature: impl FnMut(&str) -> bool,
|
||||
_target: &Target,
|
||||
_allocating: bool,
|
||||
) -> Result<(), &'static str> {
|
||||
match arch {
|
||||
InlineAsmArch::X86 => Err("register is only available on x86_64"),
|
||||
|
@ -146,13 +145,9 @@ fn high_byte(
|
|||
arch: InlineAsmArch,
|
||||
_has_feature: impl FnMut(&str) -> bool,
|
||||
_target: &Target,
|
||||
allocating: bool,
|
||||
) -> Result<(), &'static str> {
|
||||
match arch {
|
||||
InlineAsmArch::X86_64 if allocating => {
|
||||
// The error message isn't actually used...
|
||||
Err("high byte registers are not allocated by reg_byte")
|
||||
}
|
||||
InlineAsmArch::X86_64 => Err("high byte registers cannot be used as an operand on x86_64"),
|
||||
_ => Ok(()),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,5 +28,5 @@ pub mod spec;
|
|||
|
||||
/// Requirements for a `StableHashingContext` to be used in this crate.
|
||||
/// This is a hack to allow using the `HashStable_Generic` derive macro
|
||||
/// instead of implementing everything in librustc_middle.
|
||||
/// instead of implementing everything in `rustc_middle`.
|
||||
pub trait HashStableContext {}
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
use crate::spec::{LinkerFlavor, Target, TargetOptions};
|
||||
use crate::spec::{LinkerFlavor, SanitizerSet, Target, TargetOptions};
|
||||
|
||||
pub fn target() -> Target {
|
||||
let mut base = super::apple_base::opts("macos");
|
||||
base.cpu = "apple-a12".to_string();
|
||||
base.max_atomic_width = Some(128);
|
||||
base.pre_link_args.insert(LinkerFlavor::Gcc, vec!["-arch".to_string(), "arm64".to_string()]);
|
||||
base.supported_sanitizers = SanitizerSet::ADDRESS | SanitizerSet::LEAK | SanitizerSet::THREAD;
|
||||
|
||||
base.pre_link_args.insert(LinkerFlavor::Gcc, vec!["-arch".to_string(), "arm64".to_string()]);
|
||||
base.link_env_remove.extend(super::apple_base::macos_link_env_remove());
|
||||
|
||||
// Clang automatically chooses a more specific target based on
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
use crate::spec::{Target, TargetOptions};
|
||||
use crate::spec::{SanitizerSet, Target, TargetOptions};
|
||||
|
||||
pub fn target() -> Target {
|
||||
let mut base = super::fuchsia_base::opts();
|
||||
base.max_atomic_width = Some(128);
|
||||
base.supported_sanitizers = SanitizerSet::ADDRESS;
|
||||
|
||||
Target {
|
||||
llvm_target: "aarch64-fuchsia".to_string(),
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use crate::spec::{Target, TargetOptions};
|
||||
use crate::spec::{SanitizerSet, Target, TargetOptions};
|
||||
|
||||
// See https://developer.android.com/ndk/guides/abis.html#arm64-v8a
|
||||
// for target ABI requirements.
|
||||
|
@ -9,6 +9,7 @@ pub fn target() -> Target {
|
|||
// As documented in http://developer.android.com/ndk/guides/cpu-features.html
|
||||
// the neon (ASIMD) and FP must exist on all android aarch64 targets.
|
||||
base.features = "+neon,+fp-armv8".to_string();
|
||||
base.supported_sanitizers = SanitizerSet::HWADDRESS;
|
||||
Target {
|
||||
llvm_target: "aarch64-linux-android".to_string(),
|
||||
pointer_width: 64,
|
||||
|
|
|
@ -1,8 +1,13 @@
|
|||
use crate::spec::{Target, TargetOptions};
|
||||
use crate::spec::{SanitizerSet, Target, TargetOptions};
|
||||
|
||||
pub fn target() -> Target {
|
||||
let mut base = super::linux_gnu_base::opts();
|
||||
base.max_atomic_width = Some(128);
|
||||
base.supported_sanitizers = SanitizerSet::ADDRESS
|
||||
| SanitizerSet::LEAK
|
||||
| SanitizerSet::MEMORY
|
||||
| SanitizerSet::THREAD
|
||||
| SanitizerSet::HWADDRESS;
|
||||
|
||||
Target {
|
||||
llvm_target: "aarch64-unknown-linux-gnu".to_string(),
|
||||
|
|
|
@ -8,24 +8,21 @@ mod tests;
|
|||
#[derive(PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Copy, Debug)]
|
||||
#[derive(HashStable_Generic, Encodable, Decodable)]
|
||||
pub enum Abi {
|
||||
// N.B., this ordering MUST match the AbiDatas array below.
|
||||
// (This is ensured by the test indices_are_correct().)
|
||||
|
||||
// Multiplatform / generic ABIs
|
||||
//
|
||||
// These ABIs come first because every time we add a new ABI, we
|
||||
// have to re-bless all the hashing tests. These are used in many
|
||||
// places, so giving them stable values reduces test churn. The
|
||||
// specific values are meaningless.
|
||||
Rust = 0,
|
||||
C = 1,
|
||||
Rust,
|
||||
C { unwind: bool },
|
||||
|
||||
// Single platform ABIs
|
||||
Cdecl,
|
||||
Stdcall,
|
||||
Stdcall { unwind: bool },
|
||||
Fastcall,
|
||||
Vectorcall,
|
||||
Thiscall,
|
||||
Thiscall { unwind: bool },
|
||||
Aapcs,
|
||||
Win64,
|
||||
SysV64,
|
||||
|
@ -37,9 +34,10 @@ pub enum Abi {
|
|||
AvrInterrupt,
|
||||
AvrNonBlockingInterrupt,
|
||||
CCmseNonSecureCall,
|
||||
Wasm,
|
||||
|
||||
// Multiplatform / generic ABIs
|
||||
System,
|
||||
System { unwind: bool },
|
||||
RustIntrinsic,
|
||||
RustCall,
|
||||
PlatformIntrinsic,
|
||||
|
@ -61,13 +59,16 @@ pub struct AbiData {
|
|||
const AbiDatas: &[AbiData] = &[
|
||||
// Cross-platform ABIs
|
||||
AbiData { abi: Abi::Rust, name: "Rust", generic: true },
|
||||
AbiData { abi: Abi::C, name: "C", generic: true },
|
||||
AbiData { abi: Abi::C { unwind: false }, name: "C", generic: true },
|
||||
AbiData { abi: Abi::C { unwind: true }, name: "C-unwind", generic: true },
|
||||
// Platform-specific ABIs
|
||||
AbiData { abi: Abi::Cdecl, name: "cdecl", generic: false },
|
||||
AbiData { abi: Abi::Stdcall, name: "stdcall", generic: false },
|
||||
AbiData { abi: Abi::Stdcall { unwind: false }, name: "stdcall", generic: false },
|
||||
AbiData { abi: Abi::Stdcall { unwind: true }, name: "stdcall-unwind", generic: false },
|
||||
AbiData { abi: Abi::Fastcall, name: "fastcall", generic: false },
|
||||
AbiData { abi: Abi::Vectorcall, name: "vectorcall", generic: false },
|
||||
AbiData { abi: Abi::Thiscall, name: "thiscall", generic: false },
|
||||
AbiData { abi: Abi::Thiscall { unwind: false }, name: "thiscall", generic: false },
|
||||
AbiData { abi: Abi::Thiscall { unwind: true }, name: "thiscall-unwind", generic: false },
|
||||
AbiData { abi: Abi::Aapcs, name: "aapcs", generic: false },
|
||||
AbiData { abi: Abi::Win64, name: "win64", generic: false },
|
||||
AbiData { abi: Abi::SysV64, name: "sysv64", generic: false },
|
||||
|
@ -83,8 +84,10 @@ const AbiDatas: &[AbiData] = &[
|
|||
generic: false,
|
||||
},
|
||||
AbiData { abi: Abi::CCmseNonSecureCall, name: "C-cmse-nonsecure-call", generic: false },
|
||||
AbiData { abi: Abi::Wasm, name: "wasm", generic: false },
|
||||
// Cross-platform ABIs
|
||||
AbiData { abi: Abi::System, name: "system", generic: true },
|
||||
AbiData { abi: Abi::System { unwind: false }, name: "system", generic: true },
|
||||
AbiData { abi: Abi::System { unwind: true }, name: "system-unwind", generic: true },
|
||||
AbiData { abi: Abi::RustIntrinsic, name: "rust-intrinsic", generic: true },
|
||||
AbiData { abi: Abi::RustCall, name: "rust-call", generic: true },
|
||||
AbiData { abi: Abi::PlatformIntrinsic, name: "platform-intrinsic", generic: true },
|
||||
|
@ -103,7 +106,53 @@ pub fn all_names() -> Vec<&'static str> {
|
|||
impl Abi {
|
||||
#[inline]
|
||||
pub fn index(self) -> usize {
|
||||
self as usize
|
||||
// N.B., this ordering MUST match the AbiDatas array above.
|
||||
// (This is ensured by the test indices_are_correct().)
|
||||
use Abi::*;
|
||||
let i = match self {
|
||||
// Cross-platform ABIs
|
||||
Rust => 0,
|
||||
C { unwind: false } => 1,
|
||||
C { unwind: true } => 2,
|
||||
// Platform-specific ABIs
|
||||
Cdecl => 3,
|
||||
Stdcall { unwind: false } => 4,
|
||||
Stdcall { unwind: true } => 5,
|
||||
Fastcall => 6,
|
||||
Vectorcall => 7,
|
||||
Thiscall { unwind: false } => 8,
|
||||
Thiscall { unwind: true } => 9,
|
||||
Aapcs => 10,
|
||||
Win64 => 11,
|
||||
SysV64 => 12,
|
||||
PtxKernel => 13,
|
||||
Msp430Interrupt => 14,
|
||||
X86Interrupt => 15,
|
||||
AmdGpuKernel => 16,
|
||||
EfiApi => 17,
|
||||
AvrInterrupt => 18,
|
||||
AvrNonBlockingInterrupt => 19,
|
||||
CCmseNonSecureCall => 20,
|
||||
Wasm => 21,
|
||||
// Cross-platform ABIs
|
||||
System { unwind: false } => 22,
|
||||
System { unwind: true } => 23,
|
||||
RustIntrinsic => 24,
|
||||
RustCall => 25,
|
||||
PlatformIntrinsic => 26,
|
||||
Unadjusted => 27,
|
||||
};
|
||||
debug_assert!(
|
||||
AbiDatas
|
||||
.iter()
|
||||
.enumerate()
|
||||
.find(|(_, AbiData { abi, .. })| *abi == self)
|
||||
.map(|(index, _)| index)
|
||||
.expect("abi variant has associated data")
|
||||
== i,
|
||||
"Abi index did not match `AbiDatas` ordering"
|
||||
);
|
||||
i
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
@ -122,6 +171,8 @@ impl Abi {
|
|||
|
||||
impl fmt::Display for Abi {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "\"{}\"", self.name())
|
||||
match self {
|
||||
abi => write!(f, "\"{}\"", abi.name()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,13 +6,16 @@ pub fn opts() -> TargetOptions {
|
|||
// Many of the symbols defined in compiler-rt are also defined in libgcc.
|
||||
// Android's linker doesn't like that by default.
|
||||
base.pre_link_args
|
||||
.get_mut(&LinkerFlavor::Gcc)
|
||||
.unwrap()
|
||||
.entry(LinkerFlavor::Gcc)
|
||||
.or_default()
|
||||
.push("-Wl,--allow-multiple-definition".to_string());
|
||||
base.dwarf_version = Some(2);
|
||||
base.position_independent_executables = true;
|
||||
base.has_elf_tls = false;
|
||||
base.requires_uwtable = true;
|
||||
// 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`).
|
||||
base.default_uwtable = true;
|
||||
base.crt_static_respected = false;
|
||||
base
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use std::env;
|
||||
|
||||
use crate::spec::{LinkArgs, SplitDebuginfo, TargetOptions};
|
||||
use crate::spec::{SplitDebuginfo, TargetOptions};
|
||||
|
||||
pub fn opts(os: &str) -> TargetOptions {
|
||||
// ELF TLS is only available in macOS 10.7+. If you try to compile for 10.6
|
||||
|
@ -27,10 +27,8 @@ pub fn opts(os: &str) -> TargetOptions {
|
|||
is_like_osx: true,
|
||||
dwarf_version: Some(2),
|
||||
has_rpath: true,
|
||||
dll_prefix: "lib".to_string(),
|
||||
dll_suffix: ".dylib".to_string(),
|
||||
archive_format: "darwin".to_string(),
|
||||
pre_link_args: LinkArgs::new(),
|
||||
has_elf_tls: version >= (10, 7),
|
||||
abi_return_struct_as_int: true,
|
||||
emit_debug_gdb_scripts: false,
|
||||
|
|
|
@ -2,5 +2,14 @@ use crate::spec::abi::Abi;
|
|||
|
||||
// All the calling conventions trigger an assertion(Unsupported calling convention) in llvm on arm
|
||||
pub fn unsupported_abis() -> Vec<Abi> {
|
||||
vec![Abi::Stdcall, Abi::Fastcall, Abi::Vectorcall, Abi::Thiscall, Abi::Win64, Abi::SysV64]
|
||||
vec![
|
||||
Abi::Stdcall { unwind: false },
|
||||
Abi::Stdcall { unwind: true },
|
||||
Abi::Fastcall,
|
||||
Abi::Vectorcall,
|
||||
Abi::Thiscall { unwind: false },
|
||||
Abi::Thiscall { unwind: true },
|
||||
Abi::Win64,
|
||||
Abi::SysV64,
|
||||
]
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ pub fn target() -> Target {
|
|||
let mut base = super::android_base::opts();
|
||||
base.features = "+v7,+thumb-mode,+thumb2,+vfp3,-d32,-neon".to_string();
|
||||
base.max_atomic_width = Some(64);
|
||||
base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-march=armv7-a".to_string());
|
||||
base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-march=armv7-a".to_string());
|
||||
|
||||
Target {
|
||||
llvm_target: "armv7-none-linux-android".to_string(),
|
||||
|
|
|
@ -13,7 +13,6 @@ pub fn target() -> Target {
|
|||
|
||||
options: TargetOptions {
|
||||
features: "+v7,+thumb2,+soft-float,-neon".to_string(),
|
||||
cpu: "generic".to_string(),
|
||||
max_atomic_width: Some(64),
|
||||
unsupported_abis: super::arm_base::unsupported_abis(),
|
||||
mcount: "\u{1}__gnu_mcount_nc".to_string(),
|
||||
|
|
|
@ -14,7 +14,6 @@ pub fn target() -> Target {
|
|||
options: TargetOptions {
|
||||
// Info about features at https://wiki.debian.org/ArmHardFloatPort
|
||||
features: "+v7,+vfp3,-d32,+thumb2,-neon".to_string(),
|
||||
cpu: "generic".to_string(),
|
||||
max_atomic_width: Some(64),
|
||||
unsupported_abis: super::arm_base::unsupported_abis(),
|
||||
mcount: "\u{1}__gnu_mcount_nc".to_string(),
|
||||
|
|
|
@ -18,7 +18,6 @@ pub fn target() -> Target {
|
|||
|
||||
options: TargetOptions {
|
||||
features: "+v7,+thumb2,+soft-float,-neon".to_string(),
|
||||
cpu: "generic".to_string(),
|
||||
max_atomic_width: Some(64),
|
||||
unsupported_abis: super::arm_base::unsupported_abis(),
|
||||
mcount: "\u{1}mcount".to_string(),
|
||||
|
|
|
@ -17,7 +17,6 @@ pub fn target() -> Target {
|
|||
// target.
|
||||
options: TargetOptions {
|
||||
features: "+v7,+vfp3,-d32,+thumb2,-neon".to_string(),
|
||||
cpu: "generic".to_string(),
|
||||
max_atomic_width: Some(64),
|
||||
unsupported_abis: super::arm_base::unsupported_abis(),
|
||||
mcount: "\u{1}mcount".to_string(),
|
||||
|
|
|
@ -11,7 +11,6 @@ pub fn target() -> Target {
|
|||
options: TargetOptions {
|
||||
env: "eabihf".to_string(),
|
||||
features: "+v7,+vfp3,-d32,+thumb2,-neon".to_string(),
|
||||
cpu: "generic".to_string(),
|
||||
max_atomic_width: Some(64),
|
||||
unsupported_abis: super::arm_base::unsupported_abis(),
|
||||
mcount: "__mcount".to_string(),
|
||||
|
|
|
@ -10,7 +10,6 @@ pub fn target() -> Target {
|
|||
options: TargetOptions {
|
||||
// Info about features at https://wiki.debian.org/ArmHardFloatPort
|
||||
features: "+v7,+vfp3,-d32,+thumb2,-neon".to_string(),
|
||||
cpu: "generic".to_string(),
|
||||
max_atomic_width: Some(64),
|
||||
unsupported_abis: super::arm_base::unsupported_abis(),
|
||||
..base
|
||||
|
|
|
@ -15,28 +15,12 @@ pub fn target(target_cpu: String) -> Target {
|
|||
exe_suffix: ".elf".to_string(),
|
||||
|
||||
linker: Some("avr-gcc".to_owned()),
|
||||
dynamic_linking: false,
|
||||
executables: true,
|
||||
linker_is_gnu: true,
|
||||
has_rpath: false,
|
||||
position_independent_executables: false,
|
||||
eh_frame_header: false,
|
||||
pre_link_args: vec![(
|
||||
LinkerFlavor::Gcc,
|
||||
vec![
|
||||
format!("-mmcu={}", target_cpu),
|
||||
// We want to be able to strip as much executable code as possible
|
||||
// from the linker command line, and this flag indicates to the
|
||||
// linker that it can avoid linking in dynamic libraries that don't
|
||||
// actually satisfy any symbols up to that point (as with many other
|
||||
// resolutions the linker does). This option only applies to all
|
||||
// following libraries so we're sure to pass it as one of the first
|
||||
// arguments.
|
||||
"-Wl,--as-needed".to_string(),
|
||||
],
|
||||
)]
|
||||
.into_iter()
|
||||
.collect(),
|
||||
pre_link_args: vec![(LinkerFlavor::Gcc, vec![format!("-mmcu={}", target_cpu)])]
|
||||
.into_iter()
|
||||
.collect(),
|
||||
late_link_args: vec![(LinkerFlavor::Gcc, vec!["-lgcc".to_owned()])]
|
||||
.into_iter()
|
||||
.collect(),
|
||||
|
|
|
@ -108,11 +108,13 @@ pub(super) fn post_mingw() -> CrtObjects {
|
|||
}
|
||||
|
||||
pub(super) fn pre_wasi_fallback() -> CrtObjects {
|
||||
// Use crt1-command.o instead of crt1.o to enable support for new-style
|
||||
// commands. See https://reviews.llvm.org/D81689 for more info.
|
||||
new(&[
|
||||
(LinkOutputKind::DynamicNoPicExe, &["crt1.o"]),
|
||||
(LinkOutputKind::DynamicPicExe, &["crt1.o"]),
|
||||
(LinkOutputKind::StaticNoPicExe, &["crt1.o"]),
|
||||
(LinkOutputKind::StaticPicExe, &["crt1.o"]),
|
||||
(LinkOutputKind::DynamicNoPicExe, &["crt1-command.o"]),
|
||||
(LinkOutputKind::DynamicPicExe, &["crt1-command.o"]),
|
||||
(LinkOutputKind::StaticNoPicExe, &["crt1-command.o"]),
|
||||
(LinkOutputKind::StaticPicExe, &["crt1-command.o"]),
|
||||
(LinkOutputKind::WasiReactorExe, &["crt1-reactor.o"]),
|
||||
])
|
||||
}
|
||||
|
|
|
@ -1,20 +1,6 @@
|
|||
use crate::spec::{LinkArgs, LinkerFlavor, RelroLevel, TargetOptions};
|
||||
use crate::spec::{RelroLevel, TargetOptions};
|
||||
|
||||
pub fn opts() -> TargetOptions {
|
||||
let mut args = LinkArgs::new();
|
||||
args.insert(
|
||||
LinkerFlavor::Gcc,
|
||||
vec![
|
||||
// GNU-style linkers will use this to omit linking to libraries
|
||||
// which don't actually fulfill any relocations, but only for
|
||||
// libraries which follow this flag. Thus, use it before
|
||||
// specifying libraries to link to.
|
||||
"-Wl,--as-needed".to_string(),
|
||||
// Always enable NX protection when it is available
|
||||
"-Wl,-z,noexecstack".to_string(),
|
||||
],
|
||||
);
|
||||
|
||||
TargetOptions {
|
||||
os: "dragonfly".to_string(),
|
||||
dynamic_linking: true,
|
||||
|
@ -22,7 +8,6 @@ pub fn opts() -> TargetOptions {
|
|||
os_family: Some("unix".to_string()),
|
||||
linker_is_gnu: true,
|
||||
has_rpath: true,
|
||||
pre_link_args: args,
|
||||
position_independent_executables: true,
|
||||
relro_level: RelroLevel::Full,
|
||||
dwarf_version: Some(2),
|
||||
|
|
|
@ -1,20 +1,6 @@
|
|||
use crate::spec::{LinkArgs, LinkerFlavor, RelroLevel, TargetOptions};
|
||||
use crate::spec::{RelroLevel, TargetOptions};
|
||||
|
||||
pub fn opts() -> TargetOptions {
|
||||
let mut args = LinkArgs::new();
|
||||
args.insert(
|
||||
LinkerFlavor::Gcc,
|
||||
vec![
|
||||
// GNU-style linkers will use this to omit linking to libraries
|
||||
// which don't actually fulfill any relocations, but only for
|
||||
// libraries which follow this flag. Thus, use it before
|
||||
// specifying libraries to link to.
|
||||
"-Wl,--as-needed".to_string(),
|
||||
// Always enable NX protection when it is available
|
||||
"-Wl,-z,noexecstack".to_string(),
|
||||
],
|
||||
);
|
||||
|
||||
TargetOptions {
|
||||
os: "freebsd".to_string(),
|
||||
dynamic_linking: true,
|
||||
|
@ -22,7 +8,6 @@ pub fn opts() -> TargetOptions {
|
|||
os_family: Some("unix".to_string()),
|
||||
linker_is_gnu: true,
|
||||
has_rpath: true,
|
||||
pre_link_args: args,
|
||||
position_independent_executables: true,
|
||||
eliminate_frame_pointer: false, // FIXME 43575
|
||||
relro_level: RelroLevel::Full,
|
||||
|
|
|
@ -23,13 +23,11 @@ pub fn opts() -> TargetOptions {
|
|||
os: "fuchsia".to_string(),
|
||||
linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
|
||||
linker: Some("rust-lld".to_owned()),
|
||||
lld_flavor: LldFlavor::Ld,
|
||||
dynamic_linking: true,
|
||||
executables: true,
|
||||
os_family: Some("unix".to_string()),
|
||||
is_like_fuchsia: true,
|
||||
linker_is_gnu: true,
|
||||
has_rpath: false,
|
||||
pre_link_args,
|
||||
pre_link_objects: crt_objects::new(&[
|
||||
(LinkOutputKind::DynamicNoPicExe, &["Scrt1.o"]),
|
||||
|
|
|
@ -5,7 +5,6 @@ pub fn opts() -> TargetOptions {
|
|||
os: "haiku".to_string(),
|
||||
dynamic_linking: true,
|
||||
executables: true,
|
||||
has_rpath: false,
|
||||
os_family: Some("unix".to_string()),
|
||||
relro_level: RelroLevel::Full,
|
||||
linker_is_gnu: true,
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
use crate::spec::{LinkArgs, LinkerFlavor, LldFlavor, PanicStrategy};
|
||||
use crate::spec::{RelocModel, TargetOptions, TlsModel};
|
||||
use crate::spec::{LinkArgs, LinkerFlavor, LldFlavor, PanicStrategy, TargetOptions, TlsModel};
|
||||
|
||||
pub fn opts() -> TargetOptions {
|
||||
let mut pre_link_args = LinkArgs::new();
|
||||
|
@ -19,8 +18,6 @@ pub fn opts() -> TargetOptions {
|
|||
panic_strategy: PanicStrategy::Abort,
|
||||
position_independent_executables: true,
|
||||
static_position_independent_executables: true,
|
||||
relocation_model: RelocModel::Pic,
|
||||
os_family: None,
|
||||
tls_model: TlsModel::InitialExec,
|
||||
..Default::default()
|
||||
}
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
use crate::spec::{LinkArgs, LinkerFlavor, LldFlavor, PanicStrategy};
|
||||
use crate::spec::{RelocModel, TargetOptions, TlsModel};
|
||||
use crate::spec::{LinkArgs, LinkerFlavor, LldFlavor, PanicStrategy, TargetOptions, TlsModel};
|
||||
|
||||
pub fn opts() -> TargetOptions {
|
||||
let mut pre_link_args = LinkArgs::new();
|
||||
|
@ -20,8 +19,6 @@ pub fn opts() -> TargetOptions {
|
|||
panic_strategy: PanicStrategy::Abort,
|
||||
position_independent_executables: true,
|
||||
static_position_independent_executables: true,
|
||||
relocation_model: RelocModel::Pic,
|
||||
os_family: None,
|
||||
tls_model: TlsModel::InitialExec,
|
||||
..Default::default()
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use crate::spec::{LinkArgs, Target};
|
||||
use crate::spec::Target;
|
||||
|
||||
pub fn target() -> Target {
|
||||
let mut base = super::linux_musl_base::opts();
|
||||
|
@ -8,15 +8,11 @@ pub fn target() -> Target {
|
|||
base.features = "-small-data,+hvx-length128b".to_string();
|
||||
|
||||
base.crt_static_default = false;
|
||||
base.atomic_cas = true;
|
||||
base.has_rpath = true;
|
||||
base.linker_is_gnu = false;
|
||||
base.dynamic_linking = true;
|
||||
base.executables = true;
|
||||
|
||||
base.pre_link_args = LinkArgs::new();
|
||||
base.post_link_args = LinkArgs::new();
|
||||
|
||||
Target {
|
||||
llvm_target: "hexagon-unknown-linux-musl".to_string(),
|
||||
pointer_width: 32,
|
||||
|
|
|
@ -12,8 +12,8 @@ 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.pre_link_args
|
||||
.get_mut(&LinkerFlavor::Gcc)
|
||||
.unwrap()
|
||||
.entry(LinkerFlavor::Gcc)
|
||||
.or_default()
|
||||
.push("-Wl,--large-address-aware".to_string());
|
||||
|
||||
Target {
|
||||
|
|
|
@ -14,10 +14,10 @@ pub fn target() -> Target {
|
|||
// https://docs.microsoft.com/en-us/cpp/build/reference/safeseh-image-has-safe-exception-handlers
|
||||
"/SAFESEH".to_string(),
|
||||
];
|
||||
base.pre_link_args.get_mut(&LinkerFlavor::Msvc).unwrap().extend(pre_link_args_msvc.clone());
|
||||
base.pre_link_args.entry(LinkerFlavor::Msvc).or_default().extend(pre_link_args_msvc.clone());
|
||||
base.pre_link_args
|
||||
.get_mut(&LinkerFlavor::Lld(LldFlavor::Link))
|
||||
.unwrap()
|
||||
.entry(LinkerFlavor::Lld(LldFlavor::Link))
|
||||
.or_default()
|
||||
.extend(pre_link_args_msvc);
|
||||
|
||||
Target {
|
||||
|
|
|
@ -4,7 +4,7 @@ pub fn target() -> Target {
|
|||
let mut base = super::freebsd_base::opts();
|
||||
base.cpu = "pentium4".to_string();
|
||||
base.max_atomic_width = Some(64);
|
||||
let pre_link_args = base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap();
|
||||
let pre_link_args = base.pre_link_args.entry(LinkerFlavor::Gcc).or_default();
|
||||
pre_link_args.push("-m32".to_string());
|
||||
pre_link_args.push("-Wl,-znotext".to_string());
|
||||
base.stack_probes = StackProbeType::InlineOrCall { min_llvm_version_for_inline: (11, 0, 1) };
|
||||
|
|
|
@ -4,7 +4,7 @@ pub fn target() -> Target {
|
|||
let mut base = super::linux_gnu_base::opts();
|
||||
base.cpu = "pentium4".to_string();
|
||||
base.max_atomic_width = Some(64);
|
||||
base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-m32".to_string());
|
||||
base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-m32".to_string());
|
||||
base.stack_probes = StackProbeType::InlineOrCall { min_llvm_version_for_inline: (11, 0, 1) };
|
||||
|
||||
Target {
|
||||
|
|
|
@ -4,8 +4,8 @@ pub fn target() -> Target {
|
|||
let mut base = super::linux_musl_base::opts();
|
||||
base.cpu = "pentium4".to_string();
|
||||
base.max_atomic_width = Some(64);
|
||||
base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-m32".to_string());
|
||||
base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-Wl,-melf_i386".to_string());
|
||||
base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-m32".to_string());
|
||||
base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-Wl,-melf_i386".to_string());
|
||||
base.stack_probes = StackProbeType::InlineOrCall { min_llvm_version_for_inline: (11, 0, 1) };
|
||||
|
||||
// The unwinder used by i686-unknown-linux-musl, the LLVM libunwind
|
||||
|
|
|
@ -4,7 +4,7 @@ pub fn target() -> Target {
|
|||
let mut base = super::netbsd_base::opts();
|
||||
base.cpu = "pentium4".to_string();
|
||||
base.max_atomic_width = Some(64);
|
||||
base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-m32".to_string());
|
||||
base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-m32".to_string());
|
||||
base.stack_probes = StackProbeType::InlineOrCall { min_llvm_version_for_inline: (11, 0, 1) };
|
||||
|
||||
Target {
|
||||
|
|
|
@ -4,8 +4,8 @@ pub fn target() -> Target {
|
|||
let mut base = super::openbsd_base::opts();
|
||||
base.cpu = "pentium4".to_string();
|
||||
base.max_atomic_width = Some(64);
|
||||
base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-m32".to_string());
|
||||
base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-fuse-ld=lld".to_string());
|
||||
base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-m32".to_string());
|
||||
base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-fuse-ld=lld".to_string());
|
||||
base.stack_probes = StackProbeType::InlineOrCall { min_llvm_version_for_inline: (11, 0, 1) };
|
||||
|
||||
Target {
|
||||
|
|
|
@ -11,8 +11,8 @@ 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.pre_link_args
|
||||
.get_mut(&LinkerFlavor::Gcc)
|
||||
.unwrap()
|
||||
.entry(LinkerFlavor::Gcc)
|
||||
.or_default()
|
||||
.push("-Wl,--large-address-aware".to_string());
|
||||
|
||||
Target {
|
||||
|
|
|
@ -4,7 +4,7 @@ pub fn target() -> Target {
|
|||
let mut base = super::vxworks_base::opts();
|
||||
base.cpu = "pentium4".to_string();
|
||||
base.max_atomic_width = Some(64);
|
||||
base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-m32".to_string());
|
||||
base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-m32".to_string());
|
||||
base.stack_probes = StackProbeType::InlineOrCall { min_llvm_version_for_inline: (11, 0, 1) };
|
||||
|
||||
Target {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use crate::spec::{LinkArgs, LinkerFlavor, PanicStrategy, TargetOptions};
|
||||
use crate::spec::{LinkerFlavor, PanicStrategy, TargetOptions};
|
||||
//use std::process::Command;
|
||||
|
||||
// Use GCC to locate code for crt* libraries from the host, not from L4Re. Note
|
||||
|
@ -13,18 +13,13 @@ use crate::spec::{LinkArgs, LinkerFlavor, PanicStrategy, TargetOptions};
|
|||
//}
|
||||
|
||||
pub fn opts() -> TargetOptions {
|
||||
let mut args = LinkArgs::new();
|
||||
args.insert(LinkerFlavor::Gcc, vec![]);
|
||||
|
||||
TargetOptions {
|
||||
os: "l4re".to_string(),
|
||||
env: "uclibc".to_string(),
|
||||
linker_flavor: LinkerFlavor::Ld,
|
||||
executables: true,
|
||||
has_elf_tls: false,
|
||||
panic_strategy: PanicStrategy::Abort,
|
||||
linker: Some("ld".to_string()),
|
||||
pre_link_args: args,
|
||||
os_family: Some("unix".to_string()),
|
||||
..Default::default()
|
||||
}
|
||||
|
|
|
@ -1,23 +1,6 @@
|
|||
use crate::spec::{LinkArgs, LinkerFlavor, RelroLevel, TargetOptions};
|
||||
use crate::spec::{RelroLevel, TargetOptions};
|
||||
|
||||
pub fn opts() -> TargetOptions {
|
||||
let mut args = LinkArgs::new();
|
||||
args.insert(
|
||||
LinkerFlavor::Gcc,
|
||||
vec![
|
||||
// We want to be able to strip as much executable code as possible
|
||||
// from the linker command line, and this flag indicates to the
|
||||
// linker that it can avoid linking in dynamic libraries that don't
|
||||
// actually satisfy any symbols up to that point (as with many other
|
||||
// resolutions the linker does). This option only applies to all
|
||||
// following libraries so we're sure to pass it as one of the first
|
||||
// arguments.
|
||||
"-Wl,--as-needed".to_string(),
|
||||
// Always enable NX protection when it is available
|
||||
"-Wl,-z,noexecstack".to_string(),
|
||||
],
|
||||
);
|
||||
|
||||
TargetOptions {
|
||||
os: "linux".to_string(),
|
||||
dynamic_linking: true,
|
||||
|
@ -25,7 +8,6 @@ pub fn opts() -> TargetOptions {
|
|||
os_family: Some("unix".to_string()),
|
||||
linker_is_gnu: true,
|
||||
has_rpath: true,
|
||||
pre_link_args: args,
|
||||
position_independent_executables: true,
|
||||
relro_level: RelroLevel::Full,
|
||||
has_elf_tls: true,
|
||||
|
|
|
@ -1,14 +1,6 @@
|
|||
use crate::spec::{
|
||||
LinkArgs, LinkerFlavor, PanicStrategy, RelocModel, RelroLevel, StackProbeType, TargetOptions,
|
||||
};
|
||||
use crate::spec::{PanicStrategy, RelocModel, RelroLevel, StackProbeType, TargetOptions};
|
||||
|
||||
pub fn opts() -> TargetOptions {
|
||||
let mut pre_link_args = LinkArgs::new();
|
||||
pre_link_args.insert(
|
||||
LinkerFlavor::Gcc,
|
||||
vec!["-Wl,--as-needed".to_string(), "-Wl,-z,noexecstack".to_string()],
|
||||
);
|
||||
|
||||
TargetOptions {
|
||||
env: "gnu".to_string(),
|
||||
disable_redzone: true,
|
||||
|
@ -20,7 +12,6 @@ pub fn opts() -> TargetOptions {
|
|||
needs_plt: true,
|
||||
relro_level: RelroLevel::Full,
|
||||
relocation_model: RelocModel::Static,
|
||||
pre_link_args,
|
||||
|
||||
..Default::default()
|
||||
}
|
||||
|
|
|
@ -23,10 +23,12 @@ pub fn target() -> Target {
|
|||
panic_strategy: PanicStrategy::Abort,
|
||||
relocation_model: RelocModel::Static,
|
||||
unsupported_abis: vec![
|
||||
Abi::Stdcall,
|
||||
Abi::Stdcall { unwind: false },
|
||||
Abi::Stdcall { unwind: true },
|
||||
Abi::Fastcall,
|
||||
Abi::Vectorcall,
|
||||
Abi::Thiscall,
|
||||
Abi::Thiscall { unwind: false },
|
||||
Abi::Thiscall { unwind: true },
|
||||
Abi::Win64,
|
||||
Abi::SysV64,
|
||||
],
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
use crate::abi::Endian;
|
||||
use crate::spec::abi::{lookup as lookup_abi, Abi};
|
||||
use crate::spec::crt_objects::{CrtObjects, CrtObjectsFallback};
|
||||
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
|
||||
use rustc_serialize::json::{Json, ToJson};
|
||||
use rustc_span::symbol::{sym, Symbol};
|
||||
use std::collections::BTreeMap;
|
||||
|
@ -78,7 +79,7 @@ mod solaris_base;
|
|||
mod thumb_base;
|
||||
mod uefi_msvc_base;
|
||||
mod vxworks_base;
|
||||
mod wasm32_base;
|
||||
mod wasm_base;
|
||||
mod windows_gnu_base;
|
||||
mod windows_msvc_base;
|
||||
mod windows_uwp_gnu_base;
|
||||
|
@ -511,38 +512,6 @@ impl fmt::Display for SplitDebuginfo {
|
|||
}
|
||||
}
|
||||
|
||||
macro_rules! supported_targets {
|
||||
( $(($( $triple:literal, )+ $module:ident ),)+ ) => {
|
||||
$(mod $module;)+
|
||||
|
||||
/// List of supported targets
|
||||
pub const TARGETS: &[&str] = &[$($($triple),+),+];
|
||||
|
||||
fn load_builtin(target: &str) -> Option<Target> {
|
||||
let mut t = match target {
|
||||
$( $($triple)|+ => $module::target(), )+
|
||||
_ => return None,
|
||||
};
|
||||
t.is_builtin = true;
|
||||
debug!("got builtin target: {:?}", t);
|
||||
Some(t)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
mod tests_impl;
|
||||
|
||||
// Cannot put this into a separate file without duplication, make an exception.
|
||||
$(
|
||||
#[test] // `#[test]`
|
||||
fn $module() {
|
||||
tests_impl::test_target(super::$module::target());
|
||||
}
|
||||
)+
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub enum StackProbeType {
|
||||
/// Don't emit any stack probes.
|
||||
|
@ -620,6 +589,117 @@ impl ToJson for StackProbeType {
|
|||
}
|
||||
}
|
||||
|
||||
bitflags::bitflags! {
|
||||
#[derive(Default, Encodable, Decodable)]
|
||||
pub struct SanitizerSet: u8 {
|
||||
const ADDRESS = 1 << 0;
|
||||
const LEAK = 1 << 1;
|
||||
const MEMORY = 1 << 2;
|
||||
const THREAD = 1 << 3;
|
||||
const HWADDRESS = 1 << 4;
|
||||
}
|
||||
}
|
||||
|
||||
impl SanitizerSet {
|
||||
/// Return sanitizer's name
|
||||
///
|
||||
/// Returns none if the flags is a set of sanitizers numbering not exactly one.
|
||||
fn as_str(self) -> Option<&'static str> {
|
||||
Some(match self {
|
||||
SanitizerSet::ADDRESS => "address",
|
||||
SanitizerSet::LEAK => "leak",
|
||||
SanitizerSet::MEMORY => "memory",
|
||||
SanitizerSet::THREAD => "thread",
|
||||
SanitizerSet::HWADDRESS => "hwaddress",
|
||||
_ => return None,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/// Formats a sanitizer set as a comma separated list of sanitizers' names.
|
||||
impl fmt::Display for SanitizerSet {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
let mut first = true;
|
||||
for s in *self {
|
||||
let name = s.as_str().unwrap_or_else(|| panic!("unrecognized sanitizer {:?}", s));
|
||||
if !first {
|
||||
f.write_str(", ")?;
|
||||
}
|
||||
f.write_str(name)?;
|
||||
first = false;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl IntoIterator for SanitizerSet {
|
||||
type Item = SanitizerSet;
|
||||
type IntoIter = std::vec::IntoIter<SanitizerSet>;
|
||||
|
||||
fn into_iter(self) -> Self::IntoIter {
|
||||
[
|
||||
SanitizerSet::ADDRESS,
|
||||
SanitizerSet::LEAK,
|
||||
SanitizerSet::MEMORY,
|
||||
SanitizerSet::THREAD,
|
||||
SanitizerSet::HWADDRESS,
|
||||
]
|
||||
.iter()
|
||||
.copied()
|
||||
.filter(|&s| self.contains(s))
|
||||
.collect::<Vec<_>>()
|
||||
.into_iter()
|
||||
}
|
||||
}
|
||||
|
||||
impl<CTX> HashStable<CTX> for SanitizerSet {
|
||||
fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) {
|
||||
self.bits().hash_stable(ctx, hasher);
|
||||
}
|
||||
}
|
||||
|
||||
impl ToJson for SanitizerSet {
|
||||
fn to_json(&self) -> Json {
|
||||
self.into_iter()
|
||||
.map(|v| Some(v.as_str()?.to_json()))
|
||||
.collect::<Option<Vec<_>>>()
|
||||
.unwrap_or(Vec::new())
|
||||
.to_json()
|
||||
}
|
||||
}
|
||||
|
||||
macro_rules! supported_targets {
|
||||
( $(($( $triple:literal, )+ $module:ident ),)+ ) => {
|
||||
$(mod $module;)+
|
||||
|
||||
/// List of supported targets
|
||||
pub const TARGETS: &[&str] = &[$($($triple),+),+];
|
||||
|
||||
fn load_builtin(target: &str) -> Option<Target> {
|
||||
let mut t = match target {
|
||||
$( $($triple)|+ => $module::target(), )+
|
||||
_ => return None,
|
||||
};
|
||||
t.is_builtin = true;
|
||||
debug!("got builtin target: {:?}", t);
|
||||
Some(t)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
mod tests_impl;
|
||||
|
||||
// Cannot put this into a separate file without duplication, make an exception.
|
||||
$(
|
||||
#[test] // `#[test]`
|
||||
fn $module() {
|
||||
tests_impl::test_target(super::$module::target());
|
||||
}
|
||||
)+
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
supported_targets! {
|
||||
("x86_64-unknown-linux-gnu", x86_64_unknown_linux_gnu),
|
||||
("x86_64-unknown-linux-gnux32", x86_64_unknown_linux_gnux32),
|
||||
|
@ -679,7 +759,7 @@ supported_targets! {
|
|||
("thumbv7neon-linux-androideabi", thumbv7neon_linux_androideabi),
|
||||
("aarch64-linux-android", aarch64_linux_android),
|
||||
|
||||
("x86_64-linux-kernel", x86_64_linux_kernel),
|
||||
("x86_64-unknown-none-linuxkernel", x86_64_unknown_none_linuxkernel),
|
||||
|
||||
("aarch64-unknown-freebsd", aarch64_unknown_freebsd),
|
||||
("armv6-unknown-freebsd", armv6_unknown_freebsd),
|
||||
|
@ -694,6 +774,7 @@ supported_targets! {
|
|||
("i686-unknown-openbsd", i686_unknown_openbsd),
|
||||
("sparc64-unknown-openbsd", sparc64_unknown_openbsd),
|
||||
("x86_64-unknown-openbsd", x86_64_unknown_openbsd),
|
||||
("powerpc-unknown-openbsd", powerpc_unknown_openbsd),
|
||||
|
||||
("aarch64-unknown-netbsd", aarch64_unknown_netbsd),
|
||||
("armv6-unknown-netbsd-eabihf", armv6_unknown_netbsd_eabihf),
|
||||
|
@ -761,6 +842,7 @@ supported_targets! {
|
|||
("wasm32-unknown-emscripten", wasm32_unknown_emscripten),
|
||||
("wasm32-unknown-unknown", wasm32_unknown_unknown),
|
||||
("wasm32-wasi", wasm32_wasi),
|
||||
("wasm64-unknown-unknown", wasm64_unknown_unknown),
|
||||
|
||||
("thumbv6m-none-eabi", thumbv6m_none_eabi),
|
||||
("thumbv7m-none-eabi", thumbv7m_none_eabi),
|
||||
|
@ -777,7 +859,8 @@ supported_targets! {
|
|||
|
||||
("aarch64-unknown-hermit", aarch64_unknown_hermit),
|
||||
("x86_64-unknown-hermit", x86_64_unknown_hermit),
|
||||
("x86_64-unknown-hermit-kernel", x86_64_unknown_hermit_kernel),
|
||||
|
||||
("x86_64-unknown-none-hermitkernel", x86_64_unknown_none_hermitkernel),
|
||||
|
||||
("riscv32i-unknown-none-elf", riscv32i_unknown_none_elf),
|
||||
("riscv32imc-unknown-none-elf", riscv32imc_unknown_none_elf),
|
||||
|
@ -994,6 +1077,8 @@ pub struct TargetOptions {
|
|||
pub is_like_emscripten: bool,
|
||||
/// Whether the target toolchain is like Fuchsia's.
|
||||
pub is_like_fuchsia: bool,
|
||||
/// Whether a target toolchain is like WASM.
|
||||
pub is_like_wasm: bool,
|
||||
/// Version of DWARF to use if not using the default.
|
||||
/// Useful because some platforms (osx, bsd) only want up to DWARF2.
|
||||
pub dwarf_version: Option<u32>,
|
||||
|
@ -1109,6 +1194,10 @@ pub struct TargetOptions {
|
|||
/// unwinders.
|
||||
pub requires_uwtable: bool,
|
||||
|
||||
/// Whether or not to emit `uwtable` attributes on functions if `-C force-unwind-tables`
|
||||
/// is not specified and `uwtable` is not required on this target.
|
||||
pub default_uwtable: bool,
|
||||
|
||||
/// Whether or not SIMD types are passed by reference in the Rust ABI,
|
||||
/// typically required if a target can be compiled with a mixed set of
|
||||
/// target features. This is `true` by default, and `false` for targets like
|
||||
|
@ -1158,6 +1247,16 @@ pub struct TargetOptions {
|
|||
/// How to handle split debug information, if at all. Specifying `None` has
|
||||
/// target-specific meaning.
|
||||
pub split_debuginfo: SplitDebuginfo,
|
||||
|
||||
/// The sanitizers supported by this target
|
||||
///
|
||||
/// Note that the support here is at a codegen level. If the machine code with sanitizer
|
||||
/// enabled can generated on this target, but the necessary supporting libraries are not
|
||||
/// distributed with the target, the sanitizer should still appear in this list for the target.
|
||||
pub supported_sanitizers: SanitizerSet,
|
||||
|
||||
/// If present it's a default value to use for adjusting the C ABI.
|
||||
pub default_adjusted_cabi: Option<Abi>,
|
||||
}
|
||||
|
||||
impl Default for TargetOptions {
|
||||
|
@ -1202,6 +1301,7 @@ impl Default for TargetOptions {
|
|||
is_like_emscripten: false,
|
||||
is_like_msvc: false,
|
||||
is_like_fuchsia: false,
|
||||
is_like_wasm: false,
|
||||
dwarf_version: None,
|
||||
linker_is_gnu: false,
|
||||
allows_weak_linkage: true,
|
||||
|
@ -1246,6 +1346,7 @@ impl Default for TargetOptions {
|
|||
default_hidden_visibility: false,
|
||||
emit_debug_gdb_scripts: true,
|
||||
requires_uwtable: false,
|
||||
default_uwtable: false,
|
||||
simd_types_indirect: true,
|
||||
limit_rdylib_exports: true,
|
||||
override_export_symbols: None,
|
||||
|
@ -1258,6 +1359,8 @@ impl Default for TargetOptions {
|
|||
eh_frame_header: true,
|
||||
has_thumb_interworking: false,
|
||||
split_debuginfo: SplitDebuginfo::Off,
|
||||
supported_sanitizers: SanitizerSet::empty(),
|
||||
default_adjusted_cabi: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1282,26 +1385,36 @@ impl Target {
|
|||
/// Given a function ABI, turn it into the correct ABI for this target.
|
||||
pub fn adjust_abi(&self, abi: Abi) -> Abi {
|
||||
match abi {
|
||||
Abi::System => {
|
||||
Abi::System { unwind } => {
|
||||
if self.is_like_windows && self.arch == "x86" {
|
||||
Abi::Stdcall
|
||||
Abi::Stdcall { unwind }
|
||||
} else {
|
||||
Abi::C
|
||||
Abi::C { unwind }
|
||||
}
|
||||
}
|
||||
// These ABI kinds are ignored on non-x86 Windows targets.
|
||||
// See https://docs.microsoft.com/en-us/cpp/cpp/argument-passing-and-naming-conventions
|
||||
// and the individual pages for __stdcall et al.
|
||||
Abi::Stdcall | Abi::Fastcall | Abi::Vectorcall | Abi::Thiscall => {
|
||||
if self.is_like_windows && self.arch != "x86" { Abi::C } else { abi }
|
||||
Abi::Stdcall { unwind } | Abi::Thiscall { unwind } => {
|
||||
if self.is_like_windows && self.arch != "x86" { Abi::C { unwind } } else { abi }
|
||||
}
|
||||
Abi::Fastcall | Abi::Vectorcall => {
|
||||
if self.is_like_windows && self.arch != "x86" {
|
||||
Abi::C { unwind: false }
|
||||
} else {
|
||||
abi
|
||||
}
|
||||
}
|
||||
Abi::EfiApi => {
|
||||
if self.arch == "x86_64" {
|
||||
Abi::Win64
|
||||
} else {
|
||||
Abi::C
|
||||
Abi::C { unwind: false }
|
||||
}
|
||||
}
|
||||
|
||||
Abi::C { unwind } => self.default_adjusted_cabi.unwrap_or(Abi::C { unwind }),
|
||||
|
||||
abi => abi,
|
||||
}
|
||||
}
|
||||
|
@ -1333,8 +1446,8 @@ impl Target {
|
|||
|
||||
let get_req_field = |name: &str| {
|
||||
obj.find(name)
|
||||
.map(|s| s.as_string())
|
||||
.and_then(|os| os.map(|s| s.to_string()))
|
||||
.and_then(Json::as_string)
|
||||
.map(str::to_string)
|
||||
.ok_or_else(|| format!("Field {} in target specification is required", name))
|
||||
};
|
||||
|
||||
|
@ -1537,6 +1650,24 @@ impl Target {
|
|||
)),
|
||||
}).unwrap_or(Ok(()))
|
||||
} );
|
||||
($key_name:ident, SanitizerSet) => ( {
|
||||
let name = (stringify!($key_name)).replace("_", "-");
|
||||
obj.find(&name[..]).and_then(|o| o.as_array()).and_then(|a| {
|
||||
for s in a {
|
||||
base.$key_name |= match s.as_string() {
|
||||
Some("address") => SanitizerSet::ADDRESS,
|
||||
Some("leak") => SanitizerSet::LEAK,
|
||||
Some("memory") => SanitizerSet::MEMORY,
|
||||
Some("thread") => SanitizerSet::THREAD,
|
||||
Some("hwaddress") => SanitizerSet::HWADDRESS,
|
||||
Some(s) => return Some(Err(format!("unknown sanitizer {}", s))),
|
||||
_ => return Some(Err(format!("not a string: {:?}", s))),
|
||||
};
|
||||
}
|
||||
Some(Ok(()))
|
||||
}).unwrap_or(Ok(()))
|
||||
} );
|
||||
|
||||
($key_name:ident, crt_objects_fallback) => ( {
|
||||
let name = (stringify!($key_name)).replace("_", "-");
|
||||
obj.find(&name[..]).and_then(|o| o.as_string().and_then(|s| {
|
||||
|
@ -1618,6 +1749,16 @@ impl Target {
|
|||
}
|
||||
}
|
||||
} );
|
||||
($key_name:ident, Option<Abi>) => ( {
|
||||
let name = (stringify!($key_name)).replace("_", "-");
|
||||
obj.find(&name[..]).and_then(|o| o.as_string().and_then(|s| {
|
||||
match lookup_abi(s) {
|
||||
Some(abi) => base.$key_name = Some(abi),
|
||||
_ => return Some(Err(format!("'{}' is not a valid value for abi", s))),
|
||||
}
|
||||
Some(Ok(()))
|
||||
})).unwrap_or(Ok(()))
|
||||
} );
|
||||
}
|
||||
|
||||
if let Some(s) = obj.find("target-endian").and_then(Json::as_string) {
|
||||
|
@ -1669,6 +1810,7 @@ impl Target {
|
|||
key!(is_like_msvc, bool);
|
||||
key!(is_like_emscripten, bool);
|
||||
key!(is_like_fuchsia, bool);
|
||||
key!(is_like_wasm, bool);
|
||||
key!(dwarf_version, Option<u32>);
|
||||
key!(linker_is_gnu, bool);
|
||||
key!(allows_weak_linkage, bool);
|
||||
|
@ -1702,6 +1844,7 @@ impl Target {
|
|||
key!(default_hidden_visibility, bool);
|
||||
key!(emit_debug_gdb_scripts, bool);
|
||||
key!(requires_uwtable, bool);
|
||||
key!(default_uwtable, bool);
|
||||
key!(simd_types_indirect, bool);
|
||||
key!(limit_rdylib_exports, bool);
|
||||
key!(override_export_symbols, opt_list);
|
||||
|
@ -1714,6 +1857,8 @@ impl Target {
|
|||
key!(eh_frame_header, bool);
|
||||
key!(has_thumb_interworking, bool);
|
||||
key!(split_debuginfo, SplitDebuginfo)?;
|
||||
key!(supported_sanitizers, SanitizerSet)?;
|
||||
key!(default_adjusted_cabi, Option<Abi>)?;
|
||||
|
||||
// NB: The old name is deprecated, but support for it is retained for
|
||||
// compatibility.
|
||||
|
@ -1914,6 +2059,7 @@ impl ToJson for Target {
|
|||
target_option_val!(is_like_msvc);
|
||||
target_option_val!(is_like_emscripten);
|
||||
target_option_val!(is_like_fuchsia);
|
||||
target_option_val!(is_like_wasm);
|
||||
target_option_val!(dwarf_version);
|
||||
target_option_val!(linker_is_gnu);
|
||||
target_option_val!(allows_weak_linkage);
|
||||
|
@ -1947,6 +2093,7 @@ impl ToJson for Target {
|
|||
target_option_val!(default_hidden_visibility);
|
||||
target_option_val!(emit_debug_gdb_scripts);
|
||||
target_option_val!(requires_uwtable);
|
||||
target_option_val!(default_uwtable);
|
||||
target_option_val!(simd_types_indirect);
|
||||
target_option_val!(limit_rdylib_exports);
|
||||
target_option_val!(override_export_symbols);
|
||||
|
@ -1959,6 +2106,11 @@ impl ToJson for Target {
|
|||
target_option_val!(eh_frame_header);
|
||||
target_option_val!(has_thumb_interworking);
|
||||
target_option_val!(split_debuginfo);
|
||||
target_option_val!(supported_sanitizers);
|
||||
|
||||
if let Some(abi) = self.default_adjusted_cabi {
|
||||
d.insert("default-adjusted-cabi".to_string(), Abi::name(abi).to_json());
|
||||
}
|
||||
|
||||
if default.unsupported_abis != self.unsupported_abis {
|
||||
d.insert(
|
||||
|
|
|
@ -5,13 +5,6 @@ pub fn opts() -> TargetOptions {
|
|||
// Suppress the verbose logo and authorship debugging output, which would needlessly
|
||||
// clog any log files.
|
||||
"/NOLOGO".to_string(),
|
||||
// Tell the compiler that non-code sections can be marked as non-executable,
|
||||
// including stack pages.
|
||||
// UEFI is fully compatible to non-executable data pages.
|
||||
// In fact, firmware might enforce this, so we better let the linker know about this,
|
||||
// so it will fail if the compiler ever tries placing code on the stack
|
||||
// (e.g., trampoline constructs and alike).
|
||||
"/NXCOMPAT".to_string(),
|
||||
];
|
||||
let mut pre_link_args = LinkArgs::new();
|
||||
pre_link_args.insert(LinkerFlavor::Msvc, pre_link_args_msvc.clone());
|
||||
|
|
|
@ -1,18 +1,6 @@
|
|||
use crate::spec::{LinkArgs, LinkerFlavor, RelroLevel, TargetOptions};
|
||||
use crate::spec::{RelroLevel, TargetOptions};
|
||||
|
||||
pub fn opts() -> TargetOptions {
|
||||
let mut args = LinkArgs::new();
|
||||
args.insert(
|
||||
LinkerFlavor::Gcc,
|
||||
vec![
|
||||
// GNU-style linkers will use this to omit linking to libraries
|
||||
// which don't actually fulfill any relocations, but only for
|
||||
// libraries which follow this flag. Thus, use it before
|
||||
// specifying libraries to link to.
|
||||
"-Wl,--as-needed".to_string(),
|
||||
],
|
||||
);
|
||||
|
||||
TargetOptions {
|
||||
os: "netbsd".to_string(),
|
||||
dynamic_linking: true,
|
||||
|
@ -21,7 +9,6 @@ pub fn opts() -> TargetOptions {
|
|||
linker_is_gnu: true,
|
||||
no_default_libraries: false,
|
||||
has_rpath: true,
|
||||
pre_link_args: args,
|
||||
position_independent_executables: true,
|
||||
relro_level: RelroLevel::Full,
|
||||
use_ctors_section: true,
|
||||
|
|
|
@ -49,10 +49,12 @@ pub fn target() -> Target {
|
|||
// create the tests for this.
|
||||
unsupported_abis: vec![
|
||||
Abi::Cdecl,
|
||||
Abi::Stdcall,
|
||||
Abi::Stdcall { unwind: false },
|
||||
Abi::Stdcall { unwind: true },
|
||||
Abi::Fastcall,
|
||||
Abi::Vectorcall,
|
||||
Abi::Thiscall,
|
||||
Abi::Thiscall { unwind: false },
|
||||
Abi::Thiscall { unwind: true },
|
||||
Abi::Aapcs,
|
||||
Abi::Win64,
|
||||
Abi::SysV64,
|
||||
|
|
|
@ -1,20 +1,6 @@
|
|||
use crate::spec::{LinkArgs, LinkerFlavor, RelroLevel, TargetOptions};
|
||||
use crate::spec::{RelroLevel, TargetOptions};
|
||||
|
||||
pub fn opts() -> TargetOptions {
|
||||
let mut args = LinkArgs::new();
|
||||
args.insert(
|
||||
LinkerFlavor::Gcc,
|
||||
vec![
|
||||
// GNU-style linkers will use this to omit linking to libraries
|
||||
// which don't actually fulfill any relocations, but only for
|
||||
// libraries which follow this flag. Thus, use it before
|
||||
// specifying libraries to link to.
|
||||
"-Wl,--as-needed".to_string(),
|
||||
// Always enable NX protection when it is available
|
||||
"-Wl,-z,noexecstack".to_string(),
|
||||
],
|
||||
);
|
||||
|
||||
TargetOptions {
|
||||
os: "openbsd".to_string(),
|
||||
dynamic_linking: true,
|
||||
|
@ -23,7 +9,6 @@ pub fn opts() -> TargetOptions {
|
|||
linker_is_gnu: true,
|
||||
has_rpath: true,
|
||||
abi_return_struct_as_int: true,
|
||||
pre_link_args: args,
|
||||
position_independent_executables: true,
|
||||
eliminate_frame_pointer: false, // FIXME 43575
|
||||
relro_level: RelroLevel::Full,
|
||||
|
|
|
@ -4,7 +4,7 @@ use crate::spec::{LinkerFlavor, Target, TargetOptions};
|
|||
pub fn target() -> Target {
|
||||
let mut base = super::freebsd_base::opts();
|
||||
base.cpu = "ppc64".to_string();
|
||||
base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-m64".to_string());
|
||||
base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-m64".to_string());
|
||||
base.max_atomic_width = Some(64);
|
||||
|
||||
Target {
|
||||
|
|
|
@ -4,7 +4,7 @@ use crate::spec::{LinkerFlavor, RelroLevel, Target, TargetOptions};
|
|||
pub fn target() -> Target {
|
||||
let mut base = super::linux_gnu_base::opts();
|
||||
base.cpu = "ppc64".to_string();
|
||||
base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-m64".to_string());
|
||||
base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-m64".to_string());
|
||||
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
|
||||
|
|
|
@ -4,7 +4,7 @@ use crate::spec::{LinkerFlavor, Target, TargetOptions};
|
|||
pub fn target() -> Target {
|
||||
let mut base = super::linux_musl_base::opts();
|
||||
base.cpu = "ppc64".to_string();
|
||||
base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-m64".to_string());
|
||||
base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-m64".to_string());
|
||||
base.max_atomic_width = Some(64);
|
||||
|
||||
Target {
|
||||
|
|
|
@ -4,7 +4,7 @@ use crate::spec::{LinkerFlavor, Target, TargetOptions};
|
|||
pub fn target() -> Target {
|
||||
let mut base = super::vxworks_base::opts();
|
||||
base.cpu = "ppc64".to_string();
|
||||
base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-m64".to_string());
|
||||
base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-m64".to_string());
|
||||
base.max_atomic_width = Some(64);
|
||||
|
||||
Target {
|
||||
|
|
|
@ -3,7 +3,7 @@ use crate::spec::{LinkerFlavor, Target, TargetOptions};
|
|||
pub fn target() -> Target {
|
||||
let mut base = super::linux_gnu_base::opts();
|
||||
base.cpu = "ppc64le".to_string();
|
||||
base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-m64".to_string());
|
||||
base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-m64".to_string());
|
||||
base.max_atomic_width = Some(64);
|
||||
|
||||
Target {
|
||||
|
|
|
@ -3,7 +3,7 @@ use crate::spec::{LinkerFlavor, Target, TargetOptions};
|
|||
pub fn target() -> Target {
|
||||
let mut base = super::linux_musl_base::opts();
|
||||
base.cpu = "ppc64le".to_string();
|
||||
base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-m64".to_string());
|
||||
base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-m64".to_string());
|
||||
base.max_atomic_width = Some(64);
|
||||
|
||||
Target {
|
||||
|
|
|
@ -3,7 +3,7 @@ use crate::spec::{LinkerFlavor, Target, TargetOptions};
|
|||
|
||||
pub fn target() -> Target {
|
||||
let mut base = super::linux_gnu_base::opts();
|
||||
base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-m32".to_string());
|
||||
base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-m32".to_string());
|
||||
base.max_atomic_width = Some(32);
|
||||
|
||||
Target {
|
||||
|
|
|
@ -3,7 +3,7 @@ use crate::spec::{LinkerFlavor, Target, TargetOptions};
|
|||
|
||||
pub fn target() -> Target {
|
||||
let mut base = super::linux_gnu_base::opts();
|
||||
base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-mspe".to_string());
|
||||
base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-mspe".to_string());
|
||||
base.max_atomic_width = Some(32);
|
||||
|
||||
Target {
|
||||
|
|
|
@ -3,7 +3,7 @@ use crate::spec::{LinkerFlavor, Target, TargetOptions};
|
|||
|
||||
pub fn target() -> Target {
|
||||
let mut base = super::linux_musl_base::opts();
|
||||
base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-m32".to_string());
|
||||
base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-m32".to_string());
|
||||
base.max_atomic_width = Some(32);
|
||||
|
||||
Target {
|
||||
|
|
|
@ -3,7 +3,7 @@ use crate::spec::{LinkerFlavor, Target, TargetOptions};
|
|||
|
||||
pub fn target() -> Target {
|
||||
let mut base = super::netbsd_base::opts();
|
||||
base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-m32".to_string());
|
||||
base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-m32".to_string());
|
||||
base.max_atomic_width = Some(32);
|
||||
|
||||
Target {
|
||||
|
|
16
compiler/rustc_target/src/spec/powerpc_unknown_openbsd.rs
Normal file
16
compiler/rustc_target/src/spec/powerpc_unknown_openbsd.rs
Normal file
|
@ -0,0 +1,16 @@
|
|||
use crate::abi::Endian;
|
||||
use crate::spec::Target;
|
||||
|
||||
pub fn target() -> Target {
|
||||
let mut base = super::openbsd_base::opts();
|
||||
base.endian = Endian::Big;
|
||||
base.max_atomic_width = Some(32);
|
||||
|
||||
Target {
|
||||
llvm_target: "powerpc-unknown-openbsd".to_string(),
|
||||
pointer_width: 32,
|
||||
data_layout: "E-m:e-p:32:32-i64:64-n32".to_string(),
|
||||
arch: "powerpc".to_string(),
|
||||
options: base,
|
||||
}
|
||||
}
|
|
@ -3,8 +3,8 @@ use crate::spec::{LinkerFlavor, Target, TargetOptions};
|
|||
|
||||
pub fn target() -> Target {
|
||||
let mut base = super::vxworks_base::opts();
|
||||
base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-m32".to_string());
|
||||
base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("--secure-plt".to_string());
|
||||
base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-m32".to_string());
|
||||
base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("--secure-plt".to_string());
|
||||
base.max_atomic_width = Some(32);
|
||||
|
||||
Target {
|
||||
|
|
|
@ -3,8 +3,8 @@ use crate::spec::{LinkerFlavor, Target, TargetOptions};
|
|||
|
||||
pub fn target() -> Target {
|
||||
let mut base = super::vxworks_base::opts();
|
||||
base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-mspe".to_string());
|
||||
base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("--secure-plt".to_string());
|
||||
base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-mspe".to_string());
|
||||
base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("--secure-plt".to_string());
|
||||
base.max_atomic_width = Some(32);
|
||||
|
||||
Target {
|
||||
|
|
|
@ -1,23 +1,6 @@
|
|||
use crate::spec::{LinkArgs, LinkerFlavor, RelroLevel, TargetOptions};
|
||||
use crate::spec::{RelroLevel, TargetOptions};
|
||||
|
||||
pub fn opts() -> TargetOptions {
|
||||
let mut args = LinkArgs::new();
|
||||
args.insert(
|
||||
LinkerFlavor::Gcc,
|
||||
vec![
|
||||
// We want to be able to strip as much executable code as possible
|
||||
// from the linker command line, and this flag indicates to the
|
||||
// linker that it can avoid linking in dynamic libraries that don't
|
||||
// actually satisfy any symbols up to that point (as with many other
|
||||
// resolutions the linker does). This option only applies to all
|
||||
// following libraries so we're sure to pass it as one of the first
|
||||
// arguments.
|
||||
"-Wl,--as-needed".to_string(),
|
||||
// Always enable NX protection when it is available
|
||||
"-Wl,-z,noexecstack".to_string(),
|
||||
],
|
||||
);
|
||||
|
||||
TargetOptions {
|
||||
os: "redox".to_string(),
|
||||
env: "relibc".to_string(),
|
||||
|
@ -26,7 +9,6 @@ pub fn opts() -> TargetOptions {
|
|||
os_family: Some("unix".to_string()),
|
||||
linker_is_gnu: true,
|
||||
has_rpath: true,
|
||||
pre_link_args: args,
|
||||
position_independent_executables: true,
|
||||
relro_level: RelroLevel::Full,
|
||||
has_elf_tls: true,
|
||||
|
|
|
@ -14,7 +14,6 @@ pub fn target() -> Target {
|
|||
cpu: "generic-rv32".to_string(),
|
||||
max_atomic_width: Some(0),
|
||||
atomic_cas: false,
|
||||
features: String::new(),
|
||||
executables: true,
|
||||
panic_strategy: PanicStrategy::Abort,
|
||||
relocation_model: RelocModel::Static,
|
||||
|
|
|
@ -13,7 +13,6 @@ pub fn target() -> Target {
|
|||
linker: Some("rust-lld".to_string()),
|
||||
cpu: "generic-rv32".to_string(),
|
||||
max_atomic_width: Some(32),
|
||||
atomic_cas: true,
|
||||
features: "+m,+a,+c".to_string(),
|
||||
executables: true,
|
||||
panic_strategy: PanicStrategy::Abort,
|
||||
|
|
|
@ -11,9 +11,9 @@ pub fn target() -> Target {
|
|||
options: TargetOptions {
|
||||
linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
|
||||
linker: Some("rust-lld".to_string()),
|
||||
llvm_abiname: "lp64d".to_string(),
|
||||
cpu: "generic-rv64".to_string(),
|
||||
max_atomic_width: Some(64),
|
||||
atomic_cas: true,
|
||||
features: "+m,+a,+f,+d,+c".to_string(),
|
||||
executables: true,
|
||||
panic_strategy: PanicStrategy::Abort,
|
||||
|
|
|
@ -13,7 +13,6 @@ pub fn target() -> Target {
|
|||
linker: Some("rust-lld".to_string()),
|
||||
cpu: "generic-rv64".to_string(),
|
||||
max_atomic_width: Some(64),
|
||||
atomic_cas: true,
|
||||
features: "+m,+a,+c".to_string(),
|
||||
executables: true,
|
||||
panic_strategy: PanicStrategy::Abort,
|
||||
|
|
|
@ -5,10 +5,12 @@ use crate::spec::abi::Abi;
|
|||
pub fn unsupported_abis() -> Vec<Abi> {
|
||||
vec![
|
||||
Abi::Cdecl,
|
||||
Abi::Stdcall,
|
||||
Abi::Stdcall { unwind: false },
|
||||
Abi::Stdcall { unwind: true },
|
||||
Abi::Fastcall,
|
||||
Abi::Vectorcall,
|
||||
Abi::Thiscall,
|
||||
Abi::Thiscall { unwind: false },
|
||||
Abi::Thiscall { unwind: true },
|
||||
Abi::Aapcs,
|
||||
Abi::Win64,
|
||||
Abi::SysV64,
|
||||
|
|
|
@ -4,7 +4,7 @@ use crate::spec::{LinkerFlavor, Target, TargetOptions};
|
|||
pub fn target() -> Target {
|
||||
let mut base = super::netbsd_base::opts();
|
||||
base.cpu = "v9".to_string();
|
||||
base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-m64".to_string());
|
||||
base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-m64".to_string());
|
||||
base.max_atomic_width = Some(64);
|
||||
|
||||
Target {
|
||||
|
|
|
@ -5,7 +5,7 @@ pub fn target() -> Target {
|
|||
let mut base = super::openbsd_base::opts();
|
||||
base.endian = Endian::Big;
|
||||
base.cpu = "v9".to_string();
|
||||
base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-m64".to_string());
|
||||
base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-m64".to_string());
|
||||
base.max_atomic_width = Some(64);
|
||||
|
||||
Target {
|
||||
|
|
|
@ -6,7 +6,7 @@ pub fn target() -> Target {
|
|||
base.endian = Endian::Big;
|
||||
base.cpu = "v9".to_string();
|
||||
base.max_atomic_width = Some(64);
|
||||
base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-mv8plus".to_string());
|
||||
base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-mv8plus".to_string());
|
||||
|
||||
Target {
|
||||
llvm_target: "sparc-unknown-linux-gnu".to_string(),
|
||||
|
|
|
@ -50,6 +50,7 @@ impl Target {
|
|||
// and you certainly want "unknown" for the OS name.
|
||||
fn can_use_os_unknown(&self) -> bool {
|
||||
self.llvm_target == "wasm32-unknown-unknown"
|
||||
|| self.llvm_target == "wasm64-unknown-unknown"
|
||||
|| (self.env == "sgx" && self.vendor == "fortanix")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,9 +45,6 @@ pub fn target() -> Target {
|
|||
|
||||
main_needs_argc_argv: false,
|
||||
|
||||
// No thread-local storage (just use a static Cell)
|
||||
has_elf_tls: false,
|
||||
|
||||
// don't have atomic compare-and-swap
|
||||
atomic_cas: false,
|
||||
has_thumb_interworking: true,
|
||||
|
|
|
@ -11,10 +11,10 @@ pub fn target() -> Target {
|
|||
// where necessary, but this is not the observed behavior.
|
||||
// Disabling the LBR optimization works around the issue.
|
||||
let pre_link_args_msvc = "/OPT:NOLBR".to_string();
|
||||
base.pre_link_args.get_mut(&LinkerFlavor::Msvc).unwrap().push(pre_link_args_msvc.clone());
|
||||
base.pre_link_args.entry(LinkerFlavor::Msvc).or_default().push(pre_link_args_msvc.clone());
|
||||
base.pre_link_args
|
||||
.get_mut(&LinkerFlavor::Lld(LldFlavor::Link))
|
||||
.unwrap()
|
||||
.entry(LinkerFlavor::Lld(LldFlavor::Link))
|
||||
.or_default()
|
||||
.push(pre_link_args_msvc);
|
||||
|
||||
// FIXME(jordanrh): use PanicStrategy::Unwind when SEH is
|
||||
|
@ -29,7 +29,6 @@ pub fn target() -> Target {
|
|||
|
||||
options: TargetOptions {
|
||||
features: "+vfp3,+neon".to_string(),
|
||||
cpu: "generic".to_string(),
|
||||
max_atomic_width: Some(64),
|
||||
unsupported_abis: super::arm_base::unsupported_abis(),
|
||||
..base
|
||||
|
|
|
@ -16,7 +16,6 @@ pub fn target() -> Target {
|
|||
arch: "arm".to_string(),
|
||||
options: TargetOptions {
|
||||
features: "+vfp3,+neon".to_string(),
|
||||
cpu: "generic".to_string(),
|
||||
unsupported_abis: super::arm_base::unsupported_abis(),
|
||||
..base
|
||||
},
|
||||
|
|
|
@ -12,7 +12,7 @@ pub fn target() -> Target {
|
|||
let mut base = super::android_base::opts();
|
||||
base.features = "+v7,+thumb-mode,+thumb2,+vfp3,+neon".to_string();
|
||||
base.max_atomic_width = Some(64);
|
||||
base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-march=armv7-a".to_string());
|
||||
base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-march=armv7-a".to_string());
|
||||
|
||||
Target {
|
||||
llvm_target: "armv7-none-linux-android".to_string(),
|
||||
|
|
|
@ -17,7 +17,6 @@ pub fn target() -> Target {
|
|||
options: TargetOptions {
|
||||
// Info about features at https://wiki.debian.org/ArmHardFloatPort
|
||||
features: "+v7,+thumb-mode,+thumb2,+vfp3,+neon".to_string(),
|
||||
cpu: "generic".to_string(),
|
||||
max_atomic_width: Some(64),
|
||||
unsupported_abis: super::arm_base::unsupported_abis(),
|
||||
..base
|
||||
|
|
|
@ -21,7 +21,6 @@ pub fn target() -> Target {
|
|||
// target.
|
||||
options: TargetOptions {
|
||||
features: "+v7,+thumb-mode,+thumb2,+vfp3,+neon".to_string(),
|
||||
cpu: "generic".to_string(),
|
||||
max_atomic_width: Some(64),
|
||||
unsupported_abis: super::arm_base::unsupported_abis(),
|
||||
mcount: "\u{1}mcount".to_string(),
|
||||
|
|
|
@ -30,10 +30,10 @@ pub fn opts() -> TargetOptions {
|
|||
// exit (default for applications).
|
||||
"/subsystem:efi_application".to_string(),
|
||||
];
|
||||
base.pre_link_args.get_mut(&LinkerFlavor::Msvc).unwrap().extend(pre_link_args_msvc.clone());
|
||||
base.pre_link_args.entry(LinkerFlavor::Msvc).or_default().extend(pre_link_args_msvc.clone());
|
||||
base.pre_link_args
|
||||
.get_mut(&LinkerFlavor::Lld(LldFlavor::Link))
|
||||
.unwrap()
|
||||
.entry(LinkerFlavor::Lld(LldFlavor::Link))
|
||||
.or_default()
|
||||
.extend(pre_link_args_msvc);
|
||||
|
||||
TargetOptions {
|
||||
|
|
|
@ -1,21 +1,6 @@
|
|||
use crate::spec::{LinkArgs, LinkerFlavor, TargetOptions};
|
||||
use crate::spec::TargetOptions;
|
||||
|
||||
pub fn opts() -> TargetOptions {
|
||||
let mut args = LinkArgs::new();
|
||||
args.insert(
|
||||
LinkerFlavor::Gcc,
|
||||
vec![
|
||||
// We want to be able to strip as much executable code as possible
|
||||
// from the linker command line, and this flag indicates to the
|
||||
// linker that it can avoid linking in dynamic libraries that don't
|
||||
// actually satisfy any symbols up to that point (as with many other
|
||||
// resolutions the linker does). This option only applies to all
|
||||
// following libraries so we're sure to pass it as one of the first
|
||||
// arguments.
|
||||
"-Wl,--as-needed".to_string(),
|
||||
],
|
||||
);
|
||||
|
||||
TargetOptions {
|
||||
os: "vxworks".to_string(),
|
||||
env: "gnu".to_string(),
|
||||
|
@ -27,8 +12,6 @@ pub fn opts() -> TargetOptions {
|
|||
os_family: Some("unix".to_string()),
|
||||
linker_is_gnu: true,
|
||||
has_rpath: true,
|
||||
pre_link_args: args,
|
||||
position_independent_executables: false,
|
||||
has_elf_tls: true,
|
||||
crt_static_default: true,
|
||||
crt_static_respected: true,
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
use super::wasm32_base;
|
||||
use super::wasm_base;
|
||||
use super::{LinkArgs, LinkerFlavor, PanicStrategy, Target, TargetOptions};
|
||||
|
||||
pub fn target() -> Target {
|
||||
let mut options = wasm32_base::options();
|
||||
let mut options = wasm_base::options();
|
||||
|
||||
let clang_args = options.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap();
|
||||
let clang_args = options.pre_link_args.entry(LinkerFlavor::Gcc).or_default();
|
||||
|
||||
// Rust really needs a way for users to specify exports and imports in
|
||||
// the source code. --export-dynamic isn't the right tool for this job,
|
||||
|
|
|
@ -10,14 +10,26 @@
|
|||
//! This target is more or less managed by the Rust and WebAssembly Working
|
||||
//! Group nowadays at <https://github.com/rustwasm>.
|
||||
|
||||
use super::wasm32_base;
|
||||
use super::wasm_base;
|
||||
use super::{LinkerFlavor, LldFlavor, Target};
|
||||
use crate::spec::abi::Abi;
|
||||
|
||||
pub fn target() -> Target {
|
||||
let mut options = wasm32_base::options();
|
||||
let mut options = wasm_base::options();
|
||||
options.os = "unknown".to_string();
|
||||
options.linker_flavor = LinkerFlavor::Lld(LldFlavor::Wasm);
|
||||
let clang_args = options.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap();
|
||||
|
||||
// This is a default for backwards-compatibility with the original
|
||||
// definition of this target oh-so-long-ago. Once the "wasm" ABI is
|
||||
// stable and the wasm-bindgen project has switched to using it then there's
|
||||
// no need for this and it can be removed.
|
||||
//
|
||||
// Currently this is the reason that this target's ABI is mismatched with
|
||||
// clang's ABI. This means that, in the limit, you can't merge C and Rust
|
||||
// code on this target due to this ABI mismatch.
|
||||
options.default_adjusted_cabi = Some(Abi::Wasm);
|
||||
|
||||
let clang_args = options.pre_link_args.entry(LinkerFlavor::Gcc).or_default();
|
||||
|
||||
// Make sure clang uses LLD as its linker and is configured appropriately
|
||||
// otherwise
|
||||
|
@ -35,7 +47,7 @@ pub fn target() -> Target {
|
|||
clang_args.push("-Wl,--export-dynamic".to_string());
|
||||
|
||||
// Add the flags to wasm-ld's args too.
|
||||
let lld_args = options.pre_link_args.get_mut(&LinkerFlavor::Lld(LldFlavor::Wasm)).unwrap();
|
||||
let lld_args = options.pre_link_args.entry(LinkerFlavor::Lld(LldFlavor::Wasm)).or_default();
|
||||
lld_args.push("--no-entry".to_string());
|
||||
lld_args.push("--export-dynamic".to_string());
|
||||
|
||||
|
|
|
@ -72,11 +72,11 @@
|
|||
//! 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::wasm32_base;
|
||||
use super::wasm_base;
|
||||
use super::{crt_objects, LinkerFlavor, LldFlavor, Target};
|
||||
|
||||
pub fn target() -> Target {
|
||||
let mut options = wasm32_base::options();
|
||||
let mut options = wasm_base::options();
|
||||
|
||||
options.os = "wasi".to_string();
|
||||
options.linker_flavor = LinkerFlavor::Lld(LldFlavor::Wasm);
|
||||
|
|
39
compiler/rustc_target/src/spec/wasm64_unknown_unknown.rs
Normal file
39
compiler/rustc_target/src/spec/wasm64_unknown_unknown.rs
Normal file
|
@ -0,0 +1,39 @@
|
|||
//! A "bare wasm" target representing a WebAssembly output that makes zero
|
||||
//! assumptions about its environment.
|
||||
//!
|
||||
//! The `wasm64-unknown-unknown` target is intended to encapsulate use cases
|
||||
//! that do not rely on any imported functionality. The binaries generated are
|
||||
//! entirely self-contained by default when using the standard library. Although
|
||||
//! 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};
|
||||
|
||||
pub fn target() -> Target {
|
||||
let mut options = wasm_base::options();
|
||||
options.os = "unknown".to_string();
|
||||
options.linker_flavor = LinkerFlavor::Lld(LldFlavor::Wasm);
|
||||
let clang_args = options.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap();
|
||||
|
||||
// Make sure clang uses LLD as its linker and is configured appropriately
|
||||
// otherwise
|
||||
clang_args.push("--target=wasm64-unknown-unknown".to_string());
|
||||
|
||||
// For now this target just never has an entry symbol no matter the output
|
||||
// type, so unconditionally pass this.
|
||||
clang_args.push("-Wl,--no-entry".to_string());
|
||||
options
|
||||
.pre_link_args
|
||||
.get_mut(&LinkerFlavor::Lld(LldFlavor::Wasm))
|
||||
.unwrap()
|
||||
.push("--no-entry".to_string());
|
||||
|
||||
Target {
|
||||
llvm_target: "wasm64-unknown-unknown".to_string(),
|
||||
pointer_width: 64,
|
||||
data_layout: "e-m:e-p:64:64-i64:64-n32:64-S128".to_string(),
|
||||
arch: "wasm64".to_string(),
|
||||
options,
|
||||
}
|
||||
}
|
|
@ -60,6 +60,8 @@ pub fn options() -> TargetOptions {
|
|||
pre_link_args.insert(LinkerFlavor::Gcc, clang_args);
|
||||
|
||||
TargetOptions {
|
||||
is_like_wasm: true,
|
||||
|
||||
// we allow dynamic linking, but only cdylibs. Basically we allow a
|
||||
// final library artifact that exports some symbols (a wasm module) but
|
||||
// we don't allow intermediate `dylib` crate types
|
||||
|
@ -73,7 +75,6 @@ pub fn options() -> TargetOptions {
|
|||
exe_suffix: ".wasm".to_string(),
|
||||
dll_prefix: String::new(),
|
||||
dll_suffix: ".wasm".to_string(),
|
||||
linker_is_gnu: false,
|
||||
eh_frame_header: false,
|
||||
|
||||
max_atomic_width: Some(64),
|
|
@ -9,8 +9,6 @@ pub fn opts() -> TargetOptions {
|
|||
// Tell GCC to avoid linker plugins, because we are not bundling
|
||||
// them with Windows installer, and Rust does its own LTO anyways.
|
||||
"-fno-use-linker-plugin".to_string(),
|
||||
// Always enable DEP (NX bit) when it is available
|
||||
"-Wl,--nxcompat".to_string(),
|
||||
// Enable ASLR
|
||||
"-Wl,--dynamicbase".to_string(),
|
||||
// ASLR will rebase it anyway so leaving that option enabled only leads to confusion
|
||||
|
@ -73,8 +71,6 @@ pub fn opts() -> TargetOptions {
|
|||
dll_prefix: String::new(),
|
||||
dll_suffix: ".dll".to_string(),
|
||||
exe_suffix: ".exe".to_string(),
|
||||
staticlib_prefix: "lib".to_string(),
|
||||
staticlib_suffix: ".a".to_string(),
|
||||
os_family: Some("windows".to_string()),
|
||||
is_like_windows: true,
|
||||
allows_weak_linkage: false,
|
||||
|
|
|
@ -5,10 +5,10 @@ pub fn opts() -> TargetOptions {
|
|||
|
||||
opts.vendor = "uwp".to_string();
|
||||
let pre_link_args_msvc = vec!["/APPCONTAINER".to_string(), "mincore.lib".to_string()];
|
||||
opts.pre_link_args.get_mut(&LinkerFlavor::Msvc).unwrap().extend(pre_link_args_msvc.clone());
|
||||
opts.pre_link_args.entry(LinkerFlavor::Msvc).or_default().extend(pre_link_args_msvc.clone());
|
||||
opts.pre_link_args
|
||||
.get_mut(&LinkerFlavor::Lld(LldFlavor::Link))
|
||||
.unwrap()
|
||||
.entry(LinkerFlavor::Lld(LldFlavor::Link))
|
||||
.or_default()
|
||||
.extend(pre_link_args_msvc);
|
||||
|
||||
opts
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use crate::spec::{LinkerFlavor, StackProbeType, Target, TargetOptions};
|
||||
use crate::spec::{LinkerFlavor, SanitizerSet, StackProbeType, Target, TargetOptions};
|
||||
|
||||
pub fn target() -> Target {
|
||||
let mut base = super::apple_base::opts("macos");
|
||||
|
@ -11,6 +11,7 @@ pub fn target() -> Target {
|
|||
);
|
||||
base.link_env_remove.extend(super::apple_base::macos_link_env_remove());
|
||||
base.stack_probes = StackProbeType::InlineOrCall { min_llvm_version_for_inline: (11, 0, 1) };
|
||||
base.supported_sanitizers = SanitizerSet::ADDRESS | SanitizerSet::LEAK | SanitizerSet::THREAD;
|
||||
|
||||
// Clang automatically chooses a more specific target based on
|
||||
// MACOSX_DEPLOYMENT_TARGET. To enable cross-language LTO to work
|
||||
|
|
|
@ -1,12 +1,9 @@
|
|||
use std::iter;
|
||||
|
||||
use super::{LinkerFlavor, LldFlavor, PanicStrategy, Target, TargetOptions};
|
||||
use super::{LinkerFlavor, LldFlavor, Target, TargetOptions};
|
||||
|
||||
pub fn target() -> Target {
|
||||
const PRE_LINK_ARGS: &[&str] = &[
|
||||
"--as-needed",
|
||||
"-z",
|
||||
"noexecstack",
|
||||
"-e",
|
||||
"elf_entry",
|
||||
"-Bstatic",
|
||||
|
@ -59,12 +56,10 @@ pub fn target() -> Target {
|
|||
env: "sgx".into(),
|
||||
vendor: "fortanix".into(),
|
||||
linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
|
||||
dynamic_linking: false,
|
||||
executables: true,
|
||||
linker_is_gnu: true,
|
||||
linker: Some("rust-lld".to_owned()),
|
||||
max_atomic_width: Some(64),
|
||||
panic_strategy: PanicStrategy::Unwind,
|
||||
cpu: "x86-64".into(),
|
||||
features: "+rdrnd,+rdseed,+lvi-cfi,+lvi-load-hardening".into(),
|
||||
llvm_args: vec!["--x86-experimental-lvi-inline-asm-hardening".into()],
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
use crate::spec::{StackProbeType, Target};
|
||||
use crate::spec::{SanitizerSet, StackProbeType, Target};
|
||||
|
||||
pub fn target() -> Target {
|
||||
let mut base = super::fuchsia_base::opts();
|
||||
base.cpu = "x86-64".to_string();
|
||||
base.max_atomic_width = Some(64);
|
||||
base.stack_probes = StackProbeType::InlineOrCall { min_llvm_version_for_inline: (11, 0, 1) };
|
||||
base.supported_sanitizers = SanitizerSet::ADDRESS;
|
||||
|
||||
Target {
|
||||
llvm_target: "x86_64-fuchsia".to_string(),
|
||||
|
|
|
@ -6,7 +6,7 @@ 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".to_string();
|
||||
base.max_atomic_width = Some(64);
|
||||
base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-m64".to_string());
|
||||
base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-m64".to_string());
|
||||
base.stack_probes = StackProbeType::InlineOrCall { min_llvm_version_for_inline: (11, 0, 1) };
|
||||
|
||||
Target {
|
||||
|
|
|
@ -3,7 +3,7 @@ use crate::spec::{LinkerFlavor, LldFlavor, Target};
|
|||
pub fn target() -> Target {
|
||||
let mut base = super::windows_gnu_base::opts();
|
||||
base.cpu = "x86-64".to_string();
|
||||
let gcc_pre_link_args = base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap();
|
||||
let gcc_pre_link_args = base.pre_link_args.entry(LinkerFlavor::Gcc).or_default();
|
||||
gcc_pre_link_args.push("-m64".to_string());
|
||||
// Use high-entropy 64 bit address space for ASLR
|
||||
gcc_pre_link_args.push("-Wl,--high-entropy-va".to_string());
|
||||
|
|
|
@ -4,7 +4,7 @@ pub fn target() -> Target {
|
|||
let mut base = super::dragonfly_base::opts();
|
||||
base.cpu = "x86-64".to_string();
|
||||
base.max_atomic_width = Some(64);
|
||||
base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-m64".to_string());
|
||||
base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-m64".to_string());
|
||||
base.stack_probes = StackProbeType::InlineOrCall { min_llvm_version_for_inline: (11, 0, 1) };
|
||||
|
||||
Target {
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
use crate::spec::{LinkerFlavor, StackProbeType, Target};
|
||||
use crate::spec::{LinkerFlavor, SanitizerSet, StackProbeType, Target};
|
||||
|
||||
pub fn target() -> Target {
|
||||
let mut base = super::freebsd_base::opts();
|
||||
base.cpu = "x86-64".to_string();
|
||||
base.max_atomic_width = Some(64);
|
||||
base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-m64".to_string());
|
||||
base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-m64".to_string());
|
||||
base.stack_probes = StackProbeType::InlineOrCall { min_llvm_version_for_inline: (11, 0, 1) };
|
||||
base.supported_sanitizers = SanitizerSet::ADDRESS | SanitizerSet::MEMORY | SanitizerSet::THREAD;
|
||||
|
||||
Target {
|
||||
llvm_target: "x86_64-unknown-freebsd".to_string(),
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
use crate::spec::{LinkerFlavor, StackProbeType, Target};
|
||||
use crate::spec::{LinkerFlavor, SanitizerSet, StackProbeType, Target};
|
||||
|
||||
pub fn target() -> Target {
|
||||
let mut base = super::linux_gnu_base::opts();
|
||||
base.cpu = "x86-64".to_string();
|
||||
base.max_atomic_width = Some(64);
|
||||
base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-m64".to_string());
|
||||
base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-m64".to_string());
|
||||
base.stack_probes = StackProbeType::InlineOrCall { min_llvm_version_for_inline: (11, 0, 1) };
|
||||
base.supported_sanitizers =
|
||||
SanitizerSet::ADDRESS | SanitizerSet::LEAK | SanitizerSet::MEMORY | SanitizerSet::THREAD;
|
||||
|
||||
Target {
|
||||
llvm_target: "x86_64-unknown-linux-gnu".to_string(),
|
||||
|
|
|
@ -4,7 +4,7 @@ pub fn target() -> Target {
|
|||
let mut base = super::linux_gnu_base::opts();
|
||||
base.cpu = "x86-64".to_string();
|
||||
base.max_atomic_width = Some(64);
|
||||
base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-mx32".to_string());
|
||||
base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-mx32".to_string());
|
||||
base.stack_probes = StackProbeType::InlineOrCall { min_llvm_version_for_inline: (11, 0, 1) };
|
||||
base.has_elf_tls = false;
|
||||
// BUG(GabrielMajeri): disabling the PLT on x86_64 Linux with x32 ABI
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
use crate::spec::{LinkerFlavor, StackProbeType, Target};
|
||||
use crate::spec::{LinkerFlavor, SanitizerSet, StackProbeType, Target};
|
||||
|
||||
pub fn target() -> Target {
|
||||
let mut base = super::linux_musl_base::opts();
|
||||
base.cpu = "x86-64".to_string();
|
||||
base.max_atomic_width = Some(64);
|
||||
base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-m64".to_string());
|
||||
base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-m64".to_string());
|
||||
base.stack_probes = StackProbeType::InlineOrCall { min_llvm_version_for_inline: (11, 0, 1) };
|
||||
base.static_position_independent_executables = true;
|
||||
base.supported_sanitizers =
|
||||
SanitizerSet::ADDRESS | SanitizerSet::LEAK | SanitizerSet::MEMORY | SanitizerSet::THREAD;
|
||||
|
||||
Target {
|
||||
llvm_target: "x86_64-unknown-linux-musl".to_string(),
|
||||
|
|
|
@ -4,7 +4,7 @@ pub fn target() -> Target {
|
|||
let mut base = super::netbsd_base::opts();
|
||||
base.cpu = "x86-64".to_string();
|
||||
base.max_atomic_width = Some(64);
|
||||
base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-m64".to_string());
|
||||
base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-m64".to_string());
|
||||
base.stack_probes = StackProbeType::InlineOrCall { min_llvm_version_for_inline: (11, 0, 1) };
|
||||
|
||||
Target {
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue