@@ -172,19 +172,18 @@ impl WorkspaceBuildScripts {
172172 }
173173 let res = ( || {
174174 let target_libdir = ( || {
175- let mut cargo_config = sysroot. tool ( Tool :: Cargo ) ;
175+ let mut cargo_config = sysroot. tool ( Tool :: Cargo , current_dir ) ;
176176 cargo_config. envs ( extra_env) ;
177177 cargo_config
178- . current_dir ( current_dir)
179178 . args ( [ "rustc" , "-Z" , "unstable-options" , "--print" , "target-libdir" ] )
180179 . env ( "RUSTC_BOOTSTRAP" , "1" ) ;
181- if let Ok ( it) = utf8_stdout ( cargo_config) {
180+ if let Ok ( it) = utf8_stdout ( & mut cargo_config) {
182181 return Ok ( it) ;
183182 }
184- let mut cmd = sysroot. tool ( Tool :: Rustc ) ;
183+ let mut cmd = sysroot. tool ( Tool :: Rustc , current_dir ) ;
185184 cmd. envs ( extra_env) ;
186185 cmd. args ( [ "--print" , "target-libdir" ] ) ;
187- utf8_stdout ( cmd)
186+ utf8_stdout ( & mut cmd)
188187 } ) ( ) ?;
189188
190189 let target_libdir = AbsPathBuf :: try_from ( Utf8PathBuf :: from ( target_libdir) )
@@ -390,12 +389,12 @@ impl WorkspaceBuildScripts {
390389 ) -> io:: Result < Command > {
391390 let mut cmd = match config. run_build_script_command . as_deref ( ) {
392391 Some ( [ program, args @ ..] ) => {
393- let mut cmd = Command :: new ( program) ;
392+ let mut cmd = toolchain :: command ( program, current_dir ) ;
394393 cmd. args ( args) ;
395394 cmd
396395 }
397396 _ => {
398- let mut cmd = sysroot. tool ( Tool :: Cargo ) ;
397+ let mut cmd = sysroot. tool ( Tool :: Cargo , current_dir ) ;
399398
400399 cmd. args ( [ "check" , "--quiet" , "--workspace" , "--message-format=json" ] ) ;
401400 cmd. args ( & config. extra_args ) ;
@@ -448,7 +447,6 @@ impl WorkspaceBuildScripts {
448447 }
449448 } ;
450449
451- cmd. current_dir ( current_dir) ;
452450 cmd. envs ( & config. extra_env ) ;
453451 if config. wrap_rustc_in_build_scripts {
454452 // Setup RUSTC_WRAPPER to point to `rust-analyzer` binary itself. We use
0 commit comments