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 {
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 ( ) ,
You can’t perform that action at this time.
0 commit comments