Skip to content

Commit eb9685d

Browse files
committed
Resolve rustc path early to bypass rustup wrapper
1 parent 6066463 commit eb9685d

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/cargo/util/rustc.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,26 @@ impl Rustc {
3838
/// If successful this function returns a description of the compiler along
3939
/// with a list of its capabilities.
4040
pub fn new(
41-
path: PathBuf,
41+
mut path: PathBuf,
4242
wrapper: Option<PathBuf>,
4343
workspace_wrapper: Option<PathBuf>,
4444
rustup_rustc: &Path,
4545
cache_location: Option<PathBuf>,
4646
) -> CargoResult<Rustc> {
4747
let _p = profile::start("Rustc::new");
4848

49+
// In order to avoid calling through rustup multiple times, we first ask
50+
// rustc to give us the "resolved" rustc path, and use that instead.
51+
let mut cmd = ProcessBuilder::new(&path);
52+
cmd.arg("--print=rustc-path");
53+
if let Ok(output) = cmd.output() {
54+
if output.status.success() {
55+
if let Ok(resolved) = String::from_utf8(output.stdout) {
56+
path = PathBuf::from(resolved.trim());
57+
}
58+
}
59+
}
60+
4961
let mut cache = Cache::load(
5062
wrapper.as_deref(),
5163
workspace_wrapper.as_deref(),

0 commit comments

Comments
 (0)