File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -38,14 +38,26 @@ impl Rustc {
38
38
/// If successful this function returns a description of the compiler along
39
39
/// with a list of its capabilities.
40
40
pub fn new (
41
- path : PathBuf ,
41
+ mut path : PathBuf ,
42
42
wrapper : Option < PathBuf > ,
43
43
workspace_wrapper : Option < PathBuf > ,
44
44
rustup_rustc : & Path ,
45
45
cache_location : Option < PathBuf > ,
46
46
) -> CargoResult < Rustc > {
47
47
let _p = profile:: start ( "Rustc::new" ) ;
48
48
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
+
49
61
let mut cache = Cache :: load (
50
62
wrapper. as_deref ( ) ,
51
63
workspace_wrapper. as_deref ( ) ,
You can’t perform that action at this time.
0 commit comments