Skip to content

Commit 71daffd

Browse files
authored
Unrolled build for #155732
Rollup merge of #155732 - ferrocene:jyn/dry-run, r=jieyouxu bootstrap: Don't clone submodules unconditionally in dry-run This made it very annoying to debug bootstrap itself, because every `--dry-run` invocation would start out by cloning LLVM, which is almost never necessary. Instead change a few Steps to properly support dry_run when no submodule is checked out. I tested this by running all of `check`, `build`, `doc`, `dist`, `install`, `vendor`, `clippy`, `fix`, and `miri` with `--dry-run`.
2 parents 0a4ee3f + bbdc7c4 commit 71daffd

2 files changed

Lines changed: 9 additions & 16 deletions

File tree

src/bootstrap/src/core/config/config.rs

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2448,25 +2448,15 @@ pub(crate) fn update_submodule<'a>(
24482448
return;
24492449
}
24502450

2451-
// Submodule updating actually happens during in the dry run mode. We need to make sure that
2452-
// all the git commands below are actually executed, because some follow-up code
2453-
// in bootstrap might depend on the submodules being checked out. Furthermore, not all
2454-
// the command executions below work with an empty output (produced during dry run).
2455-
// Therefore, all commands below are marked with `run_in_dry_run()`, so that they also run in
2456-
// dry run mode.
2457-
let submodule_git = || {
2458-
let mut cmd = helpers::git(Some(&absolute_path));
2459-
cmd.run_in_dry_run();
2460-
cmd
2461-
};
2451+
let submodule_git = || helpers::git(Some(&absolute_path));
24622452

24632453
// Determine commit checked out in submodule.
24642454
let checked_out_hash =
24652455
submodule_git().args(["rev-parse", "HEAD"]).run_capture_stdout(dwn_ctx.exec_ctx).stdout();
24662456
let checked_out_hash = checked_out_hash.trim_end();
24672457
// Determine commit that the submodule *should* have.
24682458
let recorded = helpers::git(Some(dwn_ctx.src))
2469-
.run_in_dry_run()
2459+
.run_in_dry_run() // otherwise parsing `actual_hash` fails
24702460
.args(["ls-tree", "HEAD"])
24712461
.arg(relative_path)
24722462
.run_capture_stdout(dwn_ctx.exec_ctx)
@@ -2482,11 +2472,12 @@ pub(crate) fn update_submodule<'a>(
24822472
return;
24832473
}
24842474

2485-
println!("Updating submodule {relative_path}");
2475+
if !dwn_ctx.exec_ctx.dry_run() {
2476+
println!("Updating submodule {relative_path}");
2477+
};
24862478

24872479
helpers::git(Some(dwn_ctx.src))
24882480
.allow_failure()
2489-
.run_in_dry_run()
24902481
.args(["submodule", "-q", "sync"])
24912482
.arg(relative_path)
24922483
.run(dwn_ctx.exec_ctx);
@@ -2497,12 +2488,10 @@ pub(crate) fn update_submodule<'a>(
24972488
// even though that has no relation to the upstream for the submodule.
24982489
let current_branch = helpers::git(Some(dwn_ctx.src))
24992490
.allow_failure()
2500-
.run_in_dry_run()
25012491
.args(["symbolic-ref", "--short", "HEAD"])
25022492
.run_capture(dwn_ctx.exec_ctx);
25032493

25042494
let mut git = helpers::git(Some(dwn_ctx.src)).allow_failure();
2505-
git.run_in_dry_run();
25062495
if current_branch.is_success() {
25072496
// If there is a tag named after the current branch, git will try to disambiguate by prepending `heads/` to the branch name.
25082497
// This syntax isn't accepted by `branch.{branch}`. Strip it.

src/bootstrap/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -676,6 +676,10 @@ impl Build {
676676
return;
677677
}
678678

679+
if self.config.dry_run() {
680+
return;
681+
}
682+
679683
// When testing bootstrap itself, it is much faster to ignore
680684
// submodules. Almost all Steps work fine without their submodules.
681685
if cfg!(test) && !self.config.submodules() {

0 commit comments

Comments
 (0)