From 89044a908ed602ae3dee74905866cffd63c164b3 Mon Sep 17 00:00:00 2001 From: Martin Finkel Date: Wed, 7 Aug 2019 17:49:15 +0200 Subject: [PATCH] move store lib probing code to librustc_codegen_ssa --- Cargo.lock | 1 - src/librustc_codegen_ssa/back/link.rs | 14 ++++++++++++++ src/librustc_target/Cargo.toml | 1 - .../spec/aarch64_uwp_windows_msvc.rs | 13 ------------- src/librustc_target/spec/i686_uwp_windows_msvc.rs | 13 ------------- .../spec/x86_64_uwp_windows_msvc.rs | 13 ------------- 6 files changed, 14 insertions(+), 41 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f2356a261524..c08d7444d14e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3126,7 +3126,6 @@ name = "rustc_target" version = "0.0.0" dependencies = [ "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "cc 1.0.35 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_data_structures 0.0.0", "serialize 0.0.0", diff --git a/src/librustc_codegen_ssa/back/link.rs b/src/librustc_codegen_ssa/back/link.rs index 3f6a1a72ea61..ea8e55145fa6 100644 --- a/src/librustc_codegen_ssa/back/link.rs +++ b/src/librustc_codegen_ssa/back/link.rs @@ -1027,6 +1027,20 @@ fn link_args<'a, B: ArchiveBuilder<'a>>(cmd: &mut dyn Linker, let t = &sess.target.target; cmd.include_path(&fix_windows_verbatim_for_gcc(&lib_path)); + + if t.linker_flavor == LinkerFlavor::Msvc && t.target_vendor == "uwp" { + let link_tool = windows_registry::find_tool("x86_64-pc-windows-msvc", "link.exe") + .expect("no path found for link.exe"); + + let original_path = link_tool.path(); + let root_lib_path = original_path.ancestors().skip(4).next().unwrap(); + if t.arch == "aarch64".to_string() { + cmd.include_path(&root_lib_path.join(format!("lib\\arm64\\store"))); + } else { + cmd.include_path(&root_lib_path.join(format!("lib\\{}\\store", t.arch))); + } + } + for obj in codegen_results.modules.iter().filter_map(|m| m.object.as_ref()) { cmd.add_object(obj); } diff --git a/src/librustc_target/Cargo.toml b/src/librustc_target/Cargo.toml index 940acf232ad1..cab1e0e01371 100644 --- a/src/librustc_target/Cargo.toml +++ b/src/librustc_target/Cargo.toml @@ -11,7 +11,6 @@ path = "lib.rs" [dependencies] bitflags = "1.0" log = "0.4" -cc = "1.0.1" rustc_data_structures = { path = "../librustc_data_structures" } rustc_serialize = { path = "../libserialize", package = "serialize" } syntax_pos = { path = "../libsyntax_pos" } diff --git a/src/librustc_target/spec/aarch64_uwp_windows_msvc.rs b/src/librustc_target/spec/aarch64_uwp_windows_msvc.rs index ab1b6705a1da..5d8b829f2ab7 100644 --- a/src/librustc_target/spec/aarch64_uwp_windows_msvc.rs +++ b/src/librustc_target/spec/aarch64_uwp_windows_msvc.rs @@ -1,5 +1,4 @@ use crate::spec::{LinkerFlavor, Target, TargetResult, PanicStrategy}; -use cc::windows_registry; pub fn target() -> TargetResult { let mut base = super::windows_uwp_msvc_base::opts(); @@ -9,18 +8,6 @@ pub fn target() -> TargetResult { // FIXME: this shouldn't be panic=abort, it should be panic=unwind base.panic_strategy = PanicStrategy::Abort; - let link_tool = windows_registry::find_tool("x86_64-pc-windows-msvc", "link.exe") - .expect("no path found for link.exe"); - - let original_path = link_tool.path(); - let lib_root_path = original_path.ancestors().skip(4).next().unwrap().display(); - - base.pre_link_args.get_mut(&LinkerFlavor::Msvc).unwrap() - .push(format!("{}{}{}", - "/LIBPATH:".to_string(), - lib_root_path, - "lib\\arm64\\store".to_string())); - Ok(Target { llvm_target: "aarch64-pc-windows-msvc".to_string(), target_endian: "little".to_string(), diff --git a/src/librustc_target/spec/i686_uwp_windows_msvc.rs b/src/librustc_target/spec/i686_uwp_windows_msvc.rs index bc5631439d19..5e8e8c2a4149 100644 --- a/src/librustc_target/spec/i686_uwp_windows_msvc.rs +++ b/src/librustc_target/spec/i686_uwp_windows_msvc.rs @@ -1,5 +1,4 @@ use crate::spec::{LinkerFlavor, Target, TargetResult}; -use cc::windows_registry; pub fn target() -> TargetResult { let mut base = super::windows_uwp_msvc_base::opts(); @@ -7,18 +6,6 @@ pub fn target() -> TargetResult { base.max_atomic_width = Some(64); base.has_elf_tls = true; - let link_tool = windows_registry::find_tool("x86_64-pc-windows-msvc", "link.exe") - .expect("no path found for link.exe"); - - let original_path = link_tool.path(); - let lib_root_path = original_path.ancestors().skip(4).next().unwrap().display(); - - base.pre_link_args.get_mut(&LinkerFlavor::Msvc).unwrap() - .push(format!("{}{}{}", - "/LIBPATH:".to_string(), - lib_root_path, - "lib\\x86\\store".to_string())); - Ok(Target { llvm_target: "i686-pc-windows-msvc".to_string(), target_endian: "little".to_string(), diff --git a/src/librustc_target/spec/x86_64_uwp_windows_msvc.rs b/src/librustc_target/spec/x86_64_uwp_windows_msvc.rs index 8c15c7c22fcf..40dd52c15915 100644 --- a/src/librustc_target/spec/x86_64_uwp_windows_msvc.rs +++ b/src/librustc_target/spec/x86_64_uwp_windows_msvc.rs @@ -1,5 +1,4 @@ use crate::spec::{LinkerFlavor, Target, TargetResult}; -use cc::windows_registry; pub fn target() -> TargetResult { let mut base = super::windows_uwp_msvc_base::opts(); @@ -7,18 +6,6 @@ pub fn target() -> TargetResult { base.max_atomic_width = Some(64); base.has_elf_tls = true; - let link_tool = windows_registry::find_tool("x86_64-pc-windows-msvc", "link.exe") - .expect("no path found for link.exe"); - - let original_path = link_tool.path(); - let lib_root_path = original_path.ancestors().skip(4).next().unwrap().display(); - - base.pre_link_args.get_mut(&LinkerFlavor::Msvc).unwrap() - .push(format!("{}{}{}", - "/LIBPATH:".to_string(), - lib_root_path, - "lib\\x64\\store".to_string())); - Ok(Target { llvm_target: "x86_64-pc-windows-msvc".to_string(), target_endian: "little".to_string(),