Rollup merge of #148531 - tamird:vendor-enum, r=nnethercote
rustc_target: introduce Abi, Env, Os Improve type safety by using an enum rather than strings. I'm not really sure this is better since only a few vendors have special semantics. r? ``@nnethercote``
This commit is contained in:
commit
3b8d30becb
249 changed files with 1012 additions and 830 deletions
|
|
@ -49,7 +49,7 @@ use rustc_middle::dep_graph::{WorkProduct, WorkProductId};
|
|||
use rustc_session::Session;
|
||||
use rustc_session::config::OutputFilenames;
|
||||
use rustc_span::{Symbol, sym};
|
||||
use rustc_target::spec::Arch;
|
||||
use rustc_target::spec::{Abi, Arch, Env, Os};
|
||||
|
||||
pub use crate::config::*;
|
||||
use crate::prelude::*;
|
||||
|
|
@ -163,15 +163,15 @@ impl CodegenBackend for CraneliftCodegenBackend {
|
|||
fn target_config(&self, sess: &Session) -> TargetConfig {
|
||||
// FIXME return the actually used target features. this is necessary for #[cfg(target_feature)]
|
||||
let target_features = match sess.target.arch {
|
||||
Arch::X86_64 if sess.target.os != "none" => {
|
||||
Arch::X86_64 if sess.target.os != Os::None => {
|
||||
// x86_64 mandates SSE2 support and rustc requires the x87 feature to be enabled
|
||||
vec![sym::fxsr, sym::sse, sym::sse2, Symbol::intern("x87")]
|
||||
}
|
||||
Arch::AArch64 => match &*sess.target.os {
|
||||
"none" => vec![],
|
||||
Arch::AArch64 => match &sess.target.os {
|
||||
Os::None => vec![],
|
||||
// On macOS the aes, sha2 and sha3 features are enabled by default and ring
|
||||
// fails to compile on macOS when they are not present.
|
||||
"macos" => vec![sym::neon, sym::aes, sym::sha2, sym::sha3],
|
||||
Os::MacOs => vec![sym::neon, sym::aes, sym::sha2, sym::sha3],
|
||||
// AArch64 mandates Neon support
|
||||
_ => vec![sym::neon],
|
||||
},
|
||||
|
|
@ -184,9 +184,9 @@ impl CodegenBackend for CraneliftCodegenBackend {
|
|||
// targets due to GCC using a different ABI than LLVM. Therefore `f16` and `f128`
|
||||
// won't be available when using a LLVM-built sysroot.
|
||||
let has_reliable_f16_f128 = !(sess.target.arch == Arch::X86_64
|
||||
&& sess.target.os == "windows"
|
||||
&& sess.target.env == "gnu"
|
||||
&& sess.target.abi != "llvm");
|
||||
&& sess.target.os == Os::Windows
|
||||
&& sess.target.env == Env::Gnu
|
||||
&& sess.target.abi != Abi::Llvm);
|
||||
|
||||
TargetConfig {
|
||||
target_features,
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
use rustc_codegen_ssa::common;
|
||||
use rustc_middle::ty::layout::{FnAbiOf, HasTyCtxt, HasTypingEnv};
|
||||
use rustc_middle::ty::{self, Instance, TypeVisitableExt};
|
||||
use rustc_target::spec::Arch;
|
||||
use rustc_target::spec::{Arch, Env};
|
||||
use tracing::debug;
|
||||
|
||||
use crate::context::CodegenCx;
|
||||
|
|
@ -145,7 +145,7 @@ pub(crate) fn get_fn<'ll, 'tcx>(cx: &CodegenCx<'ll, 'tcx>, instance: Instance<'t
|
|||
if cx.use_dll_storage_attrs
|
||||
&& let Some(library) = tcx.native_library(instance_def_id)
|
||||
&& library.kind.is_dllimport()
|
||||
&& !matches!(tcx.sess.target.env.as_ref(), "gnu" | "uclibc")
|
||||
&& !matches!(tcx.sess.target.env, Env::Gnu | Env::Uclibc)
|
||||
{
|
||||
llvm::set_dllimport_storage_class(llfn);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ use rustc_span::source_map::Spanned;
|
|||
use rustc_span::{DUMMY_SP, Span, Symbol};
|
||||
use rustc_symbol_mangling::mangle_internal_symbol;
|
||||
use rustc_target::spec::{
|
||||
Arch, HasTargetSpec, RelocModel, SmallDataThresholdSupport, Target, TlsModel,
|
||||
Abi, Arch, Env, HasTargetSpec, Os, RelocModel, SmallDataThresholdSupport, Target, TlsModel,
|
||||
};
|
||||
use smallvec::SmallVec;
|
||||
|
||||
|
|
@ -335,9 +335,9 @@ pub(crate) unsafe fn create_module<'ll>(
|
|||
|
||||
// Control Flow Guard is currently only supported by MSVC and LLVM on Windows.
|
||||
if sess.target.is_like_msvc
|
||||
|| (sess.target.options.os == "windows"
|
||||
&& sess.target.options.env == "gnu"
|
||||
&& sess.target.options.abi == "llvm")
|
||||
|| (sess.target.options.os == Os::Windows
|
||||
&& sess.target.options.env == Env::Gnu
|
||||
&& sess.target.options.abi == Abi::Llvm)
|
||||
{
|
||||
match sess.opts.cg.control_flow_guard {
|
||||
CFGuard::Disabled => {}
|
||||
|
|
@ -669,7 +669,7 @@ impl<'ll, 'tcx> CodegenCx<'ll, 'tcx> {
|
|||
/// This corresponds to the `-fobjc-abi-version=` flag in Clang / GCC.
|
||||
pub(crate) fn objc_abi_version(&self) -> u32 {
|
||||
assert!(self.tcx.sess.target.is_like_darwin);
|
||||
if self.tcx.sess.target.arch == Arch::X86 && self.tcx.sess.target.os == "macos" {
|
||||
if self.tcx.sess.target.arch == Arch::X86 && self.tcx.sess.target.os == Os::MacOs {
|
||||
// 32-bit x86 macOS uses ABI version 1 (a.k.a. the "fragile ABI").
|
||||
1
|
||||
} else {
|
||||
|
|
@ -710,7 +710,7 @@ impl<'ll, 'tcx> CodegenCx<'ll, 'tcx> {
|
|||
},
|
||||
);
|
||||
|
||||
if self.tcx.sess.target.env == "sim" {
|
||||
if self.tcx.sess.target.env == Env::Sim {
|
||||
llvm::add_module_flag_u32(
|
||||
self.llmod,
|
||||
llvm::ModuleFlagMergeBehavior::Error,
|
||||
|
|
@ -963,7 +963,7 @@ impl<'ll> CodegenCx<'ll, '_> {
|
|||
return eh_catch_typeinfo;
|
||||
}
|
||||
let tcx = self.tcx;
|
||||
assert!(self.sess().target.os == "emscripten");
|
||||
assert!(self.sess().target.os == Os::Emscripten);
|
||||
let eh_catch_typeinfo = match tcx.lang_items().eh_catch_typeinfo() {
|
||||
Some(def_id) => self.get_static(def_id),
|
||||
_ => {
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ use rustc_middle::{bug, span_bug};
|
|||
use rustc_span::{Span, Symbol, sym};
|
||||
use rustc_symbol_mangling::{mangle_internal_symbol, symbol_name_for_instance_in_crate};
|
||||
use rustc_target::callconv::PassMode;
|
||||
use rustc_target::spec::Os;
|
||||
use tracing::debug;
|
||||
|
||||
use crate::abi::FnAbiLlvmExt;
|
||||
|
|
@ -681,7 +682,7 @@ fn catch_unwind_intrinsic<'ll, 'tcx>(
|
|||
codegen_msvc_try(bx, try_func, data, catch_func, dest);
|
||||
} else if wants_wasm_eh(bx.sess()) {
|
||||
codegen_wasm_try(bx, try_func, data, catch_func, dest);
|
||||
} else if bx.sess().target.os == "emscripten" {
|
||||
} else if bx.sess().target.os == Os::Emscripten {
|
||||
codegen_emcc_try(bx, try_func, data, catch_func, dest);
|
||||
} else {
|
||||
codegen_gnu_try(bx, try_func, data, catch_func, dest);
|
||||
|
|
|
|||
|
|
@ -15,7 +15,9 @@ use rustc_fs_util::path_to_c_string;
|
|||
use rustc_middle::bug;
|
||||
use rustc_session::Session;
|
||||
use rustc_session::config::{PrintKind, PrintRequest};
|
||||
use rustc_target::spec::{Arch, MergeFunctions, PanicStrategy, SmallDataThresholdSupport};
|
||||
use rustc_target::spec::{
|
||||
Abi, Arch, Env, MergeFunctions, Os, PanicStrategy, SmallDataThresholdSupport,
|
||||
};
|
||||
use smallvec::{SmallVec, smallvec};
|
||||
|
||||
use crate::back::write::create_informational_target_machine;
|
||||
|
|
@ -104,7 +106,7 @@ unsafe fn configure_llvm(sess: &Session) {
|
|||
add("-wasm-enable-eh", false);
|
||||
}
|
||||
|
||||
if sess.target.os == "emscripten"
|
||||
if sess.target.os == Os::Emscripten
|
||||
&& !sess.opts.unstable_opts.emscripten_wasm_eh
|
||||
&& sess.panic_strategy().unwinds()
|
||||
{
|
||||
|
|
@ -351,9 +353,9 @@ pub(crate) fn target_config(sess: &Session) -> TargetConfig {
|
|||
/// Determine whether or not experimental float types are reliable based on known bugs.
|
||||
fn update_target_reliable_float_cfg(sess: &Session, cfg: &mut TargetConfig) {
|
||||
let target_arch = &sess.target.arch;
|
||||
let target_os = sess.target.options.os.as_ref();
|
||||
let target_env = sess.target.options.env.as_ref();
|
||||
let target_abi = sess.target.options.abi.as_ref();
|
||||
let target_os = &sess.target.options.os;
|
||||
let target_env = &sess.target.options.env;
|
||||
let target_abi = &sess.target.options.abi;
|
||||
let target_pointer_width = sess.target.pointer_width;
|
||||
let version = get_version();
|
||||
let lt_20_1_1 = version < (20, 1, 1);
|
||||
|
|
@ -371,7 +373,7 @@ fn update_target_reliable_float_cfg(sess: &Session, cfg: &mut TargetConfig) {
|
|||
// Selection failure <https://github.com/llvm/llvm-project/issues/50374> (fixed in llvm21)
|
||||
(Arch::S390x, _) if lt_21_0_0 => false,
|
||||
// MinGW ABI bugs <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115054>
|
||||
(Arch::X86_64, "windows") if target_env == "gnu" && target_abi != "llvm" => false,
|
||||
(Arch::X86_64, Os::Windows) if *target_env == Env::Gnu && *target_abi != Abi::Llvm => false,
|
||||
// Infinite recursion <https://github.com/llvm/llvm-project/issues/97981>
|
||||
(Arch::CSky, _) => false,
|
||||
(Arch::Hexagon, _) if lt_21_0_0 => false, // (fixed in llvm21)
|
||||
|
|
@ -403,7 +405,7 @@ fn update_target_reliable_float_cfg(sess: &Session, cfg: &mut TargetConfig) {
|
|||
// not fail if our compiler-builtins is linked. (fixed in llvm21)
|
||||
(Arch::X86, _) if lt_21_0_0 => false,
|
||||
// MinGW ABI bugs <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115054>
|
||||
(Arch::X86_64, "windows") if target_env == "gnu" && target_abi != "llvm" => false,
|
||||
(Arch::X86_64, Os::Windows) if *target_env == Env::Gnu && *target_abi != Abi::Llvm => false,
|
||||
// There are no known problems on other platforms, so the only requirement is that symbols
|
||||
// are available. `compiler-builtins` provides all symbols required for core `f128`
|
||||
// support, so this should work for everything else.
|
||||
|
|
@ -424,9 +426,9 @@ fn update_target_reliable_float_cfg(sess: &Session, cfg: &mut TargetConfig) {
|
|||
// (ld is 80-bit extended precision).
|
||||
//
|
||||
// musl does not implement the symbols required for f128 math at all.
|
||||
_ if target_env == "musl" => false,
|
||||
_ if *target_env == Env::Musl => false,
|
||||
(Arch::X86_64, _) => false,
|
||||
(_, "linux") if target_pointer_width == 64 => true,
|
||||
(_, Os::Linux) if target_pointer_width == 64 => true,
|
||||
_ => false,
|
||||
} && cfg.has_reliable_f128;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ use rustc_codegen_ssa::traits::{
|
|||
};
|
||||
use rustc_middle::ty::Ty;
|
||||
use rustc_middle::ty::layout::{HasTyCtxt, LayoutOf};
|
||||
use rustc_target::spec::Arch;
|
||||
use rustc_target::spec::{Abi, Arch};
|
||||
|
||||
use crate::builder::Builder;
|
||||
use crate::llvm::{Type, Value};
|
||||
|
|
@ -270,7 +270,7 @@ fn emit_powerpc_va_arg<'ll, 'tcx>(
|
|||
|
||||
// Rust does not currently support any powerpc softfloat targets.
|
||||
let target = &bx.cx.tcx.sess.target;
|
||||
let is_soft_float_abi = target.abi == "softfloat";
|
||||
let is_soft_float_abi = target.abi == Abi::SoftFloat;
|
||||
assert!(!is_soft_float_abi);
|
||||
|
||||
// All instances of VaArgSafe are passed directly.
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ use itertools::Itertools;
|
|||
use rustc_middle::middle::exported_symbols::SymbolExportKind;
|
||||
use rustc_session::Session;
|
||||
pub(super) use rustc_target::spec::apple::OSVersion;
|
||||
use rustc_target::spec::{Arch, Target};
|
||||
use rustc_target::spec::{Arch, Env, Os, Target};
|
||||
use tracing::debug;
|
||||
|
||||
use crate::errors::{XcrunError, XcrunSdkPathWarning};
|
||||
|
|
@ -17,35 +17,35 @@ mod tests;
|
|||
|
||||
/// The canonical name of the desired SDK for a given target.
|
||||
pub(super) fn sdk_name(target: &Target) -> &'static str {
|
||||
match (&*target.os, &*target.env) {
|
||||
("macos", "") => "MacOSX",
|
||||
("ios", "") => "iPhoneOS",
|
||||
("ios", "sim") => "iPhoneSimulator",
|
||||
match (&target.os, &target.env) {
|
||||
(Os::MacOs, Env::Unspecified) => "MacOSX",
|
||||
(Os::IOs, Env::Unspecified) => "iPhoneOS",
|
||||
(Os::IOs, Env::Sim) => "iPhoneSimulator",
|
||||
// Mac Catalyst uses the macOS SDK
|
||||
("ios", "macabi") => "MacOSX",
|
||||
("tvos", "") => "AppleTVOS",
|
||||
("tvos", "sim") => "AppleTVSimulator",
|
||||
("visionos", "") => "XROS",
|
||||
("visionos", "sim") => "XRSimulator",
|
||||
("watchos", "") => "WatchOS",
|
||||
("watchos", "sim") => "WatchSimulator",
|
||||
(Os::IOs, Env::MacAbi) => "MacOSX",
|
||||
(Os::TvOs, Env::Unspecified) => "AppleTVOS",
|
||||
(Os::TvOs, Env::Sim) => "AppleTVSimulator",
|
||||
(Os::VisionOs, Env::Unspecified) => "XROS",
|
||||
(Os::VisionOs, Env::Sim) => "XRSimulator",
|
||||
(Os::WatchOs, Env::Unspecified) => "WatchOS",
|
||||
(Os::WatchOs, Env::Sim) => "WatchSimulator",
|
||||
(os, abi) => unreachable!("invalid os '{os}' / abi '{abi}' combination for Apple target"),
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn macho_platform(target: &Target) -> u32 {
|
||||
match (&*target.os, &*target.env) {
|
||||
("macos", _) => object::macho::PLATFORM_MACOS,
|
||||
("ios", "macabi") => object::macho::PLATFORM_MACCATALYST,
|
||||
("ios", "sim") => object::macho::PLATFORM_IOSSIMULATOR,
|
||||
("ios", _) => object::macho::PLATFORM_IOS,
|
||||
("watchos", "sim") => object::macho::PLATFORM_WATCHOSSIMULATOR,
|
||||
("watchos", _) => object::macho::PLATFORM_WATCHOS,
|
||||
("tvos", "sim") => object::macho::PLATFORM_TVOSSIMULATOR,
|
||||
("tvos", _) => object::macho::PLATFORM_TVOS,
|
||||
("visionos", "sim") => object::macho::PLATFORM_XROSSIMULATOR,
|
||||
("visionos", _) => object::macho::PLATFORM_XROS,
|
||||
_ => unreachable!("tried to get Mach-O platform for non-Apple target"),
|
||||
match (&target.os, &target.env) {
|
||||
(Os::MacOs, _) => object::macho::PLATFORM_MACOS,
|
||||
(Os::IOs, Env::MacAbi) => object::macho::PLATFORM_MACCATALYST,
|
||||
(Os::IOs, Env::Sim) => object::macho::PLATFORM_IOSSIMULATOR,
|
||||
(Os::IOs, _) => object::macho::PLATFORM_IOS,
|
||||
(Os::WatchOs, Env::Sim) => object::macho::PLATFORM_WATCHOSSIMULATOR,
|
||||
(Os::WatchOs, _) => object::macho::PLATFORM_WATCHOS,
|
||||
(Os::TvOs, Env::Sim) => object::macho::PLATFORM_TVOSSIMULATOR,
|
||||
(Os::TvOs, _) => object::macho::PLATFORM_TVOS,
|
||||
(Os::VisionOs, Env::Sim) => object::macho::PLATFORM_XROSSIMULATOR,
|
||||
(Os::VisionOs, _) => object::macho::PLATFORM_XROS,
|
||||
(os, env) => unreachable!("invalid os '{os}' / env '{env}' combination for Apple target"),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -46,9 +46,9 @@ use rustc_session::{Session, filesearch};
|
|||
use rustc_span::Symbol;
|
||||
use rustc_target::spec::crt_objects::CrtObjects;
|
||||
use rustc_target::spec::{
|
||||
BinaryFormat, Cc, LinkOutputKind, LinkSelfContainedComponents, LinkSelfContainedDefault,
|
||||
LinkerFeatures, LinkerFlavor, LinkerFlavorCli, Lld, RelocModel, RelroLevel, SanitizerSet,
|
||||
SplitDebuginfo,
|
||||
Abi, BinaryFormat, Cc, Env, LinkOutputKind, LinkSelfContainedComponents,
|
||||
LinkSelfContainedDefault, LinkerFeatures, LinkerFlavor, LinkerFlavorCli, Lld, Os, RelocModel,
|
||||
RelroLevel, SanitizerSet, SplitDebuginfo,
|
||||
};
|
||||
use tracing::{debug, info, warn};
|
||||
|
||||
|
|
@ -1407,11 +1407,9 @@ pub fn linker_and_flavor(sess: &Session) -> (PathBuf, LinkerFlavor) {
|
|||
Some(LinkerFlavorCli::Llbc) => Some(LinkerFlavor::Llbc),
|
||||
Some(LinkerFlavorCli::Ptx) => Some(LinkerFlavor::Ptx),
|
||||
// The linker flavors that corresponds to targets needs logic that keeps the base LinkerFlavor
|
||||
_ => sess
|
||||
.opts
|
||||
.cg
|
||||
.linker_flavor
|
||||
.map(|flavor| sess.target.linker_flavor.with_cli_hints(flavor)),
|
||||
linker_flavor => {
|
||||
linker_flavor.map(|flavor| sess.target.linker_flavor.with_cli_hints(flavor))
|
||||
}
|
||||
};
|
||||
if let Some(ret) = infer_from(sess, sess.opts.cg.linker.clone(), linker_flavor, features) {
|
||||
return ret;
|
||||
|
|
@ -1819,7 +1817,7 @@ fn self_contained_components(
|
|||
LinkSelfContainedDefault::InferredForMusl => sess.crt_static(Some(crate_type)),
|
||||
LinkSelfContainedDefault::InferredForMingw => {
|
||||
sess.host == sess.target
|
||||
&& sess.target.abi != "uwp"
|
||||
&& sess.target.abi != Abi::Uwp
|
||||
&& detect_self_contained_mingw(sess, linker)
|
||||
}
|
||||
}
|
||||
|
|
@ -1845,7 +1843,7 @@ fn add_pre_link_objects(
|
|||
let empty = Default::default();
|
||||
let objects = if self_contained {
|
||||
&opts.pre_link_objects_self_contained
|
||||
} else if !(sess.target.os == "fuchsia" && matches!(flavor, LinkerFlavor::Gnu(Cc::Yes, _))) {
|
||||
} else if !(sess.target.os == Os::Fuchsia && matches!(flavor, LinkerFlavor::Gnu(Cc::Yes, _))) {
|
||||
&opts.pre_link_objects
|
||||
} else {
|
||||
&empty
|
||||
|
|
@ -2496,7 +2494,7 @@ fn add_order_independent_options(
|
|||
|
||||
let apple_sdk_root = add_apple_sdk(cmd, sess, flavor);
|
||||
|
||||
if sess.target.os == "fuchsia"
|
||||
if sess.target.os == Os::Fuchsia
|
||||
&& crate_type == CrateType::Executable
|
||||
&& !matches!(flavor, LinkerFlavor::Gnu(Cc::Yes, _))
|
||||
{
|
||||
|
|
@ -2515,7 +2513,7 @@ fn add_order_independent_options(
|
|||
cmd.no_crt_objects();
|
||||
}
|
||||
|
||||
if sess.target.os == "emscripten" {
|
||||
if sess.target.os == Os::Emscripten {
|
||||
cmd.cc_arg(if sess.opts.unstable_opts.emscripten_wasm_eh {
|
||||
"-fwasm-exceptions"
|
||||
} else if sess.panic_strategy().unwinds() {
|
||||
|
|
@ -3070,8 +3068,8 @@ fn add_apple_link_args(cmd: &mut dyn Linker, sess: &Session, flavor: LinkerFlavo
|
|||
|
||||
// `sess.target.arch` (`target_arch`) is not detailed enough.
|
||||
let llvm_arch = sess.target.llvm_target.split_once('-').expect("LLVM target must have arch").0;
|
||||
let target_os = &*sess.target.os;
|
||||
let target_env = &*sess.target.env;
|
||||
let target_os = &sess.target.os;
|
||||
let target_env = &sess.target.env;
|
||||
|
||||
// The architecture name to forward to the linker.
|
||||
//
|
||||
|
|
@ -3123,12 +3121,12 @@ fn add_apple_link_args(cmd: &mut dyn Linker, sess: &Session, flavor: LinkerFlavo
|
|||
// > - xros-simulator
|
||||
// > - driverkit
|
||||
let platform_name = match (target_os, target_env) {
|
||||
(os, "") => os,
|
||||
("ios", "macabi") => "mac-catalyst",
|
||||
("ios", "sim") => "ios-simulator",
|
||||
("tvos", "sim") => "tvos-simulator",
|
||||
("watchos", "sim") => "watchos-simulator",
|
||||
("visionos", "sim") => "visionos-simulator",
|
||||
(os, Env::Unspecified) => os.desc(),
|
||||
(Os::IOs, Env::MacAbi) => "mac-catalyst",
|
||||
(Os::IOs, Env::Sim) => "ios-simulator",
|
||||
(Os::TvOs, Env::Sim) => "tvos-simulator",
|
||||
(Os::WatchOs, Env::Sim) => "watchos-simulator",
|
||||
(Os::VisionOs, Env::Sim) => "visionos-simulator",
|
||||
_ => bug!("invalid OS/env combination for Apple target: {target_os}, {target_env}"),
|
||||
};
|
||||
|
||||
|
|
@ -3192,7 +3190,7 @@ fn add_apple_link_args(cmd: &mut dyn Linker, sess: &Session, flavor: LinkerFlavo
|
|||
// fairly safely use `-target`. See also the following, where it is
|
||||
// made explicit that the recommendation by LLVM developers is to use
|
||||
// `-target`: <https://github.com/llvm/llvm-project/issues/88271>
|
||||
if target_os == "macos" {
|
||||
if *target_os == Os::MacOs {
|
||||
// `-arch` communicates the architecture.
|
||||
//
|
||||
// CC forwards the `-arch` to the linker, so we use the same value
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ use rustc_middle::middle::exported_symbols::{
|
|||
use rustc_middle::ty::TyCtxt;
|
||||
use rustc_session::Session;
|
||||
use rustc_session::config::{self, CrateType, DebugInfo, LinkerPluginLto, Lto, OptLevel, Strip};
|
||||
use rustc_target::spec::{Arch, Cc, LinkOutputKind, LinkerFlavor, Lld};
|
||||
use rustc_target::spec::{Abi, Arch, Cc, LinkOutputKind, LinkerFlavor, Lld, Os};
|
||||
use tracing::{debug, warn};
|
||||
|
||||
use super::command::Command;
|
||||
|
|
@ -83,7 +83,7 @@ pub(crate) fn get_linker<'a>(
|
|||
// To comply with the Windows App Certification Kit,
|
||||
// MSVC needs to link with the Store versions of the runtime libraries (vcruntime, msvcrt, etc).
|
||||
let t = &sess.target;
|
||||
if matches!(flavor, LinkerFlavor::Msvc(..)) && t.abi == "uwp" {
|
||||
if matches!(flavor, LinkerFlavor::Msvc(..)) && t.abi == Abi::Uwp {
|
||||
if let Some(ref tool) = msvc_tool {
|
||||
let original_path = tool.path();
|
||||
if let Some(root_lib_path) = original_path.ancestors().nth(4) {
|
||||
|
|
@ -134,12 +134,12 @@ pub(crate) fn get_linker<'a>(
|
|||
|
||||
// FIXME: Move `/LIBPATH` addition for uwp targets from the linker construction
|
||||
// to the linker args construction.
|
||||
assert!(cmd.get_args().is_empty() || sess.target.abi == "uwp");
|
||||
assert!(cmd.get_args().is_empty() || sess.target.abi == Abi::Uwp);
|
||||
match flavor {
|
||||
LinkerFlavor::Unix(Cc::No) if sess.target.os == "l4re" => {
|
||||
LinkerFlavor::Unix(Cc::No) if sess.target.os == Os::L4Re => {
|
||||
Box::new(L4Bender::new(cmd, sess)) as Box<dyn Linker>
|
||||
}
|
||||
LinkerFlavor::Unix(Cc::No) if sess.target.os == "aix" => {
|
||||
LinkerFlavor::Unix(Cc::No) if sess.target.os == Os::Aix => {
|
||||
Box::new(AixLinker::new(cmd, sess)) as Box<dyn Linker>
|
||||
}
|
||||
LinkerFlavor::WasmLld(Cc::No) => Box::new(WasmLd::new(cmd, sess)) as Box<dyn Linker>,
|
||||
|
|
@ -573,7 +573,7 @@ impl<'a> Linker for GccLinker<'a> {
|
|||
// any `#[link]` attributes in the `libc` crate, see #72782 for details.
|
||||
// FIXME: Switch to using `#[link]` attributes in the `libc` crate
|
||||
// similarly to other targets.
|
||||
if self.sess.target.os == "vxworks"
|
||||
if self.sess.target.os == Os::VxWorks
|
||||
&& matches!(
|
||||
output_kind,
|
||||
LinkOutputKind::StaticNoPicExe
|
||||
|
|
@ -595,7 +595,7 @@ impl<'a> Linker for GccLinker<'a> {
|
|||
}
|
||||
|
||||
fn link_dylib_by_name(&mut self, name: &str, verbatim: bool, as_needed: bool) {
|
||||
if self.sess.target.os == "illumos" && name == "c" {
|
||||
if self.sess.target.os == Os::Illumos && name == "c" {
|
||||
// libc will be added via late_link_args on illumos so that it will
|
||||
// appear last in the library search order.
|
||||
// FIXME: This should be replaced by a more complete and generic
|
||||
|
|
@ -1439,7 +1439,7 @@ impl<'a> Linker for WasmLd<'a> {
|
|||
// symbols explicitly passed via the `--export` flags above and hides all
|
||||
// others. Various bits and pieces of wasm32-unknown-unknown tooling use
|
||||
// this, so be sure these symbols make their way out of the linker as well.
|
||||
if self.sess.target.os == "unknown" || self.sess.target.os == "none" {
|
||||
if matches!(self.sess.target.os, Os::Unknown | Os::None) {
|
||||
self.link_args(&["--export=__heap_base", "--export=__data_end"]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ use rustc_metadata::fs::METADATA_FILENAME;
|
|||
use rustc_middle::bug;
|
||||
use rustc_session::Session;
|
||||
use rustc_span::sym;
|
||||
use rustc_target::spec::{RelocModel, Target, ef_avr_arch};
|
||||
use rustc_target::spec::{Abi, Os, RelocModel, Target, ef_avr_arch};
|
||||
use tracing::debug;
|
||||
|
||||
use super::apple;
|
||||
|
|
@ -260,10 +260,10 @@ pub(crate) fn create_object_file(sess: &Session) -> Option<write::Object<'static
|
|||
}
|
||||
|
||||
pub(super) fn elf_os_abi(sess: &Session) -> u8 {
|
||||
match sess.target.options.os.as_ref() {
|
||||
"hermit" => elf::ELFOSABI_STANDALONE,
|
||||
"freebsd" => elf::ELFOSABI_FREEBSD,
|
||||
"solaris" => elf::ELFOSABI_SOLARIS,
|
||||
match sess.target.options.os {
|
||||
Os::Hermit => elf::ELFOSABI_STANDALONE,
|
||||
Os::FreeBsd => elf::ELFOSABI_FREEBSD,
|
||||
Os::Solaris => elf::ELFOSABI_SOLARIS,
|
||||
_ => elf::ELFOSABI_NONE,
|
||||
}
|
||||
}
|
||||
|
|
@ -379,11 +379,11 @@ pub(super) fn elf_e_flags(architecture: Architecture, sess: &Session) -> u32 {
|
|||
}
|
||||
}
|
||||
Architecture::Csky => {
|
||||
let e_flags = match sess.target.options.abi.as_ref() {
|
||||
"abiv2" => elf::EF_CSKY_ABIV2,
|
||||
_ => elf::EF_CSKY_ABIV1,
|
||||
};
|
||||
e_flags
|
||||
if matches!(sess.target.options.abi, Abi::AbiV2) {
|
||||
elf::EF_CSKY_ABIV2
|
||||
} else {
|
||||
elf::EF_CSKY_ABIV1
|
||||
}
|
||||
}
|
||||
Architecture::PowerPc64 => {
|
||||
const EF_PPC64_ABI_UNKNOWN: u32 = 0;
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ use rustc_middle::ty::{self, GenericArgKind, GenericArgsRef, Instance, SymbolNam
|
|||
use rustc_middle::util::Providers;
|
||||
use rustc_session::config::{CrateType, OomStrategy};
|
||||
use rustc_symbol_mangling::mangle_internal_symbol;
|
||||
use rustc_target::spec::{Arch, TlsModel};
|
||||
use rustc_target::spec::{Arch, Os, TlsModel};
|
||||
use tracing::debug;
|
||||
|
||||
use crate::back::symbol_export;
|
||||
|
|
@ -711,7 +711,7 @@ pub(crate) fn extend_exported_symbols<'tcx>(
|
|||
) {
|
||||
let (callconv, _) = calling_convention_for_symbol(tcx, symbol);
|
||||
|
||||
if callconv != CanonAbi::GpuKernel || tcx.sess.target.os != "amdhsa" {
|
||||
if callconv != CanonAbi::GpuKernel || tcx.sess.target.os != Os::AmdHsa {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ use rustc_session::Session;
|
|||
use rustc_session::config::{self, CrateType, EntryFnType};
|
||||
use rustc_span::{DUMMY_SP, Symbol, sym};
|
||||
use rustc_symbol_mangling::mangle_internal_symbol;
|
||||
use rustc_target::spec::Arch;
|
||||
use rustc_target::spec::{Arch, Os};
|
||||
use rustc_trait_selection::infer::{BoundRegionConversionTime, TyCtxtInferExt};
|
||||
use rustc_trait_selection::traits::{ObligationCause, ObligationCtxt};
|
||||
use tracing::{debug, info};
|
||||
|
|
@ -366,7 +366,7 @@ pub(crate) fn build_shift_expr_rhs<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
|||
// us
|
||||
pub fn wants_wasm_eh(sess: &Session) -> bool {
|
||||
sess.target.is_like_wasm
|
||||
&& (sess.target.os != "emscripten" || sess.opts.unstable_opts.emscripten_wasm_eh)
|
||||
&& (sess.target.os != Os::Emscripten || sess.opts.unstable_opts.emscripten_wasm_eh)
|
||||
}
|
||||
|
||||
/// Returns `true` if this session's target will use SEH-based unwinding.
|
||||
|
|
@ -500,7 +500,7 @@ pub fn maybe_create_entry_wrapper<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
|||
) -> Bx::Function {
|
||||
// The entry function is either `int main(void)` or `int main(int argc, char **argv)`, or
|
||||
// `usize efi_main(void *handle, void *system_table)` depending on the target.
|
||||
let llfty = if cx.sess().target.os.contains("uefi") {
|
||||
let llfty = if cx.sess().target.os == Os::Uefi {
|
||||
cx.type_func(&[cx.type_ptr(), cx.type_ptr()], cx.type_isize())
|
||||
} else if cx.sess().target.main_needs_argc_argv {
|
||||
cx.type_func(&[cx.type_int(), cx.type_ptr()], cx.type_int())
|
||||
|
|
@ -562,7 +562,7 @@ pub fn maybe_create_entry_wrapper<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
|||
};
|
||||
|
||||
let result = bx.call(start_ty, None, None, start_fn, &args, None, instance);
|
||||
if cx.sess().target.os.contains("uefi") {
|
||||
if cx.sess().target.os == Os::Uefi {
|
||||
bx.ret(result);
|
||||
} else {
|
||||
let cast = bx.intcast(result, cx.type_int(), true);
|
||||
|
|
@ -576,7 +576,7 @@ pub fn maybe_create_entry_wrapper<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
|||
/// Obtain the `argc` and `argv` values to pass to the rust start function
|
||||
/// (i.e., the "start" lang item).
|
||||
fn get_argc_argv<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(bx: &mut Bx) -> (Bx::Value, Bx::Value) {
|
||||
if bx.cx().sess().target.os.contains("uefi") {
|
||||
if bx.cx().sess().target.os == Os::Uefi {
|
||||
// Params for UEFI
|
||||
let param_handle = bx.get_param(0);
|
||||
let param_system_table = bx.get_param(1);
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ use rustc_middle::ty::{self as ty, TyCtxt};
|
|||
use rustc_session::lint;
|
||||
use rustc_session::parse::feature_err;
|
||||
use rustc_span::{Ident, Span, sym};
|
||||
use rustc_target::spec::Os;
|
||||
|
||||
use crate::errors;
|
||||
use crate::target_features::{
|
||||
|
|
@ -258,7 +259,7 @@ fn process_builtin_attrs(
|
|||
UsedBy::Compiler => codegen_fn_attrs.flags |= CodegenFnAttrFlags::USED_COMPILER,
|
||||
UsedBy::Linker => codegen_fn_attrs.flags |= CodegenFnAttrFlags::USED_LINKER,
|
||||
UsedBy::Default => {
|
||||
let used_form = if tcx.sess.target.os == "illumos" {
|
||||
let used_form = if tcx.sess.target.os == Os::Illumos {
|
||||
// illumos' `ld` doesn't support a section header that would represent
|
||||
// `#[used(linker)]`, see
|
||||
// https://github.com/rust-lang/rust/issues/146169. For that target,
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ use rustc_middle::ty::{self, Instance, TyCtxt};
|
|||
use rustc_middle::{bug, mir, span_bug};
|
||||
use rustc_session::cstore::{DllCallingConvention, DllImport};
|
||||
use rustc_span::Span;
|
||||
use rustc_target::spec::Target;
|
||||
use rustc_target::spec::{Abi, Env, Os, Target};
|
||||
|
||||
use crate::traits::*;
|
||||
|
||||
|
|
@ -171,7 +171,7 @@ pub fn asm_const_to_str<'tcx>(
|
|||
}
|
||||
|
||||
pub fn is_mingw_gnu_toolchain(target: &Target) -> bool {
|
||||
target.os == "windows" && target.env == "gnu" && target.abi.is_empty()
|
||||
target.os == Os::Windows && target.env == Env::Gnu && target.abi == Abi::Unspecified
|
||||
}
|
||||
|
||||
pub fn i686_decorated_name(
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ use rustc_middle::ty::{
|
|||
use rustc_session::{declare_lint, declare_lint_pass};
|
||||
use rustc_span::def_id::LocalDefId;
|
||||
use rustc_span::{Span, sym};
|
||||
use rustc_target::spec::Os;
|
||||
use tracing::debug;
|
||||
|
||||
use super::repr_nullable_ptr;
|
||||
|
|
@ -177,7 +178,7 @@ fn variant_has_complex_ctor(variant: &ty::VariantDef) -> bool {
|
|||
/// the Power alignment Rule (see the `check_struct_for_power_alignment` function).
|
||||
fn check_arg_for_power_alignment<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> bool {
|
||||
let tcx = cx.tcx;
|
||||
assert!(tcx.sess.target.os == "aix");
|
||||
assert!(tcx.sess.target.os == Os::Aix);
|
||||
// Structs (under repr(C)) follow the power alignment rule if:
|
||||
// - the first field of the struct is a floating-point type that
|
||||
// is greater than 4-bytes, or
|
||||
|
|
@ -222,7 +223,7 @@ fn check_struct_for_power_alignment<'tcx>(
|
|||
let tcx = cx.tcx;
|
||||
|
||||
// Only consider structs (not enums or unions) on AIX.
|
||||
if tcx.sess.target.os != "aix" || !adt_def.is_struct() {
|
||||
if tcx.sess.target.os != Os::Aix || !adt_def.is_struct() {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ use rustc_session::cstore::{DllCallingConvention, DllImport, ForeignModule, Nati
|
|||
use rustc_session::search_paths::PathKind;
|
||||
use rustc_span::Symbol;
|
||||
use rustc_span::def_id::{DefId, LOCAL_CRATE};
|
||||
use rustc_target::spec::{Arch, BinaryFormat, LinkSelfContainedComponents};
|
||||
use rustc_target::spec::{Abi, Arch, BinaryFormat, Env, LinkSelfContainedComponents, Os};
|
||||
|
||||
use crate::errors;
|
||||
|
||||
|
|
@ -67,9 +67,9 @@ pub fn walk_native_lib_search_dirs<R>(
|
|||
// FIXME: On AIX this also has the side-effect of making the list of library search paths
|
||||
// non-empty, which is needed or the linker may decide to record the LIBPATH env, if
|
||||
// defined, as the search path instead of appending the default search paths.
|
||||
if sess.target.abi == "fortanix"
|
||||
|| sess.target.os == "linux"
|
||||
|| sess.target.os == "fuchsia"
|
||||
if sess.target.abi == Abi::Fortanix
|
||||
|| sess.target.os == Os::Linux
|
||||
|| sess.target.os == Os::Fuchsia
|
||||
|| sess.target.is_like_aix
|
||||
|| sess.target.is_like_darwin && !sess.sanitizers().is_empty()
|
||||
{
|
||||
|
|
@ -79,7 +79,7 @@ pub fn walk_native_lib_search_dirs<R>(
|
|||
// Mac Catalyst uses the macOS SDK, but to link to iOS-specific frameworks
|
||||
// we must have the support library stubs in the library search path (#121430).
|
||||
if let Some(sdk_root) = apple_sdk_root
|
||||
&& sess.target.env == "macabi"
|
||||
&& sess.target.env == Env::MacAbi
|
||||
{
|
||||
f(&sdk_root.join("System/iOSSupport/usr/lib"), false)?;
|
||||
f(&sdk_root.join("System/iOSSupport/System/Library/Frameworks"), true)?;
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ use rustc_hir::weak_lang_items::WEAK_LANG_ITEMS;
|
|||
use rustc_middle::middle::lang_items::required;
|
||||
use rustc_middle::ty::TyCtxt;
|
||||
use rustc_session::config::CrateType;
|
||||
use rustc_target::spec::Os;
|
||||
|
||||
use crate::errors::{
|
||||
MissingLangItem, MissingPanicHandler, PanicUnwindWithoutStd, UnknownExternLangItem,
|
||||
|
|
@ -26,7 +27,7 @@ pub(crate) fn check_crate(
|
|||
if items.eh_personality().is_none() {
|
||||
items.missing.push(LangItem::EhPersonality);
|
||||
}
|
||||
if tcx.sess.target.os == "emscripten"
|
||||
if tcx.sess.target.os == Os::Emscripten
|
||||
&& items.eh_catch_typeinfo().is_none()
|
||||
&& !tcx.sess.opts.unstable_opts.emscripten_wasm_eh
|
||||
{
|
||||
|
|
|
|||
|
|
@ -239,10 +239,10 @@ pub(crate) fn default_configuration(sess: &Session) -> Cfg {
|
|||
ins_none!(sym::sanitizer_cfi_normalize_integers);
|
||||
}
|
||||
|
||||
ins_str!(sym::target_abi, &sess.target.abi);
|
||||
ins_sym!(sym::target_abi, sess.target.abi.desc_symbol());
|
||||
ins_sym!(sym::target_arch, sess.target.arch.desc_symbol());
|
||||
ins_str!(sym::target_endian, sess.target.endian.as_str());
|
||||
ins_str!(sym::target_env, &sess.target.env);
|
||||
ins_sym!(sym::target_env, sess.target.env.desc_symbol());
|
||||
|
||||
for family in sess.target.families.as_ref() {
|
||||
ins_str!(sym::target_family, family);
|
||||
|
|
@ -291,7 +291,7 @@ pub(crate) fn default_configuration(sess: &Session) -> Cfg {
|
|||
}
|
||||
}
|
||||
|
||||
ins_str!(sym::target_os, &sess.target.os);
|
||||
ins_sym!(sym::target_os, sess.target.os.desc_symbol());
|
||||
ins_sym!(sym::target_pointer_width, sym::integer(sess.target.pointer_width));
|
||||
|
||||
if sess.opts.unstable_opts.has_thread_local.unwrap_or(sess.target.has_thread_local) {
|
||||
|
|
@ -447,14 +447,14 @@ impl CheckCfg {
|
|||
};
|
||||
|
||||
for target in Target::builtins().chain(iter::once(current_target.clone())) {
|
||||
values_target_abi.insert(Symbol::intern(&target.options.abi));
|
||||
values_target_abi.insert(target.options.abi.desc_symbol());
|
||||
values_target_arch.insert(target.arch.desc_symbol());
|
||||
values_target_endian.insert(Symbol::intern(target.options.endian.as_str()));
|
||||
values_target_env.insert(Symbol::intern(&target.options.env));
|
||||
values_target_env.insert(target.options.env.desc_symbol());
|
||||
values_target_family.extend(
|
||||
target.options.families.iter().map(|family| Symbol::intern(family)),
|
||||
);
|
||||
values_target_os.insert(Symbol::intern(&target.options.os));
|
||||
values_target_os.insert(target.options.os.desc_symbol());
|
||||
values_target_pointer_width.insert(sym::integer(target.pointer_width));
|
||||
values_target_vendor.insert(target.vendor_symbol());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ use rustc_span::source_map::{FilePathMapping, SourceMap};
|
|||
use rustc_span::{FileNameDisplayPreference, RealFileName, Span, Symbol};
|
||||
use rustc_target::asm::InlineAsmArch;
|
||||
use rustc_target::spec::{
|
||||
Arch, CodeModel, DebuginfoKind, PanicStrategy, RelocModel, RelroLevel, SanitizerSet,
|
||||
Arch, CodeModel, DebuginfoKind, Os, PanicStrategy, RelocModel, RelroLevel, SanitizerSet,
|
||||
SmallDataThresholdSupport, SplitDebuginfo, StackProtector, SymbolVisibility, Target,
|
||||
TargetTuple, TlsModel, apple,
|
||||
};
|
||||
|
|
@ -382,7 +382,7 @@ impl Session {
|
|||
}
|
||||
|
||||
pub fn is_wasi_reactor(&self) -> bool {
|
||||
self.target.options.os == "wasi"
|
||||
self.target.options.os == Os::Wasi
|
||||
&& matches!(
|
||||
self.opts.unstable_opts.wasi_exec_model,
|
||||
Some(config::WasiExecModel::Reactor)
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ use rustc_data_structures::fx::FxIndexSet;
|
|||
use rustc_span::{Symbol, sym};
|
||||
|
||||
use super::{InlineAsmArch, InlineAsmType, ModifierInfo};
|
||||
use crate::spec::{RelocModel, Target};
|
||||
use crate::spec::{Env, Os, RelocModel, Target};
|
||||
|
||||
def_reg_class! {
|
||||
AArch64 AArch64InlineAsmRegClass {
|
||||
|
|
@ -75,9 +75,9 @@ pub(crate) fn target_reserves_x18(target: &Target, target_features: &FxIndexSet<
|
|||
// See isX18ReservedByDefault in LLVM for targets reserve x18 by default:
|
||||
// https://github.com/llvm/llvm-project/blob/llvmorg-19.1.0/llvm/lib/TargetParser/AArch64TargetParser.cpp#L102-L105
|
||||
// Note that +reserve-x18 is currently not set for the above targets.
|
||||
target.os == "android"
|
||||
|| target.os == "fuchsia"
|
||||
|| target.env == "ohos"
|
||||
target.os == Os::Android
|
||||
|| target.os == Os::Fuchsia
|
||||
|| target.env == Env::Ohos
|
||||
|| target.is_like_darwin
|
||||
|| target.is_like_windows
|
||||
|| target_features.contains(&sym::reserve_x18)
|
||||
|
|
|
|||
|
|
@ -273,7 +273,7 @@ impl InlineAsmArch {
|
|||
Arch::Msp430 => Some(Self::Msp430),
|
||||
Arch::M68k => Some(Self::M68k),
|
||||
Arch::CSky => Some(Self::CSKY),
|
||||
Arch::AmdGpu | Arch::Xtensa | Arch::Unknown(_) => None,
|
||||
Arch::AmdGpu | Arch::Xtensa | Arch::Other(_) => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ use rustc_data_structures::fx::FxIndexSet;
|
|||
use rustc_span::Symbol;
|
||||
|
||||
use super::{InlineAsmArch, InlineAsmType, ModifierInfo};
|
||||
use crate::spec::{RelocModel, Target};
|
||||
use crate::spec::{Abi, RelocModel, Target};
|
||||
|
||||
def_reg_class! {
|
||||
PowerPC PowerPCInlineAsmRegClass {
|
||||
|
|
@ -104,10 +104,10 @@ fn reserved_v20to31(
|
|||
_is_clobber: bool,
|
||||
) -> Result<(), &'static str> {
|
||||
if target.is_like_aix {
|
||||
match &*target.options.abi {
|
||||
"vec-default" => Err("v20-v31 (vs52-vs63) are reserved on vec-default ABI"),
|
||||
"vec-extabi" => Ok(()),
|
||||
_ => unreachable!("unrecognized AIX ABI"),
|
||||
match &target.options.abi {
|
||||
Abi::VecDefault => Err("v20-v31 (vs52-vs63) are reserved on vec-default ABI"),
|
||||
Abi::VecExtAbi => Ok(()),
|
||||
abi => unreachable!("unrecognized AIX ABI: {abi}"),
|
||||
}
|
||||
} else {
|
||||
Ok(())
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ use std::iter;
|
|||
use rustc_abi::{BackendRepr, HasDataLayout, Primitive, TyAbiInterface};
|
||||
|
||||
use crate::callconv::{ArgAbi, FnAbi, Reg, RegKind, Uniform};
|
||||
use crate::spec::{HasTargetSpec, Target};
|
||||
use crate::spec::{Abi, HasTargetSpec, Target};
|
||||
|
||||
/// Indicates the variant of the AArch64 ABI we are compiling for.
|
||||
/// Used to accommodate Apple and Microsoft's deviations from the usual AAPCS ABI.
|
||||
|
|
@ -33,7 +33,7 @@ where
|
|||
RegKind::Integer => false,
|
||||
// The softfloat ABI treats floats like integers, so they
|
||||
// do not get homogeneous aggregate treatment.
|
||||
RegKind::Float => cx.target_spec().abi != "softfloat",
|
||||
RegKind::Float => cx.target_spec().abi != Abi::SoftFloat,
|
||||
RegKind::Vector => size.bits() == 64 || size.bits() == 128,
|
||||
};
|
||||
|
||||
|
|
@ -42,7 +42,7 @@ where
|
|||
}
|
||||
|
||||
fn softfloat_float_abi<Ty>(target: &Target, arg: &mut ArgAbi<'_, Ty>) {
|
||||
if target.abi != "softfloat" {
|
||||
if target.abi != Abi::SoftFloat {
|
||||
return;
|
||||
}
|
||||
// Do *not* use the float registers for passing arguments, as that would make LLVM pick the ABI
|
||||
|
|
|
|||
|
|
@ -702,7 +702,7 @@ impl<'a, Ty> FnAbi<'a, Ty> {
|
|||
Arch::RiscV32 | Arch::RiscV64 => riscv::compute_abi_info(cx, self),
|
||||
Arch::Wasm32 | Arch::Wasm64 => wasm::compute_abi_info(cx, self),
|
||||
Arch::Bpf => bpf::compute_abi_info(cx, self),
|
||||
arch @ (Arch::PowerPC64LE | Arch::SpirV | Arch::Unknown(_)) => {
|
||||
arch @ (Arch::PowerPC64LE | Arch::SpirV | Arch::Other(_)) => {
|
||||
panic!("no lowering implemented for {arch}")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use rustc_abi::TyAbiInterface;
|
||||
|
||||
use crate::callconv::{ArgAbi, FnAbi};
|
||||
use crate::spec::HasTargetSpec;
|
||||
use crate::spec::{Env, HasTargetSpec, Os};
|
||||
|
||||
fn classify_ret<Ty>(ret: &mut ArgAbi<'_, Ty>) {
|
||||
if ret.layout.is_aggregate() {
|
||||
|
|
@ -17,8 +17,8 @@ where
|
|||
{
|
||||
if arg.is_ignore() {
|
||||
// powerpc-unknown-linux-{gnu,musl,uclibc} doesn't ignore ZSTs.
|
||||
if cx.target_spec().os == "linux"
|
||||
&& matches!(&*cx.target_spec().env, "gnu" | "musl" | "uclibc")
|
||||
if cx.target_spec().os == Os::Linux
|
||||
&& matches!(cx.target_spec().env, Env::Gnu | Env::Musl | Env::Uclibc)
|
||||
&& arg.layout.is_zst()
|
||||
{
|
||||
arg.make_indirect_from_ignore();
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
use rustc_abi::{Endian, HasDataLayout, TyAbiInterface};
|
||||
|
||||
use crate::callconv::{Align, ArgAbi, FnAbi, Reg, RegKind, Uniform};
|
||||
use crate::spec::HasTargetSpec;
|
||||
use crate::spec::{Env, HasTargetSpec, Os};
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||
enum ABI {
|
||||
|
|
@ -106,9 +106,9 @@ where
|
|||
Ty: TyAbiInterface<'a, C> + Copy,
|
||||
C: HasDataLayout + HasTargetSpec,
|
||||
{
|
||||
let abi = if cx.target_spec().env == "musl" || cx.target_spec().os == "freebsd" {
|
||||
let abi = if cx.target_spec().env == Env::Musl || cx.target_spec().os == Os::FreeBsd {
|
||||
ELFv2
|
||||
} else if cx.target_spec().os == "aix" {
|
||||
} else if cx.target_spec().os == Os::Aix {
|
||||
AIX
|
||||
} else {
|
||||
match cx.data_layout().endian {
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
use rustc_abi::{BackendRepr, HasDataLayout, TyAbiInterface};
|
||||
|
||||
use crate::callconv::{ArgAbi, FnAbi, Reg, RegKind};
|
||||
use crate::spec::HasTargetSpec;
|
||||
use crate::spec::{Env, HasTargetSpec, Os};
|
||||
|
||||
fn classify_ret<Ty>(ret: &mut ArgAbi<'_, Ty>) {
|
||||
let size = ret.layout.size;
|
||||
|
|
@ -29,8 +29,8 @@ where
|
|||
}
|
||||
if arg.is_ignore() {
|
||||
// s390x-unknown-linux-{gnu,musl,uclibc} doesn't ignore ZSTs.
|
||||
if cx.target_spec().os == "linux"
|
||||
&& matches!(&*cx.target_spec().env, "gnu" | "musl" | "uclibc")
|
||||
if cx.target_spec().os == Os::Linux
|
||||
&& matches!(cx.target_spec().env, Env::Gnu | Env::Musl | Env::Uclibc)
|
||||
&& arg.layout.is_zst()
|
||||
{
|
||||
arg.make_indirect_from_ignore();
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ use rustc_abi::{
|
|||
};
|
||||
|
||||
use crate::callconv::{ArgAbi, ArgAttribute, CastTarget, FnAbi, Uniform};
|
||||
use crate::spec::HasTargetSpec;
|
||||
use crate::spec::{Env, HasTargetSpec, Os};
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
struct Sdata {
|
||||
|
|
@ -223,8 +223,8 @@ where
|
|||
for arg in fn_abi.args.iter_mut() {
|
||||
if arg.is_ignore() {
|
||||
// sparc64-unknown-linux-{gnu,musl,uclibc} doesn't ignore ZSTs.
|
||||
if cx.target_spec().os == "linux"
|
||||
&& matches!(&*cx.target_spec().env, "gnu" | "musl" | "uclibc")
|
||||
if cx.target_spec().os == Os::Linux
|
||||
&& matches!(cx.target_spec().env, Env::Gnu | Env::Musl | Env::Uclibc)
|
||||
&& arg.layout.is_zst()
|
||||
{
|
||||
arg.make_indirect_from_ignore();
|
||||
|
|
|
|||
|
|
@ -137,6 +137,14 @@ macro_rules! target_spec_enum {
|
|||
$( #[$variant_attr:meta] )*
|
||||
$Variant,
|
||||
)*
|
||||
/// The vast majority of the time, the compiler deals with a fixed
|
||||
/// set of values, so it is convenient for them to be represented in
|
||||
/// an enum. However, it is possible to have arbitrary values in a
|
||||
/// target JSON file (which can be parsed when `--target` is
|
||||
/// specified). This might occur, for example, for an out-of-tree
|
||||
/// codegen backend that supports a value (e.g. architecture or OS)
|
||||
/// that rustc currently doesn't know about. This variant exists as
|
||||
/// an escape hatch for such cases.
|
||||
$( #[$other_variant_attr] )*
|
||||
$OtherVariant(crate::spec::StaticCow<str>),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,15 +1,16 @@
|
|||
use rustc_abi::Endian;
|
||||
|
||||
use crate::spec::{
|
||||
BinaryFormat, Cc, CodeModel, LinkOutputKind, LinkerFlavor, TargetOptions, crt_objects, cvs,
|
||||
Abi, BinaryFormat, Cc, CodeModel, LinkOutputKind, LinkerFlavor, Os, TargetOptions, crt_objects,
|
||||
cvs,
|
||||
};
|
||||
|
||||
pub(crate) fn opts() -> TargetOptions {
|
||||
TargetOptions {
|
||||
abi: "vec-extabi".into(),
|
||||
abi: Abi::VecExtAbi,
|
||||
code_model: Some(CodeModel::Large),
|
||||
cpu: "pwr7".into(),
|
||||
os: "aix".into(),
|
||||
os: Os::Aix,
|
||||
vendor: "ibm".into(),
|
||||
dynamic_linking: true,
|
||||
endian: Endian::Big,
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
use crate::spec::{SanitizerSet, TargetOptions, TlsModel, base};
|
||||
use crate::spec::{Os, SanitizerSet, TargetOptions, TlsModel, base};
|
||||
|
||||
pub(crate) fn opts() -> TargetOptions {
|
||||
let mut base = base::linux::opts();
|
||||
base.os = "android".into();
|
||||
base.os = Os::Android;
|
||||
base.is_like_android = true;
|
||||
base.default_dwarf_version = 2;
|
||||
base.tls_model = TlsModel::Emulated;
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@ use std::num::ParseIntError;
|
|||
use std::str::FromStr;
|
||||
|
||||
use crate::spec::{
|
||||
BinaryFormat, Cc, DebuginfoKind, FloatAbi, FramePointer, LinkerFlavor, Lld, RustcAbi,
|
||||
SplitDebuginfo, StackProbeType, StaticCow, Target, TargetOptions, cvs,
|
||||
Abi, BinaryFormat, Cc, DebuginfoKind, Env, FloatAbi, FramePointer, LinkerFlavor, Lld, Os,
|
||||
RustcAbi, SplitDebuginfo, StackProbeType, StaticCow, Target, TargetOptions, cvs,
|
||||
};
|
||||
|
||||
#[cfg(test)]
|
||||
|
|
@ -94,11 +94,25 @@ pub(crate) enum TargetEnv {
|
|||
}
|
||||
|
||||
impl TargetEnv {
|
||||
fn target_env(self) -> &'static str {
|
||||
fn target_env(self) -> Env {
|
||||
match self {
|
||||
Self::Normal => "",
|
||||
Self::MacCatalyst => "macabi",
|
||||
Self::Simulator => "sim",
|
||||
Self::Normal => Env::Unspecified,
|
||||
Self::MacCatalyst => Env::MacAbi,
|
||||
Self::Simulator => Env::Sim,
|
||||
}
|
||||
}
|
||||
|
||||
// NOTE: We originally set `cfg(target_abi = "macabi")` / `cfg(target_abi = "sim")`,
|
||||
// before it was discovered that those are actually environments:
|
||||
// https://github.com/rust-lang/rust/issues/133331
|
||||
//
|
||||
// But let's continue setting them for backwards compatibility.
|
||||
// FIXME(madsmtm): Warn about using these in the future.
|
||||
fn target_abi(self) -> Abi {
|
||||
match self {
|
||||
Self::Normal => Abi::Unspecified,
|
||||
Self::MacCatalyst => Abi::MacAbi,
|
||||
Self::Simulator => Abi::Sim,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -106,23 +120,19 @@ impl TargetEnv {
|
|||
/// Get the base target options, unversioned LLVM target and `target_arch` from the three
|
||||
/// things that uniquely identify Rust's Apple targets: The OS, the architecture, and the ABI.
|
||||
pub(crate) fn base(
|
||||
os: &'static str,
|
||||
os: Os,
|
||||
arch: Arch,
|
||||
env: TargetEnv,
|
||||
) -> (TargetOptions, StaticCow<str>, crate::spec::Arch) {
|
||||
let link_env_remove = link_env_remove(&os);
|
||||
let unversioned_llvm_target = unversioned_llvm_target(&os, arch, env);
|
||||
let mut opts = TargetOptions {
|
||||
llvm_floatabi: Some(FloatAbi::Hard),
|
||||
os: os.into(),
|
||||
env: env.target_env().into(),
|
||||
// NOTE: We originally set `cfg(target_abi = "macabi")` / `cfg(target_abi = "sim")`,
|
||||
// before it was discovered that those are actually environments:
|
||||
// https://github.com/rust-lang/rust/issues/133331
|
||||
//
|
||||
// But let's continue setting them for backwards compatibility.
|
||||
// FIXME(madsmtm): Warn about using these in the future.
|
||||
abi: env.target_env().into(),
|
||||
os,
|
||||
env: env.target_env(),
|
||||
abi: env.target_abi(),
|
||||
cpu: arch.target_cpu(env).into(),
|
||||
link_env_remove: link_env_remove(os),
|
||||
link_env_remove,
|
||||
vendor: "apple".into(),
|
||||
linker_flavor: LinkerFlavor::Darwin(Cc::Yes, Lld::No),
|
||||
// macOS has -dead_strip, which doesn't rely on function_sections
|
||||
|
|
@ -189,23 +199,23 @@ pub(crate) fn base(
|
|||
// All Apple x86-32 targets have SSE2.
|
||||
opts.rustc_abi = Some(RustcAbi::X86Sse2);
|
||||
}
|
||||
(opts, unversioned_llvm_target(os, arch, env), arch.target_arch())
|
||||
(opts, unversioned_llvm_target, arch.target_arch())
|
||||
}
|
||||
|
||||
/// Generate part of the LLVM target triple.
|
||||
///
|
||||
/// See `rustc_codegen_ssa::back::versioned_llvm_target` for the full triple passed to LLVM and
|
||||
/// Clang.
|
||||
fn unversioned_llvm_target(os: &str, arch: Arch, env: TargetEnv) -> StaticCow<str> {
|
||||
fn unversioned_llvm_target(os: &Os, arch: Arch, env: TargetEnv) -> StaticCow<str> {
|
||||
let arch = arch.target_name();
|
||||
// Convert to the "canonical" OS name used by LLVM:
|
||||
// https://github.com/llvm/llvm-project/blob/llvmorg-18.1.8/llvm/lib/TargetParser/Triple.cpp#L236-L282
|
||||
let os = match os {
|
||||
"macos" => "macosx",
|
||||
"ios" => "ios",
|
||||
"watchos" => "watchos",
|
||||
"tvos" => "tvos",
|
||||
"visionos" => "xros",
|
||||
Os::MacOs => "macosx",
|
||||
Os::IOs => "ios",
|
||||
Os::WatchOs => "watchos",
|
||||
Os::TvOs => "tvos",
|
||||
Os::VisionOs => "xros",
|
||||
_ => unreachable!("tried to get LLVM target OS for non-Apple platform"),
|
||||
};
|
||||
let environment = match env {
|
||||
|
|
@ -216,13 +226,13 @@ fn unversioned_llvm_target(os: &str, arch: Arch, env: TargetEnv) -> StaticCow<st
|
|||
format!("{arch}-apple-{os}{environment}").into()
|
||||
}
|
||||
|
||||
fn link_env_remove(os: &'static str) -> StaticCow<[StaticCow<str>]> {
|
||||
fn link_env_remove(os: &Os) -> StaticCow<[StaticCow<str>]> {
|
||||
// Apple platforms only officially support macOS as a host for any compilation.
|
||||
//
|
||||
// If building for macOS, we go ahead and remove any erroneous environment state
|
||||
// that's only applicable to cross-OS compilation. Always leave anything for the
|
||||
// host OS alone though.
|
||||
if os == "macos" {
|
||||
if *os == Os::MacOs {
|
||||
// `IPHONEOS_DEPLOYMENT_TARGET` must not be set when using the Xcode linker at
|
||||
// "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld",
|
||||
// although this is apparently ignored when using the linker at "/usr/bin/ld".
|
||||
|
|
@ -284,7 +294,7 @@ impl OSVersion {
|
|||
}
|
||||
|
||||
/// Minimum operating system versions currently supported by `rustc`.
|
||||
pub fn os_minimum_deployment_target(os: &str) -> Self {
|
||||
pub fn os_minimum_deployment_target(os: &Os) -> Self {
|
||||
// When bumping a version in here, remember to update the platform-support docs too.
|
||||
//
|
||||
// NOTE: The defaults may change in future `rustc` versions, so if you are looking for the
|
||||
|
|
@ -293,12 +303,14 @@ impl OSVersion {
|
|||
// $ rustc --print deployment-target
|
||||
// ```
|
||||
let (major, minor, patch) = match os {
|
||||
"macos" => (10, 12, 0),
|
||||
"ios" => (10, 0, 0),
|
||||
"tvos" => (10, 0, 0),
|
||||
"watchos" => (5, 0, 0),
|
||||
"visionos" => (1, 0, 0),
|
||||
_ => unreachable!("tried to get deployment target for non-Apple platform"),
|
||||
Os::MacOs => (10, 12, 0),
|
||||
Os::IOs => (10, 0, 0),
|
||||
Os::TvOs => (10, 0, 0),
|
||||
Os::WatchOs => (5, 0, 0),
|
||||
Os::VisionOs => (1, 0, 0),
|
||||
other => {
|
||||
unreachable!("tried to get deployment target for non-Apple platform: {:?}", other)
|
||||
}
|
||||
};
|
||||
Self { major, minor, patch }
|
||||
}
|
||||
|
|
@ -311,36 +323,36 @@ impl OSVersion {
|
|||
/// This matches what LLVM does, see in part:
|
||||
/// <https://github.com/llvm/llvm-project/blob/llvmorg-21.1.3/llvm/lib/TargetParser/Triple.cpp#L2140-L2175>
|
||||
pub fn minimum_deployment_target(target: &Target) -> Self {
|
||||
let (major, minor, patch) = match (&*target.os, &target.arch, &*target.env) {
|
||||
("macos", crate::spec::Arch::AArch64, _) => (11, 0, 0),
|
||||
("ios", crate::spec::Arch::AArch64, "macabi") => (14, 0, 0),
|
||||
("ios", crate::spec::Arch::AArch64, "sim") => (14, 0, 0),
|
||||
("ios", _, _) if target.llvm_target.starts_with("arm64e") => (14, 0, 0),
|
||||
let (major, minor, patch) = match (&target.os, &target.arch, &target.env) {
|
||||
(Os::MacOs, crate::spec::Arch::AArch64, _) => (11, 0, 0),
|
||||
(Os::IOs, crate::spec::Arch::AArch64, Env::MacAbi) => (14, 0, 0),
|
||||
(Os::IOs, crate::spec::Arch::AArch64, Env::Sim) => (14, 0, 0),
|
||||
(Os::IOs, _, _) if target.llvm_target.starts_with("arm64e") => (14, 0, 0),
|
||||
// Mac Catalyst defaults to 13.1 in Clang.
|
||||
("ios", _, "macabi") => (13, 1, 0),
|
||||
("tvos", crate::spec::Arch::AArch64, "sim") => (14, 0, 0),
|
||||
("watchos", crate::spec::Arch::AArch64, "sim") => (7, 0, 0),
|
||||
(Os::IOs, _, Env::MacAbi) => (13, 1, 0),
|
||||
(Os::TvOs, crate::spec::Arch::AArch64, Env::Sim) => (14, 0, 0),
|
||||
(Os::WatchOs, crate::spec::Arch::AArch64, Env::Sim) => (7, 0, 0),
|
||||
// True Aarch64 on watchOS (instead of their Aarch64 Ilp32 called `arm64_32`) has been
|
||||
// available since Xcode 14, but it's only actually used more recently in watchOS 26.
|
||||
("watchos", crate::spec::Arch::AArch64, "")
|
||||
(Os::WatchOs, crate::spec::Arch::AArch64, Env::Unspecified)
|
||||
if !target.llvm_target.starts_with("arm64_32") =>
|
||||
{
|
||||
(26, 0, 0)
|
||||
}
|
||||
(os, _, _) => return Self::os_minimum_deployment_target(os),
|
||||
_ => return Self::os_minimum_deployment_target(&target.os),
|
||||
};
|
||||
Self { major, minor, patch }
|
||||
}
|
||||
}
|
||||
|
||||
/// Name of the environment variable used to fetch the deployment target on the given OS.
|
||||
pub fn deployment_target_env_var(os: &str) -> &'static str {
|
||||
pub fn deployment_target_env_var(os: &Os) -> &'static str {
|
||||
match os {
|
||||
"macos" => "MACOSX_DEPLOYMENT_TARGET",
|
||||
"ios" => "IPHONEOS_DEPLOYMENT_TARGET",
|
||||
"watchos" => "WATCHOS_DEPLOYMENT_TARGET",
|
||||
"tvos" => "TVOS_DEPLOYMENT_TARGET",
|
||||
"visionos" => "XROS_DEPLOYMENT_TARGET",
|
||||
Os::MacOs => "MACOSX_DEPLOYMENT_TARGET",
|
||||
Os::IOs => "IPHONEOS_DEPLOYMENT_TARGET",
|
||||
Os::WatchOs => "WATCHOS_DEPLOYMENT_TARGET",
|
||||
Os::TvOs => "TVOS_DEPLOYMENT_TARGET",
|
||||
Os::VisionOs => "XROS_DEPLOYMENT_TARGET",
|
||||
_ => unreachable!("tried to get deployment target env var for non-Apple platform"),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ use crate::spec::targets::{
|
|||
aarch64_apple_watchos_sim, i686_apple_darwin, x86_64_apple_darwin, x86_64_apple_ios,
|
||||
x86_64_apple_tvos, x86_64_apple_watchos_sim,
|
||||
};
|
||||
use crate::spec::{Abi, Env};
|
||||
|
||||
#[test]
|
||||
fn simulator_targets_set_env() {
|
||||
|
|
@ -18,9 +19,9 @@ fn simulator_targets_set_env() {
|
|||
];
|
||||
|
||||
for target in &all_sim_targets {
|
||||
assert_eq!(target.env, "sim");
|
||||
assert_eq!(target.env, Env::Sim);
|
||||
// Ensure backwards compat
|
||||
assert_eq!(target.abi, "sim");
|
||||
assert_eq!(target.abi, Abi::Sim);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
use std::borrow::Cow;
|
||||
|
||||
use crate::spec::{
|
||||
BinaryFormat, Cc, DebuginfoKind, LinkerFlavor, Lld, SplitDebuginfo, TargetOptions, TlsModel,
|
||||
cvs,
|
||||
BinaryFormat, Cc, DebuginfoKind, LinkerFlavor, Lld, Os, SplitDebuginfo, TargetOptions,
|
||||
TlsModel, cvs,
|
||||
};
|
||||
|
||||
pub(crate) fn opts() -> TargetOptions {
|
||||
|
|
@ -24,7 +24,7 @@ pub(crate) fn opts() -> TargetOptions {
|
|||
cygwin_libs,
|
||||
);
|
||||
TargetOptions {
|
||||
os: "cygwin".into(),
|
||||
os: Os::Cygwin,
|
||||
vendor: "pc".into(),
|
||||
// FIXME(#13846) this should be enabled for cygwin
|
||||
function_sections: false,
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
use crate::spec::{RelroLevel, TargetOptions, cvs};
|
||||
use crate::spec::{Os, RelroLevel, TargetOptions, cvs};
|
||||
|
||||
pub(crate) fn opts() -> TargetOptions {
|
||||
TargetOptions {
|
||||
os: "dragonfly".into(),
|
||||
os: Os::Dragonfly,
|
||||
dynamic_linking: true,
|
||||
families: cvs!["unix"],
|
||||
has_rpath: true,
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
use crate::spec::{RelroLevel, TargetOptions, cvs};
|
||||
use crate::spec::{Os, RelroLevel, TargetOptions, cvs};
|
||||
|
||||
pub(crate) fn opts() -> TargetOptions {
|
||||
TargetOptions {
|
||||
os: "freebsd".into(),
|
||||
os: Os::FreeBsd,
|
||||
dynamic_linking: true,
|
||||
families: cvs!["unix"],
|
||||
has_rpath: true,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use crate::spec::{
|
||||
Cc, FramePointer, LinkOutputKind, LinkerFlavor, Lld, TargetOptions, crt_objects, cvs,
|
||||
Cc, FramePointer, LinkOutputKind, LinkerFlavor, Lld, Os, TargetOptions, crt_objects, cvs,
|
||||
};
|
||||
|
||||
pub(crate) fn opts() -> TargetOptions {
|
||||
|
|
@ -30,7 +30,7 @@ pub(crate) fn opts() -> TargetOptions {
|
|||
);
|
||||
|
||||
TargetOptions {
|
||||
os: "fuchsia".into(),
|
||||
os: Os::Fuchsia,
|
||||
linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes),
|
||||
linker: Some("rust-lld".into()),
|
||||
dynamic_linking: true,
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
use crate::spec::{RelroLevel, TargetOptions, cvs};
|
||||
use crate::spec::{Os, RelroLevel, TargetOptions, cvs};
|
||||
|
||||
pub(crate) fn opts() -> TargetOptions {
|
||||
TargetOptions {
|
||||
os: "haiku".into(),
|
||||
os: Os::Haiku,
|
||||
dynamic_linking: true,
|
||||
families: cvs!["unix"],
|
||||
relro_level: RelroLevel::Full,
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
use crate::spec::{PanicStrategy, RelroLevel, StackProbeType, TargetOptions};
|
||||
use crate::spec::{Os, PanicStrategy, RelroLevel, StackProbeType, TargetOptions};
|
||||
|
||||
pub(crate) fn opts() -> TargetOptions {
|
||||
TargetOptions {
|
||||
os: "helenos".into(),
|
||||
os: Os::HelenOs,
|
||||
|
||||
dynamic_linking: true,
|
||||
// we need the linker to keep libgcc and friends
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
use crate::spec::{Cc, LinkerFlavor, Lld, PanicStrategy, TargetOptions, TlsModel};
|
||||
use crate::spec::{Cc, LinkerFlavor, Lld, Os, PanicStrategy, TargetOptions, TlsModel};
|
||||
|
||||
pub(crate) fn opts() -> TargetOptions {
|
||||
TargetOptions {
|
||||
os: "hermit".into(),
|
||||
os: Os::Hermit,
|
||||
linker: Some("rust-lld".into()),
|
||||
linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes),
|
||||
tls_model: TlsModel::InitialExec,
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
use crate::spec::{RelroLevel, TargetOptions, cvs};
|
||||
use crate::spec::{Os, RelroLevel, TargetOptions, cvs};
|
||||
|
||||
pub(crate) fn opts() -> TargetOptions {
|
||||
TargetOptions {
|
||||
os: "hurd".into(),
|
||||
os: Os::Hurd,
|
||||
dynamic_linking: true,
|
||||
families: cvs!["unix"],
|
||||
has_rpath: true,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use crate::spec::{TargetOptions, base};
|
||||
use crate::spec::{Env, TargetOptions, base};
|
||||
|
||||
pub(crate) fn opts() -> TargetOptions {
|
||||
TargetOptions { env: "gnu".into(), ..base::hurd::opts() }
|
||||
TargetOptions { env: Env::Gnu, ..base::hurd::opts() }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use crate::spec::{Cc, FramePointer, LinkerFlavor, TargetOptions, cvs};
|
||||
use crate::spec::{Cc, FramePointer, LinkerFlavor, Os, TargetOptions, cvs};
|
||||
|
||||
pub(crate) fn opts() -> TargetOptions {
|
||||
let late_link_args = TargetOptions::link_args(
|
||||
|
|
@ -25,7 +25,7 @@ pub(crate) fn opts() -> TargetOptions {
|
|||
);
|
||||
|
||||
TargetOptions {
|
||||
os: "illumos".into(),
|
||||
os: Os::Illumos,
|
||||
dynamic_linking: true,
|
||||
has_rpath: true,
|
||||
families: cvs!["unix"],
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
use crate::spec::{Cc, LinkerFlavor, PanicStrategy, RelocModel, TargetOptions, cvs};
|
||||
use crate::spec::{Cc, Env, LinkerFlavor, Os, PanicStrategy, RelocModel, TargetOptions, cvs};
|
||||
|
||||
pub(crate) fn opts() -> TargetOptions {
|
||||
TargetOptions {
|
||||
os: "l4re".into(),
|
||||
env: "uclibc".into(),
|
||||
os: Os::L4Re,
|
||||
env: Env::Uclibc,
|
||||
linker_flavor: LinkerFlavor::Unix(Cc::No),
|
||||
panic_strategy: PanicStrategy::Abort,
|
||||
linker: Some("l4-bender".into()),
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
use std::borrow::Cow;
|
||||
|
||||
use crate::spec::{RelroLevel, SplitDebuginfo, TargetOptions, cvs};
|
||||
use crate::spec::{Os, RelroLevel, SplitDebuginfo, TargetOptions, cvs};
|
||||
|
||||
pub(crate) fn opts() -> TargetOptions {
|
||||
TargetOptions {
|
||||
os: "linux".into(),
|
||||
os: Os::Linux,
|
||||
dynamic_linking: true,
|
||||
families: cvs!["unix"],
|
||||
has_rpath: true,
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use crate::spec::{Cc, LinkerFlavor, Lld, TargetOptions, base};
|
||||
use crate::spec::{Cc, Env, LinkerFlavor, Lld, TargetOptions, base};
|
||||
|
||||
pub(crate) fn opts() -> TargetOptions {
|
||||
let mut base = TargetOptions { env: "gnu".into(), ..base::linux::opts() };
|
||||
let mut base = TargetOptions { env: Env::Gnu, ..base::linux::opts() };
|
||||
|
||||
// When we're asked to use the `rust-lld` linker by default, set the appropriate lld-using
|
||||
// linker flavor, and self-contained linker component.
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
use crate::spec::{LinkSelfContainedDefault, TargetOptions, base, crt_objects};
|
||||
use crate::spec::{Env, LinkSelfContainedDefault, TargetOptions, base, crt_objects};
|
||||
|
||||
pub(crate) fn opts() -> TargetOptions {
|
||||
TargetOptions {
|
||||
env: "musl".into(),
|
||||
env: Env::Musl,
|
||||
pre_link_objects_self_contained: crt_objects::pre_musl_self_contained(),
|
||||
post_link_objects_self_contained: crt_objects::post_musl_self_contained(),
|
||||
link_self_contained: LinkSelfContainedDefault::InferredForMusl,
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
use crate::spec::{TargetOptions, TlsModel, base};
|
||||
use crate::spec::{Env, TargetOptions, TlsModel, base};
|
||||
|
||||
pub(crate) fn opts() -> TargetOptions {
|
||||
TargetOptions {
|
||||
env: "ohos".into(),
|
||||
env: Env::Ohos,
|
||||
crt_static_default: false,
|
||||
tls_model: TlsModel::Emulated,
|
||||
has_thread_local: false,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use crate::spec::{TargetOptions, base};
|
||||
use crate::spec::{Env, TargetOptions, base};
|
||||
|
||||
pub(crate) fn opts() -> TargetOptions {
|
||||
TargetOptions { env: "uclibc".into(), ..base::linux::opts() }
|
||||
TargetOptions { env: Env::Uclibc, ..base::linux::opts() }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@
|
|||
//! aspects from their respective base targets
|
||||
|
||||
use crate::spec::{
|
||||
Cc, LinkSelfContainedDefault, LinkerFlavor, PanicStrategy, RelocModel, TargetOptions, TlsModel,
|
||||
add_link_args, crt_objects, cvs,
|
||||
Cc, Env, LinkSelfContainedDefault, LinkerFlavor, Os, PanicStrategy, RelocModel, TargetOptions,
|
||||
TlsModel, add_link_args, crt_objects, cvs,
|
||||
};
|
||||
|
||||
pub(crate) fn opts() -> TargetOptions {
|
||||
|
|
@ -57,8 +57,8 @@ pub(crate) fn opts() -> TargetOptions {
|
|||
TargetOptions {
|
||||
is_like_wasm: true,
|
||||
families: cvs!["wasm", "unix"],
|
||||
os: "linux".into(),
|
||||
env: "musl".into(),
|
||||
os: Os::Linux,
|
||||
env: Env::Musl,
|
||||
|
||||
// we allow dynamic linking, but only cdylibs. Basically we allow a
|
||||
// final library artifact that exports some symbols (a wasm module) but
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
use std::borrow::Cow;
|
||||
|
||||
use crate::spec::{
|
||||
PanicStrategy, RelocModel, RelroLevel, SplitDebuginfo, StackProbeType, TargetOptions, cvs,
|
||||
Os, PanicStrategy, RelocModel, RelroLevel, SplitDebuginfo, StackProbeType, TargetOptions, cvs,
|
||||
};
|
||||
|
||||
pub(crate) fn opts() -> TargetOptions {
|
||||
TargetOptions {
|
||||
os: "lynxos178".into(),
|
||||
os: Os::LynxOs178,
|
||||
dynamic_linking: false,
|
||||
families: cvs!["unix"],
|
||||
position_independent_executables: false,
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
use crate::spec::{RelroLevel, TargetOptions, cvs};
|
||||
use crate::spec::{Env, Os, RelroLevel, TargetOptions, cvs};
|
||||
|
||||
pub(crate) fn opts() -> TargetOptions {
|
||||
TargetOptions {
|
||||
os: "managarm".into(),
|
||||
env: "mlibc".into(),
|
||||
os: Os::Managarm,
|
||||
env: Env::Mlibc,
|
||||
dynamic_linking: true,
|
||||
executables: true,
|
||||
families: cvs!["unix"],
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use crate::spec::{
|
||||
Cc, FramePointer, LinkerFlavor, Lld, PanicStrategy, StackProbeType, TargetOptions,
|
||||
Cc, FramePointer, LinkerFlavor, Lld, Os, PanicStrategy, StackProbeType, TargetOptions,
|
||||
};
|
||||
|
||||
pub(crate) fn opts() -> TargetOptions {
|
||||
|
|
@ -16,7 +16,7 @@ pub(crate) fn opts() -> TargetOptions {
|
|||
],
|
||||
);
|
||||
TargetOptions {
|
||||
os: "motor".into(),
|
||||
os: Os::Motor,
|
||||
executables: true,
|
||||
// TLS is false below because if true, the compiler assumes
|
||||
// we handle TLS at the ELF loading level, which we don't.
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
use crate::spec::{RelroLevel, TargetOptions, cvs};
|
||||
use crate::spec::{Os, RelroLevel, TargetOptions, cvs};
|
||||
|
||||
pub(crate) fn opts() -> TargetOptions {
|
||||
TargetOptions {
|
||||
os: "netbsd".into(),
|
||||
os: Os::NetBsd,
|
||||
dynamic_linking: true,
|
||||
families: cvs!["unix"],
|
||||
no_default_libraries: false,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use crate::spec::{
|
||||
Cc, LinkArgs, LinkerFlavor, Lld, RelroLevel, Target, TargetMetadata, TargetOptions, cvs,
|
||||
Cc, LinkArgs, LinkerFlavor, Lld, Os, RelroLevel, Target, TargetMetadata, TargetOptions, cvs,
|
||||
};
|
||||
|
||||
pub(crate) fn opts() -> TargetOptions {
|
||||
|
|
@ -11,7 +11,7 @@ pub(crate) fn opts() -> TargetOptions {
|
|||
has_rpath: true,
|
||||
has_thread_local: false,
|
||||
linker: Some("qcc".into()),
|
||||
os: "nto".into(),
|
||||
os: Os::Nto,
|
||||
// We want backtraces to work by default and they rely on unwind tables
|
||||
// (regardless of `-C panic` strategy).
|
||||
default_uwtable: true,
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
use crate::spec::{FramePointer, RelroLevel, TargetOptions, TlsModel, cvs};
|
||||
use crate::spec::{FramePointer, Os, RelroLevel, TargetOptions, TlsModel, cvs};
|
||||
|
||||
pub(crate) fn opts() -> TargetOptions {
|
||||
TargetOptions {
|
||||
os: "openbsd".into(),
|
||||
os: Os::OpenBsd,
|
||||
dynamic_linking: true,
|
||||
families: cvs!["unix"],
|
||||
has_rpath: true,
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
use crate::spec::{Cc, LinkerFlavor, Lld, RelroLevel, TargetOptions, cvs};
|
||||
use crate::spec::{Cc, Env, LinkerFlavor, Lld, Os, RelroLevel, TargetOptions, cvs};
|
||||
|
||||
pub(crate) fn opts() -> TargetOptions {
|
||||
TargetOptions {
|
||||
os: "redox".into(),
|
||||
env: "relibc".into(),
|
||||
os: Os::Redox,
|
||||
env: Env::Relibc,
|
||||
dynamic_linking: true,
|
||||
families: cvs!["unix"],
|
||||
has_rpath: true,
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
use crate::spec::{Cc, LinkerFlavor, TargetOptions, cvs};
|
||||
use crate::spec::{Cc, LinkerFlavor, Os, TargetOptions, cvs};
|
||||
|
||||
pub(crate) fn opts() -> TargetOptions {
|
||||
TargetOptions {
|
||||
os: "solaris".into(),
|
||||
os: Os::Solaris,
|
||||
dynamic_linking: true,
|
||||
has_rpath: true,
|
||||
families: cvs!["unix"],
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
use crate::spec::{FramePointer, TargetOptions};
|
||||
use crate::spec::{FramePointer, Os, TargetOptions};
|
||||
|
||||
pub(crate) fn opts(kernel: &str) -> TargetOptions {
|
||||
pub(crate) fn opts() -> TargetOptions {
|
||||
TargetOptions {
|
||||
os: format!("solid_{kernel}").into(),
|
||||
os: Os::SolidAsp3,
|
||||
vendor: "kmc".into(),
|
||||
executables: false,
|
||||
frame_pointer: FramePointer::NonLeaf,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
use crate::spec::{Cc, LinkerFlavor, Lld, PanicStrategy, RelroLevel, TargetOptions, add_link_args};
|
||||
use crate::spec::{
|
||||
Cc, LinkerFlavor, Lld, Os, PanicStrategy, RelroLevel, TargetOptions, add_link_args,
|
||||
};
|
||||
|
||||
pub(crate) fn opts() -> TargetOptions {
|
||||
let lld_args = &["-zmax-page-size=4096", "-znow", "-ztext", "--execute-only"];
|
||||
|
|
@ -8,8 +10,7 @@ pub(crate) fn opts() -> TargetOptions {
|
|||
add_link_args(&mut pre_link_args, LinkerFlavor::Gnu(Cc::Yes, Lld::No), cc_args);
|
||||
|
||||
TargetOptions {
|
||||
os: "teeos".into(),
|
||||
vendor: "unknown".into(),
|
||||
os: Os::TeeOs,
|
||||
dynamic_linking: true,
|
||||
linker_flavor: LinkerFlavor::Gnu(Cc::Yes, Lld::No),
|
||||
// rpath hardcodes -Wl, so it can't be used together with ld.lld.
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
// 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, Lld, PanicStrategy, StackProbeType, TargetOptions, base};
|
||||
use crate::spec::{LinkerFlavor, Lld, Os, PanicStrategy, StackProbeType, TargetOptions, base};
|
||||
|
||||
pub(crate) fn opts() -> TargetOptions {
|
||||
let mut base = base::msvc::opts();
|
||||
|
|
@ -35,7 +35,7 @@ pub(crate) fn opts() -> TargetOptions {
|
|||
);
|
||||
|
||||
TargetOptions {
|
||||
os: "uefi".into(),
|
||||
os: Os::Uefi,
|
||||
linker_flavor: LinkerFlavor::Msvc(Lld::Yes),
|
||||
disable_redzone: true,
|
||||
exe_suffix: ".efi".into(),
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
use crate::spec::{PanicStrategy, RelocModel, TargetOptions, cvs};
|
||||
use crate::spec::{Env, Os, PanicStrategy, RelocModel, TargetOptions, cvs};
|
||||
|
||||
pub(crate) fn opts() -> TargetOptions {
|
||||
TargetOptions {
|
||||
os: "linux".into(),
|
||||
env: "musl".into(),
|
||||
os: Os::Linux,
|
||||
env: Env::Musl,
|
||||
vendor: "unikraft".into(),
|
||||
linker: Some("kraftld".into()),
|
||||
relocation_model: RelocModel::Static,
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
use crate::spec::{TargetOptions, cvs};
|
||||
use crate::spec::{Env, Os, TargetOptions, cvs};
|
||||
|
||||
pub(crate) fn opts() -> TargetOptions {
|
||||
TargetOptions {
|
||||
os: "vxworks".into(),
|
||||
env: "gnu".into(),
|
||||
os: Os::VxWorks,
|
||||
env: Env::Gnu,
|
||||
vendor: "wrs".into(),
|
||||
linker: Some("wr-c++".into()),
|
||||
exe_suffix: ".vxe".into(),
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
use std::borrow::Cow;
|
||||
|
||||
use crate::spec::{
|
||||
BinaryFormat, Cc, DebuginfoKind, LinkSelfContainedDefault, LinkerFlavor, Lld, SplitDebuginfo,
|
||||
TargetOptions, add_link_args, crt_objects, cvs,
|
||||
BinaryFormat, Cc, DebuginfoKind, Env, LinkSelfContainedDefault, LinkerFlavor, Lld, Os,
|
||||
SplitDebuginfo, TargetOptions, add_link_args, crt_objects, cvs,
|
||||
};
|
||||
|
||||
pub(crate) fn opts() -> TargetOptions {
|
||||
|
|
@ -77,8 +77,8 @@ pub(crate) fn opts() -> TargetOptions {
|
|||
);
|
||||
|
||||
TargetOptions {
|
||||
os: "windows".into(),
|
||||
env: "gnu".into(),
|
||||
os: Os::Windows,
|
||||
env: Env::Gnu,
|
||||
vendor: "pc".into(),
|
||||
// FIXME(#13846) this should be enabled for windows
|
||||
function_sections: false,
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
use std::borrow::Cow;
|
||||
|
||||
use crate::spec::{
|
||||
BinaryFormat, Cc, DebuginfoKind, LinkerFlavor, Lld, SplitDebuginfo, TargetOptions, cvs,
|
||||
Abi, BinaryFormat, Cc, DebuginfoKind, Env, LinkerFlavor, Lld, Os, SplitDebuginfo,
|
||||
TargetOptions, cvs,
|
||||
};
|
||||
|
||||
pub(crate) fn opts() -> TargetOptions {
|
||||
|
|
@ -20,10 +21,10 @@ pub(crate) fn opts() -> TargetOptions {
|
|||
);
|
||||
|
||||
TargetOptions {
|
||||
os: "windows".into(),
|
||||
env: "gnu".into(),
|
||||
os: Os::Windows,
|
||||
env: Env::Gnu,
|
||||
vendor: "pc".into(),
|
||||
abi: "llvm".into(),
|
||||
abi: Abi::Llvm,
|
||||
linker: Some("clang".into()),
|
||||
dynamic_linking: true,
|
||||
dll_tls_export: false,
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
use crate::spec::{TargetOptions, base, cvs};
|
||||
use crate::spec::{Env, Os, TargetOptions, base, cvs};
|
||||
|
||||
pub(crate) fn opts() -> TargetOptions {
|
||||
let base = base::msvc::opts();
|
||||
|
||||
TargetOptions {
|
||||
os: "windows".into(),
|
||||
env: "msvc".into(),
|
||||
os: Os::Windows,
|
||||
env: Env::Msvc,
|
||||
vendor: "pc".into(),
|
||||
dynamic_linking: true,
|
||||
dll_prefix: "".into(),
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use crate::spec::{Cc, LinkArgs, LinkerFlavor, Lld, TargetOptions, add_link_args, base};
|
||||
use crate::spec::{Abi, Cc, LinkArgs, LinkerFlavor, Lld, TargetOptions, add_link_args, base};
|
||||
|
||||
pub(crate) fn opts() -> TargetOptions {
|
||||
let base = base::windows_gnu::opts();
|
||||
|
|
@ -23,7 +23,7 @@ pub(crate) fn opts() -> TargetOptions {
|
|||
let late_link_args_static = LinkArgs::new();
|
||||
|
||||
TargetOptions {
|
||||
abi: "uwp".into(),
|
||||
abi: Abi::Uwp,
|
||||
vendor: "uwp".into(),
|
||||
limit_rdylib_exports: false,
|
||||
late_link_args,
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
use crate::spec::{LinkerFlavor, Lld, TargetOptions, base};
|
||||
use crate::spec::{Abi, LinkerFlavor, Lld, TargetOptions, base};
|
||||
|
||||
pub(crate) fn opts() -> TargetOptions {
|
||||
let mut opts =
|
||||
TargetOptions { abi: "uwp".into(), vendor: "uwp".into(), ..base::windows_msvc::opts() };
|
||||
TargetOptions { abi: Abi::Uwp, vendor: "uwp".into(), ..base::windows_msvc::opts() };
|
||||
|
||||
opts.add_pre_link_args(LinkerFlavor::Msvc(Lld::No), &["/APPCONTAINER", "mincore.lib"]);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
use rustc_abi::Endian;
|
||||
|
||||
use crate::spec::{Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, TargetOptions};
|
||||
use crate::spec::{Cc, LinkerFlavor, Lld, Os, PanicStrategy, RelocModel, TargetOptions};
|
||||
|
||||
pub(crate) fn opts() -> TargetOptions {
|
||||
TargetOptions {
|
||||
os: "none".into(),
|
||||
os: Os::None,
|
||||
endian: Endian::Little,
|
||||
c_int_width: 32,
|
||||
linker_flavor: LinkerFlavor::Gnu(Cc::Yes, Lld::No),
|
||||
|
|
|
|||
|
|
@ -5,9 +5,9 @@ use rustc_abi::{Align, AlignFromBytesError};
|
|||
|
||||
use super::crt_objects::CrtObjects;
|
||||
use super::{
|
||||
Arch, BinaryFormat, CodeModel, DebuginfoKind, FloatAbi, FramePointer, LinkArgsCli,
|
||||
Abi, Arch, BinaryFormat, CodeModel, DebuginfoKind, Env, FloatAbi, FramePointer, LinkArgsCli,
|
||||
LinkSelfContainedComponents, LinkSelfContainedDefault, LinkerFlavorCli, LldFlavor,
|
||||
MergeFunctions, PanicStrategy, RelocModel, RelroLevel, RustcAbi, SanitizerSet,
|
||||
MergeFunctions, Os, PanicStrategy, RelocModel, RelroLevel, RustcAbi, SanitizerSet,
|
||||
SmallDataThresholdSupport, SplitDebuginfo, StackProbeType, StaticCow, SymbolVisibility, Target,
|
||||
TargetKind, TargetOptions, TargetWarnings, TlsModel,
|
||||
};
|
||||
|
|
@ -505,9 +505,9 @@ struct TargetSpecJson {
|
|||
#[serde(rename = "target-c-int-width")]
|
||||
c_int_width: Option<u16>,
|
||||
c_enum_min_bits: Option<u64>,
|
||||
os: Option<StaticCow<str>>,
|
||||
env: Option<StaticCow<str>>,
|
||||
abi: Option<StaticCow<str>>,
|
||||
os: Option<Os>,
|
||||
env: Option<Env>,
|
||||
abi: Option<Abi>,
|
||||
vendor: Option<StaticCow<str>>,
|
||||
linker: Option<StaticCow<str>>,
|
||||
#[serde(rename = "linker-flavor")]
|
||||
|
|
|
|||
|
|
@ -1884,14 +1884,7 @@ crate::target_spec_enum! {
|
|||
X86_64 = "x86_64",
|
||||
Xtensa = "xtensa",
|
||||
}
|
||||
/// The vast majority of the time, the compiler deals with a fixed set of
|
||||
/// target architectures, so it is convenient for them to be represented in
|
||||
/// an enum. However, it is possible to have arbitrary values for the "arch"
|
||||
/// field in a target JSON file (which can be parsed when `--target` is
|
||||
/// specified). This might occur, for example, for an out-of-tree codegen
|
||||
/// backend that supports an architecture that rustc currently doesn't know
|
||||
/// about. This variant exists as an escape hatch for such cases.
|
||||
other_variant = Unknown;
|
||||
other_variant = Other;
|
||||
}
|
||||
|
||||
impl Arch {
|
||||
|
|
@ -1928,11 +1921,135 @@ impl Arch {
|
|||
Self::X86 => sym::x86,
|
||||
Self::X86_64 => sym::x86_64,
|
||||
Self::Xtensa => sym::xtensa,
|
||||
Self::Unknown(name) => rustc_span::Symbol::intern(name),
|
||||
Self::Other(name) => rustc_span::Symbol::intern(name),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
crate::target_spec_enum! {
|
||||
pub enum Os {
|
||||
Aix = "aix",
|
||||
AmdHsa = "amdhsa",
|
||||
Android = "android",
|
||||
Cuda = "cuda",
|
||||
Cygwin = "cygwin",
|
||||
Dragonfly = "dragonfly",
|
||||
Emscripten = "emscripten",
|
||||
EspIdf = "espidf",
|
||||
FreeBsd = "freebsd",
|
||||
Fuchsia = "fuchsia",
|
||||
Haiku = "haiku",
|
||||
HelenOs = "helenos",
|
||||
Hermit = "hermit",
|
||||
Horizon = "horizon",
|
||||
Hurd = "hurd",
|
||||
Illumos = "illumos",
|
||||
IOs = "ios",
|
||||
L4Re = "l4re",
|
||||
Linux = "linux",
|
||||
LynxOs178 = "lynxos178",
|
||||
MacOs = "macos",
|
||||
Managarm = "managarm",
|
||||
Motor = "motor",
|
||||
NetBsd = "netbsd",
|
||||
None = "none",
|
||||
Nto = "nto",
|
||||
NuttX = "nuttx",
|
||||
OpenBsd = "openbsd",
|
||||
Psp = "psp",
|
||||
Psx = "psx",
|
||||
Redox = "redox",
|
||||
Rtems = "rtems",
|
||||
Solaris = "solaris",
|
||||
SolidAsp3 = "solid_asp3",
|
||||
TeeOs = "teeos",
|
||||
Trusty = "trusty",
|
||||
TvOs = "tvos",
|
||||
Uefi = "uefi",
|
||||
VexOs = "vexos",
|
||||
VisionOs = "visionos",
|
||||
Vita = "vita",
|
||||
VxWorks = "vxworks",
|
||||
Wasi = "wasi",
|
||||
WatchOs = "watchos",
|
||||
Windows = "windows",
|
||||
Xous = "xous",
|
||||
Zkvm = "zkvm",
|
||||
Unknown = "unknown",
|
||||
}
|
||||
other_variant = Other;
|
||||
}
|
||||
|
||||
impl Os {
|
||||
pub fn desc_symbol(&self) -> Symbol {
|
||||
Symbol::intern(self.desc())
|
||||
}
|
||||
}
|
||||
|
||||
crate::target_spec_enum! {
|
||||
pub enum Env {
|
||||
Gnu = "gnu",
|
||||
MacAbi = "macabi",
|
||||
Mlibc = "mlibc",
|
||||
Msvc = "msvc",
|
||||
Musl = "musl",
|
||||
Newlib = "newlib",
|
||||
Nto70 = "nto70",
|
||||
Nto71 = "nto71",
|
||||
Nto71IoSock = "nto71_iosock",
|
||||
Nto80 = "nto80",
|
||||
Ohos = "ohos",
|
||||
Relibc = "relibc",
|
||||
Sgx = "sgx",
|
||||
Sim = "sim",
|
||||
P1 = "p1",
|
||||
P2 = "p2",
|
||||
P3 = "p3",
|
||||
Uclibc = "uclibc",
|
||||
V5 = "v5",
|
||||
Unspecified = "",
|
||||
}
|
||||
other_variant = Other;
|
||||
}
|
||||
|
||||
impl Env {
|
||||
pub fn desc_symbol(&self) -> Symbol {
|
||||
Symbol::intern(self.desc())
|
||||
}
|
||||
}
|
||||
|
||||
crate::target_spec_enum! {
|
||||
pub enum Abi {
|
||||
Abi64 = "abi64",
|
||||
AbiV2 = "abiv2",
|
||||
AbiV2Hf = "abiv2hf",
|
||||
Eabi = "eabi",
|
||||
EabiHf = "eabihf",
|
||||
ElfV1 = "elfv1",
|
||||
ElfV2 = "elfv2",
|
||||
Fortanix = "fortanix",
|
||||
Ilp32 = "ilp32",
|
||||
Ilp32e = "ilp32e",
|
||||
Llvm = "llvm",
|
||||
MacAbi = "macabi",
|
||||
Sim = "sim",
|
||||
SoftFloat = "softfloat",
|
||||
Spe = "spe",
|
||||
Uwp = "uwp",
|
||||
VecDefault = "vec-default",
|
||||
VecExtAbi = "vec-extabi",
|
||||
X32 = "x32",
|
||||
Unspecified = "",
|
||||
}
|
||||
other_variant = Other;
|
||||
}
|
||||
|
||||
impl Abi {
|
||||
pub fn desc_symbol(&self) -> Symbol {
|
||||
Symbol::intern(self.desc())
|
||||
}
|
||||
}
|
||||
|
||||
/// Everything `rustc` knows about how to compile for a specific target.
|
||||
///
|
||||
/// Every field here must be specified, and has no default value.
|
||||
|
|
@ -2051,18 +2168,18 @@ pub struct TargetOptions {
|
|||
pub endian: Endian,
|
||||
/// Width of c_int type. Defaults to "32".
|
||||
pub c_int_width: u16,
|
||||
/// OS name to use for conditional compilation (`target_os`). Defaults to "none".
|
||||
/// "none" implies a bare metal target without `std` library.
|
||||
/// A couple of targets having `std` also use "unknown" as an `os` value,
|
||||
/// OS name to use for conditional compilation (`target_os`). Defaults to [`Os::None`].
|
||||
/// [`Os::None`] implies a bare metal target without `std` library.
|
||||
/// A couple of targets having `std` also use [`Os::Unknown`] as their `os` value,
|
||||
/// but they are exceptions.
|
||||
pub os: StaticCow<str>,
|
||||
/// Environment name to use for conditional compilation (`target_env`). Defaults to "".
|
||||
pub env: StaticCow<str>,
|
||||
pub os: Os,
|
||||
/// Environment name to use for conditional compilation (`target_env`). Defaults to [`Env::Unspecified`].
|
||||
pub env: Env,
|
||||
/// ABI name to distinguish multiple ABIs on the same OS and architecture. For instance, `"eabi"`
|
||||
/// or `"eabihf"`. Defaults to "".
|
||||
/// or `"eabihf"`. Defaults to [`Abi::Unspecified`].
|
||||
/// This field is *not* forwarded directly to LLVM; its primary purpose is `cfg(target_abi)`.
|
||||
/// However, parts of the backend do check this field for specific values to enable special behavior.
|
||||
pub abi: StaticCow<str>,
|
||||
pub abi: Abi,
|
||||
/// Vendor name to use for conditional compilation (`target_vendor`). Defaults to "unknown".
|
||||
#[rustc_lint_opt_deny_field_access(
|
||||
"use `Target::is_like_*` instead of this field; see https://github.com/rust-lang/rust/issues/100343 for rationale"
|
||||
|
|
@ -2565,9 +2682,9 @@ impl Default for TargetOptions {
|
|||
TargetOptions {
|
||||
endian: Endian::Little,
|
||||
c_int_width: 32,
|
||||
os: "none".into(),
|
||||
env: "".into(),
|
||||
abi: "".into(),
|
||||
os: Os::None,
|
||||
env: Env::Unspecified,
|
||||
abi: Abi::Unspecified,
|
||||
vendor: "unknown".into(),
|
||||
linker: option_env!("CFG_DEFAULT_LINKER").map(|s| s.into()),
|
||||
linker_flavor: LinkerFlavor::Gnu(Cc::Yes, Lld::No),
|
||||
|
|
@ -2763,7 +2880,7 @@ impl Target {
|
|||
);
|
||||
check_eq!(
|
||||
self.is_like_solaris,
|
||||
self.os == "solaris" || self.os == "illumos",
|
||||
matches!(self.os, Os::Solaris | Os::Illumos),
|
||||
"`is_like_solaris` must be set if and only if `os` is `solaris` or `illumos`"
|
||||
);
|
||||
check_eq!(
|
||||
|
|
@ -2773,7 +2890,7 @@ impl Target {
|
|||
);
|
||||
check_eq!(
|
||||
self.is_like_windows,
|
||||
self.os == "windows" || self.os == "uefi" || self.os == "cygwin",
|
||||
matches!(self.os, Os::Windows | Os::Uefi | Os::Cygwin),
|
||||
"`is_like_windows` must be set if and only if `os` is `windows`, `uefi` or `cygwin`"
|
||||
);
|
||||
check_eq!(
|
||||
|
|
@ -2784,7 +2901,7 @@ impl Target {
|
|||
if self.is_like_msvc {
|
||||
check!(self.is_like_windows, "if `is_like_msvc` is set, `is_like_windows` must be set");
|
||||
}
|
||||
if self.os == "emscripten" {
|
||||
if self.os == Os::Emscripten {
|
||||
check!(self.is_like_wasm, "the `emcscripten` os only makes sense on wasm-like targets");
|
||||
}
|
||||
|
||||
|
|
@ -2800,12 +2917,12 @@ impl Target {
|
|||
"`linker_flavor` must be `msvc` if and only if `is_like_msvc` is set"
|
||||
);
|
||||
check_eq!(
|
||||
self.is_like_wasm && self.os != "emscripten",
|
||||
self.is_like_wasm && self.os != Os::Emscripten,
|
||||
matches!(self.linker_flavor, LinkerFlavor::WasmLld(..)),
|
||||
"`linker_flavor` must be `wasm-lld` if and only if `is_like_wasm` is set and the `os` is not `emscripten`",
|
||||
);
|
||||
check_eq!(
|
||||
self.os == "emscripten",
|
||||
self.os == Os::Emscripten,
|
||||
matches!(self.linker_flavor, LinkerFlavor::EmCc),
|
||||
"`linker_flavor` must be `em-cc` if and only if `os` is `emscripten`"
|
||||
);
|
||||
|
|
@ -2932,12 +3049,14 @@ impl Target {
|
|||
// except it and document the reasons.
|
||||
// Keep the default "unknown" vendor instead.
|
||||
check_ne!(self.vendor, "", "`vendor` cannot be empty");
|
||||
check_ne!(self.os, "", "`os` cannot be empty");
|
||||
if let Os::Other(s) = &self.os {
|
||||
check!(!s.is_empty(), "`os` cannot be empty");
|
||||
}
|
||||
if !self.can_use_os_unknown() {
|
||||
// Keep the default "none" for bare metal targets instead.
|
||||
check_ne!(
|
||||
self.os,
|
||||
"unknown",
|
||||
Os::Unknown,
|
||||
"`unknown` os can only be used on particular targets; use `none` for bare-metal targets"
|
||||
);
|
||||
}
|
||||
|
|
@ -2951,7 +3070,7 @@ impl Target {
|
|||
// BPF: when targeting user space vms (like rbpf), those can load dynamic libraries.
|
||||
// hexagon: when targeting QuRT, that OS can load dynamic libraries.
|
||||
// wasm{32,64}: dynamic linking is inherent in the definition of the VM.
|
||||
if self.os == "none"
|
||||
if self.os == Os::None
|
||||
&& !matches!(self.arch, Arch::Bpf | Arch::Hexagon | Arch::Wasm32 | Arch::Wasm64)
|
||||
{
|
||||
check!(
|
||||
|
|
@ -2984,7 +3103,7 @@ impl Target {
|
|||
);
|
||||
}
|
||||
// The UEFI targets do not support dynamic linking but still require PIC (#101377).
|
||||
if self.relocation_model == RelocModel::Pic && (self.os != "uefi") {
|
||||
if self.relocation_model == RelocModel::Pic && self.os != Os::Uefi {
|
||||
check!(
|
||||
self.dynamic_linking || self.position_independent_executables,
|
||||
"when the relocation model is `pic`, the target must support dynamic linking or use position-independent executables. \
|
||||
|
|
@ -3123,7 +3242,7 @@ impl Target {
|
|||
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")
|
||||
|| (self.env == Env::Sgx && self.vendor == "fortanix")
|
||||
}
|
||||
|
||||
/// Load a built-in target
|
||||
|
|
@ -3305,7 +3424,7 @@ impl Target {
|
|||
| Arch::SpirV
|
||||
| Arch::Wasm32
|
||||
| Arch::Wasm64
|
||||
| Arch::Unknown(_) => return None,
|
||||
| Arch::Other(_) => return None,
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
use crate::spec::base::apple::{Arch, TargetEnv, base};
|
||||
use crate::spec::{SanitizerSet, Target, TargetMetadata, TargetOptions};
|
||||
use crate::spec::{Os, SanitizerSet, Target, TargetMetadata, TargetOptions};
|
||||
|
||||
pub(crate) fn target() -> Target {
|
||||
let (opts, llvm_target, arch) = base("macos", Arch::Arm64, TargetEnv::Normal);
|
||||
let (opts, llvm_target, arch) = base(Os::MacOs, Arch::Arm64, TargetEnv::Normal);
|
||||
Target {
|
||||
llvm_target,
|
||||
metadata: TargetMetadata {
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
use crate::spec::base::apple::{Arch, TargetEnv, base};
|
||||
use crate::spec::{SanitizerSet, Target, TargetMetadata, TargetOptions};
|
||||
use crate::spec::{Os, SanitizerSet, Target, TargetMetadata, TargetOptions};
|
||||
|
||||
pub(crate) fn target() -> Target {
|
||||
let (opts, llvm_target, arch) = base("ios", Arch::Arm64, TargetEnv::Normal);
|
||||
let (opts, llvm_target, arch) = base(Os::IOs, Arch::Arm64, TargetEnv::Normal);
|
||||
Target {
|
||||
llvm_target,
|
||||
metadata: TargetMetadata {
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
use crate::spec::base::apple::{Arch, TargetEnv, base};
|
||||
use crate::spec::{SanitizerSet, Target, TargetMetadata, TargetOptions};
|
||||
use crate::spec::{Os, SanitizerSet, Target, TargetMetadata, TargetOptions};
|
||||
|
||||
pub(crate) fn target() -> Target {
|
||||
let (opts, llvm_target, arch) = base("ios", Arch::Arm64, TargetEnv::MacCatalyst);
|
||||
let (opts, llvm_target, arch) = base(Os::IOs, Arch::Arm64, TargetEnv::MacCatalyst);
|
||||
Target {
|
||||
llvm_target,
|
||||
metadata: TargetMetadata {
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
use crate::spec::base::apple::{Arch, TargetEnv, base};
|
||||
use crate::spec::{SanitizerSet, Target, TargetMetadata, TargetOptions};
|
||||
use crate::spec::{Os, SanitizerSet, Target, TargetMetadata, TargetOptions};
|
||||
|
||||
pub(crate) fn target() -> Target {
|
||||
let (opts, llvm_target, arch) = base("ios", Arch::Arm64, TargetEnv::Simulator);
|
||||
let (opts, llvm_target, arch) = base(Os::IOs, Arch::Arm64, TargetEnv::Simulator);
|
||||
Target {
|
||||
llvm_target,
|
||||
metadata: TargetMetadata {
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
use crate::spec::base::apple::{Arch, TargetEnv, base};
|
||||
use crate::spec::{Target, TargetMetadata, TargetOptions};
|
||||
use crate::spec::{Os, Target, TargetMetadata, TargetOptions};
|
||||
|
||||
pub(crate) fn target() -> Target {
|
||||
let (opts, llvm_target, arch) = base("tvos", Arch::Arm64, TargetEnv::Normal);
|
||||
let (opts, llvm_target, arch) = base(Os::TvOs, Arch::Arm64, TargetEnv::Normal);
|
||||
Target {
|
||||
llvm_target,
|
||||
metadata: TargetMetadata {
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
use crate::spec::base::apple::{Arch, TargetEnv, base};
|
||||
use crate::spec::{Target, TargetMetadata, TargetOptions};
|
||||
use crate::spec::{Os, Target, TargetMetadata, TargetOptions};
|
||||
|
||||
pub(crate) fn target() -> Target {
|
||||
let (opts, llvm_target, arch) = base("tvos", Arch::Arm64, TargetEnv::Simulator);
|
||||
let (opts, llvm_target, arch) = base(Os::TvOs, Arch::Arm64, TargetEnv::Simulator);
|
||||
Target {
|
||||
llvm_target,
|
||||
metadata: TargetMetadata {
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
use crate::spec::base::apple::{Arch, TargetEnv, base};
|
||||
use crate::spec::{SanitizerSet, Target, TargetMetadata, TargetOptions};
|
||||
use crate::spec::{Os, SanitizerSet, Target, TargetMetadata, TargetOptions};
|
||||
|
||||
pub(crate) fn target() -> Target {
|
||||
let (opts, llvm_target, arch) = base("visionos", Arch::Arm64, TargetEnv::Normal);
|
||||
let (opts, llvm_target, arch) = base(Os::VisionOs, Arch::Arm64, TargetEnv::Normal);
|
||||
Target {
|
||||
llvm_target,
|
||||
metadata: TargetMetadata {
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
use crate::spec::base::apple::{Arch, TargetEnv, base};
|
||||
use crate::spec::{SanitizerSet, Target, TargetMetadata, TargetOptions};
|
||||
use crate::spec::{Os, SanitizerSet, Target, TargetMetadata, TargetOptions};
|
||||
|
||||
pub(crate) fn target() -> Target {
|
||||
let (opts, llvm_target, arch) = base("visionos", Arch::Arm64, TargetEnv::Simulator);
|
||||
let (opts, llvm_target, arch) = base(Os::VisionOs, Arch::Arm64, TargetEnv::Simulator);
|
||||
Target {
|
||||
llvm_target,
|
||||
metadata: TargetMetadata {
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
use crate::spec::base::apple::{Arch, TargetEnv, base};
|
||||
use crate::spec::{Target, TargetMetadata, TargetOptions};
|
||||
use crate::spec::{Os, Target, TargetMetadata, TargetOptions};
|
||||
|
||||
pub(crate) fn target() -> Target {
|
||||
let (opts, llvm_target, arch) = base("watchos", Arch::Arm64, TargetEnv::Normal);
|
||||
let (opts, llvm_target, arch) = base(Os::WatchOs, Arch::Arm64, TargetEnv::Normal);
|
||||
Target {
|
||||
llvm_target,
|
||||
metadata: TargetMetadata {
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
use crate::spec::base::apple::{Arch, TargetEnv, base};
|
||||
use crate::spec::{Target, TargetMetadata, TargetOptions};
|
||||
use crate::spec::{Os, Target, TargetMetadata, TargetOptions};
|
||||
|
||||
pub(crate) fn target() -> Target {
|
||||
let (opts, llvm_target, arch) = base("watchos", Arch::Arm64, TargetEnv::Simulator);
|
||||
let (opts, llvm_target, arch) = base(Os::WatchOs, Arch::Arm64, TargetEnv::Simulator);
|
||||
Target {
|
||||
llvm_target,
|
||||
metadata: TargetMetadata {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use rustc_abi::Endian;
|
||||
|
||||
use crate::spec::{
|
||||
Arch, FramePointer, StackProbeType, Target, TargetMetadata, TargetOptions, base,
|
||||
Abi, Arch, FramePointer, StackProbeType, Target, TargetMetadata, TargetOptions, base,
|
||||
};
|
||||
|
||||
pub(crate) fn target() -> Target {
|
||||
|
|
@ -20,7 +20,7 @@ pub(crate) fn target() -> Target {
|
|||
data_layout: "E-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32".into(),
|
||||
arch: Arch::AArch64,
|
||||
options: TargetOptions {
|
||||
abi: "ilp32".into(),
|
||||
abi: Abi::Ilp32,
|
||||
features: "+v8a,+outline-atomics".into(),
|
||||
// the AAPCS64 expects use of non-leaf frame pointers per
|
||||
// https://github.com/ARM-software/abi-aa/blob/4492d1570eb70c8fd146623e0db65b2d241f12e7/aapcs64/aapcs64.rst#the-frame-pointer
|
||||
|
|
|
|||
|
|
@ -8,13 +8,13 @@
|
|||
use rustc_abi::Endian;
|
||||
|
||||
use crate::spec::{
|
||||
Arch, Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, SanitizerSet, StackProbeType, Target,
|
||||
TargetMetadata, TargetOptions,
|
||||
Abi, Arch, Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, SanitizerSet, StackProbeType,
|
||||
Target, TargetMetadata, TargetOptions,
|
||||
};
|
||||
|
||||
pub(crate) fn target() -> Target {
|
||||
let opts = TargetOptions {
|
||||
abi: "softfloat".into(),
|
||||
abi: Abi::SoftFloat,
|
||||
linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes),
|
||||
linker: Some("rust-lld".into()),
|
||||
features: "+v8a,+strict-align,-neon,-fp-armv8".into(),
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use crate::spec::{Arch, RelocModel, StackProbeType, Target, TargetMetadata, TargetOptions, base};
|
||||
|
||||
pub(crate) fn target() -> Target {
|
||||
let base = base::solid::opts("asp3");
|
||||
let base = base::solid::opts();
|
||||
Target {
|
||||
llvm_target: "aarch64-unknown-none".into(),
|
||||
metadata: TargetMetadata {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use crate::spec::{
|
||||
Arch, Cc, LinkerFlavor, Lld, PanicStrategy, RelroLevel, StackProbeType, Target, TargetMetadata,
|
||||
TargetOptions,
|
||||
Arch, Cc, LinkerFlavor, Lld, Os, PanicStrategy, RelroLevel, StackProbeType, Target,
|
||||
TargetMetadata, TargetOptions,
|
||||
};
|
||||
|
||||
const LINKER_SCRIPT: &str = include_str!("./aarch64_nintendo_switch_freestanding_linker_script.ld");
|
||||
|
|
@ -23,7 +23,7 @@ pub(crate) fn target() -> Target {
|
|||
linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes),
|
||||
linker: Some("rust-lld".into()),
|
||||
link_script: Some(LINKER_SCRIPT.into()),
|
||||
os: "horizon".into(),
|
||||
os: Os::Horizon,
|
||||
vendor: "nintendo".into(),
|
||||
max_atomic_width: Some(128),
|
||||
stack_probes: StackProbeType::Inline,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use crate::spec::{
|
||||
Arch, FramePointer, StackProbeType, Target, TargetMetadata, TargetOptions, base,
|
||||
Abi, Arch, FramePointer, StackProbeType, Target, TargetMetadata, TargetOptions, base,
|
||||
};
|
||||
|
||||
pub(crate) fn target() -> Target {
|
||||
|
|
@ -15,7 +15,7 @@ pub(crate) fn target() -> Target {
|
|||
data_layout: "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32".into(),
|
||||
arch: Arch::AArch64,
|
||||
options: TargetOptions {
|
||||
abi: "ilp32".into(),
|
||||
abi: Abi::Ilp32,
|
||||
features: "+v8a,+outline-atomics".into(),
|
||||
// the AAPCS64 expects use of non-leaf frame pointers per
|
||||
// https://github.com/ARM-software/abi-aa/blob/4492d1570eb70c8fd146623e0db65b2d241f12e7/aapcs64/aapcs64.rst#the-frame-pointer
|
||||
|
|
|
|||
|
|
@ -7,13 +7,13 @@
|
|||
// For example, `-C target-cpu=cortex-a53`.
|
||||
|
||||
use crate::spec::{
|
||||
Arch, Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, SanitizerSet, StackProbeType, Target,
|
||||
TargetMetadata, TargetOptions,
|
||||
Abi, Arch, Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, SanitizerSet, StackProbeType,
|
||||
Target, TargetMetadata, TargetOptions,
|
||||
};
|
||||
|
||||
pub(crate) fn target() -> Target {
|
||||
let opts = TargetOptions {
|
||||
abi: "softfloat".into(),
|
||||
abi: Abi::SoftFloat,
|
||||
linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes),
|
||||
linker: Some("rust-lld".into()),
|
||||
features: "+v8a,+strict-align,-neon,-fp-armv8".into(),
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
use crate::spec::Target;
|
||||
use crate::spec::base::nto_qnx;
|
||||
use crate::spec::{Env, Target};
|
||||
|
||||
pub(crate) fn target() -> Target {
|
||||
let mut target = nto_qnx::aarch64();
|
||||
target.metadata.description = Some("ARM64 QNX Neutrino 7.0 RTOS".into());
|
||||
target.options.pre_link_args =
|
||||
nto_qnx::pre_link_args(nto_qnx::ApiVariant::Default, nto_qnx::Arch::Aarch64);
|
||||
target.options.env = "nto70".into();
|
||||
target.options.env = Env::Nto70;
|
||||
target
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use crate::spec::Target;
|
||||
use crate::spec::base::nto_qnx;
|
||||
use crate::spec::{Env, Target};
|
||||
|
||||
pub(crate) fn target() -> Target {
|
||||
let mut target = nto_qnx::aarch64();
|
||||
|
|
@ -7,6 +7,6 @@ pub(crate) fn target() -> Target {
|
|||
Some("ARM64 QNX Neutrino 7.1 RTOS with io-pkt network stack".into());
|
||||
target.options.pre_link_args =
|
||||
nto_qnx::pre_link_args(nto_qnx::ApiVariant::Default, nto_qnx::Arch::Aarch64);
|
||||
target.options.env = "nto71".into();
|
||||
target.options.env = Env::Nto71;
|
||||
target
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use crate::spec::Target;
|
||||
use crate::spec::base::nto_qnx;
|
||||
use crate::spec::{Env, Target};
|
||||
|
||||
pub(crate) fn target() -> Target {
|
||||
let mut target = nto_qnx::aarch64();
|
||||
|
|
@ -7,6 +7,6 @@ pub(crate) fn target() -> Target {
|
|||
Some("ARM64 QNX Neutrino 7.1 RTOS with io-sock network stack".into());
|
||||
target.options.pre_link_args =
|
||||
nto_qnx::pre_link_args(nto_qnx::ApiVariant::IoSock, nto_qnx::Arch::Aarch64);
|
||||
target.options.env = "nto71_iosock".into();
|
||||
target.options.env = Env::Nto71IoSock;
|
||||
target
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
use crate::spec::Target;
|
||||
use crate::spec::base::nto_qnx;
|
||||
use crate::spec::{Env, Target};
|
||||
|
||||
pub(crate) fn target() -> Target {
|
||||
let mut target = nto_qnx::aarch64();
|
||||
target.metadata.description = Some("ARM64 QNX Neutrino 8.0 RTOS".into());
|
||||
target.options.pre_link_args =
|
||||
nto_qnx::pre_link_args(nto_qnx::ApiVariant::Default, nto_qnx::Arch::Aarch64);
|
||||
target.options.env = "nto80".into();
|
||||
target.options.env = Env::Nto80;
|
||||
target
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,8 +7,8 @@
|
|||
// For example, `-C target-cpu=cortex-a53`.
|
||||
|
||||
use crate::spec::{
|
||||
Arch, Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, SanitizerSet, StackProbeType, Target,
|
||||
TargetMetadata, TargetOptions, cvs,
|
||||
Arch, Cc, LinkerFlavor, Lld, Os, PanicStrategy, RelocModel, SanitizerSet, StackProbeType,
|
||||
Target, TargetMetadata, TargetOptions, cvs,
|
||||
};
|
||||
|
||||
pub(crate) fn target() -> Target {
|
||||
|
|
@ -28,7 +28,7 @@ pub(crate) fn target() -> Target {
|
|||
stack_probes: StackProbeType::Inline,
|
||||
panic_strategy: PanicStrategy::Abort,
|
||||
families: cvs!["unix"],
|
||||
os: "nuttx".into(),
|
||||
os: Os::NuttX,
|
||||
..Default::default()
|
||||
};
|
||||
Target {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
// Trusty OS target for AArch64.
|
||||
|
||||
use crate::spec::{
|
||||
Arch, LinkSelfContainedDefault, PanicStrategy, RelroLevel, Target, TargetMetadata,
|
||||
Arch, LinkSelfContainedDefault, Os, PanicStrategy, RelroLevel, Target, TargetMetadata,
|
||||
TargetOptions,
|
||||
};
|
||||
|
||||
|
|
@ -22,7 +22,7 @@ pub(crate) fn target() -> Target {
|
|||
executables: true,
|
||||
max_atomic_width: Some(128),
|
||||
panic_strategy: PanicStrategy::Abort,
|
||||
os: "trusty".into(),
|
||||
os: Os::Trusty,
|
||||
position_independent_executables: true,
|
||||
static_position_independent_executables: true,
|
||||
crt_static_default: true,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use crate::spec::{
|
||||
Arch, Cc, LinkerFlavor, Lld, PanicStrategy, Target, TargetMetadata, TargetOptions,
|
||||
Arch, Cc, LinkerFlavor, Lld, Os, PanicStrategy, Target, TargetMetadata, TargetOptions,
|
||||
};
|
||||
|
||||
pub(crate) fn target() -> Target {
|
||||
|
|
@ -16,7 +16,7 @@ pub(crate) fn target() -> Target {
|
|||
pointer_width: 64,
|
||||
|
||||
options: TargetOptions {
|
||||
os: "amdhsa".into(),
|
||||
os: Os::AmdHsa,
|
||||
vendor: "amd".into(),
|
||||
linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes),
|
||||
linker: Some("rust-lld".into()),
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
use crate::spec::base::apple::{Arch, TargetEnv, base};
|
||||
use crate::spec::{Target, TargetMetadata, TargetOptions};
|
||||
use crate::spec::{Os, Target, TargetMetadata, TargetOptions};
|
||||
|
||||
pub(crate) fn target() -> Target {
|
||||
let (opts, llvm_target, arch) = base("watchos", Arch::Arm64_32, TargetEnv::Normal);
|
||||
let (opts, llvm_target, arch) = base(Os::WatchOs, Arch::Arm64_32, TargetEnv::Normal);
|
||||
Target {
|
||||
llvm_target,
|
||||
metadata: TargetMetadata {
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
use crate::spec::base::apple::{Arch, TargetEnv, base};
|
||||
use crate::spec::{SanitizerSet, Target, TargetMetadata, TargetOptions};
|
||||
use crate::spec::{Os, SanitizerSet, Target, TargetMetadata, TargetOptions};
|
||||
|
||||
pub(crate) fn target() -> Target {
|
||||
let (opts, llvm_target, arch) = base("macos", Arch::Arm64e, TargetEnv::Normal);
|
||||
let (opts, llvm_target, arch) = base(Os::MacOs, Arch::Arm64e, TargetEnv::Normal);
|
||||
Target {
|
||||
llvm_target,
|
||||
metadata: TargetMetadata {
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
use crate::spec::base::apple::{Arch, TargetEnv, base};
|
||||
use crate::spec::{SanitizerSet, Target, TargetMetadata, TargetOptions};
|
||||
use crate::spec::{Os, SanitizerSet, Target, TargetMetadata, TargetOptions};
|
||||
|
||||
pub(crate) fn target() -> Target {
|
||||
let (opts, llvm_target, arch) = base("ios", Arch::Arm64e, TargetEnv::Normal);
|
||||
let (opts, llvm_target, arch) = base(Os::IOs, Arch::Arm64e, TargetEnv::Normal);
|
||||
Target {
|
||||
llvm_target,
|
||||
metadata: TargetMetadata {
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
use crate::spec::base::apple::{Arch, TargetEnv, base};
|
||||
use crate::spec::{Target, TargetMetadata, TargetOptions};
|
||||
use crate::spec::{Os, Target, TargetMetadata, TargetOptions};
|
||||
|
||||
pub(crate) fn target() -> Target {
|
||||
let (opts, llvm_target, arch) = base("tvos", Arch::Arm64e, TargetEnv::Normal);
|
||||
let (opts, llvm_target, arch) = base(Os::TvOs, Arch::Arm64e, TargetEnv::Normal);
|
||||
Target {
|
||||
llvm_target,
|
||||
metadata: TargetMetadata {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use crate::spec::{Arch, FloatAbi, SanitizerSet, Target, TargetMetadata, TargetOptions, base};
|
||||
use crate::spec::{Abi, Arch, FloatAbi, SanitizerSet, Target, TargetMetadata, TargetOptions, base};
|
||||
|
||||
pub(crate) fn target() -> Target {
|
||||
Target {
|
||||
|
|
@ -13,7 +13,7 @@ pub(crate) fn target() -> Target {
|
|||
data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(),
|
||||
arch: Arch::Arm,
|
||||
options: TargetOptions {
|
||||
abi: "eabi".into(),
|
||||
abi: Abi::Eabi,
|
||||
llvm_floatabi: Some(FloatAbi::Soft),
|
||||
// https://developer.android.com/ndk/guides/abis.html#armeabi
|
||||
features: "+strict-align,+v5te".into(),
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use crate::spec::{Arch, FloatAbi, Target, TargetMetadata, TargetOptions, base};
|
||||
use crate::spec::{Abi, Arch, FloatAbi, Target, TargetMetadata, TargetOptions, base};
|
||||
|
||||
pub(crate) fn target() -> Target {
|
||||
Target {
|
||||
|
|
@ -13,7 +13,7 @@ pub(crate) fn target() -> Target {
|
|||
data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(),
|
||||
arch: Arch::Arm,
|
||||
options: TargetOptions {
|
||||
abi: "eabi".into(),
|
||||
abi: Abi::Eabi,
|
||||
llvm_floatabi: Some(FloatAbi::Soft),
|
||||
features: "+strict-align,+v6".into(),
|
||||
max_atomic_width: Some(64),
|
||||
|
|
|
|||
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