Skip to content

Commit aaa50cb

Browse files
authored
Rollup merge of rust-lang#78951 - petrochenkov:unknown, r=ehuss
rustc_target: Change os and vendor values to "none" and "unknown" for some targets Closes rust-lang#77730 r? ``@ehuss``
2 parents 8d173a5 + e0a8f22 commit aaa50cb

16 files changed

+19
-20
lines changed

compiler/rustc_target/src/spec/aarch64_unknown_none.rs

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ use super::{LinkerFlavor, LldFlavor, PanicStrategy, RelocModel, Target, TargetOp
1010

1111
pub fn target() -> Target {
1212
let opts = TargetOptions {
13-
vendor: String::new(),
1413
linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
1514
linker: Some("rust-lld".to_owned()),
1615
features: "+strict-align,+neon,+fp-armv8".to_string(),

compiler/rustc_target/src/spec/aarch64_unknown_none_softfloat.rs

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ use super::{LinkerFlavor, LldFlavor, PanicStrategy, RelocModel, Target, TargetOp
1010

1111
pub fn target() -> Target {
1212
let opts = TargetOptions {
13-
vendor: String::new(),
1413
linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
1514
linker: Some("rust-lld".to_owned()),
1615
features: "+strict-align,-neon,-fp-armv8".to_string(),

compiler/rustc_target/src/spec/armebv7r_none_eabi.rs

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ pub fn target() -> Target {
1212

1313
options: TargetOptions {
1414
endian: "big".to_string(),
15-
vendor: String::new(),
1615
linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
1716
executables: true,
1817
linker: Some("rust-lld".to_owned()),

compiler/rustc_target/src/spec/armebv7r_none_eabihf.rs

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ pub fn target() -> Target {
1212

1313
options: TargetOptions {
1414
endian: "big".to_string(),
15-
vendor: String::new(),
1615
linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
1716
executables: true,
1817
linker: Some("rust-lld".to_owned()),

compiler/rustc_target/src/spec/armv7a_none_eabi.rs

-4
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@
1010
// bare-metal binaries (the `gcc` linker has the advantage that it knows where C
1111
// libraries and crt*.o are but it's not much of an advantage here); LLD is also
1212
// faster
13-
// - `os` set to `none`. rationale: matches `thumb` targets
14-
// - `env` and `vendor` are set to an empty string. rationale: matches `thumb`
15-
// targets
1613
// - `panic_strategy` set to `abort`. rationale: matches `thumb` targets
1714
// - `relocation-model` set to `static`; also no PIE, no relro and no dynamic
1815
// linking. rationale: matches `thumb` targets
@@ -21,7 +18,6 @@ use super::{LinkerFlavor, LldFlavor, PanicStrategy, RelocModel, Target, TargetOp
2118

2219
pub fn target() -> Target {
2320
let opts = TargetOptions {
24-
vendor: String::new(),
2521
linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
2622
linker: Some("rust-lld".to_owned()),
2723
features: "+v7,+thumb2,+soft-float,-neon,+strict-align".to_string(),

compiler/rustc_target/src/spec/armv7a_none_eabihf.rs

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ use super::{LinkerFlavor, LldFlavor, PanicStrategy, RelocModel, Target, TargetOp
99

1010
pub fn target() -> Target {
1111
let opts = TargetOptions {
12-
vendor: String::new(),
1312
linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
1413
linker: Some("rust-lld".to_owned()),
1514
features: "+v7,+vfp3,-d32,+thumb2,-neon,+strict-align".to_string(),

compiler/rustc_target/src/spec/armv7r_none_eabi.rs

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ pub fn target() -> Target {
1111
arch: "arm".to_string(),
1212

1313
options: TargetOptions {
14-
vendor: String::new(),
1514
linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
1615
executables: true,
1716
linker: Some("rust-lld".to_owned()),

compiler/rustc_target/src/spec/armv7r_none_eabihf.rs

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ pub fn target() -> Target {
1111
arch: "arm".to_string(),
1212

1313
options: TargetOptions {
14-
vendor: String::new(),
1514
linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
1615
executables: true,
1716
linker: Some("rust-lld".to_owned()),

compiler/rustc_target/src/spec/avr_gnu_base.rs

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ pub fn target(target_cpu: String) -> Target {
1111
pointer_width: 16,
1212
options: TargetOptions {
1313
c_int_width: "16".to_string(),
14-
os: "unknown".to_string(),
1514
cpu: target_cpu.clone(),
1615
exe_suffix: ".elf".to_string(),
1716

compiler/rustc_target/src/spec/fuchsia_base.rs

-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ pub fn opts() -> TargetOptions {
2121

2222
TargetOptions {
2323
os: "fuchsia".to_string(),
24-
vendor: String::new(),
2524
linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
2625
linker: Some("rust-lld".to_owned()),
2726
lld_flavor: LldFlavor::Ld,

compiler/rustc_target/src/spec/mipsel_unknown_none.rs

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ pub fn target() -> Target {
1414
arch: "mips".to_string(),
1515

1616
options: TargetOptions {
17-
vendor: String::new(),
1817
linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
1918
cpu: "mips32r2".to_string(),
2019
features: "+mips32r2,+soft-float,+noabicalls".to_string(),

compiler/rustc_target/src/spec/mod.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -713,11 +713,14 @@ pub struct TargetOptions {
713713
pub endian: String,
714714
/// Width of c_int type. Defaults to "32".
715715
pub c_int_width: String,
716-
/// OS name to use for conditional compilation. Defaults to "none".
716+
/// OS name to use for conditional compilation (`target_os`). Defaults to "none".
717+
/// "none" implies a bare metal target without `std` library.
718+
/// A couple of targets having `std` also use "unknown" as an `os` value,
719+
/// but they are exceptions.
717720
pub os: String,
718-
/// Environment name to use for conditional compilation. Defaults to "".
721+
/// Environment name to use for conditional compilation (`target_env`). Defaults to "".
719722
pub env: String,
720-
/// Vendor name to use for conditional compilation. Defaults to "unknown".
723+
/// Vendor name to use for conditional compilation (`target_vendor`). Defaults to "unknown".
721724
pub vendor: String,
722725
/// Default linker flavor used if `-C linker-flavor` or `-C linker` are not passed
723726
/// on the command line. Defaults to `LinkerFlavor::Gcc`.

compiler/rustc_target/src/spec/msp430_none_elf.rs

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ pub fn target() -> Target {
99

1010
options: TargetOptions {
1111
c_int_width: "16".to_string(),
12-
vendor: String::new(),
1312
executables: true,
1413

1514
// The LLVM backend currently can't generate object files. To

compiler/rustc_target/src/spec/tests/tests_impl.rs

+13
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,18 @@ impl Target {
3636
&& self.post_link_objects_fallback.is_empty())
3737
|| self.crt_objects_fallback.is_some()
3838
);
39+
// Keep the default "unknown" vendor instead.
40+
assert_ne!(self.vendor, "");
41+
if !self.can_use_os_unknown() {
42+
// Keep the default "none" for bare metal targets instead.
43+
assert_ne!(self.os, "unknown");
44+
}
45+
}
46+
47+
// Add your target to the whitelist if it has `std` library
48+
// and you certainly want "unknown" for the OS name.
49+
fn can_use_os_unknown(&self) -> bool {
50+
self.llvm_target == "wasm32-unknown-unknown"
51+
|| (self.env == "sgx" && self.vendor == "fortanix")
3952
}
4053
}

compiler/rustc_target/src/spec/thumb_base.rs

-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ use crate::spec::{LinkerFlavor, LldFlavor, PanicStrategy, RelocModel, TargetOpti
3232
pub fn opts() -> TargetOptions {
3333
// See rust-lang/rfcs#1645 for a discussion about these defaults
3434
TargetOptions {
35-
vendor: String::new(),
3635
linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
3736
executables: true,
3837
// In most cases, LLD is good enough

compiler/rustc_target/src/spec/wasm32_wasi.rs

-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ pub fn target() -> Target {
7979
let mut options = wasm32_base::options();
8080

8181
options.os = "wasi".to_string();
82-
options.vendor = String::new();
8382
options.linker_flavor = LinkerFlavor::Lld(LldFlavor::Wasm);
8483
options
8584
.pre_link_args

0 commit comments

Comments
 (0)