mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-27 18:57:42 +03:00
rustc_target: introduce Os
Improve type safety by using an enum rather than strings.
This commit is contained in:
@@ -49,7 +49,7 @@
|
||||
use rustc_session::Session;
|
||||
use rustc_session::config::OutputFilenames;
|
||||
use rustc_span::{Symbol, sym};
|
||||
use rustc_target::spec::{Abi, Arch, Env};
|
||||
use rustc_target::spec::{Abi, Arch, Env, Os};
|
||||
|
||||
pub use crate::config::*;
|
||||
use crate::prelude::*;
|
||||
@@ -163,15 +163,15 @@ fn init(&self, sess: &Session) {
|
||||
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,7 +184,7 @@ fn target_config(&self, sess: &Session) -> TargetConfig {
|
||||
// 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.os == Os::Windows
|
||||
&& sess.target.env == Env::Gnu
|
||||
&& sess.target.abi != Abi::Llvm);
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
use rustc_span::{DUMMY_SP, Span, Symbol};
|
||||
use rustc_symbol_mangling::mangle_internal_symbol;
|
||||
use rustc_target::spec::{
|
||||
Abi, Arch, Env, HasTargetSpec, RelocModel, SmallDataThresholdSupport, Target, TlsModel,
|
||||
Abi, Arch, Env, HasTargetSpec, Os, RelocModel, SmallDataThresholdSupport, Target, TlsModel,
|
||||
};
|
||||
use smallvec::SmallVec;
|
||||
|
||||
@@ -335,7 +335,7 @@ 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.os == Os::Windows
|
||||
&& sess.target.options.env == Env::Gnu
|
||||
&& sess.target.options.abi == Abi::Llvm)
|
||||
{
|
||||
@@ -669,7 +669,7 @@ pub(crate) fn create_used_variable_impl(&self, name: &'static CStr, values: &[&'
|
||||
/// 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 {
|
||||
@@ -963,7 +963,7 @@ pub(crate) fn eh_catch_typeinfo(&self) -> &'ll Value {
|
||||
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_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);
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
use rustc_session::Session;
|
||||
use rustc_session::config::{PrintKind, PrintRequest};
|
||||
use rustc_target::spec::{
|
||||
Abi, Arch, Env, MergeFunctions, PanicStrategy, SmallDataThresholdSupport,
|
||||
Abi, Arch, Env, MergeFunctions, Os, PanicStrategy, SmallDataThresholdSupport,
|
||||
};
|
||||
use smallvec::{SmallVec, smallvec};
|
||||
|
||||
@@ -106,7 +106,7 @@ fn llvm_arg_to_arg_name(full_arg: &str) -> &str {
|
||||
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()
|
||||
{
|
||||
@@ -353,7 +353,7 @@ 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_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;
|
||||
@@ -373,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 == Env::Gnu && *target_abi != 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)
|
||||
@@ -405,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 == Env::Gnu && *target_abi != 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.
|
||||
@@ -428,7 +428,7 @@ fn update_target_reliable_float_cfg(sess: &Session, cfg: &mut TargetConfig) {
|
||||
// musl does not implement the symbols required for f128 math at all.
|
||||
_ 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;
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
use rustc_middle::middle::exported_symbols::SymbolExportKind;
|
||||
use rustc_session::Session;
|
||||
pub(super) use rustc_target::spec::apple::OSVersion;
|
||||
use rustc_target::spec::{Arch, Env, Target};
|
||||
use rustc_target::spec::{Arch, Env, Os, Target};
|
||||
use tracing::debug;
|
||||
|
||||
use crate::errors::{XcrunError, XcrunSdkPathWarning};
|
||||
@@ -17,34 +17,34 @@
|
||||
|
||||
/// 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", Env::Unspecified) => "MacOSX",
|
||||
("ios", Env::Unspecified) => "iPhoneOS",
|
||||
("ios", Env::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", Env::MacAbi) => "MacOSX",
|
||||
("tvos", Env::Unspecified) => "AppleTVOS",
|
||||
("tvos", Env::Sim) => "AppleTVSimulator",
|
||||
("visionos", Env::Unspecified) => "XROS",
|
||||
("visionos", Env::Sim) => "XRSimulator",
|
||||
("watchos", Env::Unspecified) => "WatchOS",
|
||||
("watchos", Env::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", Env::MacAbi) => object::macho::PLATFORM_MACCATALYST,
|
||||
("ios", Env::Sim) => object::macho::PLATFORM_IOSSIMULATOR,
|
||||
("ios", _) => object::macho::PLATFORM_IOS,
|
||||
("watchos", Env::Sim) => object::macho::PLATFORM_WATCHOSSIMULATOR,
|
||||
("watchos", _) => object::macho::PLATFORM_WATCHOS,
|
||||
("tvos", Env::Sim) => object::macho::PLATFORM_TVOSSIMULATOR,
|
||||
("tvos", _) => object::macho::PLATFORM_TVOS,
|
||||
("visionos", Env::Sim) => object::macho::PLATFORM_XROSSIMULATOR,
|
||||
("visionos", _) => object::macho::PLATFORM_XROS,
|
||||
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"),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
use rustc_target::spec::crt_objects::CrtObjects;
|
||||
use rustc_target::spec::{
|
||||
Abi, BinaryFormat, Cc, Env, LinkOutputKind, LinkSelfContainedComponents,
|
||||
LinkSelfContainedDefault, LinkerFeatures, LinkerFlavor, LinkerFlavorCli, Lld, RelocModel,
|
||||
LinkSelfContainedDefault, LinkerFeatures, LinkerFlavor, LinkerFlavorCli, Lld, Os, RelocModel,
|
||||
RelroLevel, SanitizerSet, SplitDebuginfo,
|
||||
};
|
||||
use tracing::{debug, info, warn};
|
||||
@@ -1845,7 +1845,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 +2496,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 +2515,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,7 +3070,7 @@ 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_os = &sess.target.os;
|
||||
let target_env = &sess.target.env;
|
||||
|
||||
// The architecture name to forward to the linker.
|
||||
@@ -3123,12 +3123,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, Env::Unspecified) => os,
|
||||
("ios", Env::MacAbi) => "mac-catalyst",
|
||||
("ios", Env::Sim) => "ios-simulator",
|
||||
("tvos", Env::Sim) => "tvos-simulator",
|
||||
("watchos", Env::Sim) => "watchos-simulator",
|
||||
("visionos", Env::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 +3192,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::ty::TyCtxt;
|
||||
use rustc_session::Session;
|
||||
use rustc_session::config::{self, CrateType, DebugInfo, LinkerPluginLto, Lto, OptLevel, Strip};
|
||||
use rustc_target::spec::{Abi, Arch, Cc, LinkOutputKind, LinkerFlavor, Lld};
|
||||
use rustc_target::spec::{Abi, Arch, Cc, LinkOutputKind, LinkerFlavor, Lld, Os};
|
||||
use tracing::{debug, warn};
|
||||
|
||||
use super::command::Command;
|
||||
@@ -136,10 +136,10 @@ pub(crate) fn get_linker<'a>(
|
||||
// to the linker args construction.
|
||||
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 @@ fn set_output_kind(
|
||||
// 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 @@ fn set_output_kind(
|
||||
}
|
||||
|
||||
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 @@ fn export_symbols(
|
||||
// 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_middle::bug;
|
||||
use rustc_session::Session;
|
||||
use rustc_span::sym;
|
||||
use rustc_target::spec::{Abi, 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,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
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::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 @@ fn create_entry_fn<'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 @@ fn create_entry_fn<'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 @@ fn create_entry_fn<'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_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::{bug, mir, span_bug};
|
||||
use rustc_session::cstore::{DllCallingConvention, DllImport};
|
||||
use rustc_span::Span;
|
||||
use rustc_target::spec::{Abi, Env, 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 == Env::Gnu && target.abi == Abi::Unspecified
|
||||
target.os == Os::Windows && target.env == Env::Gnu && target.abi == Abi::Unspecified
|
||||
}
|
||||
|
||||
pub fn i686_decorated_name(
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
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::search_paths::PathKind;
|
||||
use rustc_span::Symbol;
|
||||
use rustc_span::def_id::{DefId, LOCAL_CRATE};
|
||||
use rustc_target::spec::{Abi, Arch, BinaryFormat, Env, LinkSelfContainedComponents};
|
||||
use rustc_target::spec::{Abi, Arch, BinaryFormat, Env, LinkSelfContainedComponents, Os};
|
||||
|
||||
use crate::errors;
|
||||
|
||||
@@ -68,8 +68,8 @@ pub fn walk_native_lib_search_dirs<R>(
|
||||
// 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 == Abi::Fortanix
|
||||
|| sess.target.os == "linux"
|
||||
|| sess.target.os == "fuchsia"
|
||||
|| sess.target.os == Os::Linux
|
||||
|| sess.target.os == Os::Fuchsia
|
||||
|| sess.target.is_like_aix
|
||||
|| sess.target.is_like_darwin && !sess.sanitizers().is_empty()
|
||||
{
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
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
|
||||
{
|
||||
|
||||
@@ -291,7 +291,7 @@ macro_rules! ins_sym {
|
||||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
@@ -454,7 +454,7 @@ macro_rules! ins {
|
||||
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::{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 @@ pub fn crt_static(&self, crate_type: Option<CrateType>) -> bool {
|
||||
}
|
||||
|
||||
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_span::{Symbol, sym};
|
||||
|
||||
use super::{InlineAsmArch, InlineAsmType, ModifierInfo};
|
||||
use crate::spec::{Env, RelocModel, Target};
|
||||
use crate::spec::{Env, Os, RelocModel, Target};
|
||||
|
||||
def_reg_class! {
|
||||
AArch64 AArch64InlineAsmRegClass {
|
||||
@@ -75,8 +75,8 @@ 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.os == Os::Android
|
||||
|| target.os == Os::Fuchsia
|
||||
|| target.env == Env::Ohos
|
||||
|| target.is_like_darwin
|
||||
|| target.is_like_windows
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use rustc_abi::TyAbiInterface;
|
||||
|
||||
use crate::callconv::{ArgAbi, FnAbi};
|
||||
use crate::spec::{Env, HasTargetSpec};
|
||||
use crate::spec::{Env, HasTargetSpec, Os};
|
||||
|
||||
fn classify_ret<Ty>(ret: &mut ArgAbi<'_, Ty>) {
|
||||
if ret.layout.is_aggregate() {
|
||||
@@ -17,7 +17,7 @@ fn classify_arg<'a, Ty, C: HasTargetSpec>(cx: &C, arg: &mut ArgAbi<'a, Ty>)
|
||||
{
|
||||
if arg.is_ignore() {
|
||||
// powerpc-unknown-linux-{gnu,musl,uclibc} doesn't ignore ZSTs.
|
||||
if cx.target_spec().os == "linux"
|
||||
if cx.target_spec().os == Os::Linux
|
||||
&& matches!(cx.target_spec().env, Env::Gnu | Env::Musl | Env::Uclibc)
|
||||
&& arg.layout.is_zst()
|
||||
{
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
use rustc_abi::{Endian, HasDataLayout, TyAbiInterface};
|
||||
|
||||
use crate::callconv::{Align, ArgAbi, FnAbi, Reg, RegKind, Uniform};
|
||||
use crate::spec::{Env, HasTargetSpec};
|
||||
use crate::spec::{Env, HasTargetSpec, Os};
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||
enum ABI {
|
||||
@@ -106,9 +106,9 @@ pub(crate) fn compute_abi_info<'a, Ty, C>(cx: &C, fn_abi: &mut FnAbi<'a, Ty>)
|
||||
Ty: TyAbiInterface<'a, C> + Copy,
|
||||
C: HasDataLayout + HasTargetSpec,
|
||||
{
|
||||
let abi = if cx.target_spec().env == 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::{Env, HasTargetSpec};
|
||||
use crate::spec::{Env, HasTargetSpec, Os};
|
||||
|
||||
fn classify_ret<Ty>(ret: &mut ArgAbi<'_, Ty>) {
|
||||
let size = ret.layout.size;
|
||||
@@ -29,7 +29,7 @@ fn classify_arg<'a, Ty, C>(cx: &C, arg: &mut ArgAbi<'a, Ty>)
|
||||
}
|
||||
if arg.is_ignore() {
|
||||
// s390x-unknown-linux-{gnu,musl,uclibc} doesn't ignore ZSTs.
|
||||
if cx.target_spec().os == "linux"
|
||||
if cx.target_spec().os == Os::Linux
|
||||
&& matches!(cx.target_spec().env, Env::Gnu | Env::Musl | Env::Uclibc)
|
||||
&& arg.layout.is_zst()
|
||||
{
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
};
|
||||
|
||||
use crate::callconv::{ArgAbi, ArgAttribute, CastTarget, FnAbi, Uniform};
|
||||
use crate::spec::{Env, HasTargetSpec};
|
||||
use crate::spec::{Env, HasTargetSpec, Os};
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
struct Sdata {
|
||||
@@ -223,7 +223,7 @@ pub(crate) fn compute_abi_info<'a, Ty, C>(cx: &C, fn_abi: &mut FnAbi<'a, Ty>)
|
||||
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"
|
||||
if cx.target_spec().os == Os::Linux
|
||||
&& matches!(cx.target_spec().env, Env::Gnu | Env::Musl | Env::Uclibc)
|
||||
&& arg.layout.is_zst()
|
||||
{
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
use rustc_abi::Endian;
|
||||
|
||||
use crate::spec::{
|
||||
Abi, 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 {
|
||||
@@ -9,7 +10,7 @@ pub(crate) fn opts() -> TargetOptions {
|
||||
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::str::FromStr;
|
||||
|
||||
use crate::spec::{
|
||||
Abi, BinaryFormat, Cc, DebuginfoKind, Env, 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)]
|
||||
@@ -114,13 +114,15 @@ fn target_abi(self) -> Abi {
|
||||
/// 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(),
|
||||
os,
|
||||
env: env.target_env(),
|
||||
// NOTE: We originally set `cfg(target_abi = "macabi")` / `cfg(target_abi = "sim")`,
|
||||
// before it was discovered that those are actually environments:
|
||||
@@ -130,7 +132,7 @@ pub(crate) fn base(
|
||||
// FIXME(madsmtm): Warn about using these in the future.
|
||||
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
|
||||
@@ -197,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 {
|
||||
@@ -224,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".
|
||||
@@ -292,7 +294,7 @@ pub fn fmt_full(self) -> impl Display {
|
||||
}
|
||||
|
||||
/// 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
|
||||
@@ -301,12 +303,14 @@ pub fn os_minimum_deployment_target(os: &str) -> Self {
|
||||
// $ 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 }
|
||||
}
|
||||
@@ -319,36 +323,36 @@ pub fn os_minimum_deployment_target(os: &str) -> Self {
|
||||
/// 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, Env::MacAbi) => (14, 0, 0),
|
||||
("ios", crate::spec::Arch::AArch64, Env::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", _, Env::MacAbi) => (13, 1, 0),
|
||||
("tvos", crate::spec::Arch::AArch64, Env::Sim) => (14, 0, 0),
|
||||
("watchos", crate::spec::Arch::AArch64, Env::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, Env::Unspecified)
|
||||
(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"),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,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,8 +1,8 @@
|
||||
use crate::spec::{Cc, Env, 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(),
|
||||
os: Os::L4Re,
|
||||
env: Env::Uclibc,
|
||||
linker_flavor: LinkerFlavor::Unix(Cc::No),
|
||||
panic_strategy: PanicStrategy::Abort,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
//! aspects from their respective base targets
|
||||
|
||||
use crate::spec::{
|
||||
Cc, Env, LinkSelfContainedDefault, LinkerFlavor, PanicStrategy, RelocModel, TargetOptions,
|
||||
Cc, Env, LinkSelfContainedDefault, LinkerFlavor, Os, PanicStrategy, RelocModel, TargetOptions,
|
||||
TlsModel, add_link_args, crt_objects, cvs,
|
||||
};
|
||||
|
||||
@@ -57,7 +57,7 @@ macro_rules! args {
|
||||
TargetOptions {
|
||||
is_like_wasm: true,
|
||||
families: cvs!["wasm", "unix"],
|
||||
os: "linux".into(),
|
||||
os: Os::Linux,
|
||||
env: Env::Musl,
|
||||
|
||||
// we allow dynamic linking, but only cdylibs. Basically we allow a
|
||||
|
||||
@@ -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,8 +1,8 @@
|
||||
use crate::spec::{Env, RelroLevel, TargetOptions, cvs};
|
||||
use crate::spec::{Env, Os, RelroLevel, TargetOptions, cvs};
|
||||
|
||||
pub(crate) fn opts() -> TargetOptions {
|
||||
TargetOptions {
|
||||
os: "managarm".into(),
|
||||
os: Os::Managarm,
|
||||
env: Env::Mlibc,
|
||||
dynamic_linking: true,
|
||||
executables: true,
|
||||
|
||||
@@ -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,8 +1,8 @@
|
||||
use crate::spec::{Cc, Env, 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(),
|
||||
os: Os::Redox,
|
||||
env: Env::Relibc,
|
||||
dynamic_linking: true,
|
||||
families: cvs!["unix"],
|
||||
|
||||
@@ -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,8 +1,8 @@
|
||||
use crate::spec::{Env, PanicStrategy, RelocModel, TargetOptions, cvs};
|
||||
use crate::spec::{Env, Os, PanicStrategy, RelocModel, TargetOptions, cvs};
|
||||
|
||||
pub(crate) fn opts() -> TargetOptions {
|
||||
TargetOptions {
|
||||
os: "linux".into(),
|
||||
os: Os::Linux,
|
||||
env: Env::Musl,
|
||||
vendor: "unikraft".into(),
|
||||
linker: Some("kraftld".into()),
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
use crate::spec::{Env, TargetOptions, cvs};
|
||||
use crate::spec::{Env, Os, TargetOptions, cvs};
|
||||
|
||||
pub(crate) fn opts() -> TargetOptions {
|
||||
TargetOptions {
|
||||
os: "vxworks".into(),
|
||||
os: Os::VxWorks,
|
||||
env: Env::Gnu,
|
||||
vendor: "wrs".into(),
|
||||
linker: Some("wr-c++".into()),
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use std::borrow::Cow;
|
||||
|
||||
use crate::spec::{
|
||||
BinaryFormat, Cc, DebuginfoKind, Env, LinkSelfContainedDefault, LinkerFlavor, Lld,
|
||||
BinaryFormat, Cc, DebuginfoKind, Env, LinkSelfContainedDefault, LinkerFlavor, Lld, Os,
|
||||
SplitDebuginfo, TargetOptions, add_link_args, crt_objects, cvs,
|
||||
};
|
||||
|
||||
@@ -77,7 +77,7 @@ pub(crate) fn opts() -> TargetOptions {
|
||||
);
|
||||
|
||||
TargetOptions {
|
||||
os: "windows".into(),
|
||||
os: Os::Windows,
|
||||
env: Env::Gnu,
|
||||
vendor: "pc".into(),
|
||||
// FIXME(#13846) this should be enabled for windows
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
use std::borrow::Cow;
|
||||
|
||||
use crate::spec::{
|
||||
Abi, BinaryFormat, Cc, DebuginfoKind, Env, LinkerFlavor, Lld, SplitDebuginfo, TargetOptions,
|
||||
cvs,
|
||||
Abi, BinaryFormat, Cc, DebuginfoKind, Env, LinkerFlavor, Lld, Os, SplitDebuginfo,
|
||||
TargetOptions, cvs,
|
||||
};
|
||||
|
||||
pub(crate) fn opts() -> TargetOptions {
|
||||
@@ -21,7 +21,7 @@ pub(crate) fn opts() -> TargetOptions {
|
||||
);
|
||||
|
||||
TargetOptions {
|
||||
os: "windows".into(),
|
||||
os: Os::Windows,
|
||||
env: Env::Gnu,
|
||||
vendor: "pc".into(),
|
||||
abi: Abi::Llvm,
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
use crate::spec::{Env, 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(),
|
||||
os: Os::Windows,
|
||||
env: Env::Msvc,
|
||||
vendor: "pc".into(),
|
||||
dynamic_linking: true,
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
use super::{
|
||||
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,7 +505,7 @@ struct TargetSpecJson {
|
||||
#[serde(rename = "target-c-int-width")]
|
||||
c_int_width: Option<u16>,
|
||||
c_enum_min_bits: Option<u64>,
|
||||
os: Option<StaticCow<str>>,
|
||||
os: Option<Os>,
|
||||
env: Option<Env>,
|
||||
abi: Option<Abi>,
|
||||
vendor: Option<StaticCow<str>>,
|
||||
|
||||
@@ -1926,6 +1926,66 @@ pub fn desc_symbol(&self) -> Symbol {
|
||||
}
|
||||
}
|
||||
|
||||
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",
|
||||
@@ -2108,11 +2168,11 @@ 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>,
|
||||
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"`
|
||||
@@ -2622,7 +2682,7 @@ fn default() -> TargetOptions {
|
||||
TargetOptions {
|
||||
endian: Endian::Little,
|
||||
c_int_width: 32,
|
||||
os: "none".into(),
|
||||
os: Os::None,
|
||||
env: Env::Unspecified,
|
||||
abi: Abi::Unspecified,
|
||||
vendor: "unknown".into(),
|
||||
@@ -2820,7 +2880,7 @@ macro_rules! check_matches {
|
||||
);
|
||||
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!(
|
||||
@@ -2830,7 +2890,7 @@ macro_rules! check_matches {
|
||||
);
|
||||
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!(
|
||||
@@ -2841,7 +2901,7 @@ macro_rules! check_matches {
|
||||
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");
|
||||
}
|
||||
|
||||
@@ -2857,12 +2917,12 @@ macro_rules! check_matches {
|
||||
"`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`"
|
||||
);
|
||||
@@ -2989,12 +3049,14 @@ macro_rules! check_matches {
|
||||
// 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"
|
||||
);
|
||||
}
|
||||
@@ -3008,7 +3070,7 @@ macro_rules! check_matches {
|
||||
// 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!(
|
||||
@@ -3041,7 +3103,7 @@ macro_rules! check_matches {
|
||||
);
|
||||
}
|
||||
// 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. \
|
||||
|
||||
@@ -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 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,
|
||||
|
||||
@@ -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,5 +1,5 @@
|
||||
use crate::spec::{
|
||||
Abi, Arch, Cc, Env, FloatAbi, LinkerFlavor, Lld, RelocModel, Target, TargetMetadata,
|
||||
Abi, Arch, Cc, Env, FloatAbi, LinkerFlavor, Lld, Os, RelocModel, Target, TargetMetadata,
|
||||
TargetOptions, cvs,
|
||||
};
|
||||
|
||||
@@ -25,7 +25,7 @@ pub(crate) fn target() -> Target {
|
||||
arch: Arch::Arm,
|
||||
|
||||
options: TargetOptions {
|
||||
os: "horizon".into(),
|
||||
os: Os::Horizon,
|
||||
env: Env::Newlib,
|
||||
vendor: "nintendo".into(),
|
||||
cpu: "mpcore".into(),
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use crate::spec::{
|
||||
Abi, Arch, Cc, Env, FloatAbi, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target,
|
||||
Abi, Arch, Cc, Env, FloatAbi, LinkerFlavor, Lld, Os, PanicStrategy, RelocModel, Target,
|
||||
TargetMetadata, TargetOptions, cvs,
|
||||
};
|
||||
|
||||
@@ -17,7 +17,7 @@ pub(crate) fn target() -> Target {
|
||||
arch: Arch::Arm,
|
||||
|
||||
options: TargetOptions {
|
||||
os: "rtems".into(),
|
||||
os: Os::Rtems,
|
||||
families: cvs!["unix"],
|
||||
abi: Abi::EabiHf,
|
||||
llvm_floatabi: Some(FloatAbi::Hard),
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use rustc_abi::Endian;
|
||||
|
||||
use crate::spec::{
|
||||
Abi, Arch, Cc, Env, FloatAbi, LinkerFlavor, Lld, RelocModel, Target, TargetMetadata,
|
||||
Abi, Arch, Cc, Env, FloatAbi, LinkerFlavor, Lld, Os, RelocModel, Target, TargetMetadata,
|
||||
TargetOptions, cvs,
|
||||
};
|
||||
|
||||
@@ -29,7 +29,7 @@ pub(crate) fn target() -> Target {
|
||||
arch: Arch::Arm,
|
||||
|
||||
options: TargetOptions {
|
||||
os: "vita".into(),
|
||||
os: Os::Vita,
|
||||
endian: Endian::Little,
|
||||
c_int_width: 32,
|
||||
env: Env::Newlib,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use crate::spec::{
|
||||
Abi, Arch, FloatAbi, LinkSelfContainedDefault, PanicStrategy, RelroLevel, Target,
|
||||
Abi, Arch, FloatAbi, LinkSelfContainedDefault, Os, PanicStrategy, RelroLevel, Target,
|
||||
TargetMetadata, TargetOptions,
|
||||
};
|
||||
|
||||
@@ -24,7 +24,7 @@ pub(crate) fn target() -> Target {
|
||||
features: "+v7,+thumb2,+soft-float,-neon".into(),
|
||||
max_atomic_width: Some(64),
|
||||
mcount: "\u{1}mcount".into(),
|
||||
os: "trusty".into(),
|
||||
os: Os::Trusty,
|
||||
link_self_contained: LinkSelfContainedDefault::InferredForMusl,
|
||||
dynamic_linking: false,
|
||||
executables: true,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use crate::spec::{Abi, Arch, FloatAbi, RelocModel, Target, TargetMetadata, TargetOptions, base};
|
||||
|
||||
pub(crate) fn target() -> Target {
|
||||
let base = base::solid::opts("asp3");
|
||||
let base = base::solid::opts();
|
||||
Target {
|
||||
llvm_target: "armv7a-none-eabi".into(),
|
||||
metadata: TargetMetadata {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use crate::spec::{Abi, Arch, FloatAbi, RelocModel, Target, TargetMetadata, TargetOptions, base};
|
||||
|
||||
pub(crate) fn target() -> Target {
|
||||
let base = base::solid::opts("asp3");
|
||||
let base = base::solid::opts();
|
||||
Target {
|
||||
llvm_target: "armv7a-none-eabihf".into(),
|
||||
metadata: TargetMetadata {
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
// configuration without hardware floating point support.
|
||||
|
||||
use crate::spec::{
|
||||
Abi, Arch, Cc, FloatAbi, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetMetadata,
|
||||
TargetOptions, cvs,
|
||||
Abi, Arch, Cc, FloatAbi, LinkerFlavor, Lld, Os, PanicStrategy, RelocModel, Target,
|
||||
TargetMetadata, TargetOptions, cvs,
|
||||
};
|
||||
|
||||
pub(crate) fn target() -> Target {
|
||||
@@ -23,7 +23,7 @@ pub(crate) fn target() -> Target {
|
||||
emit_debug_gdb_scripts: false,
|
||||
c_enum_min_bits: Some(8),
|
||||
families: cvs!["unix"],
|
||||
os: "nuttx".into(),
|
||||
os: Os::NuttX,
|
||||
..Default::default()
|
||||
};
|
||||
Target {
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
// configuration with hardware floating point support.
|
||||
|
||||
use crate::spec::{
|
||||
Abi, Arch, Cc, FloatAbi, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetMetadata,
|
||||
TargetOptions, cvs,
|
||||
Abi, Arch, Cc, FloatAbi, LinkerFlavor, Lld, Os, PanicStrategy, RelocModel, Target,
|
||||
TargetMetadata, TargetOptions, cvs,
|
||||
};
|
||||
|
||||
pub(crate) fn target() -> Target {
|
||||
@@ -23,7 +23,7 @@ pub(crate) fn target() -> Target {
|
||||
emit_debug_gdb_scripts: false,
|
||||
c_enum_min_bits: Some(8),
|
||||
families: cvs!["unix"],
|
||||
os: "nuttx".into(),
|
||||
os: Os::NuttX,
|
||||
..Default::default()
|
||||
};
|
||||
Target {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use crate::spec::{
|
||||
Abi, Arch, Cc, Env, FloatAbi, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target,
|
||||
Abi, Arch, Cc, Env, FloatAbi, LinkerFlavor, Lld, Os, PanicStrategy, RelocModel, Target,
|
||||
TargetMetadata, TargetOptions,
|
||||
};
|
||||
|
||||
@@ -9,7 +9,7 @@ pub(crate) fn target() -> Target {
|
||||
let opts = TargetOptions {
|
||||
vendor: "vex".into(),
|
||||
env: Env::V5,
|
||||
os: "vexos".into(),
|
||||
os: Os::VexOs,
|
||||
cpu: "cortex-a9".into(),
|
||||
abi: Abi::EabiHf,
|
||||
is_like_vexos: true,
|
||||
|
||||
@@ -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::Armv7k, TargetEnv::Normal);
|
||||
let (opts, llvm_target, arch) = base(Os::WatchOs, Arch::Armv7k, 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("ios", Arch::Armv7s, TargetEnv::Normal);
|
||||
let (opts, llvm_target, arch) = base(Os::IOs, Arch::Armv7s, TargetEnv::Normal);
|
||||
Target {
|
||||
llvm_target,
|
||||
metadata: TargetMetadata {
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
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 {
|
||||
// i386-apple-ios is a simulator target, even though it isn't declared
|
||||
// that way in the target name like the other ones...
|
||||
let (opts, llvm_target, arch) = base("ios", Arch::I386, TargetEnv::Simulator);
|
||||
let (opts, llvm_target, arch) = base(Os::IOs, Arch::I386, 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("macos", Arch::I686, TargetEnv::Normal);
|
||||
let (opts, llvm_target, arch) = base(Os::MacOs, Arch::I686, TargetEnv::Normal);
|
||||
Target {
|
||||
llvm_target,
|
||||
metadata: TargetMetadata {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use crate::spec::{
|
||||
Arch, Cc, LinkerFlavor, Lld, RelocModel, Target, TargetMetadata, TargetOptions, cvs,
|
||||
Arch, Cc, LinkerFlavor, Lld, Os, RelocModel, Target, TargetMetadata, TargetOptions, cvs,
|
||||
};
|
||||
|
||||
// The PSP has custom linker requirements.
|
||||
@@ -24,7 +24,7 @@ pub(crate) fn target() -> Target {
|
||||
arch: Arch::Mips,
|
||||
|
||||
options: TargetOptions {
|
||||
os: "psp".into(),
|
||||
os: Os::Psp,
|
||||
vendor: "sony".into(),
|
||||
linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes),
|
||||
cpu: "mips2".into(),
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use crate::spec::{
|
||||
Arch, Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetMetadata, TargetOptions,
|
||||
cvs,
|
||||
Arch, Cc, LinkerFlavor, Lld, Os, PanicStrategy, RelocModel, Target, TargetMetadata,
|
||||
TargetOptions, cvs,
|
||||
};
|
||||
|
||||
pub(crate) fn target() -> Target {
|
||||
@@ -21,7 +21,7 @@ pub(crate) fn target() -> Target {
|
||||
// of functionality post load, so we still declare it as `cfg!(target_os = "psx")`.
|
||||
//
|
||||
// See <https://github.com/rust-lang/rust/pull/131168> for details.
|
||||
os: "psx".into(),
|
||||
os: Os::Psx,
|
||||
vendor: "sony".into(),
|
||||
linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes),
|
||||
cpu: "mips1".into(),
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use crate::spec::{
|
||||
Arch, LinkSelfContainedDefault, LinkerFlavor, MergeFunctions, PanicStrategy, Target,
|
||||
Arch, LinkSelfContainedDefault, LinkerFlavor, MergeFunctions, Os, PanicStrategy, Target,
|
||||
TargetMetadata, TargetOptions,
|
||||
};
|
||||
|
||||
@@ -17,7 +17,7 @@ pub(crate) fn target() -> Target {
|
||||
pointer_width: 64,
|
||||
|
||||
options: TargetOptions {
|
||||
os: "cuda".into(),
|
||||
os: Os::Cuda,
|
||||
vendor: "nvidia".into(),
|
||||
linker_flavor: LinkerFlavor::Ptx,
|
||||
// The linker can be installed from `crates.io`.
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
use crate::spec::{
|
||||
Arch, Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetMetadata, TargetOptions,
|
||||
Arch, Cc, LinkerFlavor, Lld, Os, PanicStrategy, RelocModel, Target, TargetMetadata,
|
||||
TargetOptions,
|
||||
};
|
||||
|
||||
pub(crate) fn target() -> Target {
|
||||
@@ -16,7 +17,7 @@ pub(crate) fn target() -> Target {
|
||||
arch: Arch::RiscV32,
|
||||
|
||||
options: TargetOptions {
|
||||
os: "zkvm".into(),
|
||||
os: Os::Zkvm,
|
||||
vendor: "risc0".into(),
|
||||
linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes),
|
||||
linker: Some("rust-lld".into()),
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use crate::spec::{
|
||||
Arch, Env, PanicStrategy, RelocModel, Target, TargetMetadata, TargetOptions, cvs,
|
||||
Arch, Env, Os, PanicStrategy, RelocModel, Target, TargetMetadata, TargetOptions, cvs,
|
||||
};
|
||||
|
||||
pub(crate) fn target() -> Target {
|
||||
@@ -17,7 +17,7 @@ pub(crate) fn target() -> Target {
|
||||
|
||||
options: TargetOptions {
|
||||
families: cvs!["unix"],
|
||||
os: "espidf".into(),
|
||||
os: Os::EspIdf,
|
||||
env: Env::Newlib,
|
||||
vendor: "espressif".into(),
|
||||
linker: Some("riscv32-esp-elf-gcc".into()),
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use crate::spec::{
|
||||
Arch, Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetMetadata, TargetOptions,
|
||||
cvs,
|
||||
Arch, Cc, LinkerFlavor, Lld, Os, PanicStrategy, RelocModel, Target, TargetMetadata,
|
||||
TargetOptions, cvs,
|
||||
};
|
||||
|
||||
pub(crate) fn target() -> Target {
|
||||
@@ -18,7 +18,7 @@ pub(crate) fn target() -> Target {
|
||||
|
||||
options: TargetOptions {
|
||||
families: cvs!["unix"],
|
||||
os: "nuttx".into(),
|
||||
os: Os::NuttX,
|
||||
linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes),
|
||||
linker: Some("rust-lld".into()),
|
||||
cpu: "generic-rv32".into(),
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
use crate::spec::{
|
||||
Arch, Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetMetadata, TargetOptions,
|
||||
Arch, Cc, LinkerFlavor, Lld, Os, PanicStrategy, RelocModel, Target, TargetMetadata,
|
||||
TargetOptions,
|
||||
};
|
||||
|
||||
pub(crate) fn target() -> Target {
|
||||
@@ -16,7 +17,7 @@ pub(crate) fn target() -> Target {
|
||||
arch: Arch::RiscV32,
|
||||
|
||||
options: TargetOptions {
|
||||
os: "xous".into(),
|
||||
os: Os::Xous,
|
||||
linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes),
|
||||
linker: Some("rust-lld".into()),
|
||||
cpu: "generic-rv32".into(),
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use crate::spec::{
|
||||
Arch, Env, PanicStrategy, RelocModel, Target, TargetMetadata, TargetOptions, cvs,
|
||||
Arch, Env, Os, PanicStrategy, RelocModel, Target, TargetMetadata, TargetOptions, cvs,
|
||||
};
|
||||
|
||||
pub(crate) fn target() -> Target {
|
||||
@@ -17,7 +17,7 @@ pub(crate) fn target() -> Target {
|
||||
|
||||
options: TargetOptions {
|
||||
families: cvs!["unix"],
|
||||
os: "espidf".into(),
|
||||
os: Os::EspIdf,
|
||||
env: Env::Newlib,
|
||||
vendor: "espressif".into(),
|
||||
linker: Some("riscv32-esp-elf-gcc".into()),
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use crate::spec::{
|
||||
Arch, Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetMetadata, TargetOptions,
|
||||
cvs,
|
||||
Arch, Cc, LinkerFlavor, Lld, Os, PanicStrategy, RelocModel, Target, TargetMetadata,
|
||||
TargetOptions, cvs,
|
||||
};
|
||||
|
||||
pub(crate) fn target() -> Target {
|
||||
@@ -18,7 +18,7 @@ pub(crate) fn target() -> Target {
|
||||
|
||||
options: TargetOptions {
|
||||
families: cvs!["unix"],
|
||||
os: "nuttx".into(),
|
||||
os: Os::NuttX,
|
||||
linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes),
|
||||
linker: Some("rust-lld".into()),
|
||||
cpu: "generic-rv32".into(),
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use crate::spec::{
|
||||
Arch, Env, PanicStrategy, RelocModel, Target, TargetMetadata, TargetOptions, cvs,
|
||||
Arch, Env, Os, PanicStrategy, RelocModel, Target, TargetMetadata, TargetOptions, cvs,
|
||||
};
|
||||
|
||||
pub(crate) fn target() -> Target {
|
||||
@@ -17,7 +17,7 @@ pub(crate) fn target() -> Target {
|
||||
|
||||
options: TargetOptions {
|
||||
families: cvs!["unix"],
|
||||
os: "espidf".into(),
|
||||
os: Os::EspIdf,
|
||||
env: Env::Newlib,
|
||||
vendor: "espressif".into(),
|
||||
linker: Some("riscv32-esp-elf-gcc".into()),
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use crate::spec::{
|
||||
Arch, Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetMetadata, TargetOptions,
|
||||
cvs,
|
||||
Arch, Cc, LinkerFlavor, Lld, Os, PanicStrategy, RelocModel, Target, TargetMetadata,
|
||||
TargetOptions, cvs,
|
||||
};
|
||||
|
||||
pub(crate) fn target() -> Target {
|
||||
@@ -18,7 +18,7 @@ pub(crate) fn target() -> Target {
|
||||
|
||||
options: TargetOptions {
|
||||
families: cvs!["unix"],
|
||||
os: "nuttx".into(),
|
||||
os: Os::NuttX,
|
||||
linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes),
|
||||
linker: Some("rust-lld".into()),
|
||||
cpu: "generic-rv32".into(),
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use crate::spec::{
|
||||
Arch, Cc, CodeModel, LinkerFlavor, Lld, PanicStrategy, RelocModel, SanitizerSet, Target,
|
||||
Arch, Cc, CodeModel, LinkerFlavor, Lld, Os, PanicStrategy, RelocModel, SanitizerSet, Target,
|
||||
TargetMetadata, TargetOptions, cvs,
|
||||
};
|
||||
|
||||
@@ -18,7 +18,7 @@ pub(crate) fn target() -> Target {
|
||||
|
||||
options: TargetOptions {
|
||||
families: cvs!["unix"],
|
||||
os: "nuttx".into(),
|
||||
os: Os::NuttX,
|
||||
linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes),
|
||||
linker: Some("rust-lld".into()),
|
||||
llvm_abiname: "lp64d".into(),
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user