diff --git a/compiler/rustc_codegen_llvm/src/context.rs b/compiler/rustc_codegen_llvm/src/context.rs index b5c31fcebe0c2..c007728095f79 100644 --- a/compiler/rustc_codegen_llvm/src/context.rs +++ b/compiler/rustc_codegen_llvm/src/context.rs @@ -906,7 +906,7 @@ impl<'ll> CodegenCx<'ll, '_> { return eh_catch_typeinfo; } let tcx = self.tcx; - assert!(self.sess().target.is_like_emscripten); + assert!(self.sess().target.os == "emscripten"); let eh_catch_typeinfo = match tcx.lang_items().eh_catch_typeinfo() { Some(def_id) => self.get_static(def_id), _ => { diff --git a/compiler/rustc_codegen_llvm/src/intrinsic.rs b/compiler/rustc_codegen_llvm/src/intrinsic.rs index a18f5b9dd7f9c..9f3647492877c 100644 --- a/compiler/rustc_codegen_llvm/src/intrinsic.rs +++ b/compiler/rustc_codegen_llvm/src/intrinsic.rs @@ -441,7 +441,7 @@ fn try_intrinsic<'ll>( bx.store(bx.const_i32(0), dest, ret_align); } else if wants_msvc_seh(bx.sess()) { codegen_msvc_try(bx, try_func, data, catch_func, dest); - } else if bx.sess().target.is_like_emscripten { + } else if bx.sess().target.os == "emscripten" { codegen_emcc_try(bx, try_func, data, catch_func, dest); } else { codegen_gnu_try(bx, try_func, data, catch_func, dest); diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs index edf49b8c80eea..72aa790c36357 100644 --- a/compiler/rustc_codegen_ssa/src/back/link.rs +++ b/compiler/rustc_codegen_ssa/src/back/link.rs @@ -2031,7 +2031,7 @@ fn add_order_independent_options( add_link_script(cmd, sess, tmpdir, crate_type); - if sess.target.is_like_fuchsia && crate_type == CrateType::Executable { + if sess.target.os == "fuchsia" && crate_type == CrateType::Executable { let prefix = if sess.opts.debugging_opts.sanitizer.contains(SanitizerSet::ADDRESS) { "asan/" } else { @@ -2051,7 +2051,7 @@ fn add_order_independent_options( cmd.no_crt_objects(); } - if sess.target.is_like_emscripten { + if sess.target.os == "emscripten" { cmd.arg("-s"); cmd.arg(if sess.panic_strategy() == PanicStrategy::Abort { "DISABLE_EXCEPTION_CATCHING=1" diff --git a/compiler/rustc_passes/src/weak_lang_items.rs b/compiler/rustc_passes/src/weak_lang_items.rs index 5411946343b74..3291be05807f6 100644 --- a/compiler/rustc_passes/src/weak_lang_items.rs +++ b/compiler/rustc_passes/src/weak_lang_items.rs @@ -17,7 +17,7 @@ pub fn check_crate<'tcx>(tcx: TyCtxt<'tcx>, items: &mut lang_items::LanguageItem if items.eh_personality().is_none() { items.missing.push(LangItem::EhPersonality); } - if tcx.sess.target.is_like_emscripten && items.eh_catch_typeinfo().is_none() { + if tcx.sess.target.os == "emscripten" && items.eh_catch_typeinfo().is_none() { items.missing.push(LangItem::EhCatchTypeinfo); } diff --git a/compiler/rustc_target/src/asm/aarch64.rs b/compiler/rustc_target/src/asm/aarch64.rs index fba8cc6ef8b4a..25842049413bd 100644 --- a/compiler/rustc_target/src/asm/aarch64.rs +++ b/compiler/rustc_target/src/asm/aarch64.rs @@ -74,7 +74,7 @@ impl AArch64InlineAsmRegClass { } pub fn target_reserves_x18(target: &Target) -> bool { - target.os == "android" || target.is_like_fuchsia || target.is_like_osx || target.is_like_windows + target.os == "android" || target.os == "fuchsia" || target.is_like_osx || target.is_like_windows } fn reserved_x18( diff --git a/compiler/rustc_target/src/spec/fuchsia_base.rs b/compiler/rustc_target/src/spec/fuchsia_base.rs index 04e30ff0c3e6e..b64875e32bdd7 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 fd0c3f36e7299..da0589cdd2093 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); 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 6730319dcfae2..0865ca7ea7df0 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 6a1a5e7a1d712..f1087db09d132 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,