From 73660649cd9663e98d07458a62d967de1ad33fd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Sat, 29 Jun 2024 15:01:11 +0200 Subject: [PATCH] Add `run` method to `BootstrapCommand` This makes it easier to use commands in a "Fluent-API" style, and also removes the need for the `AsMut` trait hack that was used before to allow passing both `BootstrapCommand` and `&mut BootstrapCommand` to `Builder::run`. The `Builder::run` method was still kept and can be used explicitly, if needed for some reason. --- src/bootstrap/src/core/build_steps/clean.rs | 2 +- src/bootstrap/src/core/build_steps/compile.rs | 25 +- src/bootstrap/src/core/build_steps/dist.rs | 257 +++++++++--------- src/bootstrap/src/core/build_steps/doc.rs | 38 +-- src/bootstrap/src/core/build_steps/format.rs | 34 +-- src/bootstrap/src/core/build_steps/install.rs | 2 +- src/bootstrap/src/core/build_steps/llvm.rs | 17 +- src/bootstrap/src/core/build_steps/perf.rs | 2 +- src/bootstrap/src/core/build_steps/run.rs | 16 +- src/bootstrap/src/core/build_steps/suggest.rs | 12 +- .../src/core/build_steps/synthetic_targets.rs | 2 +- src/bootstrap/src/core/build_steps/test.rs | 80 +++--- src/bootstrap/src/core/build_steps/tool.rs | 8 +- src/bootstrap/src/core/build_steps/vendor.rs | 2 +- src/bootstrap/src/core/builder.rs | 6 +- src/bootstrap/src/core/metadata.rs | 2 +- src/bootstrap/src/core/sanity.rs | 2 +- src/bootstrap/src/lib.rs | 67 +++-- src/bootstrap/src/utils/cc_detect.rs | 4 +- src/bootstrap/src/utils/exec.rs | 10 +- src/bootstrap/src/utils/helpers.rs | 2 +- src/bootstrap/src/utils/tarball.rs | 2 +- 22 files changed, 296 insertions(+), 296 deletions(-) diff --git a/src/bootstrap/src/core/build_steps/clean.rs b/src/bootstrap/src/core/build_steps/clean.rs index 479af4af666..a4be6bc56c5 100644 --- a/src/bootstrap/src/core/build_steps/clean.rs +++ b/src/bootstrap/src/core/build_steps/clean.rs @@ -85,7 +85,7 @@ macro_rules! clean_crate_tree { // NOTE: doesn't use `run_cargo` because we don't want to save a stamp file, // and doesn't use `stream_cargo` to avoid passing `--message-format` which `clean` doesn't accept. - builder.run(cargo); + cargo.run(builder); } } )+ } diff --git a/src/bootstrap/src/core/build_steps/compile.rs b/src/bootstrap/src/core/build_steps/compile.rs index 01b25224de4..4cabc77f2be 100644 --- a/src/bootstrap/src/core/build_steps/compile.rs +++ b/src/bootstrap/src/core/build_steps/compile.rs @@ -779,14 +779,13 @@ impl Step for StartupObjects { // a local_rebuild compiler already has stage1 features cmd.arg("--cfg").arg("bootstrap"); } - builder.run( - cmd.arg("--target") - .arg(target.rustc_target_arg()) - .arg("--emit=obj") - .arg("-o") - .arg(dst_file) - .arg(src_file), - ); + cmd.arg("--target") + .arg(target.rustc_target_arg()) + .arg("--emit=obj") + .arg("-o") + .arg(dst_file) + .arg(src_file) + .run(builder); } let target = sysroot_dir.join((*file).to_string() + ".o"); @@ -1491,7 +1490,7 @@ pub fn compiler_file( let mut cmd = BootstrapCommand::new(compiler); cmd.args(builder.cflags(target, GitRepo::Rustc, c)); cmd.arg(format!("-print-file-name={file}")); - let out = builder.run(cmd.capture_stdout()).stdout(); + let out = cmd.capture_stdout().run(builder).stdout(); PathBuf::from(out.trim()) } @@ -1836,8 +1835,10 @@ impl Step for Assemble { let llvm::LlvmResult { llvm_config, .. } = builder.ensure(llvm::Llvm { target: target_compiler.host }); if !builder.config.dry_run() && builder.config.llvm_tools_enabled { - let llvm_bin_dir = builder - .run(BootstrapCommand::new(llvm_config).capture_stdout().arg("--bindir")) + let llvm_bin_dir = BootstrapCommand::new(llvm_config) + .capture_stdout() + .arg("--bindir") + .run(builder) .stdout(); let llvm_bin_dir = Path::new(llvm_bin_dir.trim()); @@ -2163,7 +2164,7 @@ pub fn strip_debug(builder: &Builder<'_>, target: TargetSelection, path: &Path) } let previous_mtime = FileTime::from_last_modification_time(&path.metadata().unwrap()); - builder.run(BootstrapCommand::new("strip").capture().arg("--strip-debug").arg(path)); + BootstrapCommand::new("strip").capture().arg("--strip-debug").arg(path).run(builder); // After running `strip`, we have to set the file modification time to what it was before, // otherwise we risk Cargo invalidating its fingerprint and rebuilding the world next time diff --git a/src/bootstrap/src/core/build_steps/dist.rs b/src/bootstrap/src/core/build_steps/dist.rs index 3dc871b1ca9..0a7f3ec6b79 100644 --- a/src/bootstrap/src/core/build_steps/dist.rs +++ b/src/bootstrap/src/core/build_steps/dist.rs @@ -182,7 +182,7 @@ fn make_win_dist( //Ask gcc where it keeps its stuff let mut cmd = BootstrapCommand::new(builder.cc(target)); cmd.arg("-print-search-dirs"); - let gcc_out = builder.run(cmd.capture_stdout()).stdout(); + let gcc_out = cmd.capture_stdout().run(builder).stdout(); let mut bin_path: Vec<_> = env::split_paths(&env::var_os("PATH").unwrap_or_default()).collect(); let mut lib_path = Vec::new(); @@ -1061,7 +1061,7 @@ impl Step for PlainSourceTarball { } let config = if !builder.config.dry_run() { - builder.run(cmd.capture()).stdout() + cmd.capture().run(builder).stdout() } else { String::new() }; @@ -1606,7 +1606,7 @@ impl Step for Extended { .arg(pkg.join(component)) .arg("--nopayload") .arg(pkg.join(component).with_extension("pkg")); - builder.run(cmd); + cmd.run(builder); }; let prepare = |name: &str| { @@ -1649,7 +1649,7 @@ impl Step for Extended { .arg("--package-path") .arg(&pkg); let _time = timeit(builder); - builder.run(cmd); + cmd.run(builder); } if target.is_windows() { @@ -1703,162 +1703,153 @@ impl Step for Extended { let light = wix.join("bin/light.exe"); let heat_flags = ["-nologo", "-gg", "-sfrag", "-srd", "-sreg"]; - builder.run( - BootstrapCommand::new(&heat) - .current_dir(&exe) - .arg("dir") - .arg("rustc") - .args(heat_flags) - .arg("-cg") - .arg("RustcGroup") - .arg("-dr") - .arg("Rustc") - .arg("-var") - .arg("var.RustcDir") - .arg("-out") - .arg(exe.join("RustcGroup.wxs")), - ); + BootstrapCommand::new(&heat) + .current_dir(&exe) + .arg("dir") + .arg("rustc") + .args(heat_flags) + .arg("-cg") + .arg("RustcGroup") + .arg("-dr") + .arg("Rustc") + .arg("-var") + .arg("var.RustcDir") + .arg("-out") + .arg(exe.join("RustcGroup.wxs")) + .run(builder); if built_tools.contains("rust-docs") { - builder.run( - BootstrapCommand::new(&heat) - .current_dir(&exe) - .arg("dir") - .arg("rust-docs") - .args(heat_flags) - .arg("-cg") - .arg("DocsGroup") - .arg("-dr") - .arg("Docs") - .arg("-var") - .arg("var.DocsDir") - .arg("-out") - .arg(exe.join("DocsGroup.wxs")) - .arg("-t") - .arg(etc.join("msi/squash-components.xsl")), - ); - } - builder.run( BootstrapCommand::new(&heat) .current_dir(&exe) .arg("dir") - .arg("cargo") + .arg("rust-docs") .args(heat_flags) .arg("-cg") - .arg("CargoGroup") + .arg("DocsGroup") .arg("-dr") - .arg("Cargo") + .arg("Docs") .arg("-var") - .arg("var.CargoDir") + .arg("var.DocsDir") .arg("-out") - .arg(exe.join("CargoGroup.wxs")) + .arg(exe.join("DocsGroup.wxs")) .arg("-t") - .arg(etc.join("msi/remove-duplicates.xsl")), - ); - builder.run( + .arg(etc.join("msi/squash-components.xsl")) + .run(builder); + } + BootstrapCommand::new(&heat) + .current_dir(&exe) + .arg("dir") + .arg("cargo") + .args(heat_flags) + .arg("-cg") + .arg("CargoGroup") + .arg("-dr") + .arg("Cargo") + .arg("-var") + .arg("var.CargoDir") + .arg("-out") + .arg(exe.join("CargoGroup.wxs")) + .arg("-t") + .arg(etc.join("msi/remove-duplicates.xsl")) + .run(builder); + BootstrapCommand::new(&heat) + .current_dir(&exe) + .arg("dir") + .arg("rust-std") + .args(heat_flags) + .arg("-cg") + .arg("StdGroup") + .arg("-dr") + .arg("Std") + .arg("-var") + .arg("var.StdDir") + .arg("-out") + .arg(exe.join("StdGroup.wxs")) + .run(builder); + if built_tools.contains("rust-analyzer") { BootstrapCommand::new(&heat) .current_dir(&exe) .arg("dir") - .arg("rust-std") + .arg("rust-analyzer") .args(heat_flags) .arg("-cg") - .arg("StdGroup") + .arg("RustAnalyzerGroup") .arg("-dr") - .arg("Std") + .arg("RustAnalyzer") .arg("-var") - .arg("var.StdDir") + .arg("var.RustAnalyzerDir") .arg("-out") - .arg(exe.join("StdGroup.wxs")), - ); - if built_tools.contains("rust-analyzer") { - builder.run( - BootstrapCommand::new(&heat) - .current_dir(&exe) - .arg("dir") - .arg("rust-analyzer") - .args(heat_flags) - .arg("-cg") - .arg("RustAnalyzerGroup") - .arg("-dr") - .arg("RustAnalyzer") - .arg("-var") - .arg("var.RustAnalyzerDir") - .arg("-out") - .arg(exe.join("RustAnalyzerGroup.wxs")) - .arg("-t") - .arg(etc.join("msi/remove-duplicates.xsl")), - ); + .arg(exe.join("RustAnalyzerGroup.wxs")) + .arg("-t") + .arg(etc.join("msi/remove-duplicates.xsl")) + .run(builder); } if built_tools.contains("clippy") { - builder.run( - BootstrapCommand::new(&heat) - .current_dir(&exe) - .arg("dir") - .arg("clippy") - .args(heat_flags) - .arg("-cg") - .arg("ClippyGroup") - .arg("-dr") - .arg("Clippy") - .arg("-var") - .arg("var.ClippyDir") - .arg("-out") - .arg(exe.join("ClippyGroup.wxs")) - .arg("-t") - .arg(etc.join("msi/remove-duplicates.xsl")), - ); - } - if built_tools.contains("miri") { - builder.run( - BootstrapCommand::new(&heat) - .current_dir(&exe) - .arg("dir") - .arg("miri") - .args(heat_flags) - .arg("-cg") - .arg("MiriGroup") - .arg("-dr") - .arg("Miri") - .arg("-var") - .arg("var.MiriDir") - .arg("-out") - .arg(exe.join("MiriGroup.wxs")) - .arg("-t") - .arg(etc.join("msi/remove-duplicates.xsl")), - ); - } - builder.run( BootstrapCommand::new(&heat) .current_dir(&exe) .arg("dir") - .arg("rust-analysis") + .arg("clippy") .args(heat_flags) .arg("-cg") - .arg("AnalysisGroup") + .arg("ClippyGroup") .arg("-dr") - .arg("Analysis") + .arg("Clippy") .arg("-var") - .arg("var.AnalysisDir") + .arg("var.ClippyDir") .arg("-out") - .arg(exe.join("AnalysisGroup.wxs")) + .arg(exe.join("ClippyGroup.wxs")) .arg("-t") - .arg(etc.join("msi/remove-duplicates.xsl")), - ); + .arg(etc.join("msi/remove-duplicates.xsl")) + .run(builder); + } + if built_tools.contains("miri") { + BootstrapCommand::new(&heat) + .current_dir(&exe) + .arg("dir") + .arg("miri") + .args(heat_flags) + .arg("-cg") + .arg("MiriGroup") + .arg("-dr") + .arg("Miri") + .arg("-var") + .arg("var.MiriDir") + .arg("-out") + .arg(exe.join("MiriGroup.wxs")) + .arg("-t") + .arg(etc.join("msi/remove-duplicates.xsl")) + .run(builder); + } + BootstrapCommand::new(&heat) + .current_dir(&exe) + .arg("dir") + .arg("rust-analysis") + .args(heat_flags) + .arg("-cg") + .arg("AnalysisGroup") + .arg("-dr") + .arg("Analysis") + .arg("-var") + .arg("var.AnalysisDir") + .arg("-out") + .arg(exe.join("AnalysisGroup.wxs")) + .arg("-t") + .arg(etc.join("msi/remove-duplicates.xsl")) + .run(builder); if target.ends_with("windows-gnu") { - builder.run( - BootstrapCommand::new(&heat) - .current_dir(&exe) - .arg("dir") - .arg("rust-mingw") - .args(heat_flags) - .arg("-cg") - .arg("GccGroup") - .arg("-dr") - .arg("Gcc") - .arg("-var") - .arg("var.GccDir") - .arg("-out") - .arg(exe.join("GccGroup.wxs")), - ); + BootstrapCommand::new(&heat) + .current_dir(&exe) + .arg("dir") + .arg("rust-mingw") + .args(heat_flags) + .arg("-cg") + .arg("GccGroup") + .arg("-dr") + .arg("Gcc") + .arg("-var") + .arg("var.GccDir") + .arg("-out") + .arg(exe.join("GccGroup.wxs")) + .run(builder); } let candle = |input: &Path| { @@ -1893,7 +1884,7 @@ impl Step for Extended { if target.ends_with("windows-gnu") { cmd.arg("-dGccDir=rust-mingw"); } - builder.run(cmd); + cmd.run(builder); }; candle(&xform(&etc.join("msi/rust.wxs"))); candle(&etc.join("msi/ui.wxs")); @@ -1962,7 +1953,7 @@ impl Step for Extended { cmd.arg("-sice:ICE57"); let _time = timeit(builder); - builder.run(cmd); + cmd.run(builder); if !builder.config.dry_run() { t!(move_file(exe.join(&filename), distdir(builder).join(&filename))); @@ -2084,7 +2075,7 @@ fn maybe_install_llvm( let files = if builder.config.dry_run() { "".into() } else { - builder.run(cmd.capture_stdout()).stdout() + cmd.capture_stdout().run(builder).stdout() }; let build_llvm_out = &builder.llvm_out(builder.config.build); let target_llvm_out = &builder.llvm_out(target); diff --git a/src/bootstrap/src/core/build_steps/doc.rs b/src/bootstrap/src/core/build_steps/doc.rs index 823e842693e..4b35d6c5d4c 100644 --- a/src/bootstrap/src/core/build_steps/doc.rs +++ b/src/bootstrap/src/core/build_steps/doc.rs @@ -154,7 +154,7 @@ impl Step for RustbookSrc

{ builder.info(&format!("Rustbook ({target}) - {name}")); let _ = fs::remove_dir_all(&out); - builder.run(rustbook_cmd.arg("build").arg(&src).arg("-d").arg(&out)); + rustbook_cmd.arg("build").arg(&src).arg("-d").arg(&out).run(builder); for lang in &self.languages { let out = out.join(lang); @@ -162,10 +162,15 @@ impl Step for RustbookSrc

{ builder.info(&format!("Rustbook ({target}) - {name} - {lang}")); let _ = fs::remove_dir_all(&out); - let mut rustbook_cmd = builder.tool_cmd(Tool::Rustbook); - builder.run( - rustbook_cmd.arg("build").arg(&src).arg("-d").arg(&out).arg("-l").arg(lang), - ); + builder + .tool_cmd(Tool::Rustbook) + .arg("build") + .arg(&src) + .arg("-d") + .arg(&out) + .arg("-l") + .arg(lang) + .run(builder); } } @@ -301,7 +306,7 @@ fn invoke_rustdoc( cmd.arg("-Z").arg("unstable-options").arg("--disable-minification"); } - builder.run(cmd); + cmd.run(builder); } #[derive(Debug, Clone, Hash, PartialEq, Eq)] @@ -395,7 +400,7 @@ impl Step for Standalone { } else { cmd.arg("--markdown-css").arg("rust.css"); } - builder.run(cmd); + cmd.run(builder); } // We open doc/index.html as the default if invoked as `x.py doc --open` @@ -494,7 +499,7 @@ impl Step for Releases { cmd.arg("--disable-minification"); } - builder.run(cmd); + cmd.run(builder); } // We open doc/RELEASES.html as the default if invoked as `x.py doc --open RELEASES.md` @@ -738,7 +743,7 @@ fn doc_std( format!("library{} in {} format", crate_description(requested_crates), format.as_str()); let _guard = builder.msg_doc(compiler, description, target); - builder.run(cargo.into_cmd()); + cargo.into_cmd().run(builder); builder.cp_link_r(&out_dir, out); } @@ -863,7 +868,7 @@ impl Step for Rustc { let proc_macro_out_dir = builder.stage_out(compiler, Mode::Rustc).join("doc"); symlink_dir_force(&builder.config, &out, &proc_macro_out_dir); - builder.run(cargo.into_cmd()); + cargo.into_cmd().run(builder); if !builder.config.dry_run() { // Sanity check on linked compiler crates @@ -996,7 +1001,7 @@ macro_rules! tool_doc { symlink_dir_force(&builder.config, &out, &proc_macro_out_dir); let _guard = builder.msg_doc(compiler, stringify!($tool).to_lowercase(), target); - builder.run(cargo.into_cmd()); + cargo.into_cmd().run(builder); if !builder.config.dry_run() { // Sanity check on linked doc directories @@ -1075,12 +1080,7 @@ impl Step for ErrorIndex { builder.info(&format!("Documenting error index ({})", self.target)); let out = builder.doc_out(self.target); t!(fs::create_dir_all(&out)); - let mut index = tool::ErrorIndex::command(builder); - index.arg("html"); - index.arg(out); - index.arg(&builder.version); - - builder.run(index); + tool::ErrorIndex::command(builder).arg("html").arg(out).arg(&builder.version).run(builder); } } @@ -1116,7 +1116,7 @@ impl Step for UnstableBookGen { cmd.arg(builder.src.join("src")); cmd.arg(out); - builder.run(cmd); + cmd.run(builder); } } @@ -1211,7 +1211,7 @@ impl Step for RustcBook { self.compiler.host, self.target, ); - builder.run(cmd); + cmd.run(builder); drop(doc_generator_guard); // Run rustbook/mdbook to generate the HTML pages. diff --git a/src/bootstrap/src/core/build_steps/format.rs b/src/bootstrap/src/core/build_steps/format.rs index 66286a52813..04b3ec770d2 100644 --- a/src/bootstrap/src/core/build_steps/format.rs +++ b/src/bootstrap/src/core/build_steps/format.rs @@ -60,7 +60,7 @@ fn get_rustfmt_version(build: &Builder<'_>) -> Option<(String, PathBuf)> { }); cmd.arg("--version"); - let output = build.run(cmd.capture().allow_failure()); + let output = cmd.capture().allow_failure().run(build); if output.is_failure() { return None; } @@ -160,29 +160,25 @@ pub fn format(build: &Builder<'_>, check: bool, all: bool, paths: &[PathBuf]) { } } let git_available = - build.run(helpers::git(None).capture().allow_failure().arg("--version")).is_success(); + helpers::git(None).capture().allow_failure().arg("--version").run(build).is_success(); let mut adjective = None; if git_available { - let in_working_tree = build - .run( - helpers::git(Some(&build.src)) - .capture() - .allow_failure() - .arg("rev-parse") - .arg("--is-inside-work-tree"), - ) + let in_working_tree = helpers::git(Some(&build.src)) + .capture() + .allow_failure() + .arg("rev-parse") + .arg("--is-inside-work-tree") + .run(build) .is_success(); if in_working_tree { - let untracked_paths_output = build - .run( - helpers::git(Some(&build.src)) - .capture_stdout() - .arg("status") - .arg("--porcelain") - .arg("-z") - .arg("--untracked-files=normal"), - ) + let untracked_paths_output = helpers::git(Some(&build.src)) + .capture_stdout() + .arg("status") + .arg("--porcelain") + .arg("-z") + .arg("--untracked-files=normal") + .run(build) .stdout(); let untracked_paths: Vec<_> = untracked_paths_output .split_terminator('\0') diff --git a/src/bootstrap/src/core/build_steps/install.rs b/src/bootstrap/src/core/build_steps/install.rs index 7ee1aca2abc..2cb745deff6 100644 --- a/src/bootstrap/src/core/build_steps/install.rs +++ b/src/bootstrap/src/core/build_steps/install.rs @@ -113,7 +113,7 @@ fn install_sh( .arg(format!("--libdir={}", prepare_dir(&destdir_env, libdir))) .arg(format!("--mandir={}", prepare_dir(&destdir_env, mandir))) .arg("--disable-ldconfig"); - builder.run(cmd); + cmd.run(builder); t!(fs::remove_dir_all(&empty_dir)); } diff --git a/src/bootstrap/src/core/build_steps/llvm.rs b/src/bootstrap/src/core/build_steps/llvm.rs index 4f1c1f87d1c..32414e4e397 100644 --- a/src/bootstrap/src/core/build_steps/llvm.rs +++ b/src/bootstrap/src/core/build_steps/llvm.rs @@ -478,8 +478,10 @@ impl Step for Llvm { let LlvmResult { llvm_config, .. } = builder.ensure(Llvm { target: builder.config.build }); if !builder.config.dry_run() { - let llvm_bindir = builder - .run(BootstrapCommand::new(&llvm_config).capture_stdout().arg("--bindir")) + let llvm_bindir = BootstrapCommand::new(&llvm_config) + .capture_stdout() + .arg("--bindir") + .run(builder) .stdout(); let host_bin = Path::new(llvm_bindir.trim()); cfg.define( @@ -530,8 +532,11 @@ impl Step for Llvm { // Helper to find the name of LLVM's shared library on darwin and linux. let find_llvm_lib_name = |extension| { - let cmd = BootstrapCommand::new(&res.llvm_config); - let version = builder.run(cmd.capture_stdout().arg("--version")).stdout(); + let version = BootstrapCommand::new(&res.llvm_config) + .capture_stdout() + .arg("--version") + .run(builder) + .stdout(); let major = version.split('.').next().unwrap(); match &llvm_version_suffix { @@ -587,8 +592,8 @@ fn check_llvm_version(builder: &Builder<'_>, llvm_config: &Path) { return; } - let cmd = BootstrapCommand::new(llvm_config); - let version = builder.run(cmd.capture_stdout().arg("--version")).stdout(); + let version = + BootstrapCommand::new(llvm_config).capture_stdout().arg("--version").run(builder).stdout(); let mut parts = version.split('.').take(2).filter_map(|s| s.parse::().ok()); if let (Some(major), Some(_minor)) = (parts.next(), parts.next()) { if major >= 17 { diff --git a/src/bootstrap/src/core/build_steps/perf.rs b/src/bootstrap/src/core/build_steps/perf.rs index f41b5fe10f1..5b83080a326 100644 --- a/src/bootstrap/src/core/build_steps/perf.rs +++ b/src/bootstrap/src/core/build_steps/perf.rs @@ -31,5 +31,5 @@ Consider setting `rust.debuginfo-level = 1` in `config.toml`."#); .env("PERF_COLLECTOR", collector) .env("PERF_RESULT_DIR", profile_results_dir) .args(args); - builder.run(&mut cmd); + cmd.run(builder); } diff --git a/src/bootstrap/src/core/build_steps/run.rs b/src/bootstrap/src/core/build_steps/run.rs index 316a03a2171..7088cd0d4c2 100644 --- a/src/bootstrap/src/core/build_steps/run.rs +++ b/src/bootstrap/src/core/build_steps/run.rs @@ -41,7 +41,7 @@ impl Step for BuildManifest { }); let today = - builder.run(BootstrapCommand::new("date").capture_stdout().arg("+%Y-%m-%d")).stdout(); + BootstrapCommand::new("date").capture_stdout().arg("+%Y-%m-%d").run(builder).stdout(); cmd.arg(sign); cmd.arg(distdir(builder)); @@ -50,7 +50,7 @@ impl Step for BuildManifest { cmd.arg(&builder.config.channel); builder.create_dir(&distdir(builder)); - builder.run(cmd); + cmd.run(builder); } } @@ -72,7 +72,7 @@ impl Step for BumpStage0 { fn run(self, builder: &Builder<'_>) -> Self::Output { let mut cmd = builder.tool_cmd(Tool::BumpStage0); cmd.args(builder.config.args()); - builder.run(cmd); + cmd.run(builder); } } @@ -94,7 +94,7 @@ impl Step for ReplaceVersionPlaceholder { fn run(self, builder: &Builder<'_>) -> Self::Output { let mut cmd = builder.tool_cmd(Tool::ReplaceVersionPlaceholder); cmd.arg(&builder.src); - builder.run(cmd); + cmd.run(builder); } } @@ -158,7 +158,7 @@ impl Step for Miri { // after another --, so this must be at the end. miri.args(builder.config.args()); - builder.run(miri.into_cmd()); + miri.into_cmd().run(builder); } } @@ -188,7 +188,7 @@ impl Step for CollectLicenseMetadata { let mut cmd = builder.tool_cmd(Tool::CollectLicenseMetadata); cmd.env("REUSE_EXE", reuse); cmd.env("DEST", &dest); - builder.run(cmd); + cmd.run(builder); dest } @@ -218,7 +218,7 @@ impl Step for GenerateCopyright { let mut cmd = builder.tool_cmd(Tool::GenerateCopyright); cmd.env("LICENSE_METADATA", &license_metadata); cmd.env("DEST", &dest); - builder.run(cmd); + cmd.run(builder); dest } @@ -242,7 +242,7 @@ impl Step for GenerateWindowsSys { fn run(self, builder: &Builder<'_>) { let mut cmd = builder.tool_cmd(Tool::GenerateWindowsSys); cmd.arg(&builder.src); - builder.run(cmd); + cmd.run(builder); } } diff --git a/src/bootstrap/src/core/build_steps/suggest.rs b/src/bootstrap/src/core/build_steps/suggest.rs index 5412b3c807b..2d4409d27c6 100644 --- a/src/bootstrap/src/core/build_steps/suggest.rs +++ b/src/bootstrap/src/core/build_steps/suggest.rs @@ -13,13 +13,11 @@ use crate::core::builder::Builder; pub fn suggest(builder: &Builder<'_>, run: bool) { let git_config = builder.config.git_config(); let suggestions = builder - .run( - builder - .tool_cmd(Tool::SuggestTests) - .capture_stdout() - .env("SUGGEST_TESTS_GIT_REPOSITORY", git_config.git_repository) - .env("SUGGEST_TESTS_NIGHTLY_BRANCH", git_config.nightly_branch), - ) + .tool_cmd(Tool::SuggestTests) + .capture_stdout() + .env("SUGGEST_TESTS_GIT_REPOSITORY", git_config.git_repository) + .env("SUGGEST_TESTS_NIGHTLY_BRANCH", git_config.nightly_branch) + .run(builder) .stdout(); let suggestions = suggestions diff --git a/src/bootstrap/src/core/build_steps/synthetic_targets.rs b/src/bootstrap/src/core/build_steps/synthetic_targets.rs index a115ba2d8b2..0f3963ac663 100644 --- a/src/bootstrap/src/core/build_steps/synthetic_targets.rs +++ b/src/bootstrap/src/core/build_steps/synthetic_targets.rs @@ -64,7 +64,7 @@ fn create_synthetic_target( // we cannot use nightly features. So `RUSTC_BOOTSTRAP` is needed here. cmd.env("RUSTC_BOOTSTRAP", "1"); - let output = builder.run(cmd.capture()).stdout(); + let output = cmd.capture().run(builder).stdout(); let mut spec: serde_json::Value = serde_json::from_slice(output.as_bytes()).unwrap(); let spec_map = spec.as_object_mut().unwrap(); diff --git a/src/bootstrap/src/core/build_steps/test.rs b/src/bootstrap/src/core/build_steps/test.rs index dc53bd3cfa7..e48ef58eb0c 100644 --- a/src/bootstrap/src/core/build_steps/test.rs +++ b/src/bootstrap/src/core/build_steps/test.rs @@ -155,7 +155,7 @@ You can skip linkcheck with --skip src/tools/linkchecker" let _guard = builder.msg(Kind::Test, compiler.stage, "Linkcheck", bootstrap_host, bootstrap_host); let _time = helpers::timeit(builder); - builder.run(linkchecker.delay_failure().arg(builder.out.join(host.triple).join("doc"))); + linkchecker.delay_failure().arg(builder.out.join(host.triple).join("doc")).run(builder); } fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { @@ -212,9 +212,11 @@ impl Step for HtmlCheck { builder, )); - builder.run( - builder.tool_cmd(Tool::HtmlChecker).delay_failure().arg(builder.doc_out(self.target)), - ); + builder + .tool_cmd(Tool::HtmlChecker) + .delay_failure() + .arg(builder.doc_out(self.target)) + .run(builder); } } @@ -259,7 +261,7 @@ impl Step for Cargotest { .env("RUSTC", builder.rustc(compiler)) .env("RUSTDOC", builder.rustdoc(compiler)); add_rustdoc_cargo_linker_args(&mut cmd, builder, compiler.host, LldThreads::No); - builder.run(cmd.delay_failure()); + cmd.delay_failure().run(builder); } } @@ -460,7 +462,7 @@ impl Miri { let mut cargo = BootstrapCommand::from(cargo); let _guard = builder.msg(Kind::Build, compiler.stage, "miri sysroot", compiler.host, target); - builder.run(&mut cargo); + cargo.run(builder); // # Determine where Miri put its sysroot. // To this end, we run `cargo miri setup --print-sysroot` and capture the output. @@ -473,7 +475,7 @@ impl Miri { String::new() } else { builder.verbose(|| println!("running: {cargo:?}")); - let stdout = builder.run(cargo.capture_stdout()).stdout(); + let stdout = cargo.capture_stdout().run(builder).stdout(); // Output is "\n". let sysroot = stdout.trim_end(); builder.verbose(|| println!("`cargo miri setup --print-sysroot` said: {sysroot:?}")); @@ -561,7 +563,7 @@ impl Step for Miri { { let _guard = builder.msg_sysroot_tool(Kind::Test, stage, "miri", host, target); let _time = helpers::timeit(builder); - builder.run(&mut cargo); + cargo.run(builder); } // Run it again for mir-opt-level 4 to catch some miscompilations. @@ -583,7 +585,7 @@ impl Step for Miri { target, ); let _time = helpers::timeit(builder); - builder.run(cargo); + cargo.run(builder); } } } @@ -648,11 +650,11 @@ impl Step for CargoMiri { // Finally, pass test-args and run everything. cargo.arg("--").args(builder.config.test_args()); - let cargo = BootstrapCommand::from(cargo); + let mut cargo = BootstrapCommand::from(cargo); { let _guard = builder.msg_sysroot_tool(Kind::Test, stage, "cargo-miri", host, target); let _time = helpers::timeit(builder); - builder.run(cargo); + cargo.run(builder); } } } @@ -753,7 +755,7 @@ impl Step for Clippy { let _guard = builder.msg_sysroot_tool(Kind::Test, compiler.stage, "clippy", host, host); // Clippy reports errors if it blessed the outputs - if builder.run(cargo.allow_failure()).is_success() { + if cargo.allow_failure().run(builder).is_success() { // The tests succeeded; nothing to do. return; } @@ -806,7 +808,7 @@ impl Step for RustdocTheme { .env("RUSTC_BOOTSTRAP", "1"); cmd.args(linker_args(builder, self.compiler.host, LldThreads::No)); - builder.run(cmd.delay_failure()); + cmd.delay_failure().run(builder); } } @@ -866,7 +868,7 @@ impl Step for RustdocJSStd { builder.config.build, self.target, ); - builder.run(command); + command.run(builder); } } @@ -913,7 +915,7 @@ fn get_browser_ui_test_version_inner( if global { command.arg("--global"); } - let lines = builder.run(command.allow_failure()).stdout(); + let lines = command.allow_failure().run(builder).stdout(); lines .lines() .find_map(|l| l.split(':').nth(1)?.strip_prefix("browser-ui-test@")) @@ -1085,7 +1087,7 @@ HELP: to skip test's attempt to check tidiness, pass `--skip src/tools/tidy` to } builder.info("tidy check"); - builder.run(cmd.delay_failure()); + cmd.delay_failure().run(builder); builder.info("x.py completions check"); let [bash, zsh, fish, powershell] = ["x.py.sh", "x.py.zsh", "x.py.fish", "x.py.ps1"] @@ -1292,7 +1294,7 @@ impl Step for RunMakeSupport { &[], ); - builder.run(cargo.into_cmd()); + cargo.into_cmd().run(builder); let lib_name = "librun_make_support.rlib"; let lib = builder.tools_dir(self.compiler).join(lib_name); @@ -1804,14 +1806,20 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the } let lldb_exe = builder.config.lldb.clone().unwrap_or_else(|| PathBuf::from("lldb")); - let lldb_version = builder - .run(BootstrapCommand::new(&lldb_exe).capture().allow_failure().arg("--version")) + let lldb_version = BootstrapCommand::new(&lldb_exe) + .capture() + .allow_failure() + .arg("--version") + .run(builder) .stdout_if_ok() .and_then(|v| if v.trim().is_empty() { None } else { Some(v) }); if let Some(ref vers) = lldb_version { cmd.arg("--lldb-version").arg(vers); - let lldb_python_dir = builder - .run(BootstrapCommand::new(&lldb_exe).allow_failure().capture_stdout().arg("-P")) + let lldb_python_dir = BootstrapCommand::new(&lldb_exe) + .allow_failure() + .capture_stdout() + .arg("-P") + .run(builder) .stdout_if_ok() .map(|p| p.lines().next().expect("lldb Python dir not found").to_string()); if let Some(ref dir) = lldb_python_dir { @@ -2169,9 +2177,11 @@ impl BookTest { compiler.host, ); let _time = helpers::timeit(builder); - let cmd = rustbook_cmd.delay_failure(); - let toolstate = - if builder.run(cmd).is_success() { ToolState::TestPass } else { ToolState::TestFail }; + let toolstate = if rustbook_cmd.delay_failure().run(builder).is_success() { + ToolState::TestPass + } else { + ToolState::TestFail + }; builder.save_toolstate(self.name, toolstate); } @@ -2300,7 +2310,7 @@ impl Step for ErrorIndex { let guard = builder.msg(Kind::Test, compiler.stage, "error-index", compiler.host, compiler.host); let _time = helpers::timeit(builder); - builder.run(tool.capture()); + tool.capture().run(builder); drop(guard); // The tests themselves need to link to std, so make sure it is // available. @@ -2333,7 +2343,7 @@ fn markdown_test(builder: &Builder<'_>, compiler: Compiler, markdown: &Path) -> if !builder.config.verbose_tests { cmd = cmd.capture(); } - builder.run(cmd).is_success() + cmd.run(builder).is_success() } #[derive(Debug, Clone, PartialEq, Eq, Hash)] @@ -2359,7 +2369,7 @@ impl Step for RustcGuide { let src = builder.src.join(relative_path); let mut rustbook_cmd = builder.tool_cmd(Tool::Rustbook).delay_failure(); rustbook_cmd.arg("linkcheck").arg(&src); - let toolstate = if builder.run(rustbook_cmd).is_success() { + let toolstate = if rustbook_cmd.run(builder).is_success() { ToolState::TestPass } else { ToolState::TestFail @@ -2868,7 +2878,7 @@ impl Step for RemoteCopyLibs { if let Some(rootfs) = builder.qemu_rootfs(target) { cmd.arg(rootfs); } - builder.run(cmd); + cmd.run(builder); // Push all our dylibs to the emulator for f in t!(builder.sysroot_libdir(compiler, target).read_dir()) { @@ -2911,7 +2921,7 @@ impl Step for Distcheck { .arg(builder.ensure(dist::PlainSourceTarball).tarball()) .arg("--strip-components=1") .current_dir(&dir); - builder.run(cmd); + cmd.run(builder); builder.run( BootstrapCommand::new("./configure") .args(&builder.config.configure_args) @@ -2935,7 +2945,7 @@ impl Step for Distcheck { .arg(builder.ensure(dist::Src).tarball()) .arg("--strip-components=1") .current_dir(&dir); - builder.run(cmd); + cmd.run(builder); let toml = dir.join("rust-src/lib/rustlib/src/rust/library/std/Cargo.toml"); builder.run( @@ -2976,7 +2986,7 @@ impl Step for Bootstrap { .current_dir(builder.src.join("src/bootstrap/")); // NOTE: we intentionally don't pass test_args here because the args for unittest and cargo test are mutually incompatible. // Use `python -m unittest` manually if you want to pass arguments. - builder.run(check_bootstrap.delay_failure()); + check_bootstrap.delay_failure().run(builder); let mut cmd = BootstrapCommand::new(&builder.initial_cargo); cmd.arg("test") @@ -3053,7 +3063,7 @@ impl Step for TierCheck { self.compiler.host, self.compiler.host, ); - builder.run(BootstrapCommand::from(cargo).delay_failure()); + BootstrapCommand::from(cargo).delay_failure().run(builder); } } @@ -3138,7 +3148,7 @@ impl Step for RustInstaller { cmd.env("CARGO", &builder.initial_cargo); cmd.env("RUSTC", &builder.initial_rustc); cmd.env("TMP_DIR", &tmpdir); - builder.run(cmd.delay_failure()); + cmd.delay_failure().run(builder); } fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { @@ -3332,7 +3342,7 @@ impl Step for CodegenCranelift { .arg("testsuite.extended_sysroot"); cargo.args(builder.config.test_args()); - builder.run(cargo.into_cmd()); + cargo.into_cmd().run(builder); } } @@ -3457,6 +3467,6 @@ impl Step for CodegenGCC { .arg("--std-tests"); cargo.args(builder.config.test_args()); - builder.run(cargo.into_cmd()); + cargo.into_cmd().run(builder); } } diff --git a/src/bootstrap/src/core/build_steps/tool.rs b/src/bootstrap/src/core/build_steps/tool.rs index 5fb282db90a..7b4b5ff5a8c 100644 --- a/src/bootstrap/src/core/build_steps/tool.rs +++ b/src/bootstrap/src/core/build_steps/tool.rs @@ -602,7 +602,7 @@ impl Step for Rustdoc { &self.compiler.host, &target, ); - builder.run(cargo.into_cmd()); + cargo.into_cmd().run(builder); // Cargo adds a number of paths to the dylib search path on windows, which results in // the wrong rustdoc being executed. To avoid the conflicting rustdocs, we name the "tool" @@ -857,7 +857,7 @@ impl Step for LlvmBitcodeLinker { &self.extra_features, ); - builder.run(cargo.into_cmd()); + cargo.into_cmd().run(builder); let tool_out = builder .cargo_out(self.compiler, Mode::ToolRustc, self.target) @@ -918,7 +918,7 @@ impl Step for LibcxxVersionTool { .arg(&executable) .arg(builder.src.join("src/tools/libcxx-version/main.cpp")); - builder.run(cmd); + cmd.run(builder); if !executable.exists() { panic!("Something went wrong. {} is not present", executable.display()); @@ -926,7 +926,7 @@ impl Step for LibcxxVersionTool { } let version_output = - builder.run(BootstrapCommand::new(executable).capture_stdout()).stdout(); + BootstrapCommand::new(executable).capture_stdout().run(builder).stdout(); let version_str = version_output.split_once("version:").unwrap().1; let version = version_str.trim().parse::().unwrap(); diff --git a/src/bootstrap/src/core/build_steps/vendor.rs b/src/bootstrap/src/core/build_steps/vendor.rs index 0b999a24a1f..82cd95489d0 100644 --- a/src/bootstrap/src/core/build_steps/vendor.rs +++ b/src/bootstrap/src/core/build_steps/vendor.rs @@ -59,6 +59,6 @@ impl Step for Vendor { cmd.current_dir(self.root_dir); - builder.run(cmd); + cmd.run(builder); } } diff --git a/src/bootstrap/src/core/builder.rs b/src/bootstrap/src/core/builder.rs index 4da912994c3..91dfffdaf7e 100644 --- a/src/bootstrap/src/core/builder.rs +++ b/src/bootstrap/src/core/builder.rs @@ -1918,8 +1918,10 @@ impl<'a> Builder<'a> { // platform-specific environment variable as a workaround. if mode == Mode::ToolRustc || mode == Mode::Codegen { if let Some(llvm_config) = self.llvm_config(target) { - let llvm_libdir = self - .run(BootstrapCommand::new(llvm_config).capture_stdout().arg("--libdir")) + let llvm_libdir = BootstrapCommand::new(llvm_config) + .capture_stdout() + .arg("--libdir") + .run(self) .stdout(); add_link_lib_path(vec![llvm_libdir.trim().into()], &mut cargo); } diff --git a/src/bootstrap/src/core/metadata.rs b/src/bootstrap/src/core/metadata.rs index 49d17107125..83c22b06099 100644 --- a/src/bootstrap/src/core/metadata.rs +++ b/src/bootstrap/src/core/metadata.rs @@ -81,7 +81,7 @@ fn workspace_members(build: &Build) -> Vec { .arg("--no-deps") .arg("--manifest-path") .arg(build.src.join(manifest_path)); - let metadata_output = build.run(cargo.capture_stdout().run_always()).stdout(); + let metadata_output = cargo.capture_stdout().run_always().run(build).stdout(); let Output { packages, .. } = t!(serde_json::from_str(&metadata_output)); packages }; diff --git a/src/bootstrap/src/core/sanity.rs b/src/bootstrap/src/core/sanity.rs index 78862ccb8cd..e393d3df01f 100644 --- a/src/bootstrap/src/core/sanity.rs +++ b/src/bootstrap/src/core/sanity.rs @@ -355,7 +355,7 @@ than building it. // Cygwin. The Cygwin build does not have generators for Visual // Studio, so detect that here and error. let out = - build.run(BootstrapCommand::new("cmake").capture_stdout().arg("--help")).stdout(); + BootstrapCommand::new("cmake").capture_stdout().arg("--help").run(build).stdout(); if !out.contains("Visual Studio") { panic!( " diff --git a/src/bootstrap/src/lib.rs b/src/bootstrap/src/lib.rs index ffdd9bc885a..6604b8efa1d 100644 --- a/src/bootstrap/src/lib.rs +++ b/src/bootstrap/src/lib.rs @@ -510,9 +510,10 @@ impl Build { } println!("Updating submodule {}", relative_path.display()); - self.run( - helpers::git(Some(&self.src)).args(["submodule", "-q", "sync"]).arg(relative_path), - ); + helpers::git(Some(&self.src)) + .args(["submodule", "-q", "sync"]) + .arg(relative_path) + .run(self); // Try passing `--progress` to start, then run git again without if that fails. let update = |progress: bool| { @@ -548,23 +549,25 @@ impl Build { }; // NOTE: doesn't use `try_run` because this shouldn't print an error if it fails. if !update(true).command.status().map_or(false, |status| status.success()) { - self.run(update(false)); + update(false).run(self); } // Save any local changes, but avoid running `git stash pop` if there are none (since it will exit with an error). // diff-index reports the modifications through the exit status - let has_local_modifications = self - .run(submodule_git().allow_failure().args(["diff-index", "--quiet", "HEAD"])) + let has_local_modifications = submodule_git() + .allow_failure() + .args(["diff-index", "--quiet", "HEAD"]) + .run(self) .is_failure(); if has_local_modifications { - self.run(submodule_git().args(["stash", "push"])); + submodule_git().args(["stash", "push"]).run(self); } - self.run(submodule_git().args(["reset", "-q", "--hard"])); - self.run(submodule_git().args(["clean", "-qdfx"])); + submodule_git().args(["reset", "-q", "--hard"]).run(self); + submodule_git().args(["clean", "-qdfx"]).run(self); if has_local_modifications { - self.run(submodule_git().args(["stash", "pop"])); + submodule_git().args(["stash", "pop"]).run(self); } } @@ -575,14 +578,12 @@ impl Build { if !self.config.submodules(self.rust_info()) { return; } - let output = self - .run( - helpers::git(Some(&self.src)) - .capture() - .args(["config", "--file"]) - .arg(self.config.src.join(".gitmodules")) - .args(["--get-regexp", "path"]), - ) + let output = helpers::git(Some(&self.src)) + .capture() + .args(["config", "--file"]) + .arg(self.config.src.join(".gitmodules")) + .args(["--get-regexp", "path"]) + .run(self) .stdout(); for line in output.lines() { // Look for `submodule.$name.path = $path` @@ -861,7 +862,7 @@ impl Build { s.to_path_buf() } else if let Some(s) = target_config.and_then(|c| c.llvm_config.as_ref()) { let llvm_bindir = - self.run(BootstrapCommand::new(s).capture_stdout().arg("--bindir")).stdout(); + BootstrapCommand::new(s).capture_stdout().arg("--bindir").run(self).stdout(); let filecheck = Path::new(llvm_bindir.trim()).join(exe("FileCheck", target)); if filecheck.exists() { filecheck @@ -869,7 +870,7 @@ impl Build { // On Fedora the system LLVM installs FileCheck in the // llvm subdirectory of the libdir. let llvm_libdir = - self.run(BootstrapCommand::new(s).capture_stdout().arg("--libdir")).stdout(); + BootstrapCommand::new(s).capture_stdout().arg("--libdir").run(self).stdout(); let lib_filecheck = Path::new(llvm_libdir.trim()).join("llvm").join(exe("FileCheck", target)); if lib_filecheck.exists() { @@ -935,8 +936,7 @@ impl Build { /// Execute a command and return its output. /// This method should be used for all command executions in bootstrap. - fn run>(&self, mut command: C) -> CommandOutput { - let command = command.as_mut(); + fn run(&self, command: &mut BootstrapCommand) -> CommandOutput { if self.config.dry_run() && !command.run_always { return CommandOutput::default(); } @@ -1496,18 +1496,17 @@ impl Build { // Figure out how many merge commits happened since we branched off master. // That's our beta number! // (Note that we use a `..` range, not the `...` symmetric difference.) - self.run( - helpers::git(Some(&self.src)) - .capture() - .arg("rev-list") - .arg("--count") - .arg("--merges") - .arg(format!( - "refs/remotes/origin/{}..HEAD", - self.config.stage0_metadata.config.nightly_branch - )), - ) - .stdout() + helpers::git(Some(&self.src)) + .capture() + .arg("rev-list") + .arg("--count") + .arg("--merges") + .arg(format!( + "refs/remotes/origin/{}..HEAD", + self.config.stage0_metadata.config.nightly_branch + )) + .run(self) + .stdout() }); let n = count.trim().parse().unwrap(); self.prerelease_version.set(Some(n)); diff --git a/src/bootstrap/src/utils/cc_detect.rs b/src/bootstrap/src/utils/cc_detect.rs index b80df545202..5d8a5223a2d 100644 --- a/src/bootstrap/src/utils/cc_detect.rs +++ b/src/bootstrap/src/utils/cc_detect.rs @@ -183,14 +183,14 @@ fn default_compiler( } let cmd = BootstrapCommand::from(c.to_command()); - let output = build.run(cmd.capture_stdout().arg("--version")).stdout(); + let output = cmd.capture_stdout().arg("--version").run(build).stdout(); let i = output.find(" 4.")?; match output[i + 3..].chars().next().unwrap() { '0'..='6' => {} _ => return None, } let alternative = format!("e{gnu_compiler}"); - if build.run(BootstrapCommand::new(&alternative).capture()).is_success() { + if BootstrapCommand::new(&alternative).capture().run(build).is_success() { Some(PathBuf::from(alternative)) } else { None diff --git a/src/bootstrap/src/utils/exec.rs b/src/bootstrap/src/utils/exec.rs index 086d10c6351..8940ea24385 100644 --- a/src/bootstrap/src/utils/exec.rs +++ b/src/bootstrap/src/utils/exec.rs @@ -1,3 +1,4 @@ +use crate::Build; use std::ffi::OsStr; use std::path::Path; use std::process::{Command, CommandArgs, CommandEnvs, ExitStatus, Output, Stdio}; @@ -134,13 +135,10 @@ impl BootstrapCommand { pub fn capture_stdout(self) -> Self { Self { stdout: OutputMode::Capture, ..self } } -} -/// This implementation exists to make it possible to pass both [BootstrapCommand] and -/// `&mut BootstrapCommand` to `Build.run()`. -impl AsMut for BootstrapCommand { - fn as_mut(&mut self) -> &mut BootstrapCommand { - self + /// Run the command, returning its output. + pub fn run(&mut self, builder: &Build) -> CommandOutput { + builder.run(self) } } diff --git a/src/bootstrap/src/utils/helpers.rs b/src/bootstrap/src/utils/helpers.rs index 2575b7939b4..0a81db3cd8e 100644 --- a/src/bootstrap/src/utils/helpers.rs +++ b/src/bootstrap/src/utils/helpers.rs @@ -371,7 +371,7 @@ fn lld_flag_no_threads(builder: &Builder<'_>, lld_mode: LldMode, is_windows: boo LldMode::External => { let mut cmd = BootstrapCommand::new("lld").capture_stdout(); cmd.arg("-flavor").arg("ld").arg("--version"); - let out = builder.run(cmd).stdout(); + let out = cmd.run(builder).stdout(); match (out.find(char::is_numeric), out.find('.')) { (Some(b), Some(e)) => out.as_str()[b..e].parse::().ok().unwrap_or(14) > 10, _ => true, diff --git a/src/bootstrap/src/utils/tarball.rs b/src/bootstrap/src/utils/tarball.rs index 1a35dc1fd38..4f0104e4bba 100644 --- a/src/bootstrap/src/utils/tarball.rs +++ b/src/bootstrap/src/utils/tarball.rs @@ -379,7 +379,7 @@ impl<'a> Tarball<'a> { cmd.args(["--override-file-mtime", timestamp.trim()]); } - self.builder.run(cmd); + cmd.run(self.builder); // 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.