diff options
| author | Yuki Okushi <jtitor@2k36.org> | 2022-06-24 16:43:45 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-06-24 16:43:45 +0900 |
| commit | 33eb3c05c54b306afea341dd233671a9f039156f (patch) | |
| tree | 381a02063b8b78dc7b5de4b1dc40d4c90fa65030 /compiler/rustc_target/src/spec | |
| parent | 6580d7e784d0046ab2f8d43dac36ea0de0139978 (diff) | |
| parent | 37fd2941a1290a287935988641dc14233ee5e236 (diff) | |
| download | rust-33eb3c05c54b306afea341dd233671a9f039156f.tar.gz rust-33eb3c05c54b306afea341dd233671a9f039156f.zip | |
Rollup merge of #98214 - petrochenkov:islike, r=compiler-errors
rustc_target: Remove some redundant target properties
`is_like_emscripten` is equivalent to `os == "emscripten"`, so it's removed.
`is_like_fuchsia` is equivalent to `os == "fuchsia"`, so it's removed.
`is_like_osx` also falls into the same category and is equivalent to `vendor == "apple"`, but it's commonly used so I kept it as is for now.
`is_like_(solaris,windows,wasm)` are combinations of different operating systems or architectures (see compiler/rustc_target/src/spec/tests/tests_impl.rs) so they are also kept as is.
I think `is_like_wasm` (and maybe `is_like_osx`) are sufficiently closed sets, so we can remove these fields as well and replace them with methods like `fn is_like_wasm() { arch == "wasm32" || arch == "wasm64" }`.
On other hand, `is_like_solaris` and `is_like_windows` are sufficiently open and I can imagine custom targets introducing other values for `os`.
This is kind of a gray area.
Diffstat (limited to 'compiler/rustc_target/src/spec')
| -rw-r--r-- | compiler/rustc_target/src/spec/fuchsia_base.rs | 1 | ||||
| -rw-r--r-- | compiler/rustc_target/src/spec/mod.rs | 12 | ||||
| -rw-r--r-- | compiler/rustc_target/src/spec/tests/tests_impl.rs | 5 | ||||
| -rw-r--r-- | compiler/rustc_target/src/spec/wasm32_unknown_emscripten.rs | 1 |
4 files changed, 5 insertions, 14 deletions
diff --git a/compiler/rustc_target/src/spec/fuchsia_base.rs b/compiler/rustc_target/src/spec/fuchsia_base.rs index 04e30ff0c3e..b64875e32bd 100644 --- a/compiler/rustc_target/src/spec/fuchsia_base.rs +++ b/compiler/rustc_target/src/spec/fuchsia_base.rs @@ -28,7 +28,6 @@ pub fn opts() -> TargetOptions { dynamic_linking: true, executables: true, families: cvs!["unix"], - is_like_fuchsia: true, pre_link_args, pre_link_objects: crt_objects::new(&[ (LinkOutputKind::DynamicNoPicExe, &["Scrt1.o"]), diff --git a/compiler/rustc_target/src/spec/mod.rs b/compiler/rustc_target/src/spec/mod.rs index fd0c3f36e72..da0589cdd20 100644 --- a/compiler/rustc_target/src/spec/mod.rs +++ b/compiler/rustc_target/src/spec/mod.rs @@ -1273,12 +1273,6 @@ pub struct TargetOptions { /// - uses SEH-based unwinding, /// - supports control flow guard mechanism. pub is_like_msvc: bool, - /// Whether the target toolchain is like Emscripten's. Only useful for compiling with - /// Emscripten toolchain. - /// Defaults to false. - pub is_like_emscripten: bool, - /// Whether the target toolchain is like Fuchsia's. - pub is_like_fuchsia: bool, /// Whether a target toolchain is like WASM. pub is_like_wasm: bool, /// Version of DWARF to use if not using the default. @@ -1505,9 +1499,7 @@ impl Default for TargetOptions { is_like_osx: false, is_like_solaris: false, is_like_windows: false, - is_like_emscripten: false, is_like_msvc: false, - is_like_fuchsia: false, is_like_wasm: false, dwarf_version: None, linker_is_gnu: true, @@ -2112,8 +2104,6 @@ impl Target { key!(is_like_solaris, bool); key!(is_like_windows, bool); key!(is_like_msvc, bool); - key!(is_like_emscripten, bool); - key!(is_like_fuchsia, bool); key!(is_like_wasm, bool); key!(dwarf_version, Option<u32>); key!(linker_is_gnu, bool); @@ -2358,8 +2348,6 @@ impl ToJson for Target { target_option_val!(is_like_solaris); target_option_val!(is_like_windows); target_option_val!(is_like_msvc); - target_option_val!(is_like_emscripten); - target_option_val!(is_like_fuchsia); target_option_val!(is_like_wasm); target_option_val!(dwarf_version); target_option_val!(linker_is_gnu); diff --git a/compiler/rustc_target/src/spec/tests/tests_impl.rs b/compiler/rustc_target/src/spec/tests/tests_impl.rs index 6730319dcfa..0865ca7ea7d 100644 --- a/compiler/rustc_target/src/spec/tests/tests_impl.rs +++ b/compiler/rustc_target/src/spec/tests/tests_impl.rs @@ -8,7 +8,12 @@ pub(super) fn test_target(target: Target) { impl Target { fn check_consistency(&self) { + assert_eq!(self.is_like_osx, self.vendor == "apple"); + assert_eq!(self.is_like_solaris, self.os == "solaris" || self.os == "illumos"); + assert_eq!(self.is_like_windows, self.os == "windows" || self.os == "uefi"); + assert_eq!(self.is_like_wasm, self.arch == "wasm32" || self.arch == "wasm64"); assert!(self.is_like_windows || !self.is_like_msvc); + // Check that LLD with the given flavor is treated identically to the linker it emulates. // If your target really needs to deviate from the rules below, except it and document the // reasons. diff --git a/compiler/rustc_target/src/spec/wasm32_unknown_emscripten.rs b/compiler/rustc_target/src/spec/wasm32_unknown_emscripten.rs index 6a1a5e7a1d7..f1087db09d1 100644 --- a/compiler/rustc_target/src/spec/wasm32_unknown_emscripten.rs +++ b/compiler/rustc_target/src/spec/wasm32_unknown_emscripten.rs @@ -26,7 +26,6 @@ pub fn target() -> Target { // functionality, and a .wasm file. exe_suffix: ".js".into(), linker: None, - is_like_emscripten: true, panic_strategy: PanicStrategy::Unwind, no_default_libraries: false, post_link_args, |
