From 667eb184ad7771de148f3fd17aa806bbb7b82d63 Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Mon, 15 Aug 2022 00:31:31 +0300 Subject: [PATCH] rustc_target: Refactor internal linker flavors slightly Remove one unstable user-facing linker flavor (l4-bender) --- compiler/rustc_codegen_ssa/src/back/link.rs | 27 +++-- compiler/rustc_codegen_ssa/src/back/linker.rs | 21 ++-- compiler/rustc_interface/src/tests.rs | 8 +- compiler/rustc_session/src/config.rs | 14 +-- .../src/spec/asmjs_unknown_emscripten.rs | 2 +- compiler/rustc_target/src/spec/bpf_base.rs | 2 +- compiler/rustc_target/src/spec/l4re_base.rs | 2 +- compiler/rustc_target/src/spec/mod.rs | 110 ++++++++---------- .../src/spec/nvptx64_nvidia_cuda.rs | 2 +- .../rustc_target/src/spec/tests/tests_impl.rs | 22 ++-- .../src/spec/wasm32_unknown_emscripten.rs | 4 +- 11 files changed, 93 insertions(+), 121 deletions(-) diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs index a97bdb2be70dd..9528b131c1e1b 100644 --- a/compiler/rustc_codegen_ssa/src/back/link.rs +++ b/compiler/rustc_codegen_ssa/src/back/link.rs @@ -1173,13 +1173,6 @@ pub fn linker_and_flavor(sess: &Session) -> (PathBuf, LinkerFlavor) { // only the linker flavor is known; use the default linker for the selected flavor (None, Some(flavor)) => Some(( PathBuf::from(match flavor { - LinkerFlavor::Em => { - if cfg!(windows) { - "emcc.bat" - } else { - "emcc" - } - } LinkerFlavor::Gcc => { if cfg!(any(target_os = "solaris", target_os = "illumos")) { // On historical Solaris systems, "cc" may have @@ -1194,11 +1187,17 @@ pub fn linker_and_flavor(sess: &Session) -> (PathBuf, LinkerFlavor) { } } LinkerFlavor::Ld => "ld", - LinkerFlavor::Msvc => "link.exe", LinkerFlavor::Lld(_) => "lld", - LinkerFlavor::PtxLinker => "rust-ptx-linker", - LinkerFlavor::BpfLinker => "bpf-linker", - LinkerFlavor::L4Bender => "l4-bender", + LinkerFlavor::Msvc => "link.exe", + LinkerFlavor::EmCc => { + if cfg!(windows) { + "emcc.bat" + } else { + "emcc" + } + } + LinkerFlavor::Bpf => "bpf-linker", + LinkerFlavor::Ptx => "rust-ptx-linker", }), flavor, )), @@ -1208,7 +1207,7 @@ pub fn linker_and_flavor(sess: &Session) -> (PathBuf, LinkerFlavor) { }); let flavor = if stem == "emcc" { - LinkerFlavor::Em + LinkerFlavor::EmCc } else if stem == "gcc" || stem.ends_with("-gcc") || stem == "clang" @@ -2114,11 +2113,11 @@ fn add_order_independent_options( }); } - if flavor == LinkerFlavor::PtxLinker { + if flavor == LinkerFlavor::Ptx { // Provide the linker with fallback to internal `target-cpu`. cmd.arg("--fallback-arch"); cmd.arg(&codegen_results.crate_info.target_cpu); - } else if flavor == LinkerFlavor::BpfLinker { + } else if flavor == LinkerFlavor::Bpf { cmd.arg("--cpu"); cmd.arg(&codegen_results.crate_info.target_cpu); cmd.arg("--cpu-features"); diff --git a/compiler/rustc_codegen_ssa/src/back/linker.rs b/compiler/rustc_codegen_ssa/src/back/linker.rs index ce51b2e9531fc..8c6f526b054bc 100644 --- a/compiler/rustc_codegen_ssa/src/back/linker.rs +++ b/compiler/rustc_codegen_ssa/src/back/linker.rs @@ -126,29 +126,26 @@ pub fn get_linker<'a>( // to the linker args construction. assert!(cmd.get_args().is_empty() || sess.target.vendor == "uwp"); match flavor { - LinkerFlavor::Lld(LldFlavor::Link) | LinkerFlavor::Msvc => { - Box::new(MsvcLinker { cmd, sess }) as Box - } - LinkerFlavor::Em => Box::new(EmLinker { cmd, sess }) as Box, LinkerFlavor::Gcc => { Box::new(GccLinker { cmd, sess, target_cpu, hinted_static: false, is_ld: false }) as Box } - + LinkerFlavor::Ld if sess.target.os == "l4re" => { + Box::new(L4Bender::new(cmd, sess)) as Box + } LinkerFlavor::Lld(LldFlavor::Ld) | LinkerFlavor::Lld(LldFlavor::Ld64) | LinkerFlavor::Ld => { Box::new(GccLinker { cmd, sess, target_cpu, hinted_static: false, is_ld: true }) as Box } - + LinkerFlavor::Lld(LldFlavor::Link) | LinkerFlavor::Msvc => { + Box::new(MsvcLinker { cmd, sess }) as Box + } LinkerFlavor::Lld(LldFlavor::Wasm) => Box::new(WasmLd::new(cmd, sess)) as Box, - - LinkerFlavor::PtxLinker => Box::new(PtxLinker { cmd, sess }) as Box, - - LinkerFlavor::BpfLinker => Box::new(BpfLinker { cmd, sess }) as Box, - - LinkerFlavor::L4Bender => Box::new(L4Bender::new(cmd, sess)) as Box, + LinkerFlavor::EmCc => Box::new(EmLinker { cmd, sess }) as Box, + LinkerFlavor::Bpf => Box::new(BpfLinker { cmd, sess }) as Box, + LinkerFlavor::Ptx => Box::new(PtxLinker { cmd, sess }) as Box, } } diff --git a/compiler/rustc_interface/src/tests.rs b/compiler/rustc_interface/src/tests.rs index 9207a0488623c..5df5ab3ddc032 100644 --- a/compiler/rustc_interface/src/tests.rs +++ b/compiler/rustc_interface/src/tests.rs @@ -21,10 +21,8 @@ use rustc_session::{build_session, getopts, DiagnosticOutput, Session}; use rustc_span::edition::{Edition, DEFAULT_EDITION}; use rustc_span::symbol::sym; use rustc_span::SourceFileHashAlgorithm; -use rustc_target::spec::{CodeModel, LinkerFlavor, MergeFunctions, PanicStrategy}; -use rustc_target::spec::{ - RelocModel, RelroLevel, SanitizerSet, SplitDebuginfo, StackProtector, TlsModel, -}; +use rustc_target::spec::{CodeModel, LinkerFlavorCli, MergeFunctions, PanicStrategy, RelocModel}; +use rustc_target::spec::{RelroLevel, SanitizerSet, SplitDebuginfo, StackProtector, TlsModel}; use std::collections::{BTreeMap, BTreeSet}; use std::iter::FromIterator; @@ -552,7 +550,7 @@ fn test_codegen_options_tracking_hash() { untracked!(link_args, vec![String::from("abc"), String::from("def")]); untracked!(link_self_contained, Some(true)); untracked!(linker, Some(PathBuf::from("linker"))); - untracked!(linker_flavor, Some(LinkerFlavor::Gcc)); + untracked!(linker_flavor, Some(LinkerFlavorCli::Gcc)); untracked!(no_stack_check, true); untracked!(remark, Passes::Some(vec![String::from("pass1"), String::from("pass2")])); untracked!(rpath, true); diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs index a21fe894b6524..7005409fc4020 100644 --- a/compiler/rustc_session/src/config.rs +++ b/compiler/rustc_session/src/config.rs @@ -12,8 +12,8 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_data_structures::stable_hasher::ToStableHashKey; use rustc_target::abi::{Align, TargetDataLayout}; -use rustc_target::spec::{LinkerFlavorCli, SplitDebuginfo, Target, TargetTriple, TargetWarnings}; -use rustc_target::spec::{PanicStrategy, SanitizerSet, TARGETS}; +use rustc_target::spec::{PanicStrategy, SanitizerSet, SplitDebuginfo}; +use rustc_target::spec::{Target, TargetTriple, TargetWarnings, TARGETS}; use crate::parse::{CrateCheckConfig, CrateConfig}; use rustc_feature::UnstableFeatures; @@ -2379,16 +2379,6 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options { } } - if cg.linker_flavor == Some(LinkerFlavorCli::L4Bender) - && !nightly_options::is_unstable_enabled(matches) - { - early_error( - error_format, - "`l4-bender` linker flavor is unstable, `-Z unstable-options` \ - flag must also be passed to explicitly use it", - ); - } - let prints = collect_print_requests(&mut cg, &mut unstable_opts, matches, error_format); let cg = cg; diff --git a/compiler/rustc_target/src/spec/asmjs_unknown_emscripten.rs b/compiler/rustc_target/src/spec/asmjs_unknown_emscripten.rs index b4cf2c5ee2294..f492c3451a418 100644 --- a/compiler/rustc_target/src/spec/asmjs_unknown_emscripten.rs +++ b/compiler/rustc_target/src/spec/asmjs_unknown_emscripten.rs @@ -2,6 +2,6 @@ use super::{wasm32_unknown_emscripten, LinkerFlavor, Target}; pub fn target() -> Target { let mut target = wasm32_unknown_emscripten::target(); - target.add_post_link_args(LinkerFlavor::Em, &["-sWASM=0", "--memory-init-file", "0"]); + target.add_post_link_args(LinkerFlavor::EmCc, &["-sWASM=0", "--memory-init-file", "0"]); target } diff --git a/compiler/rustc_target/src/spec/bpf_base.rs b/compiler/rustc_target/src/spec/bpf_base.rs index 3c4da6f883d9d..baf36587147a6 100644 --- a/compiler/rustc_target/src/spec/bpf_base.rs +++ b/compiler/rustc_target/src/spec/bpf_base.rs @@ -5,7 +5,7 @@ pub fn opts(endian: Endian) -> TargetOptions { TargetOptions { allow_asm: true, endian, - linker_flavor: LinkerFlavor::BpfLinker, + linker_flavor: LinkerFlavor::Bpf, atomic_cas: false, dynamic_linking: true, no_builtins: true, diff --git a/compiler/rustc_target/src/spec/l4re_base.rs b/compiler/rustc_target/src/spec/l4re_base.rs index a08756861e5b2..26fce7dcb2b4c 100644 --- a/compiler/rustc_target/src/spec/l4re_base.rs +++ b/compiler/rustc_target/src/spec/l4re_base.rs @@ -4,7 +4,7 @@ pub fn opts() -> TargetOptions { TargetOptions { os: "l4re".into(), env: "uclibc".into(), - linker_flavor: LinkerFlavor::L4Bender, + linker_flavor: LinkerFlavor::Ld, panic_strategy: PanicStrategy::Abort, linker: Some("l4-bender".into()), linker_is_gnu: false, diff --git a/compiler/rustc_target/src/spec/mod.rs b/compiler/rustc_target/src/spec/mod.rs index 51f9edfcabe8e..11f51d267b00d 100644 --- a/compiler/rustc_target/src/spec/mod.rs +++ b/compiler/rustc_target/src/spec/mod.rs @@ -92,26 +92,24 @@ mod windows_uwp_msvc_base; #[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd)] pub enum LinkerFlavor { - Em, Gcc, - L4Bender, Ld, - Msvc, Lld(LldFlavor), - PtxLinker, - BpfLinker, + Msvc, + EmCc, + Bpf, + Ptx, } #[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd)] pub enum LinkerFlavorCli { - Em, Gcc, - L4Bender, Ld, - Msvc, Lld(LldFlavor), - PtxLinker, + Msvc, + Em, BpfLinker, + PtxLinker, } #[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd)] @@ -152,39 +150,37 @@ impl ToJson for LldFlavor { impl LinkerFlavor { pub fn from_cli(cli: LinkerFlavorCli) -> LinkerFlavor { match cli { - LinkerFlavorCli::Em => LinkerFlavor::Em, LinkerFlavorCli::Gcc => LinkerFlavor::Gcc, - LinkerFlavorCli::L4Bender => LinkerFlavor::L4Bender, LinkerFlavorCli::Ld => LinkerFlavor::Ld, - LinkerFlavorCli::Msvc => LinkerFlavor::Msvc, LinkerFlavorCli::Lld(lld_flavor) => LinkerFlavor::Lld(lld_flavor), - LinkerFlavorCli::PtxLinker => LinkerFlavor::PtxLinker, - LinkerFlavorCli::BpfLinker => LinkerFlavor::BpfLinker, + LinkerFlavorCli::Msvc => LinkerFlavor::Msvc, + LinkerFlavorCli::Em => LinkerFlavor::EmCc, + LinkerFlavorCli::BpfLinker => LinkerFlavor::Bpf, + LinkerFlavorCli::PtxLinker => LinkerFlavor::Ptx, } } fn to_cli(self) -> LinkerFlavorCli { match self { - LinkerFlavor::Em => LinkerFlavorCli::Em, LinkerFlavor::Gcc => LinkerFlavorCli::Gcc, - LinkerFlavor::L4Bender => LinkerFlavorCli::L4Bender, LinkerFlavor::Ld => LinkerFlavorCli::Ld, - LinkerFlavor::Msvc => LinkerFlavorCli::Msvc, LinkerFlavor::Lld(lld_flavor) => LinkerFlavorCli::Lld(lld_flavor), - LinkerFlavor::PtxLinker => LinkerFlavorCli::PtxLinker, - LinkerFlavor::BpfLinker => LinkerFlavorCli::BpfLinker, + LinkerFlavor::Msvc => LinkerFlavorCli::Msvc, + LinkerFlavor::EmCc => LinkerFlavorCli::Em, + LinkerFlavor::Bpf => LinkerFlavorCli::BpfLinker, + LinkerFlavor::Ptx => LinkerFlavorCli::PtxLinker, } } } -macro_rules! flavor_mappings { - ($((($($flavor:tt)*), $string:expr),)*) => ( +macro_rules! linker_flavor_cli_impls { + ($(($($flavor:tt)*) $string:literal)*) => ( impl LinkerFlavorCli { pub const fn one_of() -> &'static str { concat!("one of: ", $($string, " ",)*) } - pub fn from_str(s: &str) -> Option { + pub fn from_str(s: &str) -> Option { Some(match s { $($string => $($flavor)*,)* _ => return None, @@ -200,18 +196,17 @@ macro_rules! flavor_mappings { ) } -flavor_mappings! { - ((LinkerFlavorCli::Em), "em"), - ((LinkerFlavorCli::Gcc), "gcc"), - ((LinkerFlavorCli::L4Bender), "l4-bender"), - ((LinkerFlavorCli::Ld), "ld"), - ((LinkerFlavorCli::Msvc), "msvc"), - ((LinkerFlavorCli::PtxLinker), "ptx-linker"), - ((LinkerFlavorCli::BpfLinker), "bpf-linker"), - ((LinkerFlavorCli::Lld(LldFlavor::Wasm)), "wasm-ld"), - ((LinkerFlavorCli::Lld(LldFlavor::Ld64)), "ld64.lld"), - ((LinkerFlavorCli::Lld(LldFlavor::Ld)), "ld.lld"), - ((LinkerFlavorCli::Lld(LldFlavor::Link)), "lld-link"), +linker_flavor_cli_impls! { + (LinkerFlavorCli::Gcc) "gcc" + (LinkerFlavorCli::Ld) "ld" + (LinkerFlavorCli::Lld(LldFlavor::Ld)) "ld.lld" + (LinkerFlavorCli::Lld(LldFlavor::Ld64)) "ld64.lld" + (LinkerFlavorCli::Lld(LldFlavor::Link)) "lld-link" + (LinkerFlavorCli::Lld(LldFlavor::Wasm)) "wasm-ld" + (LinkerFlavorCli::Msvc) "msvc" + (LinkerFlavorCli::Em) "em" + (LinkerFlavorCli::BpfLinker) "bpf-linker" + (LinkerFlavorCli::PtxLinker) "ptx-linker" } impl ToJson for LinkerFlavorCli { @@ -1198,21 +1193,21 @@ pub struct TargetOptions { pub abi: StaticCow, /// Vendor name to use for conditional compilation (`target_vendor`). Defaults to "unknown". pub vendor: StaticCow, + + /// Linker to invoke + pub linker: Option>, /// Default linker flavor used if `-C linker-flavor` or `-C linker` are not passed /// on the command line. Defaults to `LinkerFlavor::Gcc`. pub linker_flavor: LinkerFlavor, linker_flavor_json: LinkerFlavorCli, - - /// Linker to invoke - pub linker: Option>, - /// LLD flavor used if `lld` (or `rust-lld`) is specified as a linker /// without clarifying its flavor in any way. + /// FIXME: Merge this into `LinkerFlavor`. pub lld_flavor: LldFlavor, + /// Whether the linker support GNU-like arguments such as -O. Defaults to true. + /// FIXME: Merge this into `LinkerFlavor`. + pub linker_is_gnu: bool, - /// Linker arguments that are passed *before* any user-defined libraries. - pub pre_link_args: LinkArgs, - pre_link_args_json: LinkArgsCli, /// Objects to link before and after all other object code. pub pre_link_objects: CrtObjects, pub post_link_objects: CrtObjects, @@ -1221,6 +1216,9 @@ pub struct TargetOptions { pub post_link_objects_self_contained: CrtObjects, pub link_self_contained: LinkSelfContainedDefault, + /// Linker arguments that are passed *before* any user-defined libraries. + pub pre_link_args: LinkArgs, + pre_link_args_json: LinkArgsCli, /// Linker arguments that are unconditionally passed after any /// user-defined but before post-link objects. Standard platform /// libraries that should be always be linked to, usually go here. @@ -1238,11 +1236,11 @@ pub struct TargetOptions { /// user-defined libraries. pub post_link_args: LinkArgs, post_link_args_json: LinkArgsCli, + /// Optional link script applied to `dylib` and `executable` crate types. /// This is a string containing the script, not a path. Can only be applied /// to linkers where `linker_is_gnu` is true. pub link_script: Option>, - /// Environment variables to be set for the linker invocation. pub link_env: StaticCow<[(StaticCow, StaticCow)]>, /// Environment variables to be removed for the linker invocation. @@ -1327,8 +1325,6 @@ pub struct TargetOptions { /// Default supported version of DWARF on this platform. /// Useful because some platforms (osx, bsd) only want up to DWARF2. pub default_dwarf_version: u32, - /// Whether the linker support GNU-like arguments such as -O. Defaults to true. - pub linker_is_gnu: bool, /// The MinGW toolchain has a known issue that prevents it from correctly /// handling COFF object files with more than 215 sections. Since each weak /// symbol needs its own COMDAT section, weak linkage implies a large @@ -1522,11 +1518,7 @@ fn add_link_args(link_args: &mut LinkArgs, flavor: LinkerFlavor, args: &[&'stati LinkerFlavor::Lld(lld_flavor) => { panic!("add_link_args: use non-LLD flavor for {:?}", lld_flavor) } - LinkerFlavor::Gcc - | LinkerFlavor::Em - | LinkerFlavor::L4Bender - | LinkerFlavor::BpfLinker - | LinkerFlavor::PtxLinker => {} + LinkerFlavor::Gcc | LinkerFlavor::EmCc | LinkerFlavor::Bpf | LinkerFlavor::Ptx => {} } } @@ -1588,14 +1580,11 @@ impl Default for TargetOptions { env: "".into(), abi: "".into(), vendor: "unknown".into(), + linker: option_env!("CFG_DEFAULT_LINKER").map(|s| s.into()), linker_flavor: LinkerFlavor::Gcc, linker_flavor_json: LinkerFlavorCli::Gcc, - linker: option_env!("CFG_DEFAULT_LINKER").map(|s| s.into()), lld_flavor: LldFlavor::Ld, - pre_link_args: LinkArgs::new(), - pre_link_args_json: LinkArgsCli::new(), - post_link_args: LinkArgs::new(), - post_link_args_json: LinkArgsCli::new(), + linker_is_gnu: true, link_script: None, asm_args: cvs![], cpu: "generic".into(), @@ -1622,7 +1611,6 @@ impl Default for TargetOptions { is_like_msvc: false, is_like_wasm: false, default_dwarf_version: 4, - linker_is_gnu: true, allows_weak_linkage: true, has_rpath: false, no_default_libraries: true, @@ -1635,12 +1623,16 @@ impl Default for TargetOptions { pre_link_objects_self_contained: Default::default(), post_link_objects_self_contained: Default::default(), link_self_contained: LinkSelfContainedDefault::False, + pre_link_args: LinkArgs::new(), + pre_link_args_json: LinkArgsCli::new(), late_link_args: LinkArgs::new(), late_link_args_json: LinkArgsCli::new(), late_link_args_dynamic: LinkArgs::new(), late_link_args_dynamic_json: LinkArgsCli::new(), late_link_args_static: LinkArgs::new(), late_link_args_static_json: LinkArgsCli::new(), + post_link_args: LinkArgs::new(), + post_link_args_json: LinkArgsCli::new(), link_env: cvs![], link_env_remove: cvs![], archive_format: "gnu".into(), @@ -2190,9 +2182,10 @@ impl Target { key!(env); key!(abi); key!(vendor); - key!(linker_flavor_json = "linker-flavor", LinkerFlavor)?; key!(linker, optional); + key!(linker_flavor_json = "linker-flavor", LinkerFlavor)?; key!(lld_flavor, LldFlavor)?; + key!(linker_is_gnu, bool); key!(pre_link_objects = "pre-link-objects", link_objects); key!(post_link_objects = "post-link-objects", link_objects); key!(pre_link_objects_self_contained = "pre-link-objects-fallback", link_objects); @@ -2230,7 +2223,6 @@ impl Target { key!(is_like_msvc, bool); key!(is_like_wasm, bool); key!(default_dwarf_version, u32); - key!(linker_is_gnu, bool); key!(allows_weak_linkage, bool); key!(has_rpath, bool); key!(no_default_libraries, bool); @@ -2437,9 +2429,10 @@ impl ToJson for Target { target_option_val!(env); target_option_val!(abi); target_option_val!(vendor); - target_option_val!(linker_flavor_json, "linker-flavor"); target_option_val!(linker); + target_option_val!(linker_flavor_json, "linker-flavor"); target_option_val!(lld_flavor); + target_option_val!(linker_is_gnu); target_option_val!(pre_link_objects); target_option_val!(post_link_objects); target_option_val!(pre_link_objects_self_contained, "pre-link-objects-fallback"); @@ -2478,7 +2471,6 @@ impl ToJson for Target { target_option_val!(is_like_msvc); target_option_val!(is_like_wasm); target_option_val!(default_dwarf_version); - target_option_val!(linker_is_gnu); target_option_val!(allows_weak_linkage); target_option_val!(has_rpath); target_option_val!(no_default_libraries); diff --git a/compiler/rustc_target/src/spec/nvptx64_nvidia_cuda.rs b/compiler/rustc_target/src/spec/nvptx64_nvidia_cuda.rs index 1c5b68001b957..6ab3a8b7eb5a0 100644 --- a/compiler/rustc_target/src/spec/nvptx64_nvidia_cuda.rs +++ b/compiler/rustc_target/src/spec/nvptx64_nvidia_cuda.rs @@ -10,7 +10,7 @@ pub fn target() -> Target { options: TargetOptions { os: "cuda".into(), vendor: "nvidia".into(), - linker_flavor: LinkerFlavor::PtxLinker, + linker_flavor: LinkerFlavor::Ptx, // The linker can be installed from `crates.io`. linker: Some("rust-ptx-linker".into()), linker_is_gnu: false, diff --git a/compiler/rustc_target/src/spec/tests/tests_impl.rs b/compiler/rustc_target/src/spec/tests/tests_impl.rs index 5e035f189c49b..5ec961a672ee8 100644 --- a/compiler/rustc_target/src/spec/tests/tests_impl.rs +++ b/compiler/rustc_target/src/spec/tests/tests_impl.rs @@ -22,10 +22,9 @@ impl Target { assert_eq!(self.is_like_osx, matches!(self.lld_flavor, LldFlavor::Ld64)); assert_eq!(self.is_like_msvc, matches!(self.lld_flavor, LldFlavor::Link)); assert_eq!(self.is_like_wasm, matches!(self.lld_flavor, LldFlavor::Wasm)); - assert_eq!(self.os == "l4re", matches!(self.linker_flavor, LinkerFlavor::L4Bender)); - assert_eq!(self.os == "emscripten", matches!(self.linker_flavor, LinkerFlavor::Em)); - assert_eq!(self.arch == "bpf", matches!(self.linker_flavor, LinkerFlavor::BpfLinker)); - assert_eq!(self.arch == "nvptx64", matches!(self.linker_flavor, LinkerFlavor::PtxLinker)); + assert_eq!(self.os == "emscripten", matches!(self.linker_flavor, LinkerFlavor::EmCc)); + assert_eq!(self.arch == "bpf", matches!(self.linker_flavor, LinkerFlavor::Bpf)); + assert_eq!(self.arch == "nvptx64", matches!(self.linker_flavor, LinkerFlavor::Ptx)); for args in [ &self.pre_link_args, @@ -65,17 +64,14 @@ impl Target { LinkerFlavor::Lld(LldFlavor::Wasm) | LinkerFlavor::Gcc ) } - (LinkerFlavor::L4Bender, LldFlavor::Ld) => { - assert_matches!(flavor, LinkerFlavor::L4Bender) + (LinkerFlavor::EmCc, LldFlavor::Wasm) => { + assert_matches!(flavor, LinkerFlavor::EmCc) } - (LinkerFlavor::Em, LldFlavor::Wasm) => { - assert_matches!(flavor, LinkerFlavor::Em) + (LinkerFlavor::Bpf, LldFlavor::Ld) => { + assert_matches!(flavor, LinkerFlavor::Bpf) } - (LinkerFlavor::BpfLinker, LldFlavor::Ld) => { - assert_matches!(flavor, LinkerFlavor::BpfLinker) - } - (LinkerFlavor::PtxLinker, LldFlavor::Ld) => { - assert_matches!(flavor, LinkerFlavor::PtxLinker) + (LinkerFlavor::Ptx, LldFlavor::Ld) => { + assert_matches!(flavor, LinkerFlavor::Ptx) } flavors => unreachable!("unexpected flavor combination: {:?}", flavors), } diff --git a/compiler/rustc_target/src/spec/wasm32_unknown_emscripten.rs b/compiler/rustc_target/src/spec/wasm32_unknown_emscripten.rs index c7e7d22108656..6f77ef98c015d 100644 --- a/compiler/rustc_target/src/spec/wasm32_unknown_emscripten.rs +++ b/compiler/rustc_target/src/spec/wasm32_unknown_emscripten.rs @@ -5,13 +5,13 @@ pub fn target() -> Target { // Reset flags for non-Em flavors back to empty to satisfy sanity checking tests. let pre_link_args = LinkArgs::new(); let post_link_args = TargetOptions::link_args( - LinkerFlavor::Em, + LinkerFlavor::EmCc, &["-sABORTING_MALLOC=0", "-Wl,--fatal-warnings"], ); let opts = TargetOptions { os: "emscripten".into(), - linker_flavor: LinkerFlavor::Em, + linker_flavor: LinkerFlavor::EmCc, // emcc emits two files - a .js file to instantiate the wasm and supply platform // functionality, and a .wasm file. exe_suffix: ".js".into(),