From ccff48f97b7a4438b9818f8ff0f60c1cd01cdbeb Mon Sep 17 00:00:00 2001 From: Loïc BRANSTETT Date: Tue, 22 Mar 2022 11:43:05 +0100 Subject: Replace every `String` in Target(Options) with `Cow<'static, str>` --- compiler/rustc_codegen_ssa/src/back/link.rs | 16 ++++++++-------- compiler/rustc_codegen_ssa/src/back/linker.rs | 4 ++-- compiler/rustc_codegen_ssa/src/back/write.rs | 4 ++-- 3 files changed, 12 insertions(+), 12 deletions(-) (limited to 'compiler/rustc_codegen_ssa/src') diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs index 548ae0e411d..8b31d24b071 100644 --- a/compiler/rustc_codegen_ssa/src/back/link.rs +++ b/compiler/rustc_codegen_ssa/src/back/link.rs @@ -675,10 +675,10 @@ fn link_natively<'a, B: ArchiveBuilder<'a>>( linker::disable_localization(&mut cmd); for &(ref k, ref v) in &sess.target.link_env { - cmd.env(k, v); + cmd.env(k.as_ref(), v.as_ref()); } for k in &sess.target.link_env_remove { - cmd.env_remove(k); + cmd.env_remove(k.as_ref()); } if sess.opts.prints.contains(&PrintRequest::LinkArgs) { @@ -1216,7 +1216,7 @@ pub fn linker_and_flavor(sess: &Session) -> (PathBuf, LinkerFlavor) { if let Some(ret) = infer_from( sess, - sess.target.linker.clone().map(PathBuf::from), + sess.target.linker.as_ref().map(|l| PathBuf::from(l.as_ref())), Some(sess.target.linker_flavor), ) { return ret; @@ -1602,7 +1602,7 @@ fn add_link_script(cmd: &mut dyn Linker, sess: &Session, tmpdir: &Path, crate_ty let file_name = ["rustc", &sess.target.llvm_target, "linkfile.ld"].join("-"); let path = tmpdir.join(file_name); - if let Err(e) = fs::write(&path, script) { + if let Err(e) = fs::write(&path, script.as_ref()) { sess.fatal(&format!("failed to write link script to {}: {}", path.display(), e)); } @@ -1960,8 +1960,8 @@ fn add_order_independent_options( cmd.arg(&codegen_results.crate_info.target_cpu); cmd.arg("--cpu-features"); cmd.arg(match &sess.opts.cg.target_feature { - feat if !feat.is_empty() => feat, - _ => &sess.target.options.features, + feat if !feat.is_empty() => feat.as_ref(), + _ => sess.target.options.features.as_ref(), }); } @@ -2478,12 +2478,12 @@ fn add_apple_sdk(cmd: &mut dyn Linker, sess: &Session, flavor: LinkerFlavor) { let os = &sess.target.os; let llvm_target = &sess.target.llvm_target; if sess.target.vendor != "apple" - || !matches!(os.as_str(), "ios" | "tvos") + || !matches!(os.as_ref(), "ios" | "tvos") || flavor != LinkerFlavor::Gcc { return; } - let sdk_name = match (arch.as_str(), os.as_str()) { + let sdk_name = match (arch.as_ref(), os.as_ref()) { ("aarch64", "tvos") => "appletvos", ("x86_64", "tvos") => "appletvsimulator", ("arm", "ios") => "iphoneos", diff --git a/compiler/rustc_codegen_ssa/src/back/linker.rs b/compiler/rustc_codegen_ssa/src/back/linker.rs index 3a66bfafaf3..2c15ed83167 100644 --- a/compiler/rustc_codegen_ssa/src/back/linker.rs +++ b/compiler/rustc_codegen_ssa/src/back/linker.rs @@ -75,7 +75,7 @@ pub fn get_linker<'a>( if let Some(ref tool) = msvc_tool { let original_path = tool.path(); if let Some(ref root_lib_path) = original_path.ancestors().nth(4) { - let arch = match t.arch.as_str() { + let arch = match t.arch.as_ref() { "x86_64" => Some("x64"), "x86" => Some("x86"), "aarch64" => Some("arm64"), @@ -1520,7 +1520,7 @@ impl<'a> L4Bender<'a> { pub(crate) fn exported_symbols(tcx: TyCtxt<'_>, crate_type: CrateType) -> Vec { if let Some(ref exports) = tcx.sess.target.override_export_symbols { - return exports.clone(); + return exports.iter().map(ToString::to_string).collect(); } let mut symbols = Vec::new(); diff --git a/compiler/rustc_codegen_ssa/src/back/write.rs b/compiler/rustc_codegen_ssa/src/back/write.rs index d4eaf6389df..9417874ffb4 100644 --- a/compiler/rustc_codegen_ssa/src/back/write.rs +++ b/compiler/rustc_codegen_ssa/src/back/write.rs @@ -218,7 +218,7 @@ impl ModuleConfig { false ), emit_obj, - bc_cmdline: sess.target.bitcode_llvm_cmdline.clone(), + bc_cmdline: sess.target.bitcode_llvm_cmdline.to_string(), verify_llvm_ir: sess.verify_llvm_ir(), no_prepopulate_passes: sess.opts.cg.no_prepopulate_passes, @@ -1061,7 +1061,7 @@ fn start_executing_work( is_pe_coff: tcx.sess.target.is_like_windows, target_can_use_split_dwarf: tcx.sess.target_can_use_split_dwarf(), target_pointer_width: tcx.sess.target.pointer_width, - target_arch: tcx.sess.target.arch.clone(), + target_arch: tcx.sess.target.arch.to_string(), debuginfo: tcx.sess.opts.debuginfo, split_debuginfo: tcx.sess.split_debuginfo(), split_dwarf_kind: tcx.sess.opts.debugging_opts.split_dwarf_kind, -- cgit 1.4.1-3-g733a5 From ce61d4044d7621fd190a2ddd1f51fa78e2941518 Mon Sep 17 00:00:00 2001 From: Loïc BRANSTETT Date: Mon, 28 Mar 2022 01:08:17 +0200 Subject: Replace every Vec in Target(Options) with it's Cow equivalent --- compiler/rustc_codegen_ssa/src/back/link.rs | 4 +- compiler/rustc_serialize/src/json.rs | 9 +++++ compiler/rustc_session/src/config.rs | 2 +- .../rustc_target/src/spec/aarch64_apple_darwin.rs | 2 +- compiler/rustc_target/src/spec/apple_base.rs | 6 ++- compiler/rustc_target/src/spec/apple_sdk_base.rs | 8 ++-- .../rustc_target/src/spec/armv6k_nintendo_3ds.rs | 4 +- compiler/rustc_target/src/spec/dragonfly_base.rs | 4 +- compiler/rustc_target/src/spec/freebsd_base.rs | 4 +- compiler/rustc_target/src/spec/fuchsia_base.rs | 4 +- compiler/rustc_target/src/spec/haiku_base.rs | 4 +- .../rustc_target/src/spec/i686_apple_darwin.rs | 2 +- compiler/rustc_target/src/spec/illumos_base.rs | 4 +- compiler/rustc_target/src/spec/l4re_base.rs | 4 +- compiler/rustc_target/src/spec/linux_base.rs | 4 +- compiler/rustc_target/src/spec/mipsel_sony_psp.rs | 4 +- compiler/rustc_target/src/spec/mod.rs | 45 +++++++++++++++------- compiler/rustc_target/src/spec/msp430_none_elf.rs | 3 +- compiler/rustc_target/src/spec/netbsd_base.rs | 4 +- compiler/rustc_target/src/spec/openbsd_base.rs | 4 +- compiler/rustc_target/src/spec/redox_base.rs | 4 +- .../rustc_target/src/spec/riscv32imc_esp_espidf.rs | 4 +- compiler/rustc_target/src/spec/solaris_base.rs | 4 +- .../rustc_target/src/spec/thumbv4t_none_eabi.rs | 7 +--- compiler/rustc_target/src/spec/vxworks_base.rs | 4 +- .../src/spec/wasm32_unknown_emscripten.rs | 4 +- compiler/rustc_target/src/spec/wasm_base.rs | 4 +- compiler/rustc_target/src/spec/windows_gnu_base.rs | 4 +- .../rustc_target/src/spec/windows_msvc_base.rs | 4 +- .../rustc_target/src/spec/x86_64_apple_darwin.rs | 2 +- .../src/spec/x86_64_fortanix_unknown_sgx.rs | 4 +- 31 files changed, 117 insertions(+), 53 deletions(-) (limited to 'compiler/rustc_codegen_ssa/src') diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs index 8b31d24b071..07edb70634e 100644 --- a/compiler/rustc_codegen_ssa/src/back/link.rs +++ b/compiler/rustc_codegen_ssa/src/back/link.rs @@ -674,10 +674,10 @@ fn link_natively<'a, B: ArchiveBuilder<'a>>( linker::disable_localization(&mut cmd); - for &(ref k, ref v) in &sess.target.link_env { + for &(ref k, ref v) in sess.target.link_env.iter() { cmd.env(k.as_ref(), v.as_ref()); } - for k in &sess.target.link_env_remove { + for k in sess.target.link_env_remove.iter() { cmd.env_remove(k.as_ref()); } diff --git a/compiler/rustc_serialize/src/json.rs b/compiler/rustc_serialize/src/json.rs index 9847fde3c49..c915dd5bbf6 100644 --- a/compiler/rustc_serialize/src/json.rs +++ b/compiler/rustc_serialize/src/json.rs @@ -2247,6 +2247,15 @@ impl ToJson for Vec { } } +impl<'a, A: ToJson> ToJson for Cow<'a, [A]> +where + [A]: ToOwned, +{ + fn to_json(&self) -> Json { + Json::Array(self.iter().map(|elt| elt.to_json()).collect()) + } +} + impl ToJson for BTreeMap { fn to_json(&self) -> Json { let mut d = BTreeMap::new(); diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs index 856436e44db..408fd4ed2e6 100644 --- a/compiler/rustc_session/src/config.rs +++ b/compiler/rustc_session/src/config.rs @@ -956,7 +956,7 @@ fn default_configuration(sess: &Session) -> CrateConfig { ret.reserve(7); // the minimum number of insertions // Target bindings. ret.insert((sym::target_os, Some(Symbol::intern(os)))); - for fam in &sess.target.families { + for fam in sess.target.families.iter() { ret.insert((sym::target_family, Some(Symbol::intern(fam)))); if fam == "windows" { ret.insert((sym::windows, None)); diff --git a/compiler/rustc_target/src/spec/aarch64_apple_darwin.rs b/compiler/rustc_target/src/spec/aarch64_apple_darwin.rs index ef9e6bbea4d..86f76fdb6a7 100644 --- a/compiler/rustc_target/src/spec/aarch64_apple_darwin.rs +++ b/compiler/rustc_target/src/spec/aarch64_apple_darwin.rs @@ -9,7 +9,7 @@ pub fn target() -> Target { base.supported_sanitizers = SanitizerSet::ADDRESS | SanitizerSet::CFI | SanitizerSet::THREAD; base.pre_link_args.insert(LinkerFlavor::Gcc, vec!["-arch".into(), "arm64".into()]); - base.link_env_remove.extend(super::apple_base::macos_link_env_remove()); + base.link_env_remove.to_mut().extend(super::apple_base::macos_link_env_remove()); // Clang automatically chooses a more specific target based on // MACOSX_DEPLOYMENT_TARGET. To enable cross-language LTO to work diff --git a/compiler/rustc_target/src/spec/apple_base.rs b/compiler/rustc_target/src/spec/apple_base.rs index 748989b2a6f..f2cef7996ff 100644 --- a/compiler/rustc_target/src/spec/apple_base.rs +++ b/compiler/rustc_target/src/spec/apple_base.rs @@ -2,6 +2,8 @@ use std::{borrow::Cow, env}; use crate::spec::{FramePointer, LldFlavor, SplitDebuginfo, TargetOptions}; +use super::cvs; + pub fn opts(os: &'static str) -> TargetOptions { // ELF TLS is only available in macOS 10.7+. If you try to compile for 10.6 // either the linker will complain if it is used or the binary will end up @@ -26,7 +28,7 @@ pub fn opts(os: &'static str) -> TargetOptions { dynamic_linking: true, linker_is_gnu: false, executables: true, - families: vec!["unix".into()], + families: cvs!["unix"], is_like_osx: true, dwarf_version: Some(2), frame_pointer: FramePointer::Always, @@ -51,7 +53,7 @@ pub fn opts(os: &'static str) -> TargetOptions { // this environment variable too in recent versions. // // For some more info see the commentary on #47086 - link_env: vec![("ZERO_AR_DATE".into(), "1".into())], + link_env: Cow::Borrowed(&[(Cow::Borrowed("ZERO_AR_DATE"), Cow::Borrowed("1"))]), ..Default::default() } diff --git a/compiler/rustc_target/src/spec/apple_sdk_base.rs b/compiler/rustc_target/src/spec/apple_sdk_base.rs index 3ab9dbe07a3..e2d08955c08 100644 --- a/compiler/rustc_target/src/spec/apple_sdk_base.rs +++ b/compiler/rustc_target/src/spec/apple_sdk_base.rs @@ -1,4 +1,4 @@ -use crate::spec::TargetOptions; +use crate::{spec::cvs, spec::TargetOptions}; use std::borrow::Cow; use Arch::*; @@ -36,12 +36,12 @@ fn target_cpu(arch: Arch) -> &'static str { } } -fn link_env_remove(arch: Arch) -> Vec> { +fn link_env_remove(arch: Arch) -> Cow<'static, [Cow<'static, str>]> { match arch { Armv7 | Armv7s | Arm64 | I386 | X86_64 | Arm64_sim => { - vec!["MACOSX_DEPLOYMENT_TARGET".into()] + cvs!["MACOSX_DEPLOYMENT_TARGET"] } - X86_64_macabi | Arm64_macabi => vec!["IPHONEOS_DEPLOYMENT_TARGET".into()], + X86_64_macabi | Arm64_macabi => cvs!["IPHONEOS_DEPLOYMENT_TARGET"], } } diff --git a/compiler/rustc_target/src/spec/armv6k_nintendo_3ds.rs b/compiler/rustc_target/src/spec/armv6k_nintendo_3ds.rs index 93897dd4938..2e050b44156 100644 --- a/compiler/rustc_target/src/spec/armv6k_nintendo_3ds.rs +++ b/compiler/rustc_target/src/spec/armv6k_nintendo_3ds.rs @@ -1,5 +1,7 @@ use crate::spec::{LinkArgs, LinkerFlavor, RelocModel, Target, TargetOptions}; +use super::cvs; + /// A base target for Nintendo 3DS devices using the devkitARM toolchain. /// /// Requires the devkitARM toolchain for 3DS targets on the host system. @@ -30,7 +32,7 @@ pub fn target() -> Target { linker_flavor: LinkerFlavor::Gcc, cpu: "mpcore".into(), executables: true, - families: vec!["unix".into()], + families: cvs!["unix"], linker: Some("arm-none-eabi-gcc".into()), relocation_model: RelocModel::Static, features: "+vfp2".into(), diff --git a/compiler/rustc_target/src/spec/dragonfly_base.rs b/compiler/rustc_target/src/spec/dragonfly_base.rs index 03e4b953184..43072d63894 100644 --- a/compiler/rustc_target/src/spec/dragonfly_base.rs +++ b/compiler/rustc_target/src/spec/dragonfly_base.rs @@ -1,11 +1,13 @@ use crate::spec::{RelroLevel, TargetOptions}; +use super::cvs; + pub fn opts() -> TargetOptions { TargetOptions { os: "dragonfly".into(), dynamic_linking: true, executables: true, - families: vec!["unix".into()], + families: cvs!["unix"], has_rpath: true, position_independent_executables: true, relro_level: RelroLevel::Full, diff --git a/compiler/rustc_target/src/spec/freebsd_base.rs b/compiler/rustc_target/src/spec/freebsd_base.rs index 0153b4dd80f..05d60574f32 100644 --- a/compiler/rustc_target/src/spec/freebsd_base.rs +++ b/compiler/rustc_target/src/spec/freebsd_base.rs @@ -1,11 +1,13 @@ use crate::spec::{RelroLevel, TargetOptions}; +use super::cvs; + pub fn opts() -> TargetOptions { TargetOptions { os: "freebsd".into(), dynamic_linking: true, executables: true, - families: vec!["unix".into()], + families: cvs!["unix"], has_rpath: true, position_independent_executables: true, relro_level: RelroLevel::Full, diff --git a/compiler/rustc_target/src/spec/fuchsia_base.rs b/compiler/rustc_target/src/spec/fuchsia_base.rs index e802cdcf489..2ee7047d7e0 100644 --- a/compiler/rustc_target/src/spec/fuchsia_base.rs +++ b/compiler/rustc_target/src/spec/fuchsia_base.rs @@ -1,5 +1,7 @@ use crate::spec::{crt_objects, LinkArgs, LinkOutputKind, LinkerFlavor, LldFlavor, TargetOptions}; +use super::cvs; + pub fn opts() -> TargetOptions { let mut pre_link_args = LinkArgs::new(); pre_link_args.insert( @@ -25,7 +27,7 @@ pub fn opts() -> TargetOptions { linker: Some("rust-lld".into()), dynamic_linking: true, executables: true, - families: vec!["unix".into()], + families: cvs!["unix"], is_like_fuchsia: true, pre_link_args, pre_link_objects: crt_objects::new(&[ diff --git a/compiler/rustc_target/src/spec/haiku_base.rs b/compiler/rustc_target/src/spec/haiku_base.rs index 3585604a640..25549491f4b 100644 --- a/compiler/rustc_target/src/spec/haiku_base.rs +++ b/compiler/rustc_target/src/spec/haiku_base.rs @@ -1,11 +1,13 @@ use crate::spec::{RelroLevel, TargetOptions}; +use super::cvs; + pub fn opts() -> TargetOptions { TargetOptions { os: "haiku".into(), dynamic_linking: true, executables: true, - families: vec!["unix".into()], + families: cvs!["unix"], relro_level: RelroLevel::Full, ..Default::default() } diff --git a/compiler/rustc_target/src/spec/i686_apple_darwin.rs b/compiler/rustc_target/src/spec/i686_apple_darwin.rs index a083a83e377..ad716a6cd5a 100644 --- a/compiler/rustc_target/src/spec/i686_apple_darwin.rs +++ b/compiler/rustc_target/src/spec/i686_apple_darwin.rs @@ -5,7 +5,7 @@ pub fn target() -> Target { base.cpu = "yonah".into(); base.max_atomic_width = Some(64); base.pre_link_args.insert(LinkerFlavor::Gcc, vec!["-m32".into()]); - base.link_env_remove.extend(super::apple_base::macos_link_env_remove()); + base.link_env_remove.to_mut().extend(super::apple_base::macos_link_env_remove()); // don't use probe-stack=inline-asm until rust#83139 and rust#84667 are resolved base.stack_probes = StackProbeType::Call; base.frame_pointer = FramePointer::Always; diff --git a/compiler/rustc_target/src/spec/illumos_base.rs b/compiler/rustc_target/src/spec/illumos_base.rs index 68917171105..1f6202dd7f5 100644 --- a/compiler/rustc_target/src/spec/illumos_base.rs +++ b/compiler/rustc_target/src/spec/illumos_base.rs @@ -1,6 +1,8 @@ use crate::spec::{FramePointer, LinkArgs, LinkerFlavor, TargetOptions}; use std::default::Default; +use super::cvs; + pub fn opts() -> TargetOptions { let mut late_link_args = LinkArgs::new(); late_link_args.insert( @@ -31,7 +33,7 @@ pub fn opts() -> TargetOptions { dynamic_linking: true, executables: true, has_rpath: true, - families: vec!["unix".into()], + families: cvs!["unix"], is_like_solaris: true, linker_is_gnu: false, limit_rdylib_exports: false, // Linker doesn't support this diff --git a/compiler/rustc_target/src/spec/l4re_base.rs b/compiler/rustc_target/src/spec/l4re_base.rs index dbc851cc1e1..e185de78bca 100644 --- a/compiler/rustc_target/src/spec/l4re_base.rs +++ b/compiler/rustc_target/src/spec/l4re_base.rs @@ -1,6 +1,8 @@ use crate::spec::{LinkerFlavor, PanicStrategy, TargetOptions}; use std::default::Default; +use super::cvs; + pub fn opts() -> TargetOptions { TargetOptions { os: "l4re".into(), @@ -10,7 +12,7 @@ pub fn opts() -> TargetOptions { panic_strategy: PanicStrategy::Abort, linker: Some("l4-bender".into()), linker_is_gnu: false, - families: vec!["unix".into()], + families: cvs!["unix"], ..Default::default() } } diff --git a/compiler/rustc_target/src/spec/linux_base.rs b/compiler/rustc_target/src/spec/linux_base.rs index 135ca547d1d..84d8e19159a 100644 --- a/compiler/rustc_target/src/spec/linux_base.rs +++ b/compiler/rustc_target/src/spec/linux_base.rs @@ -1,11 +1,13 @@ use crate::spec::{RelroLevel, TargetOptions}; +use super::cvs; + pub fn opts() -> TargetOptions { TargetOptions { os: "linux".into(), dynamic_linking: true, executables: true, - families: vec!["unix".into()], + families: cvs!["unix"], has_rpath: true, position_independent_executables: true, relro_level: RelroLevel::Full, diff --git a/compiler/rustc_target/src/spec/mipsel_sony_psp.rs b/compiler/rustc_target/src/spec/mipsel_sony_psp.rs index 6857f7fd17d..dc8169b7118 100644 --- a/compiler/rustc_target/src/spec/mipsel_sony_psp.rs +++ b/compiler/rustc_target/src/spec/mipsel_sony_psp.rs @@ -1,6 +1,8 @@ use crate::spec::{LinkArgs, LinkerFlavor, LldFlavor, RelocModel}; use crate::spec::{Target, TargetOptions}; +use super::cvs; + // The PSP has custom linker requirements. const LINKER_SCRIPT: &str = include_str!("./mipsel_sony_psp_linker_script.ld"); @@ -27,7 +29,7 @@ pub fn target() -> Target { features: "+single-float".into(), // PSP does not support trap-on-condition instructions. - llvm_args: vec!["-mno-check-zero-division".into()], + llvm_args: cvs!["-mno-check-zero-division"], pre_link_args, link_script: Some(LINKER_SCRIPT.into()), ..Default::default() diff --git a/compiler/rustc_target/src/spec/mod.rs b/compiler/rustc_target/src/spec/mod.rs index 0c5bddad72a..6d23ddc0985 100644 --- a/compiler/rustc_target/src/spec/mod.rs +++ b/compiler/rustc_target/src/spec/mod.rs @@ -1027,6 +1027,25 @@ supported_targets! { ("mips64-openwrt-linux-musl", mips64_openwrt_linux_musl), } +/// Cow-Vec-Str: Cow<'static, [Cow<'static, str>]> +// FIXME(Urgau): Figure out why the obvious form `["".into()].into()` doesn't work. +macro_rules! cvs { + () => { + ::std::borrow::Cow::Borrowed(&[]) + }; + ($($x:expr),+ $(,)?) => { + { + ::std::borrow::Cow::Borrowed(&[ + $( + ::std::borrow::Cow::Borrowed($x), + )* + ]) + } + }; +} + +pub(crate) use cvs; + /// Warnings encountered when parsing the target `json`. /// /// Includes fields that weren't recognized and fields that don't have the expected type. @@ -1160,12 +1179,12 @@ pub struct TargetOptions { pub link_script: Option>, /// Environment variables to be set for the linker invocation. - pub link_env: Vec<(Cow<'static, str>, Cow<'static, str>)>, + pub link_env: Cow<'static, [(Cow<'static, str>, Cow<'static, str>)]>, /// Environment variables to be removed for the linker invocation. - pub link_env_remove: Vec>, + pub link_env_remove: Cow<'static, [Cow<'static, str>]>, /// Extra arguments to pass to the external assembler (when used) - pub asm_args: Vec>, + pub asm_args: Cow<'static, [Cow<'static, str>]>, /// Default CPU to pass to LLVM. Corresponds to `llc -mcpu=$cpu`. Defaults /// to "generic". @@ -1211,7 +1230,7 @@ pub struct TargetOptions { /// Common options are: "unix", "windows". Defaults to no families. /// /// See . - pub families: Vec>, + pub families: Cow<'static, [Cow<'static, str>]>, /// Whether the target toolchain's ABI supports returning small structs as an integer. pub abi_return_struct_as_int: bool, /// Whether the target toolchain is like macOS's. Only useful for compiling against iOS/macOS, @@ -1371,7 +1390,7 @@ pub struct TargetOptions { /// If set, have the linker export exactly these symbols, instead of using /// the usual logic to figure this out from the crate itself. - pub override_export_symbols: Option>>, + pub override_export_symbols: Option]>>, /// Determines how or whether the MergeFunctions LLVM pass should run for /// this target. Either "disabled", "trampolines", or "aliases". @@ -1391,7 +1410,7 @@ pub struct TargetOptions { pub relax_elf_relocations: bool, /// Additional arguments to pass to LLVM, similar to the `-C llvm-args` codegen option. - pub llvm_args: Vec>, + pub llvm_args: Cow<'static, [Cow<'static, str>]>, /// Whether to use legacy .ctors initialization hooks rather than .init_array. Defaults /// to false (uses .init_array). @@ -1449,7 +1468,7 @@ impl Default for TargetOptions { pre_link_args: LinkArgs::new(), post_link_args: LinkArgs::new(), link_script: None, - asm_args: Vec::new(), + asm_args: Cow::Borrowed(&[]), cpu: "generic".into(), features: Cow::from(""), dynamic_linking: false, @@ -1466,7 +1485,7 @@ impl Default for TargetOptions { exe_suffix: Cow::from(""), staticlib_prefix: "lib".into(), staticlib_suffix: ".a".into(), - families: Vec::new(), + families: cvs![], abi_return_struct_as_int: false, is_like_osx: false, is_like_solaris: false, @@ -1492,8 +1511,8 @@ impl Default for TargetOptions { late_link_args: LinkArgs::new(), late_link_args_dynamic: LinkArgs::new(), late_link_args_static: LinkArgs::new(), - link_env: Vec::new(), - link_env_remove: Vec::new(), + link_env: Cow::Borrowed(&[]), + link_env_remove: Cow::Borrowed(&[]), archive_format: "gnu".into(), main_needs_argc_argv: true, allow_asm: true, @@ -1526,7 +1545,7 @@ impl Default for TargetOptions { mcount: "mcount".into(), llvm_abiname: "".into(), relax_elf_relocations: false, - llvm_args: vec![], + llvm_args: cvs![], use_ctors_section: false, eh_frame_header: true, has_thumb_interworking: false, @@ -1978,7 +1997,7 @@ impl Target { if p.len() == 2 { let k = p[0].to_string(); let v = p[1].to_string(); - base.$key_name.push((k.into(), v.into())); + base.$key_name.to_mut().push((k.into(), v.into())); } } } @@ -2004,7 +2023,7 @@ impl Target { .map(|a| a.as_string().unwrap().to_string().into()) .collect(); } else if let Some(v) = Json::as_string(&value) { - base.$key_name = vec![v.to_string().into()]; + base.$key_name = vec![v.to_string().into()].into(); } } } ); diff --git a/compiler/rustc_target/src/spec/msp430_none_elf.rs b/compiler/rustc_target/src/spec/msp430_none_elf.rs index 2dd23b7d3c3..f22c8672639 100644 --- a/compiler/rustc_target/src/spec/msp430_none_elf.rs +++ b/compiler/rustc_target/src/spec/msp430_none_elf.rs @@ -1,3 +1,4 @@ +use super::cvs; use crate::spec::{PanicStrategy, RelocModel, Target, TargetOptions}; pub fn target() -> Target { @@ -15,7 +16,7 @@ pub fn target() -> Target { // workaround this LLVM generates assembly files which then we feed // to gcc to get object files. For this reason we have a hard // dependency on this specific gcc. - asm_args: vec!["-mcpu=msp430".into()], + asm_args: cvs!["-mcpu=msp430"], linker: Some("msp430-elf-gcc".into()), linker_is_gnu: false, diff --git a/compiler/rustc_target/src/spec/netbsd_base.rs b/compiler/rustc_target/src/spec/netbsd_base.rs index c20eb163dda..a5fb58f5e7b 100644 --- a/compiler/rustc_target/src/spec/netbsd_base.rs +++ b/compiler/rustc_target/src/spec/netbsd_base.rs @@ -1,11 +1,13 @@ use crate::spec::{RelroLevel, TargetOptions}; +use super::cvs; + pub fn opts() -> TargetOptions { TargetOptions { os: "netbsd".into(), dynamic_linking: true, executables: true, - families: vec!["unix".into()], + families: cvs!["unix"], no_default_libraries: false, has_rpath: true, position_independent_executables: true, diff --git a/compiler/rustc_target/src/spec/openbsd_base.rs b/compiler/rustc_target/src/spec/openbsd_base.rs index a913be93861..7745d10e13e 100644 --- a/compiler/rustc_target/src/spec/openbsd_base.rs +++ b/compiler/rustc_target/src/spec/openbsd_base.rs @@ -1,11 +1,13 @@ use crate::spec::{FramePointer, RelroLevel, TargetOptions}; +use super::cvs; + pub fn opts() -> TargetOptions { TargetOptions { os: "openbsd".into(), dynamic_linking: true, executables: true, - families: vec!["unix".into()], + families: cvs!["unix"], has_rpath: true, abi_return_struct_as_int: true, position_independent_executables: true, diff --git a/compiler/rustc_target/src/spec/redox_base.rs b/compiler/rustc_target/src/spec/redox_base.rs index 51774059c10..667aa8e9c94 100644 --- a/compiler/rustc_target/src/spec/redox_base.rs +++ b/compiler/rustc_target/src/spec/redox_base.rs @@ -1,12 +1,14 @@ use crate::spec::{RelroLevel, TargetOptions}; +use super::cvs; + pub fn opts() -> TargetOptions { TargetOptions { os: "redox".into(), env: "relibc".into(), dynamic_linking: true, executables: true, - families: vec!["unix".into()], + families: cvs!["unix"], has_rpath: true, position_independent_executables: true, relro_level: RelroLevel::Full, diff --git a/compiler/rustc_target/src/spec/riscv32imc_esp_espidf.rs b/compiler/rustc_target/src/spec/riscv32imc_esp_espidf.rs index d9f40d51069..4c7401380fd 100644 --- a/compiler/rustc_target/src/spec/riscv32imc_esp_espidf.rs +++ b/compiler/rustc_target/src/spec/riscv32imc_esp_espidf.rs @@ -1,6 +1,8 @@ use crate::spec::{LinkerFlavor, PanicStrategy, RelocModel}; use crate::spec::{Target, TargetOptions}; +use super::cvs; + pub fn target() -> Target { Target { data_layout: "e-m:e-p:32:32-i64:64-n32-S128".into(), @@ -9,7 +11,7 @@ pub fn target() -> Target { arch: "riscv32".into(), options: TargetOptions { - families: vec!["unix".into()], + families: cvs!["unix"], os: "espidf".into(), env: "newlib".into(), vendor: "espressif".into(), diff --git a/compiler/rustc_target/src/spec/solaris_base.rs b/compiler/rustc_target/src/spec/solaris_base.rs index 2f47abd9c7a..8d8ad049b33 100644 --- a/compiler/rustc_target/src/spec/solaris_base.rs +++ b/compiler/rustc_target/src/spec/solaris_base.rs @@ -1,12 +1,14 @@ use crate::spec::TargetOptions; +use super::cvs; + pub fn opts() -> TargetOptions { TargetOptions { os: "solaris".into(), dynamic_linking: true, executables: true, has_rpath: true, - families: vec!["unix".into()], + families: cvs!["unix"], is_like_solaris: true, linker_is_gnu: false, limit_rdylib_exports: false, // Linker doesn't support this diff --git a/compiler/rustc_target/src/spec/thumbv4t_none_eabi.rs b/compiler/rustc_target/src/spec/thumbv4t_none_eabi.rs index d05cb6582ba..457b78850ac 100644 --- a/compiler/rustc_target/src/spec/thumbv4t_none_eabi.rs +++ b/compiler/rustc_target/src/spec/thumbv4t_none_eabi.rs @@ -8,6 +8,7 @@ //! //! **Important:** This target profile **does not** specify a linker script. You just get the default link script when you build a binary for this target. The default link script is very likely wrong, so you should use `-Clink-arg=-Tmy_script.ld` to override that with a correct linker script. +use super::cvs; use crate::spec::{LinkerFlavor, Target, TargetOptions}; pub fn target() -> Target { @@ -34,11 +35,7 @@ pub fn target() -> Target { // * activate t32/a32 interworking // * use arch ARMv4T // * use little-endian - asm_args: vec![ - "-mthumb-interwork".into(), - "-march=armv4t".into(), - "-mlittle-endian".into(), - ], + asm_args: cvs!["-mthumb-interwork", "-march=armv4t", "-mlittle-endian",], // minimum extra features, these cannot be disabled via -C features: "+soft-float,+strict-align".into(), diff --git a/compiler/rustc_target/src/spec/vxworks_base.rs b/compiler/rustc_target/src/spec/vxworks_base.rs index 9808d60d891..f43cea131b7 100644 --- a/compiler/rustc_target/src/spec/vxworks_base.rs +++ b/compiler/rustc_target/src/spec/vxworks_base.rs @@ -1,5 +1,7 @@ use crate::spec::TargetOptions; +use super::cvs; + pub fn opts() -> TargetOptions { TargetOptions { os: "vxworks".into(), @@ -9,7 +11,7 @@ pub fn opts() -> TargetOptions { exe_suffix: ".vxe".into(), dynamic_linking: true, executables: true, - families: vec!["unix".into()], + families: cvs!["unix"], has_rpath: true, has_thread_local: true, crt_static_default: true, diff --git a/compiler/rustc_target/src/spec/wasm32_unknown_emscripten.rs b/compiler/rustc_target/src/spec/wasm32_unknown_emscripten.rs index 89f4e6d3588..b34cac41d78 100644 --- a/compiler/rustc_target/src/spec/wasm32_unknown_emscripten.rs +++ b/compiler/rustc_target/src/spec/wasm32_unknown_emscripten.rs @@ -1,4 +1,4 @@ -use super::wasm_base; +use super::{cvs, wasm_base}; use super::{LinkArgs, LinkerFlavor, PanicStrategy, Target, TargetOptions}; pub fn target() -> Target { @@ -37,7 +37,7 @@ pub fn target() -> Target { is_like_emscripten: true, panic_strategy: PanicStrategy::Unwind, post_link_args, - families: vec!["unix".into(), "wasm".into()], + families: cvs!["unix", "wasm"], ..options }; Target { diff --git a/compiler/rustc_target/src/spec/wasm_base.rs b/compiler/rustc_target/src/spec/wasm_base.rs index e02fb1f946f..d884dcf68bf 100644 --- a/compiler/rustc_target/src/spec/wasm_base.rs +++ b/compiler/rustc_target/src/spec/wasm_base.rs @@ -1,5 +1,5 @@ use super::crt_objects::CrtObjectsFallback; -use super::{LinkerFlavor, LldFlavor, PanicStrategy, RelocModel, TargetOptions, TlsModel}; +use super::{cvs, LinkerFlavor, LldFlavor, PanicStrategy, RelocModel, TargetOptions, TlsModel}; use std::collections::BTreeMap; pub fn options() -> TargetOptions { @@ -61,7 +61,7 @@ pub fn options() -> TargetOptions { TargetOptions { is_like_wasm: true, - families: vec!["wasm".into()], + families: cvs!["wasm"], // we allow dynamic linking, but only cdylibs. Basically we allow a // final library artifact that exports some symbols (a wasm module) but diff --git a/compiler/rustc_target/src/spec/windows_gnu_base.rs b/compiler/rustc_target/src/spec/windows_gnu_base.rs index d21d86caa73..1e5ced684bd 100644 --- a/compiler/rustc_target/src/spec/windows_gnu_base.rs +++ b/compiler/rustc_target/src/spec/windows_gnu_base.rs @@ -1,6 +1,8 @@ use crate::spec::crt_objects::{self, CrtObjectsFallback}; use crate::spec::{LinkArgs, LinkerFlavor, LldFlavor, TargetOptions}; +use super::cvs; + pub fn opts() -> TargetOptions { let mut pre_link_args = LinkArgs::new(); pre_link_args.insert( @@ -71,7 +73,7 @@ pub fn opts() -> TargetOptions { dll_prefix: "".into(), dll_suffix: ".dll".into(), exe_suffix: ".exe".into(), - families: vec!["windows".into()], + families: cvs!["windows"], is_like_windows: true, allows_weak_linkage: false, pre_link_args, diff --git a/compiler/rustc_target/src/spec/windows_msvc_base.rs b/compiler/rustc_target/src/spec/windows_msvc_base.rs index a3bcaeeeb7a..bfe8edecac4 100644 --- a/compiler/rustc_target/src/spec/windows_msvc_base.rs +++ b/compiler/rustc_target/src/spec/windows_msvc_base.rs @@ -1,5 +1,7 @@ use crate::spec::TargetOptions; +use super::cvs; + pub fn opts() -> TargetOptions { let base = super::msvc_base::opts(); @@ -13,7 +15,7 @@ pub fn opts() -> TargetOptions { exe_suffix: ".exe".into(), staticlib_prefix: "".into(), staticlib_suffix: ".lib".into(), - families: vec!["windows".into()], + families: cvs!["windows"], crt_static_allows_dylibs: true, crt_static_respected: true, requires_uwtable: true, diff --git a/compiler/rustc_target/src/spec/x86_64_apple_darwin.rs b/compiler/rustc_target/src/spec/x86_64_apple_darwin.rs index b7b976e8d5d..51d14f0403a 100644 --- a/compiler/rustc_target/src/spec/x86_64_apple_darwin.rs +++ b/compiler/rustc_target/src/spec/x86_64_apple_darwin.rs @@ -8,7 +8,7 @@ pub fn target() -> Target { base.frame_pointer = FramePointer::Always; base.pre_link_args .insert(LinkerFlavor::Gcc, vec!["-m64".into(), "-arch".into(), "x86_64".into()]); - base.link_env_remove.extend(super::apple_base::macos_link_env_remove()); + base.link_env_remove.to_mut().extend(super::apple_base::macos_link_env_remove()); // don't use probe-stack=inline-asm until rust#83139 and rust#84667 are resolved base.stack_probes = StackProbeType::Call; base.supported_sanitizers = diff --git a/compiler/rustc_target/src/spec/x86_64_fortanix_unknown_sgx.rs b/compiler/rustc_target/src/spec/x86_64_fortanix_unknown_sgx.rs index d78d057dea0..33b5917b401 100644 --- a/compiler/rustc_target/src/spec/x86_64_fortanix_unknown_sgx.rs +++ b/compiler/rustc_target/src/spec/x86_64_fortanix_unknown_sgx.rs @@ -1,5 +1,7 @@ use std::{borrow::Cow, iter}; +use crate::spec::cvs; + use super::{LinkerFlavor, LldFlavor, Target, TargetOptions}; pub fn target() -> Target { @@ -62,7 +64,7 @@ pub fn target() -> Target { max_atomic_width: Some(64), cpu: "x86-64".into(), features: "+rdrnd,+rdseed,+lvi-cfi,+lvi-load-hardening".into(), - llvm_args: vec!["--x86-experimental-lvi-inline-asm-hardening".into()], + llvm_args: cvs!["--x86-experimental-lvi-inline-asm-hardening"], position_independent_executables: true, pre_link_args: iter::once(( LinkerFlavor::Lld(LldFlavor::Ld), -- cgit 1.4.1-3-g733a5 From c16a558f245cdf363ede29bed0d682434885f826 Mon Sep 17 00:00:00 2001 From: Loïc BRANSTETT Date: Mon, 28 Mar 2022 15:06:46 +0200 Subject: Replace LinkArgs with Cow<'static, str> --- compiler/rustc_codegen_ssa/src/back/link.rs | 11 ++++++----- compiler/rustc_target/src/spec/avr_gnu_base.rs | 2 +- compiler/rustc_target/src/spec/mod.rs | 4 ++-- compiler/rustc_target/src/spec/wasm_base.rs | 4 ++-- compiler/rustc_target/src/spec/x86_64_fortanix_unknown_sgx.rs | 2 +- 5 files changed, 12 insertions(+), 11 deletions(-) (limited to 'compiler/rustc_codegen_ssa/src') diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs index 07edb70634e..40fe3c86e43 100644 --- a/compiler/rustc_codegen_ssa/src/back/link.rs +++ b/compiler/rustc_codegen_ssa/src/back/link.rs @@ -40,6 +40,7 @@ use std::ffi::OsString; use std::fs::{File, OpenOptions}; use std::io::{BufWriter, Write}; use std::lazy::OnceCell; +use std::ops::Deref; use std::path::{Path, PathBuf}; use std::process::{ExitStatus, Output, Stdio}; use std::{ascii, char, env, fmt, fs, io, mem, str}; @@ -1586,7 +1587,7 @@ fn add_post_link_objects( /// FIXME: Determine where exactly these args need to be inserted. fn add_pre_link_args(cmd: &mut dyn Linker, sess: &Session, flavor: LinkerFlavor) { if let Some(args) = sess.target.pre_link_args.get(&flavor) { - cmd.args(args); + cmd.args(args.iter().map(Deref::deref)); } cmd.args(&sess.opts.debugging_opts.pre_link_args); } @@ -1634,15 +1635,15 @@ fn add_late_link_args( }); if any_dynamic_crate { if let Some(args) = sess.target.late_link_args_dynamic.get(&flavor) { - cmd.args(args); + cmd.args(args.iter().map(Deref::deref)); } } else { if let Some(args) = sess.target.late_link_args_static.get(&flavor) { - cmd.args(args); + cmd.args(args.iter().map(Deref::deref)); } } if let Some(args) = sess.target.late_link_args.get(&flavor) { - cmd.args(args); + cmd.args(args.iter().map(Deref::deref)); } } @@ -1650,7 +1651,7 @@ fn add_late_link_args( /// FIXME: Determine where exactly these args need to be inserted. fn add_post_link_args(cmd: &mut dyn Linker, sess: &Session, flavor: LinkerFlavor) { if let Some(args) = sess.target.post_link_args.get(&flavor) { - cmd.args(args); + cmd.args(args.iter().map(Deref::deref)); } } diff --git a/compiler/rustc_target/src/spec/avr_gnu_base.rs b/compiler/rustc_target/src/spec/avr_gnu_base.rs index 9d4ec2edc51..c288e8b0e9e 100644 --- a/compiler/rustc_target/src/spec/avr_gnu_base.rs +++ b/compiler/rustc_target/src/spec/avr_gnu_base.rs @@ -17,7 +17,7 @@ pub fn target(target_cpu: &'static str) -> Target { linker: Some("avr-gcc".into()), executables: true, eh_frame_header: false, - pre_link_args: [(LinkerFlavor::Gcc, vec![format!("-mmcu={}", target_cpu)])] + pre_link_args: [(LinkerFlavor::Gcc, vec![format!("-mmcu={}", target_cpu).into()])] .into_iter() .collect(), late_link_args: [(LinkerFlavor::Gcc, vec!["-lgcc".into()])].into_iter().collect(), diff --git a/compiler/rustc_target/src/spec/mod.rs b/compiler/rustc_target/src/spec/mod.rs index 6d23ddc0985..96623e1c163 100644 --- a/compiler/rustc_target/src/spec/mod.rs +++ b/compiler/rustc_target/src/spec/mod.rs @@ -459,7 +459,7 @@ impl fmt::Display for LinkOutputKind { } } -pub type LinkArgs = BTreeMap>; +pub type LinkArgs = BTreeMap>>; #[derive(Clone, Copy, Hash, Debug, PartialEq, Eq)] pub enum SplitDebuginfo { @@ -1978,7 +1978,7 @@ impl Target { .map(|(i,s)| { let s = s.as_string().ok_or_else(|| format!("{}.{}[{}]: expected a JSON string", name, k, i))?; - Ok(s.into()) + Ok(s.to_string().into()) }) .collect::, String>>()?; diff --git a/compiler/rustc_target/src/spec/wasm_base.rs b/compiler/rustc_target/src/spec/wasm_base.rs index d884dcf68bf..de7b7374af3 100644 --- a/compiler/rustc_target/src/spec/wasm_base.rs +++ b/compiler/rustc_target/src/spec/wasm_base.rs @@ -5,9 +5,9 @@ use std::collections::BTreeMap; pub fn options() -> TargetOptions { let mut lld_args = Vec::new(); let mut clang_args = Vec::new(); - let mut arg = |arg: &str| { + let mut arg = |arg: &'static str| { lld_args.push(arg.into()); - clang_args.push(format!("-Wl,{}", arg)); + clang_args.push(format!("-Wl,{}", arg).into()); }; // By default LLD only gives us one page of stack (64k) which is a diff --git a/compiler/rustc_target/src/spec/x86_64_fortanix_unknown_sgx.rs b/compiler/rustc_target/src/spec/x86_64_fortanix_unknown_sgx.rs index 33b5917b401..47c70513faf 100644 --- a/compiler/rustc_target/src/spec/x86_64_fortanix_unknown_sgx.rs +++ b/compiler/rustc_target/src/spec/x86_64_fortanix_unknown_sgx.rs @@ -68,7 +68,7 @@ pub fn target() -> Target { position_independent_executables: true, pre_link_args: iter::once(( LinkerFlavor::Lld(LldFlavor::Ld), - PRE_LINK_ARGS.iter().cloned().map(String::from).collect(), + PRE_LINK_ARGS.iter().cloned().map(Cow::from).collect(), )) .collect(), override_export_symbols: Some(EXPORT_SYMBOLS.iter().cloned().map(Cow::from).collect()), -- cgit 1.4.1-3-g733a5 From 1a1f5b89a4acf44fc4720c097b4bbcebcfa26818 Mon Sep 17 00:00:00 2001 From: Loïc BRANSTETT Date: Sun, 3 Apr 2022 18:42:39 +0200 Subject: Cleanup after some refactoring in rustc_target --- compiler/rustc_codegen_cranelift/src/driver/aot.rs | 8 +- compiler/rustc_codegen_gcc/src/lib.rs | 6 +- compiler/rustc_codegen_ssa/src/back/link.rs | 6 +- compiler/rustc_session/src/config.rs | 2 +- compiler/rustc_target/src/spec/apple_base.rs | 4 +- .../rustc_target/src/spec/armv6k_nintendo_3ds.rs | 4 +- compiler/rustc_target/src/spec/dragonfly_base.rs | 4 +- compiler/rustc_target/src/spec/freebsd_base.rs | 4 +- compiler/rustc_target/src/spec/fuchsia_base.rs | 6 +- compiler/rustc_target/src/spec/haiku_base.rs | 4 +- compiler/rustc_target/src/spec/illumos_base.rs | 5 +- compiler/rustc_target/src/spec/l4re_base.rs | 5 +- compiler/rustc_target/src/spec/linux_base.rs | 4 +- compiler/rustc_target/src/spec/mipsel_sony_psp.rs | 4 +- compiler/rustc_target/src/spec/mod.rs | 87 +++++++++++----------- compiler/rustc_target/src/spec/msp430_none_elf.rs | 3 +- compiler/rustc_target/src/spec/netbsd_base.rs | 4 +- compiler/rustc_target/src/spec/openbsd_base.rs | 4 +- compiler/rustc_target/src/spec/redox_base.rs | 4 +- .../rustc_target/src/spec/riscv32imc_esp_espidf.rs | 4 +- compiler/rustc_target/src/spec/solaris_base.rs | 4 +- .../rustc_target/src/spec/thumbv4t_none_eabi.rs | 3 +- compiler/rustc_target/src/spec/vxworks_base.rs | 4 +- compiler/rustc_target/src/spec/windows_gnu_base.rs | 4 +- .../rustc_target/src/spec/windows_msvc_base.rs | 4 +- 25 files changed, 79 insertions(+), 112 deletions(-) (limited to 'compiler/rustc_codegen_ssa/src') diff --git a/compiler/rustc_codegen_cranelift/src/driver/aot.rs b/compiler/rustc_codegen_cranelift/src/driver/aot.rs index 2e047c7eea1..5e1e1c81d26 100644 --- a/compiler/rustc_codegen_cranelift/src/driver/aot.rs +++ b/compiler/rustc_codegen_cranelift/src/driver/aot.rs @@ -304,8 +304,12 @@ pub(crate) fn run_aot( }; // FIXME handle `-Ctarget-cpu=native` - let target_cpu = - tcx.sess.opts.cg.target_cpu.as_ref().unwrap_or(&tcx.sess.target.cpu).to_owned(); + let target_cpu = match tcx.sess.opts.cg.target_cpu { + Some(ref name) => name, + None => tcx.sess.target.cpu.as_ref(), + } + .to_owned(); + Box::new(( CodegenResults { modules, diff --git a/compiler/rustc_codegen_gcc/src/lib.rs b/compiler/rustc_codegen_gcc/src/lib.rs index eac4a06226c..497a28354d8 100644 --- a/compiler/rustc_codegen_gcc/src/lib.rs +++ b/compiler/rustc_codegen_gcc/src/lib.rs @@ -287,8 +287,10 @@ fn handle_native(name: &str) -> &str { } pub fn target_cpu(sess: &Session) -> &str { - let name = sess.opts.cg.target_cpu.as_ref().unwrap_or(&sess.target.cpu); - handle_native(name) + match sess.opts.cg.target_cpu { + Some(ref name) => handle_native(name), + None => handle_native(sess.target.cpu.as_ref()), + } } pub fn target_features(sess: &Session) -> Vec { diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs index 40fe3c86e43..84a1043a6a0 100644 --- a/compiler/rustc_codegen_ssa/src/back/link.rs +++ b/compiler/rustc_codegen_ssa/src/back/link.rs @@ -675,10 +675,10 @@ fn link_natively<'a, B: ArchiveBuilder<'a>>( linker::disable_localization(&mut cmd); - for &(ref k, ref v) in sess.target.link_env.iter() { + for &(ref k, ref v) in sess.target.link_env.as_ref() { cmd.env(k.as_ref(), v.as_ref()); } - for k in sess.target.link_env_remove.iter() { + for k in sess.target.link_env_remove.as_ref() { cmd.env_remove(k.as_ref()); } @@ -1217,7 +1217,7 @@ pub fn linker_and_flavor(sess: &Session) -> (PathBuf, LinkerFlavor) { if let Some(ret) = infer_from( sess, - sess.target.linker.as_ref().map(|l| PathBuf::from(l.as_ref())), + sess.target.linker.as_deref().map(PathBuf::from), Some(sess.target.linker_flavor), ) { return ret; diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs index 408fd4ed2e6..4182a5d0711 100644 --- a/compiler/rustc_session/src/config.rs +++ b/compiler/rustc_session/src/config.rs @@ -956,7 +956,7 @@ fn default_configuration(sess: &Session) -> CrateConfig { ret.reserve(7); // the minimum number of insertions // Target bindings. ret.insert((sym::target_os, Some(Symbol::intern(os)))); - for fam in sess.target.families.iter() { + for fam in sess.target.families.as_ref() { ret.insert((sym::target_family, Some(Symbol::intern(fam)))); if fam == "windows" { ret.insert((sym::windows, None)); diff --git a/compiler/rustc_target/src/spec/apple_base.rs b/compiler/rustc_target/src/spec/apple_base.rs index f2cef7996ff..238d3f8bda5 100644 --- a/compiler/rustc_target/src/spec/apple_base.rs +++ b/compiler/rustc_target/src/spec/apple_base.rs @@ -1,8 +1,6 @@ use std::{borrow::Cow, env}; -use crate::spec::{FramePointer, LldFlavor, SplitDebuginfo, TargetOptions}; - -use super::cvs; +use crate::spec::{cvs, FramePointer, LldFlavor, SplitDebuginfo, TargetOptions}; pub fn opts(os: &'static str) -> TargetOptions { // ELF TLS is only available in macOS 10.7+. If you try to compile for 10.6 diff --git a/compiler/rustc_target/src/spec/armv6k_nintendo_3ds.rs b/compiler/rustc_target/src/spec/armv6k_nintendo_3ds.rs index 2e050b44156..ffcd1a3f4df 100644 --- a/compiler/rustc_target/src/spec/armv6k_nintendo_3ds.rs +++ b/compiler/rustc_target/src/spec/armv6k_nintendo_3ds.rs @@ -1,6 +1,4 @@ -use crate::spec::{LinkArgs, LinkerFlavor, RelocModel, Target, TargetOptions}; - -use super::cvs; +use crate::spec::{cvs, LinkArgs, LinkerFlavor, RelocModel, Target, TargetOptions}; /// A base target for Nintendo 3DS devices using the devkitARM toolchain. /// diff --git a/compiler/rustc_target/src/spec/dragonfly_base.rs b/compiler/rustc_target/src/spec/dragonfly_base.rs index 43072d63894..b59322d07f5 100644 --- a/compiler/rustc_target/src/spec/dragonfly_base.rs +++ b/compiler/rustc_target/src/spec/dragonfly_base.rs @@ -1,6 +1,4 @@ -use crate::spec::{RelroLevel, TargetOptions}; - -use super::cvs; +use crate::spec::{cvs, RelroLevel, TargetOptions}; pub fn opts() -> TargetOptions { TargetOptions { diff --git a/compiler/rustc_target/src/spec/freebsd_base.rs b/compiler/rustc_target/src/spec/freebsd_base.rs index 05d60574f32..a7e0f9f7041 100644 --- a/compiler/rustc_target/src/spec/freebsd_base.rs +++ b/compiler/rustc_target/src/spec/freebsd_base.rs @@ -1,6 +1,4 @@ -use crate::spec::{RelroLevel, TargetOptions}; - -use super::cvs; +use crate::spec::{cvs, RelroLevel, TargetOptions}; pub fn opts() -> TargetOptions { TargetOptions { diff --git a/compiler/rustc_target/src/spec/fuchsia_base.rs b/compiler/rustc_target/src/spec/fuchsia_base.rs index 2ee7047d7e0..04e30ff0c3e 100644 --- a/compiler/rustc_target/src/spec/fuchsia_base.rs +++ b/compiler/rustc_target/src/spec/fuchsia_base.rs @@ -1,6 +1,6 @@ -use crate::spec::{crt_objects, LinkArgs, LinkOutputKind, LinkerFlavor, LldFlavor, TargetOptions}; - -use super::cvs; +use crate::spec::{ + crt_objects, cvs, LinkArgs, LinkOutputKind, LinkerFlavor, LldFlavor, TargetOptions, +}; pub fn opts() -> TargetOptions { let mut pre_link_args = LinkArgs::new(); diff --git a/compiler/rustc_target/src/spec/haiku_base.rs b/compiler/rustc_target/src/spec/haiku_base.rs index 25549491f4b..61c05a2bdb6 100644 --- a/compiler/rustc_target/src/spec/haiku_base.rs +++ b/compiler/rustc_target/src/spec/haiku_base.rs @@ -1,6 +1,4 @@ -use crate::spec::{RelroLevel, TargetOptions}; - -use super::cvs; +use crate::spec::{cvs, RelroLevel, TargetOptions}; pub fn opts() -> TargetOptions { TargetOptions { diff --git a/compiler/rustc_target/src/spec/illumos_base.rs b/compiler/rustc_target/src/spec/illumos_base.rs index 1f6202dd7f5..ef8f90a4da8 100644 --- a/compiler/rustc_target/src/spec/illumos_base.rs +++ b/compiler/rustc_target/src/spec/illumos_base.rs @@ -1,7 +1,4 @@ -use crate::spec::{FramePointer, LinkArgs, LinkerFlavor, TargetOptions}; -use std::default::Default; - -use super::cvs; +use crate::spec::{cvs, FramePointer, LinkArgs, LinkerFlavor, TargetOptions}; pub fn opts() -> TargetOptions { let mut late_link_args = LinkArgs::new(); diff --git a/compiler/rustc_target/src/spec/l4re_base.rs b/compiler/rustc_target/src/spec/l4re_base.rs index e185de78bca..7a051532f82 100644 --- a/compiler/rustc_target/src/spec/l4re_base.rs +++ b/compiler/rustc_target/src/spec/l4re_base.rs @@ -1,7 +1,4 @@ -use crate::spec::{LinkerFlavor, PanicStrategy, TargetOptions}; -use std::default::Default; - -use super::cvs; +use crate::spec::{cvs, LinkerFlavor, PanicStrategy, TargetOptions}; pub fn opts() -> TargetOptions { TargetOptions { diff --git a/compiler/rustc_target/src/spec/linux_base.rs b/compiler/rustc_target/src/spec/linux_base.rs index 84d8e19159a..0f79ada0d93 100644 --- a/compiler/rustc_target/src/spec/linux_base.rs +++ b/compiler/rustc_target/src/spec/linux_base.rs @@ -1,6 +1,4 @@ -use crate::spec::{RelroLevel, TargetOptions}; - -use super::cvs; +use crate::spec::{cvs, RelroLevel, TargetOptions}; pub fn opts() -> TargetOptions { TargetOptions { diff --git a/compiler/rustc_target/src/spec/mipsel_sony_psp.rs b/compiler/rustc_target/src/spec/mipsel_sony_psp.rs index dc8169b7118..45966b97d6a 100644 --- a/compiler/rustc_target/src/spec/mipsel_sony_psp.rs +++ b/compiler/rustc_target/src/spec/mipsel_sony_psp.rs @@ -1,7 +1,5 @@ +use crate::spec::{cvs, Target, TargetOptions}; use crate::spec::{LinkArgs, LinkerFlavor, LldFlavor, RelocModel}; -use crate::spec::{Target, TargetOptions}; - -use super::cvs; // The PSP has custom linker requirements. const LINKER_SCRIPT: &str = include_str!("./mipsel_sony_psp_linker_script.ld"); diff --git a/compiler/rustc_target/src/spec/mod.rs b/compiler/rustc_target/src/spec/mod.rs index 96623e1c163..bd5b712c143 100644 --- a/compiler/rustc_target/src/spec/mod.rs +++ b/compiler/rustc_target/src/spec/mod.rs @@ -459,7 +459,7 @@ impl fmt::Display for LinkOutputKind { } } -pub type LinkArgs = BTreeMap>>; +pub type LinkArgs = BTreeMap>>; #[derive(Clone, Copy, Hash, Debug, PartialEq, Eq)] pub enum SplitDebuginfo { @@ -1028,19 +1028,16 @@ supported_targets! { } /// Cow-Vec-Str: Cow<'static, [Cow<'static, str>]> -// FIXME(Urgau): Figure out why the obvious form `["".into()].into()` doesn't work. macro_rules! cvs { () => { ::std::borrow::Cow::Borrowed(&[]) }; ($($x:expr),+ $(,)?) => { - { - ::std::borrow::Cow::Borrowed(&[ - $( - ::std::borrow::Cow::Borrowed($x), - )* - ]) - } + ::std::borrow::Cow::Borrowed(&[ + $( + ::std::borrow::Cow::Borrowed($x), + )* + ]) }; } @@ -1084,14 +1081,14 @@ impl TargetWarnings { #[derive(PartialEq, Clone, Debug)] pub struct Target { /// Target triple to pass to LLVM. - pub llvm_target: Cow<'static, str>, + pub llvm_target: StaticCow, /// Number of bits in a pointer. Influences the `target_pointer_width` `cfg` variable. pub pointer_width: u32, /// Architecture to use for ABI considerations. Valid options include: "x86", /// "x86_64", "arm", "aarch64", "mips", "powerpc", "powerpc64", and others. - pub arch: Cow<'static, str>, + pub arch: StaticCow, /// [Data layout](https://llvm.org/docs/LangRef.html#data-layout) to pass to LLVM. - pub data_layout: Cow<'static, str>, + pub data_layout: StaticCow, /// Optional settings with defaults. pub options: TargetOptions, } @@ -1107,6 +1104,8 @@ impl HasTargetSpec for Target { } } +type StaticCow = Cow<'static, T>; + /// Optional aspects of a target specification. /// /// This has an implementation of `Default`, see each field for what the default is. In general, @@ -1123,25 +1122,25 @@ pub struct TargetOptions { /// Used as the `target_endian` `cfg` variable. Defaults to little endian. pub endian: Endian, /// Width of c_int type. Defaults to "32". - pub c_int_width: Cow<'static, str>, + pub c_int_width: StaticCow, /// 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: Cow<'static, str>, + pub os: StaticCow, /// Environment name to use for conditional compilation (`target_env`). Defaults to "". - pub env: Cow<'static, str>, + pub env: StaticCow, /// ABI name to distinguish multiple ABIs on the same OS and architecture. For instance, `"eabi"` /// or `"eabihf"`. Defaults to "". - pub abi: Cow<'static, str>, + pub abi: StaticCow, /// Vendor name to use for conditional compilation (`target_vendor`). Defaults to "unknown". - pub vendor: Cow<'static, str>, + pub vendor: StaticCow, /// 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 to invoke - pub linker: Option>, + pub linker: Option>, /// LLD flavor used if `lld` (or `rust-lld`) is specified as a linker /// without clarifying its flavor in any way. @@ -1176,23 +1175,23 @@ pub struct TargetOptions { /// 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>, + pub link_script: Option>, /// Environment variables to be set for the linker invocation. - pub link_env: Cow<'static, [(Cow<'static, str>, Cow<'static, str>)]>, + pub link_env: StaticCow<[(StaticCow, StaticCow)]>, /// Environment variables to be removed for the linker invocation. - pub link_env_remove: Cow<'static, [Cow<'static, str>]>, + pub link_env_remove: StaticCow<[StaticCow]>, /// Extra arguments to pass to the external assembler (when used) - pub asm_args: Cow<'static, [Cow<'static, str>]>, + pub asm_args: StaticCow<[StaticCow]>, /// Default CPU to pass to LLVM. Corresponds to `llc -mcpu=$cpu`. Defaults /// to "generic". - pub cpu: Cow<'static, str>, + pub cpu: StaticCow, /// Default target features to pass to LLVM. These features will *always* be /// passed, and cannot be disabled even via `-C`. Corresponds to `llc /// -mattr=$features`. - pub features: Cow<'static, str>, + pub features: StaticCow, /// Whether dynamic linking is available on this target. Defaults to false. pub dynamic_linking: bool, /// If dynamic linking is available, whether only cdylibs are supported. @@ -1216,21 +1215,21 @@ pub struct TargetOptions { /// Emit each function in its own section. Defaults to true. pub function_sections: bool, /// String to prepend to the name of every dynamic library. Defaults to "lib". - pub dll_prefix: Cow<'static, str>, + pub dll_prefix: StaticCow, /// String to append to the name of every dynamic library. Defaults to ".so". - pub dll_suffix: Cow<'static, str>, + pub dll_suffix: StaticCow, /// String to append to the name of every executable. - pub exe_suffix: Cow<'static, str>, + pub exe_suffix: StaticCow, /// String to prepend to the name of every static library. Defaults to "lib". - pub staticlib_prefix: Cow<'static, str>, + pub staticlib_prefix: StaticCow, /// String to append to the name of every static library. Defaults to ".a". - pub staticlib_suffix: Cow<'static, str>, + pub staticlib_suffix: StaticCow, /// Values of the `target_family` cfg set for this target. /// /// Common options are: "unix", "windows". Defaults to no families. /// /// See . - pub families: Cow<'static, [Cow<'static, str>]>, + pub families: StaticCow<[StaticCow]>, /// Whether the target toolchain's ABI supports returning small structs as an integer. pub abi_return_struct_as_int: bool, /// Whether the target toolchain is like macOS's. Only useful for compiling against iOS/macOS, @@ -1302,7 +1301,7 @@ pub struct TargetOptions { /// LLVM to assemble an archive or fall back to the system linker, and /// currently only "gnu" is used to fall into LLVM. Unknown strings cause /// the system linker to be used. - pub archive_format: Cow<'static, str>, + pub archive_format: StaticCow, /// Is asm!() allowed? Defaults to true. pub allow_asm: bool, /// Whether the runtime startup code requires the `main` function be passed @@ -1318,7 +1317,7 @@ pub struct TargetOptions { /// Whether the target requires that emitted object code includes bitcode. pub forces_embed_bitcode: bool, /// Content of the LLVM cmdline section associated with embedded bitcode. - pub bitcode_llvm_cmdline: Cow<'static, str>, + pub bitcode_llvm_cmdline: StaticCow, /// Don't use this field; instead use the `.min_atomic_width()` method. pub min_atomic_width: Option, @@ -1390,7 +1389,7 @@ pub struct TargetOptions { /// If set, have the linker export exactly these symbols, instead of using /// the usual logic to figure this out from the crate itself. - pub override_export_symbols: Option]>>, + pub override_export_symbols: Option]>>, /// Determines how or whether the MergeFunctions LLVM pass should run for /// this target. Either "disabled", "trampolines", or "aliases". @@ -1401,16 +1400,16 @@ pub struct TargetOptions { pub merge_functions: MergeFunctions, /// Use platform dependent mcount function - pub mcount: Cow<'static, str>, + pub mcount: StaticCow, /// LLVM ABI name, corresponds to the '-mabi' parameter available in multilib C compilers - pub llvm_abiname: Cow<'static, str>, + pub llvm_abiname: StaticCow, /// Whether or not RelaxElfRelocation flag will be passed to the linker pub relax_elf_relocations: bool, /// Additional arguments to pass to LLVM, similar to the `-C llvm-args` codegen option. - pub llvm_args: Cow<'static, [Cow<'static, str>]>, + pub llvm_args: StaticCow<[StaticCow]>, /// Whether to use legacy .ctors initialization hooks rather than .init_array. Defaults /// to false (uses .init_array). @@ -1459,8 +1458,8 @@ impl Default for TargetOptions { endian: Endian::Little, c_int_width: "32".into(), os: "none".into(), - env: Cow::from(""), - abi: Cow::from(""), + env: "".into(), + abi: "".into(), vendor: "unknown".into(), linker_flavor: LinkerFlavor::Gcc, linker: option_env!("CFG_DEFAULT_LINKER").map(|s| s.into()), @@ -1468,9 +1467,9 @@ impl Default for TargetOptions { pre_link_args: LinkArgs::new(), post_link_args: LinkArgs::new(), link_script: None, - asm_args: Cow::Borrowed(&[]), + asm_args: cvs![], cpu: "generic".into(), - features: Cow::from(""), + features: "".into(), dynamic_linking: false, only_cdylib: false, executables: false, @@ -1482,7 +1481,7 @@ impl Default for TargetOptions { function_sections: true, dll_prefix: "lib".into(), dll_suffix: ".so".into(), - exe_suffix: Cow::from(""), + exe_suffix: "".into(), staticlib_prefix: "lib".into(), staticlib_suffix: ".a".into(), families: cvs![], @@ -1511,15 +1510,15 @@ impl Default for TargetOptions { late_link_args: LinkArgs::new(), late_link_args_dynamic: LinkArgs::new(), late_link_args_static: LinkArgs::new(), - link_env: Cow::Borrowed(&[]), - link_env_remove: Cow::Borrowed(&[]), + link_env: cvs![], + link_env_remove: cvs![], archive_format: "gnu".into(), main_needs_argc_argv: true, allow_asm: true, has_thread_local: false, obj_is_bitcode: false, forces_embed_bitcode: false, - bitcode_llvm_cmdline: Cow::from(""), + bitcode_llvm_cmdline: "".into(), min_atomic_width: None, max_atomic_width: None, atomic_cas: true, diff --git a/compiler/rustc_target/src/spec/msp430_none_elf.rs b/compiler/rustc_target/src/spec/msp430_none_elf.rs index f22c8672639..cedacb60f31 100644 --- a/compiler/rustc_target/src/spec/msp430_none_elf.rs +++ b/compiler/rustc_target/src/spec/msp430_none_elf.rs @@ -1,5 +1,4 @@ -use super::cvs; -use crate::spec::{PanicStrategy, RelocModel, Target, TargetOptions}; +use crate::spec::{cvs, PanicStrategy, RelocModel, Target, TargetOptions}; pub fn target() -> Target { Target { diff --git a/compiler/rustc_target/src/spec/netbsd_base.rs b/compiler/rustc_target/src/spec/netbsd_base.rs index a5fb58f5e7b..69016d77cf9 100644 --- a/compiler/rustc_target/src/spec/netbsd_base.rs +++ b/compiler/rustc_target/src/spec/netbsd_base.rs @@ -1,6 +1,4 @@ -use crate::spec::{RelroLevel, TargetOptions}; - -use super::cvs; +use crate::spec::{cvs, RelroLevel, TargetOptions}; pub fn opts() -> TargetOptions { TargetOptions { diff --git a/compiler/rustc_target/src/spec/openbsd_base.rs b/compiler/rustc_target/src/spec/openbsd_base.rs index 7745d10e13e..bbd322bb6ce 100644 --- a/compiler/rustc_target/src/spec/openbsd_base.rs +++ b/compiler/rustc_target/src/spec/openbsd_base.rs @@ -1,6 +1,4 @@ -use crate::spec::{FramePointer, RelroLevel, TargetOptions}; - -use super::cvs; +use crate::spec::{cvs, FramePointer, RelroLevel, TargetOptions}; pub fn opts() -> TargetOptions { TargetOptions { diff --git a/compiler/rustc_target/src/spec/redox_base.rs b/compiler/rustc_target/src/spec/redox_base.rs index 667aa8e9c94..1878cc3fc11 100644 --- a/compiler/rustc_target/src/spec/redox_base.rs +++ b/compiler/rustc_target/src/spec/redox_base.rs @@ -1,6 +1,4 @@ -use crate::spec::{RelroLevel, TargetOptions}; - -use super::cvs; +use crate::spec::{cvs, RelroLevel, TargetOptions}; pub fn opts() -> TargetOptions { TargetOptions { diff --git a/compiler/rustc_target/src/spec/riscv32imc_esp_espidf.rs b/compiler/rustc_target/src/spec/riscv32imc_esp_espidf.rs index 4c7401380fd..0200862c7e0 100644 --- a/compiler/rustc_target/src/spec/riscv32imc_esp_espidf.rs +++ b/compiler/rustc_target/src/spec/riscv32imc_esp_espidf.rs @@ -1,7 +1,5 @@ +use crate::spec::{cvs, Target, TargetOptions}; use crate::spec::{LinkerFlavor, PanicStrategy, RelocModel}; -use crate::spec::{Target, TargetOptions}; - -use super::cvs; pub fn target() -> Target { Target { diff --git a/compiler/rustc_target/src/spec/solaris_base.rs b/compiler/rustc_target/src/spec/solaris_base.rs index 8d8ad049b33..d61e1b2ec10 100644 --- a/compiler/rustc_target/src/spec/solaris_base.rs +++ b/compiler/rustc_target/src/spec/solaris_base.rs @@ -1,6 +1,4 @@ -use crate::spec::TargetOptions; - -use super::cvs; +use crate::spec::{cvs, TargetOptions}; pub fn opts() -> TargetOptions { TargetOptions { diff --git a/compiler/rustc_target/src/spec/thumbv4t_none_eabi.rs b/compiler/rustc_target/src/spec/thumbv4t_none_eabi.rs index 457b78850ac..8d6130a8a79 100644 --- a/compiler/rustc_target/src/spec/thumbv4t_none_eabi.rs +++ b/compiler/rustc_target/src/spec/thumbv4t_none_eabi.rs @@ -8,8 +8,7 @@ //! //! **Important:** This target profile **does not** specify a linker script. You just get the default link script when you build a binary for this target. The default link script is very likely wrong, so you should use `-Clink-arg=-Tmy_script.ld` to override that with a correct linker script. -use super::cvs; -use crate::spec::{LinkerFlavor, Target, TargetOptions}; +use crate::spec::{cvs, LinkerFlavor, Target, TargetOptions}; pub fn target() -> Target { Target { diff --git a/compiler/rustc_target/src/spec/vxworks_base.rs b/compiler/rustc_target/src/spec/vxworks_base.rs index f43cea131b7..2beb279e398 100644 --- a/compiler/rustc_target/src/spec/vxworks_base.rs +++ b/compiler/rustc_target/src/spec/vxworks_base.rs @@ -1,6 +1,4 @@ -use crate::spec::TargetOptions; - -use super::cvs; +use crate::spec::{cvs, TargetOptions}; pub fn opts() -> TargetOptions { TargetOptions { diff --git a/compiler/rustc_target/src/spec/windows_gnu_base.rs b/compiler/rustc_target/src/spec/windows_gnu_base.rs index 1e5ced684bd..d11f1f7d3f8 100644 --- a/compiler/rustc_target/src/spec/windows_gnu_base.rs +++ b/compiler/rustc_target/src/spec/windows_gnu_base.rs @@ -1,7 +1,5 @@ use crate::spec::crt_objects::{self, CrtObjectsFallback}; -use crate::spec::{LinkArgs, LinkerFlavor, LldFlavor, TargetOptions}; - -use super::cvs; +use crate::spec::{cvs, LinkArgs, LinkerFlavor, LldFlavor, TargetOptions}; pub fn opts() -> TargetOptions { let mut pre_link_args = LinkArgs::new(); diff --git a/compiler/rustc_target/src/spec/windows_msvc_base.rs b/compiler/rustc_target/src/spec/windows_msvc_base.rs index bfe8edecac4..21062c337d8 100644 --- a/compiler/rustc_target/src/spec/windows_msvc_base.rs +++ b/compiler/rustc_target/src/spec/windows_msvc_base.rs @@ -1,6 +1,4 @@ -use crate::spec::TargetOptions; - -use super::cvs; +use crate::spec::{cvs, TargetOptions}; pub fn opts() -> TargetOptions { let base = super::msvc_base::opts(); -- cgit 1.4.1-3-g733a5