File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -401,6 +401,19 @@ impl<'a> InstalledCommonToolchain<'a> {
401401
402402 cmd. env ( "RUSTUP_TOOLCHAIN" , & self . 0 . name ) ;
403403 cmd. env ( "RUSTUP_HOME" , & self . 0 . cfg . rustup_dir ) ;
404+ // It's valid (although slightly cursed) to tell a rustup cargo proxy to use a custom rustc
405+ // from a different toolchain.
406+ if env:: var ( "RUSTC" ) . is_err ( ) {
407+ // Set RUSTC for the spawned binary. This serves two purposes:
408+ // 1. It avoids the overhead of having to re-parse `settings.toml` on each proxy.
409+ // In projects with many crates, this can have non-trivial overhead.
410+ // 2. For build scripts, it provides an absolute path for RUSTC rather than forcing them to look it up in PATH.
411+ // This allows them to find the sysroot path for the toolchain, rather than ending up somewhere in CARGO_HOME.
412+ cmd. env ( "RUSTC" , self . 0 . path . join ( "bin" ) . join ( "rustc" ) ) ;
413+ }
414+ if env:: var ( "RUSTDOC" ) . is_err ( ) {
415+ cmd. env ( "RUSTDOC" , self . 0 . path . join ( "bin" ) . join ( "rustdoc" ) ) ;
416+ }
404417 }
405418
406419 fn set_ldpath ( & self , cmd : & mut Command ) {
You can’t perform that action at this time.
0 commit comments