@@ -24,7 +24,7 @@ use std::{cmp, env, fs};
24
24
25
25
use build_helper:: ci:: CiEnv ;
26
26
use build_helper:: exit;
27
- use build_helper:: git:: { GitConfig , PathFreshness , check_path_modifications, output_result } ;
27
+ use build_helper:: git:: { GitConfig , PathFreshness , check_path_modifications} ;
28
28
use serde:: Deserialize ;
29
29
#[ cfg( feature = "tracing" ) ]
30
30
use tracing:: { instrument, span} ;
@@ -47,9 +47,10 @@ use crate::core::config::{
47
47
} ;
48
48
use crate :: core:: download:: is_download_ci_available;
49
49
use crate :: utils:: channel;
50
+ use crate :: utils:: exec:: command;
50
51
use crate :: utils:: execution_context:: ExecutionContext ;
51
52
use crate :: utils:: helpers:: exe;
52
- use crate :: { Command , GitInfo , OnceLock , TargetSelection , check_ci_llvm, helpers, output , t} ;
53
+ use crate :: { GitInfo , OnceLock , TargetSelection , check_ci_llvm, helpers, t} ;
53
54
54
55
/// Each path in this list is considered "allowed" in the `download-rustc="if-unchanged"` logic.
55
56
/// This means they can be modified and changes to these paths should never trigger a compiler build
@@ -445,7 +446,7 @@ impl Config {
445
446
// has already been (kinda-cross-)compiled to Windows land, we require a normal Windows path.
446
447
cmd. arg ( "rev-parse" ) . arg ( "--show-cdup" ) ;
447
448
// Discard stderr because we expect this to fail when building from a tarball.
448
- let output = cmd. run_capture_stdout_exec_ctx ( & config) ;
449
+ let output = cmd. allow_failure ( ) . run_capture_stdout_exec_ctx ( & config) ;
449
450
if output. is_success ( ) {
450
451
let git_root_relative = output. stdout ( ) ;
451
452
// We need to canonicalize this path to make sure it uses backslashes instead of forward slashes,
@@ -749,7 +750,12 @@ impl Config {
749
750
} ;
750
751
751
752
config. initial_sysroot = t ! ( PathBuf :: from_str(
752
- output( Command :: new( & config. initial_rustc) . args( [ "--print" , "sysroot" ] ) ) . trim( )
753
+ command( & config. initial_rustc)
754
+ . args( [ "--print" , "sysroot" ] )
755
+ . run_always( )
756
+ . run_capture_stdout_exec_ctx( & config)
757
+ . stdout( )
758
+ . trim( )
753
759
) ) ;
754
760
755
761
config. initial_cargo_clippy = cargo_clippy;
@@ -1062,7 +1068,7 @@ impl Config {
1062
1068
1063
1069
let mut git = helpers:: git ( Some ( & self . src ) ) ;
1064
1070
git. arg ( "show" ) . arg ( format ! ( "{commit}:{}" , file. to_str( ) . unwrap( ) ) ) ;
1065
- output ( git. as_command_mut ( ) )
1071
+ git. allow_failure ( ) . run_capture_stdout_exec_ctx ( self ) . stdout ( )
1066
1072
}
1067
1073
1068
1074
/// Bootstrap embeds a version number into the name of shared libraries it uploads in CI.
@@ -1333,16 +1339,20 @@ impl Config {
1333
1339
} ;
1334
1340
1335
1341
// Determine commit checked out in submodule.
1336
- let checked_out_hash = output ( submodule_git ( ) . args ( [ "rev-parse" , "HEAD" ] ) . as_command_mut ( ) ) ;
1342
+ let checked_out_hash = submodule_git ( )
1343
+ . allow_failure ( )
1344
+ . args ( [ "rev-parse" , "HEAD" ] )
1345
+ . run_capture_stdout_exec_ctx ( self )
1346
+ . stdout ( ) ;
1337
1347
let checked_out_hash = checked_out_hash. trim_end ( ) ;
1338
1348
// Determine commit that the submodule *should* have.
1339
- let recorded = output (
1340
- helpers :: git ( Some ( & self . src ) )
1341
- . run_always ( )
1342
- . args ( [ "ls-tree" , "HEAD" ] )
1343
- . arg ( relative_path)
1344
- . as_command_mut ( ) ,
1345
- ) ;
1349
+ let recorded = helpers :: git ( Some ( & self . src ) )
1350
+ . allow_failure ( )
1351
+ . run_always ( )
1352
+ . args ( [ "ls-tree" , "HEAD" ] )
1353
+ . arg ( relative_path)
1354
+ . run_capture_stdout_exec_ctx ( self )
1355
+ . stdout ( ) ;
1346
1356
1347
1357
let actual_hash = recorded
1348
1358
. split_whitespace ( )
@@ -1366,20 +1376,18 @@ impl Config {
1366
1376
let update = |progress : bool | {
1367
1377
// Git is buggy and will try to fetch submodules from the tracking branch for *this* repository,
1368
1378
// even though that has no relation to the upstream for the submodule.
1369
- let current_branch = output_result (
1370
- helpers:: git ( Some ( & self . src ) )
1371
- . allow_failure ( )
1372
- . run_always ( )
1373
- . args ( [ "symbolic-ref" , "--short" , "HEAD" ] )
1374
- . as_command_mut ( ) ,
1375
- )
1376
- . map ( |b| b. trim ( ) . to_owned ( ) ) ;
1379
+ let current_branch = helpers:: git ( Some ( & self . src ) )
1380
+ . allow_failure ( )
1381
+ . run_always ( )
1382
+ . args ( [ "symbolic-ref" , "--short" , "HEAD" ] )
1383
+ . run_capture_exec_ctx ( self ) ;
1377
1384
1378
1385
let mut git = helpers:: git ( Some ( & self . src ) ) . allow_failure ( ) ;
1379
1386
git. run_always ( ) ;
1380
- if let Ok ( branch ) = current_branch {
1387
+ if current_branch . is_success ( ) {
1381
1388
// If there is a tag named after the current branch, git will try to disambiguate by prepending `heads/` to the branch name.
1382
1389
// This syntax isn't accepted by `branch.{branch}`. Strip it.
1390
+ let branch = current_branch. stdout ( ) ;
1383
1391
let branch = branch. strip_prefix ( "heads/" ) . unwrap_or ( & branch) ;
1384
1392
git. arg ( "-c" ) . arg ( format ! ( "branch.{branch}.remote=origin" ) ) ;
1385
1393
}
@@ -1425,7 +1433,8 @@ impl Config {
1425
1433
return ;
1426
1434
}
1427
1435
1428
- let stage0_output = output ( Command :: new ( program_path) . arg ( "--version" ) ) ;
1436
+ let stage0_output =
1437
+ command ( program_path) . arg ( "--version" ) . run_capture_stdout_exec_ctx ( self ) . stdout ( ) ;
1429
1438
let mut stage0_output = stage0_output. lines ( ) . next ( ) . unwrap ( ) . split ( ' ' ) ;
1430
1439
1431
1440
let stage0_name = stage0_output. next ( ) . unwrap ( ) ;
0 commit comments