Auto merge of #78951 - petrochenkov:unknown, r=ehuss
rustc_target: Change os and vendor values to "none" and "unknown" for some targets Closes https://github.com/rust-lang/rust/issues/77730 r? `@ehuss`
This commit is contained in:
commit
1a25580c6c
16 changed files with 19 additions and 20 deletions
|
@ -10,7 +10,6 @@ use super::{LinkerFlavor, LldFlavor, PanicStrategy, RelocModel, Target, TargetOp
|
||||||
|
|
||||||
pub fn target() -> Target {
|
pub fn target() -> Target {
|
||||||
let opts = TargetOptions {
|
let opts = TargetOptions {
|
||||||
vendor: String::new(),
|
|
||||||
linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
|
linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
|
||||||
linker: Some("rust-lld".to_owned()),
|
linker: Some("rust-lld".to_owned()),
|
||||||
features: "+strict-align,+neon,+fp-armv8".to_string(),
|
features: "+strict-align,+neon,+fp-armv8".to_string(),
|
||||||
|
|
|
@ -10,7 +10,6 @@ use super::{LinkerFlavor, LldFlavor, PanicStrategy, RelocModel, Target, TargetOp
|
||||||
|
|
||||||
pub fn target() -> Target {
|
pub fn target() -> Target {
|
||||||
let opts = TargetOptions {
|
let opts = TargetOptions {
|
||||||
vendor: String::new(),
|
|
||||||
linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
|
linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
|
||||||
linker: Some("rust-lld".to_owned()),
|
linker: Some("rust-lld".to_owned()),
|
||||||
features: "+strict-align,-neon,-fp-armv8".to_string(),
|
features: "+strict-align,-neon,-fp-armv8".to_string(),
|
||||||
|
|
|
@ -12,7 +12,6 @@ pub fn target() -> Target {
|
||||||
|
|
||||||
options: TargetOptions {
|
options: TargetOptions {
|
||||||
endian: "big".to_string(),
|
endian: "big".to_string(),
|
||||||
vendor: String::new(),
|
|
||||||
linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
|
linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
|
||||||
executables: true,
|
executables: true,
|
||||||
linker: Some("rust-lld".to_owned()),
|
linker: Some("rust-lld".to_owned()),
|
||||||
|
|
|
@ -12,7 +12,6 @@ pub fn target() -> Target {
|
||||||
|
|
||||||
options: TargetOptions {
|
options: TargetOptions {
|
||||||
endian: "big".to_string(),
|
endian: "big".to_string(),
|
||||||
vendor: String::new(),
|
|
||||||
linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
|
linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
|
||||||
executables: true,
|
executables: true,
|
||||||
linker: Some("rust-lld".to_owned()),
|
linker: Some("rust-lld".to_owned()),
|
||||||
|
|
|
@ -10,9 +10,6 @@
|
||||||
// bare-metal binaries (the `gcc` linker has the advantage that it knows where C
|
// bare-metal binaries (the `gcc` linker has the advantage that it knows where C
|
||||||
// libraries and crt*.o are but it's not much of an advantage here); LLD is also
|
// libraries and crt*.o are but it's not much of an advantage here); LLD is also
|
||||||
// faster
|
// faster
|
||||||
// - `os` set to `none`. rationale: matches `thumb` targets
|
|
||||||
// - `env` and `vendor` are set to an empty string. rationale: matches `thumb`
|
|
||||||
// targets
|
|
||||||
// - `panic_strategy` set to `abort`. rationale: matches `thumb` targets
|
// - `panic_strategy` set to `abort`. rationale: matches `thumb` targets
|
||||||
// - `relocation-model` set to `static`; also no PIE, no relro and no dynamic
|
// - `relocation-model` set to `static`; also no PIE, no relro and no dynamic
|
||||||
// linking. rationale: matches `thumb` targets
|
// linking. rationale: matches `thumb` targets
|
||||||
|
@ -21,7 +18,6 @@ use super::{LinkerFlavor, LldFlavor, PanicStrategy, RelocModel, Target, TargetOp
|
||||||
|
|
||||||
pub fn target() -> Target {
|
pub fn target() -> Target {
|
||||||
let opts = TargetOptions {
|
let opts = TargetOptions {
|
||||||
vendor: String::new(),
|
|
||||||
linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
|
linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
|
||||||
linker: Some("rust-lld".to_owned()),
|
linker: Some("rust-lld".to_owned()),
|
||||||
features: "+v7,+thumb2,+soft-float,-neon,+strict-align".to_string(),
|
features: "+v7,+thumb2,+soft-float,-neon,+strict-align".to_string(),
|
||||||
|
|
|
@ -9,7 +9,6 @@ use super::{LinkerFlavor, LldFlavor, PanicStrategy, RelocModel, Target, TargetOp
|
||||||
|
|
||||||
pub fn target() -> Target {
|
pub fn target() -> Target {
|
||||||
let opts = TargetOptions {
|
let opts = TargetOptions {
|
||||||
vendor: String::new(),
|
|
||||||
linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
|
linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
|
||||||
linker: Some("rust-lld".to_owned()),
|
linker: Some("rust-lld".to_owned()),
|
||||||
features: "+v7,+vfp3,-d32,+thumb2,-neon,+strict-align".to_string(),
|
features: "+v7,+vfp3,-d32,+thumb2,-neon,+strict-align".to_string(),
|
||||||
|
|
|
@ -11,7 +11,6 @@ pub fn target() -> Target {
|
||||||
arch: "arm".to_string(),
|
arch: "arm".to_string(),
|
||||||
|
|
||||||
options: TargetOptions {
|
options: TargetOptions {
|
||||||
vendor: String::new(),
|
|
||||||
linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
|
linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
|
||||||
executables: true,
|
executables: true,
|
||||||
linker: Some("rust-lld".to_owned()),
|
linker: Some("rust-lld".to_owned()),
|
||||||
|
|
|
@ -11,7 +11,6 @@ pub fn target() -> Target {
|
||||||
arch: "arm".to_string(),
|
arch: "arm".to_string(),
|
||||||
|
|
||||||
options: TargetOptions {
|
options: TargetOptions {
|
||||||
vendor: String::new(),
|
|
||||||
linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
|
linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
|
||||||
executables: true,
|
executables: true,
|
||||||
linker: Some("rust-lld".to_owned()),
|
linker: Some("rust-lld".to_owned()),
|
||||||
|
|
|
@ -11,7 +11,6 @@ pub fn target(target_cpu: String) -> Target {
|
||||||
pointer_width: 16,
|
pointer_width: 16,
|
||||||
options: TargetOptions {
|
options: TargetOptions {
|
||||||
c_int_width: "16".to_string(),
|
c_int_width: "16".to_string(),
|
||||||
os: "unknown".to_string(),
|
|
||||||
cpu: target_cpu.clone(),
|
cpu: target_cpu.clone(),
|
||||||
exe_suffix: ".elf".to_string(),
|
exe_suffix: ".elf".to_string(),
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,6 @@ pub fn opts() -> TargetOptions {
|
||||||
|
|
||||||
TargetOptions {
|
TargetOptions {
|
||||||
os: "fuchsia".to_string(),
|
os: "fuchsia".to_string(),
|
||||||
vendor: String::new(),
|
|
||||||
linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
|
linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
|
||||||
linker: Some("rust-lld".to_owned()),
|
linker: Some("rust-lld".to_owned()),
|
||||||
lld_flavor: LldFlavor::Ld,
|
lld_flavor: LldFlavor::Ld,
|
||||||
|
|
|
@ -14,7 +14,6 @@ pub fn target() -> Target {
|
||||||
arch: "mips".to_string(),
|
arch: "mips".to_string(),
|
||||||
|
|
||||||
options: TargetOptions {
|
options: TargetOptions {
|
||||||
vendor: String::new(),
|
|
||||||
linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
|
linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
|
||||||
cpu: "mips32r2".to_string(),
|
cpu: "mips32r2".to_string(),
|
||||||
features: "+mips32r2,+soft-float,+noabicalls".to_string(),
|
features: "+mips32r2,+soft-float,+noabicalls".to_string(),
|
||||||
|
|
|
@ -713,11 +713,14 @@ pub struct TargetOptions {
|
||||||
pub endian: String,
|
pub endian: String,
|
||||||
/// Width of c_int type. Defaults to "32".
|
/// Width of c_int type. Defaults to "32".
|
||||||
pub c_int_width: String,
|
pub c_int_width: String,
|
||||||
/// OS name to use for conditional compilation. Defaults to "none".
|
/// 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,
|
||||||
|
/// but they are exceptions.
|
||||||
pub os: String,
|
pub os: String,
|
||||||
/// Environment name to use for conditional compilation. Defaults to "".
|
/// Environment name to use for conditional compilation (`target_env`). Defaults to "".
|
||||||
pub env: String,
|
pub env: String,
|
||||||
/// Vendor name to use for conditional compilation. Defaults to "unknown".
|
/// Vendor name to use for conditional compilation (`target_vendor`). Defaults to "unknown".
|
||||||
pub vendor: String,
|
pub vendor: String,
|
||||||
/// Default linker flavor used if `-C linker-flavor` or `-C linker` are not passed
|
/// Default linker flavor used if `-C linker-flavor` or `-C linker` are not passed
|
||||||
/// on the command line. Defaults to `LinkerFlavor::Gcc`.
|
/// on the command line. Defaults to `LinkerFlavor::Gcc`.
|
||||||
|
|
|
@ -9,7 +9,6 @@ pub fn target() -> Target {
|
||||||
|
|
||||||
options: TargetOptions {
|
options: TargetOptions {
|
||||||
c_int_width: "16".to_string(),
|
c_int_width: "16".to_string(),
|
||||||
vendor: String::new(),
|
|
||||||
executables: true,
|
executables: true,
|
||||||
|
|
||||||
// The LLVM backend currently can't generate object files. To
|
// The LLVM backend currently can't generate object files. To
|
||||||
|
|
|
@ -36,5 +36,18 @@ impl Target {
|
||||||
&& self.post_link_objects_fallback.is_empty())
|
&& self.post_link_objects_fallback.is_empty())
|
||||||
|| self.crt_objects_fallback.is_some()
|
|| self.crt_objects_fallback.is_some()
|
||||||
);
|
);
|
||||||
|
// Keep the default "unknown" vendor instead.
|
||||||
|
assert_ne!(self.vendor, "");
|
||||||
|
if !self.can_use_os_unknown() {
|
||||||
|
// Keep the default "none" for bare metal targets instead.
|
||||||
|
assert_ne!(self.os, "unknown");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add your target to the whitelist if it has `std` library
|
||||||
|
// and you certainly want "unknown" for the OS name.
|
||||||
|
fn can_use_os_unknown(&self) -> bool {
|
||||||
|
self.llvm_target == "wasm32-unknown-unknown"
|
||||||
|
|| (self.env == "sgx" && self.vendor == "fortanix")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,6 @@ use crate::spec::{LinkerFlavor, LldFlavor, PanicStrategy, RelocModel, TargetOpti
|
||||||
pub fn opts() -> TargetOptions {
|
pub fn opts() -> TargetOptions {
|
||||||
// See rust-lang/rfcs#1645 for a discussion about these defaults
|
// See rust-lang/rfcs#1645 for a discussion about these defaults
|
||||||
TargetOptions {
|
TargetOptions {
|
||||||
vendor: String::new(),
|
|
||||||
linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
|
linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
|
||||||
executables: true,
|
executables: true,
|
||||||
// In most cases, LLD is good enough
|
// In most cases, LLD is good enough
|
||||||
|
|
|
@ -79,7 +79,6 @@ pub fn target() -> Target {
|
||||||
let mut options = wasm32_base::options();
|
let mut options = wasm32_base::options();
|
||||||
|
|
||||||
options.os = "wasi".to_string();
|
options.os = "wasi".to_string();
|
||||||
options.vendor = String::new();
|
|
||||||
options.linker_flavor = LinkerFlavor::Lld(LldFlavor::Wasm);
|
options.linker_flavor = LinkerFlavor::Lld(LldFlavor::Wasm);
|
||||||
options
|
options
|
||||||
.pre_link_args
|
.pre_link_args
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue