Skip to content

Commit e3d8b68

Browse files
committed
review feedback: find lib root path from registry
1 parent 3c6f6f0 commit e3d8b68

File tree

5 files changed

+20
-9
lines changed

5 files changed

+20
-9
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3126,6 +3126,7 @@ name = "rustc_target"
31263126
version = "0.0.0"
31273127
dependencies = [
31283128
"bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
3129+
"cc 1.0.35 (registry+https://github.com/rust-lang/crates.io-index)",
31293130
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
31303131
"rustc_data_structures 0.0.0",
31313132
"serialize 0.0.0",

src/librustc_target/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ path = "lib.rs"
1111
[dependencies]
1212
bitflags = "1.0"
1313
log = "0.4"
14+
cc = "1.0.1"
1415
rustc_data_structures = { path = "../librustc_data_structures" }
1516
rustc_serialize = { path = "../libserialize", package = "serialize" }
1617
syntax_pos = { path = "../libsyntax_pos" }

src/librustc_target/spec/aarch64_uwp_windows_msvc.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::spec::{LinkerFlavor, Target, TargetResult, PanicStrategy};
2-
use std::env;
2+
use cc::windows_registry;
33

44
pub fn target() -> TargetResult {
55
let mut base = super::windows_uwp_msvc_base::opts();
@@ -9,8 +9,11 @@ pub fn target() -> TargetResult {
99
// FIXME: this shouldn't be panic=abort, it should be panic=unwind
1010
base.panic_strategy = PanicStrategy::Abort;
1111

12-
let lib_root_path = env::var("VCToolsInstallDir")
13-
.expect("VCToolsInstallDir not found in env");
12+
let link_tool = windows_registry::find_tool("x86_64-pc-windows-msvc", "link.exe")
13+
.expect("no path found for link.exe");
14+
15+
let original_path = link_tool.path();
16+
let lib_root_path = original_path.ancestors().skip(4).next().unwrap().display();
1417

1518
base.pre_link_args.get_mut(&LinkerFlavor::Msvc).unwrap()
1619
.push(format!("{}{}{}",

src/librustc_target/spec/i686_uwp_windows_msvc.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
use crate::spec::{LinkerFlavor, Target, TargetResult};
2-
use std::env;
2+
use cc::windows_registry;
33

44
pub fn target() -> TargetResult {
55
let mut base = super::windows_uwp_msvc_base::opts();
66
base.cpu = "pentium4".to_string();
77
base.max_atomic_width = Some(64);
88
base.has_elf_tls = true;
99

10-
let lib_root_path = env::var("VCToolsInstallDir")
11-
.expect("VCToolsInstallDir not found in env");
10+
let link_tool = windows_registry::find_tool("x86_64-pc-windows-msvc", "link.exe")
11+
.expect("no path found for link.exe");
12+
13+
let original_path = link_tool.path();
14+
let lib_root_path = original_path.ancestors().skip(4).next().unwrap().display();
1215

1316
base.pre_link_args.get_mut(&LinkerFlavor::Msvc).unwrap()
1417
.push(format!("{}{}{}",

src/librustc_target/spec/x86_64_uwp_windows_msvc.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
use crate::spec::{LinkerFlavor, Target, TargetResult};
2-
use std::env;
2+
use cc::windows_registry;
33

44
pub fn target() -> TargetResult {
55
let mut base = super::windows_uwp_msvc_base::opts();
66
base.cpu = "x86-64".to_string();
77
base.max_atomic_width = Some(64);
88
base.has_elf_tls = true;
99

10-
let lib_root_path = env::var("VCToolsInstallDir")
11-
.expect("VCToolsInstallDir not found in env");
10+
let link_tool = windows_registry::find_tool("x86_64-pc-windows-msvc", "link.exe")
11+
.expect("no path found for link.exe");
12+
13+
let original_path = link_tool.path();
14+
let lib_root_path = original_path.ancestors().skip(4).next().unwrap().display();
1215

1316
base.pre_link_args.get_mut(&LinkerFlavor::Msvc).unwrap()
1417
.push(format!("{}{}{}",

0 commit comments

Comments
 (0)