diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index 6fd363935079d..31158870f394e 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -1074,11 +1074,11 @@ impl<'a> Builder<'a> { let mut hasher = sha2::Sha256::new(); // FIXME: this is ok for rustfmt (4.1 MB large at time of writing), but it seems memory-intensive for rustc and larger components. // Consider using streaming IO instead? - let contents = if self.config.dry_run { vec![] } else { t!(fs::read(path)) }; + let contents = if self.config.dry_run() { vec![] } else { t!(fs::read(path)) }; hasher.update(&contents); let found = hex::encode(hasher.finalize().as_slice()); let verified = found == expected; - if !verified && !self.config.dry_run { + if !verified && !self.config.dry_run() { println!( "invalid checksum: \n\ found: {found}\n\ @@ -1292,7 +1292,7 @@ impl<'a> Builder<'a> { /// Note that this returns `None` if LLVM is disabled, or if we're in a /// check build or dry-run, where there's no need to build all of LLVM. fn llvm_config(&self, target: TargetSelection) -> Option { - if self.config.llvm_enabled() && self.kind != Kind::Check && !self.config.dry_run { + if self.config.llvm_enabled() && self.kind != Kind::Check && !self.config.dry_run() { let llvm_config = self.ensure(native::Llvm { target }); if llvm_config.is_file() { return Some(llvm_config); @@ -1644,7 +1644,7 @@ impl<'a> Builder<'a> { // // Only clear out the directory if we're compiling std; otherwise, we // should let Cargo take care of things for us (via depdep info) - if !self.config.dry_run && mode == Mode::Std && cmd == "build" { + if !self.config.dry_run() && mode == Mode::Std && cmd == "build" { self.clear_if_dirty(&out_dir, &self.rustc(compiler)); } @@ -2142,7 +2142,7 @@ impl<'a> Builder<'a> { (out, dur - deps) }; - if self.config.print_step_timings && !self.config.dry_run { + if self.config.print_step_timings && !self.config.dry_run() { let step_string = format!("{:?}", step); let brace_index = step_string.find("{").unwrap_or(0); let type_string = type_name::(); @@ -2216,7 +2216,7 @@ impl<'a> Builder<'a> { } pub(crate) fn open_in_browser(&self, path: impl AsRef) { - if self.config.dry_run || !self.config.cmd.open() { + if self.config.dry_run() || !self.config.cmd.open() { return; } diff --git a/src/bootstrap/builder/tests.rs b/src/bootstrap/builder/tests.rs index 88bbcc93d072c..5f21d2b0067dc 100644 --- a/src/bootstrap/builder/tests.rs +++ b/src/bootstrap/builder/tests.rs @@ -1,5 +1,5 @@ use super::*; -use crate::config::{Config, TargetSelection}; +use crate::config::{Config, DryRun, TargetSelection}; use std::thread; fn configure(cmd: &str, host: &[&str], target: &[&str]) -> Config { @@ -10,7 +10,7 @@ fn configure_with_args(cmd: &[String], host: &[&str], target: &[&str]) -> Config let mut config = Config::parse(cmd); // don't save toolstates config.save_toolstates = None; - config.dry_run = true; + config.dry_run = DryRun::SelfCheck; // Ignore most submodules, since we don't need them for a dry run. // But make sure to check out the `doc` and `rust-analyzer` submodules, since some steps need them diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs index 18e780a108d5a..79e07be614c0b 100644 --- a/src/bootstrap/compile.rs +++ b/src/bootstrap/compile.rs @@ -447,7 +447,7 @@ fn copy_sanitizers( ) -> Vec { let runtimes: Vec = builder.ensure(native::Sanitizers { target }); - if builder.config.dry_run { + if builder.config.dry_run() { return Vec::new(); } @@ -986,7 +986,7 @@ impl Step for CodegenBackend { compiler.stage, backend, &compiler.host, target )); let files = run_cargo(builder, cargo, vec![], &tmp_stamp, vec![], false); - if builder.config.dry_run { + if builder.config.dry_run() { return; } let mut files = files.into_iter().filter(|f| { @@ -1034,7 +1034,7 @@ fn copy_codegen_backends_to_sysroot( let dst = builder.sysroot_codegen_backends(target_compiler); t!(fs::create_dir_all(&dst), dst); - if builder.config.dry_run { + if builder.config.dry_run() { return; } @@ -1332,7 +1332,7 @@ impl Step for Assemble { if builder.config.rust_codegen_backends.contains(&INTERNER.intern_str("llvm")) { let llvm_config_bin = builder.ensure(native::Llvm { target: target_compiler.host }); - if !builder.config.dry_run { + if !builder.config.dry_run() { let llvm_bin_dir = output(Command::new(llvm_config_bin).arg("--bindir")); let llvm_bin_dir = Path::new(llvm_bin_dir.trim()); @@ -1402,7 +1402,7 @@ pub fn run_cargo( additional_target_deps: Vec<(PathBuf, DependencyType)>, is_check: bool, ) -> Vec { - if builder.config.dry_run { + if builder.config.dry_run() { return Vec::new(); } @@ -1542,7 +1542,7 @@ pub fn stream_cargo( cb: &mut dyn FnMut(CargoMessage<'_>), ) -> bool { let mut cargo = Command::from(cargo); - if builder.config.dry_run { + if builder.config.dry_run() { return true; } // Instruct Cargo to give us json messages on stdout, critically leaving diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs index 2afce4fac42f8..e843bd411c172 100644 --- a/src/bootstrap/config.rs +++ b/src/bootstrap/config.rs @@ -33,6 +33,17 @@ macro_rules! check_ci_llvm { }; } +#[derive(Clone, Default)] +pub enum DryRun { + /// This isn't a dry run. + #[default] + Disabled, + /// This is a dry run enabled by bootstrap itself, so it can verify that no work is done. + SelfCheck, + /// This is a dry run enabled by the `--dry-run` flag. + UserSelected, +} + /// Global configuration for the entire build and/or bootstrap. /// /// This structure is derived from a combination of both `config.toml` and @@ -84,7 +95,7 @@ pub struct Config { pub jobs: Option, pub cmd: Subcommand, pub incremental: bool, - pub dry_run: bool, + pub dry_run: DryRun, /// `None` if we shouldn't download CI compiler artifacts, or the commit to download if we should. #[cfg(not(test))] download_rustc_commit: Option, @@ -820,7 +831,7 @@ impl Config { config.jobs = flags.jobs.map(threads_from_config); config.cmd = flags.cmd; config.incremental = flags.incremental; - config.dry_run = flags.dry_run; + config.dry_run = if flags.dry_run { DryRun::UserSelected } else { DryRun::Disabled }; config.keep_stage = flags.keep_stage; config.keep_stage_std = flags.keep_stage_std; config.color = flags.color; @@ -965,7 +976,7 @@ impl Config { .unwrap_or_else(|| config.out.join(config.build.triple).join("stage0/bin/cargo")); // NOTE: it's important this comes *after* we set `initial_rustc` just above. - if config.dry_run { + if config.dry_run() { let dir = config.out.join("tmp-dry-run"); t!(fs::create_dir_all(&dir)); config.out = dir; @@ -1372,6 +1383,13 @@ impl Config { config } + pub(crate) fn dry_run(&self) -> bool { + match self.dry_run { + DryRun::Disabled => false, + DryRun::SelfCheck | DryRun::UserSelected => true, + } + } + /// A git invocation which runs inside the source directory. /// /// Use this rather than `Command::new("git")` in order to support out-of-tree builds. @@ -1461,7 +1479,7 @@ impl Config { /// This is computed on demand since LLVM might have to first be downloaded from CI. pub(crate) fn llvm_link_shared(builder: &Builder<'_>) -> bool { let mut opt = builder.config.llvm_link_shared.get(); - if opt.is_none() && builder.config.dry_run { + if opt.is_none() && builder.config.dry_run() { // just assume static for now - dynamic linking isn't supported on all platforms return false; } @@ -1488,7 +1506,7 @@ impl Config { /// Return whether we will use a downloaded, pre-compiled version of rustc, or just build from source. pub(crate) fn download_rustc(builder: &Builder<'_>) -> bool { static DOWNLOAD_RUSTC: OnceCell = OnceCell::new(); - if builder.config.dry_run && DOWNLOAD_RUSTC.get().is_none() { + if builder.config.dry_run() && DOWNLOAD_RUSTC.get().is_none() { // avoid trying to actually download the commit return false; } @@ -1507,7 +1525,7 @@ impl Config { RustfmtState::SystemToolchain(p) | RustfmtState::Downloaded(p) => Some(p.clone()), RustfmtState::Unavailable => None, r @ RustfmtState::LazyEvaluated => { - if builder.config.dry_run { + if builder.config.dry_run() { return Some(PathBuf::new()); } let path = maybe_download_rustfmt(builder); diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs index 110a3ee4918da..9fbe476534eb7 100644 --- a/src/bootstrap/dist.rs +++ b/src/bootstrap/dist.rs @@ -945,7 +945,7 @@ impl Step for PlainSourceTarball { .arg(builder.src.join("./src/bootstrap/Cargo.toml")) .current_dir(&plain_dst_src); - let config = if !builder.config.dry_run { + let config = if !builder.config.dry_run() { t!(String::from_utf8(t!(cmd.output()).stdout)) } else { String::new() @@ -1386,7 +1386,7 @@ impl Step for Extended { let etc = builder.src.join("src/etc/installer"); // Avoid producing tarballs during a dry run. - if builder.config.dry_run { + if builder.config.dry_run() { return; } @@ -1818,7 +1818,7 @@ impl Step for Extended { let _time = timeit(builder); builder.run(&mut cmd); - if !builder.config.dry_run { + if !builder.config.dry_run() { t!(fs::rename(exe.join(&filename), distdir(builder).join(&filename))); } } @@ -1882,12 +1882,12 @@ fn maybe_install_llvm(builder: &Builder<'_>, target: TargetSelection, dst_libdir if llvm_dylib_path.exists() { builder.install(&llvm_dylib_path, dst_libdir, 0o644); } - !builder.config.dry_run + !builder.config.dry_run() } else if let Ok(llvm_config) = crate::native::prebuilt_llvm_config(builder, target) { let mut cmd = Command::new(llvm_config); cmd.arg("--libfiles"); builder.verbose(&format!("running {:?}", cmd)); - let files = if builder.config.dry_run { "".into() } else { output(&mut cmd) }; + let files = if builder.config.dry_run() { "".into() } else { output(&mut cmd) }; let build_llvm_out = &builder.llvm_out(builder.config.build); let target_llvm_out = &builder.llvm_out(target); for file in files.trim_end().split(' ') { @@ -1899,7 +1899,7 @@ fn maybe_install_llvm(builder: &Builder<'_>, target: TargetSelection, dst_libdir }; builder.install(&file, dst_libdir, 0o644); } - !builder.config.dry_run + !builder.config.dry_run() } else { false } diff --git a/src/bootstrap/doc.rs b/src/bootstrap/doc.rs index 280e232ca2dd0..c7d21bf3cdb3f 100644 --- a/src/bootstrap/doc.rs +++ b/src/bootstrap/doc.rs @@ -151,7 +151,7 @@ impl Step for RustbookSrc { let index = out.join("index.html"); let rustbook = builder.tool_exe(Tool::Rustbook); let mut rustbook_cmd = builder.tool_cmd(Tool::Rustbook); - if builder.config.dry_run || up_to_date(&src, &index) && up_to_date(&rustbook, &index) { + if builder.config.dry_run() || up_to_date(&src, &index) && up_to_date(&rustbook, &index) { return; } builder.info(&format!("Rustbook ({}) - {}", target, name)); @@ -331,8 +331,8 @@ impl Step for Standalone { && up_to_date(&footer, &html) && up_to_date(&favicon, &html) && up_to_date(&full_toc, &html) - && (builder.config.dry_run || up_to_date(&version_info, &html)) - && (builder.config.dry_run || up_to_date(&rustdoc, &html)) + && (builder.config.dry_run() || up_to_date(&version_info, &html)) + && (builder.config.dry_run() || up_to_date(&rustdoc, &html)) { continue; } @@ -402,7 +402,7 @@ impl Step for SharedAssets { let version_input = builder.src.join("src").join("doc").join("version_info.html.template"); let version_info = out.join("version_info.html"); - if !builder.config.dry_run && !up_to_date(&version_input, &version_info) { + if !builder.config.dry_run() && !up_to_date(&version_input, &version_info) { let info = t!(fs::read_to_string(&version_input)) .replace("VERSION", &builder.rust_release()) .replace("SHORT_HASH", builder.rust_info.sha_short().unwrap_or("")) @@ -900,7 +900,7 @@ impl Step for UnstableBookGen { } fn symlink_dir_force(config: &Config, src: &Path, dst: &Path) -> io::Result<()> { - if config.dry_run { + if config.dry_run() { return Ok(()); } if let Ok(m) = fs::symlink_metadata(dst) { diff --git a/src/bootstrap/format.rs b/src/bootstrap/format.rs index 37322670e6564..5e7264fe765a9 100644 --- a/src/bootstrap/format.rs +++ b/src/bootstrap/format.rs @@ -43,7 +43,7 @@ struct RustfmtConfig { } pub fn format(build: &Builder<'_>, check: bool, paths: &[PathBuf]) { - if build.config.dry_run { + if build.config.dry_run() { return; } let mut builder = ignore::types::TypesBuilder::new(); diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs index f5def8ba8341f..bbb5a18ba07ba 100644 --- a/src/bootstrap/lib.rs +++ b/src/bootstrap/lib.rs @@ -112,7 +112,7 @@ use std::path::{Path, PathBuf}; use std::process::Command; use std::str; -use config::Target; +use config::{DryRun, Target}; use filetime::FileTime; use once_cell::sync::OnceCell; @@ -430,7 +430,7 @@ impl Build { // we always try to use git for LLVM builds let in_tree_llvm_info = channel::GitInfo::new(false, &src.join("src/llvm-project")); - let initial_target_libdir_str = if config.dry_run { + let initial_target_libdir_str = if config.dry_run() { "/dummy/lib/path/to/lib/".to_string() } else { output( @@ -444,7 +444,7 @@ impl Build { let initial_target_dir = Path::new(&initial_target_libdir_str).parent().unwrap(); let initial_lld = initial_target_dir.join("bin").join("rust-lld"); - let initial_sysroot = if config.dry_run { + let initial_sysroot = if config.dry_run() { "/dummy".to_string() } else { output(Command::new(&config.initial_rustc).arg("--print").arg("sysroot")) @@ -689,13 +689,13 @@ impl Build { } } - if !self.config.dry_run { + if !self.config.dry_run() { { - self.config.dry_run = true; + self.config.dry_run = DryRun::SelfCheck; let builder = builder::Builder::new(&self); builder.execute_cli(); } - self.config.dry_run = false; + self.config.dry_run = DryRun::Disabled; let builder = builder::Builder::new(&self); builder.execute_cli(); } else { @@ -947,7 +947,7 @@ impl Build { /// Runs a command, printing out nice contextual information if it fails. fn run(&self, cmd: &mut Command) { - if self.config.dry_run { + if self.config.dry_run() { return; } self.verbose(&format!("running: {:?}", cmd)); @@ -956,7 +956,7 @@ impl Build { /// Runs a command, printing out nice contextual information if it fails. fn run_quiet(&self, cmd: &mut Command) { - if self.config.dry_run { + if self.config.dry_run() { return; } self.verbose(&format!("running: {:?}", cmd)); @@ -967,7 +967,7 @@ impl Build { /// Exits if the command failed to execute at all, otherwise returns its /// `status.success()`. fn try_run(&self, cmd: &mut Command) -> bool { - if self.config.dry_run { + if self.config.dry_run() { return true; } self.verbose(&format!("running: {:?}", cmd)); @@ -978,7 +978,7 @@ impl Build { /// Exits if the command failed to execute at all, otherwise returns its /// `status.success()`. fn try_run_quiet(&self, cmd: &mut Command) -> bool { - if self.config.dry_run { + if self.config.dry_run() { return true; } self.verbose(&format!("running: {:?}", cmd)); @@ -989,7 +989,7 @@ impl Build { /// Returns false if do not execute at all, otherwise returns its /// `status.success()`. fn check_run(&self, cmd: &mut Command) -> bool { - if self.config.dry_run { + if self.config.dry_run() { return true; } self.verbose(&format!("running: {:?}", cmd)); @@ -1019,10 +1019,12 @@ impl Build { } fn info(&self, msg: &str) { - if self.config.dry_run { - return; + match self.config.dry_run { + DryRun::SelfCheck => return, + DryRun::Disabled | DryRun::UserSelected => { + println!("{}", msg); + } } - println!("{}", msg); } /// Returns the number of parallel jobs that have been configured for this @@ -1400,7 +1402,7 @@ impl Build { } fn read_stamp_file(&self, stamp: &Path) -> Vec<(PathBuf, DependencyType)> { - if self.config.dry_run { + if self.config.dry_run() { return Vec::new(); } @@ -1440,7 +1442,7 @@ impl Build { } fn copy_internal(&self, src: &Path, dst: &Path, dereference_symlinks: bool) { - if self.config.dry_run { + if self.config.dry_run() { return; } self.verbose_than(1, &format!("Copy {:?} to {:?}", src, dst)); @@ -1477,7 +1479,7 @@ impl Build { /// Copies the `src` directory recursively to `dst`. Both are assumed to exist /// when this function is called. pub fn cp_r(&self, src: &Path, dst: &Path) { - if self.config.dry_run { + if self.config.dry_run() { return; } for f in self.read_dir(src) { @@ -1530,7 +1532,7 @@ impl Build { } fn install(&self, src: &Path, dstdir: &Path, perms: u32) { - if self.config.dry_run { + if self.config.dry_run() { return; } let dst = dstdir.join(src.file_name().unwrap()); @@ -1544,28 +1546,28 @@ impl Build { } fn create(&self, path: &Path, s: &str) { - if self.config.dry_run { + if self.config.dry_run() { return; } t!(fs::write(path, s)); } fn read(&self, path: &Path) -> String { - if self.config.dry_run { + if self.config.dry_run() { return String::new(); } t!(fs::read_to_string(path)) } fn create_dir(&self, dir: &Path) { - if self.config.dry_run { + if self.config.dry_run() { return; } t!(fs::create_dir_all(dir)) } fn remove_dir(&self, dir: &Path) { - if self.config.dry_run { + if self.config.dry_run() { return; } t!(fs::remove_dir_all(dir)) @@ -1574,7 +1576,7 @@ impl Build { fn read_dir(&self, dir: &Path) -> impl Iterator { let iter = match fs::read_dir(dir) { Ok(v) => v, - Err(_) if self.config.dry_run => return vec![].into_iter(), + Err(_) if self.config.dry_run() => return vec![].into_iter(), Err(err) => panic!("could not read dir {:?}: {:?}", dir, err), }; iter.map(|e| t!(e)).collect::>().into_iter() @@ -1585,11 +1587,11 @@ impl Build { use std::os::unix::fs::symlink as symlink_file; #[cfg(windows)] use std::os::windows::fs::symlink_file; - if !self.config.dry_run { symlink_file(src.as_ref(), link.as_ref()) } else { Ok(()) } + if !self.config.dry_run() { symlink_file(src.as_ref(), link.as_ref()) } else { Ok(()) } } fn remove(&self, f: &Path) { - if self.config.dry_run { + if self.config.dry_run() { return; } fs::remove_file(f).unwrap_or_else(|_| panic!("failed to remove {:?}", f)); diff --git a/src/bootstrap/native.rs b/src/bootstrap/native.rs index 94a61b727a32b..2407291ceea30 100644 --- a/src/bootstrap/native.rs +++ b/src/bootstrap/native.rs @@ -226,7 +226,7 @@ pub(crate) fn maybe_download_ci_llvm(builder: &Builder<'_>) { let llvm_stamp = llvm_root.join(".llvm-stamp"); let llvm_sha = detect_llvm_sha(&config, builder.rust_info.is_managed_git_subrepository()); let key = format!("{}{}", llvm_sha, config.llvm_assertions); - if program_out_of_date(&llvm_stamp, &key) && !config.dry_run { + if program_out_of_date(&llvm_stamp, &key) && !config.dry_run() { download_ci_llvm(builder, &llvm_sha); for entry in t!(fs::read_dir(llvm_root.join("bin"))) { builder.fix_bin_or_dylib(&t!(entry).path()); @@ -505,7 +505,7 @@ impl Step for Llvm { // https://llvm.org/docs/HowToCrossCompileLLVM.html if target != builder.config.build { let llvm_config = builder.ensure(Llvm { target: builder.config.build }); - if !builder.config.dry_run { + if !builder.config.dry_run() { let llvm_bindir = output(Command::new(&llvm_config).arg("--bindir")); let host_bin = Path::new(llvm_bindir.trim()); cfg.define( @@ -519,7 +519,7 @@ impl Step for Llvm { if builder.config.llvm_clang { let build_bin = builder.llvm_out(builder.config.build).join("build").join("bin"); let clang_tblgen = build_bin.join("clang-tblgen").with_extension(EXE_EXTENSION); - if !builder.config.dry_run && !clang_tblgen.exists() { + if !builder.config.dry_run() && !clang_tblgen.exists() { panic!("unable to find {}", clang_tblgen.display()); } cfg.define("CLANG_TABLEGEN", clang_tblgen); @@ -553,7 +553,7 @@ impl Step for Llvm { // tools. Figure out how to filter them down and only build the right // tools and libs on all platforms. - if builder.config.dry_run { + if builder.config.dry_run() { return build_llvm_config; } @@ -611,7 +611,7 @@ fn check_llvm_version(builder: &Builder<'_>, llvm_config: &Path) { return; } - if builder.config.dry_run { + if builder.config.dry_run() { return; } @@ -872,7 +872,7 @@ impl Step for Lld { /// Compile LLD for `target`. fn run(self, builder: &Builder<'_>) -> PathBuf { - if builder.config.dry_run { + if builder.config.dry_run() { return PathBuf::from("lld-out-dir-test-gen"); } let target = self.target; @@ -990,7 +990,7 @@ impl Step for TestHelpers { /// Compiles the `rust_test_helpers.c` library which we used in various /// `run-pass` tests for ABI testing. fn run(self, builder: &Builder<'_>) { - if builder.config.dry_run { + if builder.config.dry_run() { return; } // The x86_64-fortanix-unknown-sgx target doesn't have a working C @@ -1066,7 +1066,7 @@ impl Step for Sanitizers { } let llvm_config = builder.ensure(Llvm { target: builder.config.build }); - if builder.config.dry_run { + if builder.config.dry_run() { return runtimes; } @@ -1240,7 +1240,7 @@ impl Step for CrtBeginEnd { fn run(self, builder: &Builder<'_>) -> Self::Output { let out_dir = builder.native_dir(self.target).join("crt"); - if builder.config.dry_run { + if builder.config.dry_run() { return out_dir; } @@ -1304,7 +1304,7 @@ impl Step for Libunwind { /// Build linunwind.a fn run(self, builder: &Builder<'_>) -> Self::Output { - if builder.config.dry_run { + if builder.config.dry_run() { return PathBuf::new(); } diff --git a/src/bootstrap/sanity.rs b/src/bootstrap/sanity.rs index bdfd5fe5c421c..35c66cfd95f2f 100644 --- a/src/bootstrap/sanity.rs +++ b/src/bootstrap/sanity.rs @@ -163,7 +163,7 @@ than building it. continue; } - if !build.config.dry_run { + if !build.config.dry_run() { cmd_finder.must_have(build.cc(*target)); if let Some(ar) = build.ar(*target) { cmd_finder.must_have(ar); @@ -172,7 +172,7 @@ than building it. } for host in &build.hosts { - if !build.config.dry_run { + if !build.config.dry_run() { cmd_finder.must_have(build.cxx(*host).unwrap()); } } diff --git a/src/bootstrap/tarball.rs b/src/bootstrap/tarball.rs index d999b6c150333..82b063583c9f9 100644 --- a/src/bootstrap/tarball.rs +++ b/src/bootstrap/tarball.rs @@ -323,7 +323,7 @@ impl<'a> Tarball<'a> { // Ensure there are no symbolic links in the tarball. In particular, // rustup-toolchain-install-master and most versions of Windows can't handle symbolic links. let decompressed_output = self.temp_dir.join(&package_name); - if !self.builder.config.dry_run && !self.permit_symlinks { + if !self.builder.config.dry_run() && !self.permit_symlinks { for entry in walkdir::WalkDir::new(&decompressed_output) { let entry = t!(entry); if entry.path_is_symlink() { diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs index 2b2257b72ae79..fd362b8367cc0 100644 --- a/src/bootstrap/test.rs +++ b/src/bootstrap/test.rs @@ -508,7 +508,7 @@ impl Miri { cargo.arg("--print-sysroot"); // FIXME: Is there a way in which we can re-use the usual `run` helpers? - if builder.config.dry_run { + if builder.config.dry_run() { String::new() } else { builder.verbose(&format!("running: {:?}", cargo)); @@ -1537,7 +1537,7 @@ note: if you're sure you want to do this, please open an issue as to why. In the let mut copts_passed = false; if builder.config.llvm_enabled() { let llvm_config = builder.ensure(native::Llvm { target: builder.config.build }); - if !builder.config.dry_run { + if !builder.config.dry_run() { let llvm_version = output(Command::new(&llvm_config).arg("--version")); let llvm_components = output(Command::new(&llvm_config).arg("--components")); // Remove trailing newline from llvm-config output. @@ -1555,14 +1555,14 @@ note: if you're sure you want to do this, please open an issue as to why. In the // requirement, but the `-L` library path is not propagated across // separate compilations. We can add LLVM's library path to the // platform-specific environment variable as a workaround. - if !builder.config.dry_run && suite.ends_with("fulldeps") { + if !builder.config.dry_run() && suite.ends_with("fulldeps") { let llvm_libdir = output(Command::new(&llvm_config).arg("--libdir")); add_link_lib_path(vec![llvm_libdir.trim().into()], &mut cmd); } // Only pass correct values for these flags for the `run-make` suite as it // requires that a C++ compiler was configured which isn't always the case. - if !builder.config.dry_run && matches!(suite, "run-make" | "run-make-fulldeps") { + if !builder.config.dry_run() && matches!(suite, "run-make" | "run-make-fulldeps") { // The llvm/bin directory contains many useful cross-platform // tools. Pass the path to run-make tests so they can use them. let llvm_bin_path = llvm_config @@ -1590,7 +1590,7 @@ note: if you're sure you want to do this, please open an issue as to why. In the // Only pass correct values for these flags for the `run-make` suite as it // requires that a C++ compiler was configured which isn't always the case. - if !builder.config.dry_run && matches!(suite, "run-make" | "run-make-fulldeps") { + if !builder.config.dry_run() && matches!(suite, "run-make" | "run-make-fulldeps") { cmd.arg("--cc") .arg(builder.cc(target)) .arg("--cxx") diff --git a/src/bootstrap/tool.rs b/src/bootstrap/tool.rs index d395220694705..ba329ea6c7592 100644 --- a/src/bootstrap/tool.rs +++ b/src/bootstrap/tool.rs @@ -522,7 +522,7 @@ impl Step for Rustdoc { builder.ensure(compile::Rustc::new(build_compiler, target_compiler.host)); // NOTE: this implies that `download-rustc` is pretty useless when compiling with the stage0 // compiler, since you do just as much work. - if !builder.config.dry_run && builder.download_rustc() && build_compiler.stage == 0 { + if !builder.config.dry_run() && builder.download_rustc() && build_compiler.stage == 0 { println!( "warning: `download-rustc` does nothing when building stage1 tools; consider using `--stage 2` instead" ); diff --git a/src/bootstrap/toolstate.rs b/src/bootstrap/toolstate.rs index 1a17744322753..1969e0b6f8722 100644 --- a/src/bootstrap/toolstate.rs +++ b/src/bootstrap/toolstate.rs @@ -158,7 +158,7 @@ impl Step for ToolStateCheck { /// stable tool. That is, the status is not allowed to get worse /// (test-pass to test-fail or build-fail). fn run(self, builder: &Builder<'_>) { - if builder.config.dry_run { + if builder.config.dry_run() { return; } @@ -265,7 +265,7 @@ impl Builder<'_> { // If we're in a dry run setting we don't want to save toolstates as // that means if we e.g. panic down the line it'll look like we tested // everything (but we actually haven't). - if self.config.dry_run { + if self.config.dry_run() { return; } // Toolstate isn't tracked for clippy or rustfmt, but since most tools do, we avoid checking diff --git a/src/bootstrap/util.rs b/src/bootstrap/util.rs index 20c3801f0a502..8a2f46abbd23c 100644 --- a/src/bootstrap/util.rs +++ b/src/bootstrap/util.rs @@ -105,7 +105,7 @@ pub struct TimeIt(bool, Instant); /// Returns an RAII structure that prints out how long it took to drop. pub fn timeit(builder: &Builder<'_>) -> TimeIt { - TimeIt(builder.config.dry_run, Instant::now()) + TimeIt(builder.config.dry_run(), Instant::now()) } impl Drop for TimeIt { @@ -128,7 +128,7 @@ pub(crate) fn program_out_of_date(stamp: &Path, key: &str) -> bool { /// Symlinks two directories, using junctions on Windows and normal symlinks on /// Unix. pub fn symlink_dir(config: &Config, src: &Path, dest: &Path) -> io::Result<()> { - if config.dry_run { + if config.dry_run() { return Ok(()); } let _ = fs::remove_dir(dest);