From bbdc7c4cc5f80369ad94d4ac1fc5cf7da1f93ba0 Mon Sep 17 00:00:00 2001 From: Jynn Nelson Date: Fri, 24 Apr 2026 13:59:31 +0200 Subject: [PATCH] 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. --- src/bootstrap/src/core/config/config.rs | 21 +++++---------------- src/bootstrap/src/lib.rs | 4 ++++ 2 files changed, 9 insertions(+), 16 deletions(-) diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs index babcafb024e0..b933e668c26a 100644 --- a/src/bootstrap/src/core/config/config.rs +++ b/src/bootstrap/src/core/config/config.rs @@ -2448,17 +2448,7 @@ pub(crate) fn update_submodule<'a>( return; } - // Submodule updating actually happens during in the dry run mode. We need to make sure that - // all the git commands below are actually executed, because some follow-up code - // in bootstrap might depend on the submodules being checked out. Furthermore, not all - // the command executions below work with an empty output (produced during dry run). - // Therefore, all commands below are marked with `run_in_dry_run()`, so that they also run in - // dry run mode. - let submodule_git = || { - let mut cmd = helpers::git(Some(&absolute_path)); - cmd.run_in_dry_run(); - cmd - }; + let submodule_git = || helpers::git(Some(&absolute_path)); // Determine commit checked out in submodule. let checked_out_hash = @@ -2466,7 +2456,7 @@ pub(crate) fn update_submodule<'a>( let checked_out_hash = checked_out_hash.trim_end(); // Determine commit that the submodule *should* have. let recorded = helpers::git(Some(dwn_ctx.src)) - .run_in_dry_run() + .run_in_dry_run() // otherwise parsing `actual_hash` fails .args(["ls-tree", "HEAD"]) .arg(relative_path) .run_capture_stdout(dwn_ctx.exec_ctx) @@ -2482,11 +2472,12 @@ pub(crate) fn update_submodule<'a>( return; } - println!("Updating submodule {relative_path}"); + if !dwn_ctx.exec_ctx.dry_run() { + println!("Updating submodule {relative_path}"); + }; helpers::git(Some(dwn_ctx.src)) .allow_failure() - .run_in_dry_run() .args(["submodule", "-q", "sync"]) .arg(relative_path) .run(dwn_ctx.exec_ctx); @@ -2497,12 +2488,10 @@ pub(crate) fn update_submodule<'a>( // even though that has no relation to the upstream for the submodule. let current_branch = helpers::git(Some(dwn_ctx.src)) .allow_failure() - .run_in_dry_run() .args(["symbolic-ref", "--short", "HEAD"]) .run_capture(dwn_ctx.exec_ctx); let mut git = helpers::git(Some(dwn_ctx.src)).allow_failure(); - git.run_in_dry_run(); if current_branch.is_success() { // If there is a tag named after the current branch, git will try to disambiguate by prepending `heads/` to the branch name. // This syntax isn't accepted by `branch.{branch}`. Strip it. diff --git a/src/bootstrap/src/lib.rs b/src/bootstrap/src/lib.rs index 6af11d9ae0a8..fd3d129c231d 100644 --- a/src/bootstrap/src/lib.rs +++ b/src/bootstrap/src/lib.rs @@ -676,6 +676,10 @@ pub fn require_submodule(&self, submodule: &str, err_hint: Option<&str>) { return; } + if self.config.dry_run() { + return; + } + // When testing bootstrap itself, it is much faster to ignore // submodules. Almost all Steps work fine without their submodules. if cfg!(test) && !self.config.submodules() {