diff --git a/src/bootstrap/src/core/build_steps/check.rs b/src/bootstrap/src/core/build_steps/check.rs index 002b46cb7fbec..1bb925f726a16 100644 --- a/src/bootstrap/src/core/build_steps/check.rs +++ b/src/bootstrap/src/core/build_steps/check.rs @@ -13,7 +13,8 @@ use crate::core::build_steps::tool::{ prepare_tool_cargo, }; use crate::core::builder::{ - self, Alias, Builder, Cargo, Kind, RunConfig, ShouldRun, Step, StepMetadata, crate_description, + self, Alias, Builder, Cargo, CommandLineStep, Kind, RunConfig, ShouldRun, Step, StepMetadata, + crate_description, }; use crate::core::config::TargetSelection; use crate::utils::build_stamp::{self, BuildStamp}; @@ -36,7 +37,7 @@ impl Std { const CRATE_OR_DEPS: &[&str] = &["sysroot", "coretests", "alloctests"]; } -impl Step for Std { +impl CommandLineStep for Std { type Output = BuildStamp; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { @@ -222,10 +223,6 @@ impl PrepareRustcRmetaSysroot { impl Step for PrepareRustcRmetaSysroot { type Output = RmetaSysroot; - fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { - run.never() - } - fn run(self, builder: &Builder<'_>) -> Self::Output { // Check rustc let stamp = builder.ensure(Rustc::from_build_compiler( @@ -266,10 +263,6 @@ impl PrepareStdRmetaSysroot { impl Step for PrepareStdRmetaSysroot { type Output = RmetaSysroot; - fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { - run.never() - } - fn run(self, builder: &Builder<'_>) -> Self::Output { // Check std let stamp = builder.ensure(Std { @@ -317,7 +310,7 @@ impl Rustc { } } -impl Step for Rustc { +impl CommandLineStep for Rustc { type Output = BuildStamp; const IS_HOST: bool = true; @@ -528,7 +521,7 @@ pub struct CraneliftCodegenBackend { target: TargetSelection, } -impl Step for CraneliftCodegenBackend { +impl CommandLineStep for CraneliftCodegenBackend { type Output = (); const IS_HOST: bool = true; @@ -607,7 +600,7 @@ pub struct GccCodegenBackend { target: TargetSelection, } -impl Step for GccCodegenBackend { +impl CommandLineStep for GccCodegenBackend { type Output = (); const IS_HOST: bool = true; @@ -701,7 +694,7 @@ macro_rules! tool_check_step { target: TargetSelection, } - impl Step for $name { + impl CommandLineStep for $name { type Output = (); const IS_HOST: bool = true; diff --git a/src/bootstrap/src/core/build_steps/clean.rs b/src/bootstrap/src/core/build_steps/clean.rs index fec4a79de3c75..292885e99a34b 100644 --- a/src/bootstrap/src/core/build_steps/clean.rs +++ b/src/bootstrap/src/core/build_steps/clean.rs @@ -9,7 +9,7 @@ use std::fs; use std::io::{self, ErrorKind}; use std::path::Path; -use crate::core::builder::{Builder, RunConfig, ShouldRun, Step, crate_description}; +use crate::core::builder::{Builder, CommandLineStep, RunConfig, ShouldRun, crate_description}; use crate::utils::build_stamp::BuildStamp; use crate::utils::helpers::t; use crate::{Build, Compiler, Kind, Mode, Subcommand}; @@ -17,12 +17,13 @@ use crate::{Build, Compiler, Kind, Mode, Subcommand}; #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct CleanAll {} -impl Step for CleanAll { +impl CommandLineStep for CleanAll { type Output = (); fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { - // Only runs as the default `./x clean` step; cannot be selected explicitly. - run.never() + // Normally this step is invoked implicitly via `./x clean`, but all + // steps are required to register at least one explicit path/alias. + run.alias("default") } fn is_default_step(_builder: &Builder<'_>) -> bool { @@ -54,7 +55,7 @@ macro_rules! clean_crate_tree { crates: Vec, } - impl Step for $name { + impl CommandLineStep for $name { type Output = (); fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { diff --git a/src/bootstrap/src/core/build_steps/clippy.rs b/src/bootstrap/src/core/build_steps/clippy.rs index 09ccd14ab88c3..8df931a24fd25 100644 --- a/src/bootstrap/src/core/build_steps/clippy.rs +++ b/src/bootstrap/src/core/build_steps/clippy.rs @@ -20,7 +20,9 @@ use crate::core::build_steps::compile::{ ArtifactKeepMode, run_cargo, rustc_cargo, std_cargo, std_crates_for_make_run, }; use crate::core::builder; -use crate::core::builder::{Alias, Kind, RunConfig, Step, StepMetadata, crate_description}; +use crate::core::builder::{ + Alias, CommandLineStep, Kind, RunConfig, StepMetadata, crate_description, +}; use crate::utils::build_stamp::{self, BuildStamp}; use crate::{Compiler, Mode, Subcommand, TargetSelection, exit}; @@ -167,7 +169,7 @@ impl Std { } } -impl Step for Std { +impl CommandLineStep for Std { type Output = (); fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { @@ -251,7 +253,7 @@ impl Rustc { } } -impl Step for Rustc { +impl CommandLineStep for Rustc { type Output = (); const IS_HOST: bool = true; @@ -336,7 +338,7 @@ impl CodegenGcc { } } -impl Step for CodegenGcc { +impl CommandLineStep for CodegenGcc { type Output = (); fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { @@ -422,7 +424,7 @@ macro_rules! lint_any { config: LintConfig, } - impl Step for $name { + impl CommandLineStep for $name { type Output = (); fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { @@ -522,7 +524,7 @@ pub struct CI { config: LintConfig, } -impl Step for CI { +impl CommandLineStep for CI { type Output = (); fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { diff --git a/src/bootstrap/src/core/build_steps/compile.rs b/src/bootstrap/src/core/build_steps/compile.rs index d186e15c75cf2..da8449f4f637b 100644 --- a/src/bootstrap/src/core/build_steps/compile.rs +++ b/src/bootstrap/src/core/build_steps/compile.rs @@ -22,9 +22,9 @@ use tracing::span; use crate::core::build_steps::gcc::{Gcc, GccOutput, GccTargetPair}; use crate::core::build_steps::tool::{RustcPrivateCompilers, SourceType, copy_lld_artifacts}; use crate::core::build_steps::{dist, llvm}; -use crate::core::builder; use crate::core::builder::{ - Builder, Cargo, Kind, RunConfig, ShouldRun, Step, StepMetadata, apply_pgo, crate_description, + self, Builder, Cargo, CommandLineStep, Kind, RunConfig, ShouldRun, Step, StepMetadata, + apply_pgo, crate_description, }; use crate::core::config::toml::target::DefaultLinuxLinkerOverride; use crate::core::config::{ @@ -109,7 +109,7 @@ impl Std { } } -impl Step for Std { +impl CommandLineStep for Std { /// Build stamp of std, if it was indeed built or uplifted. type Output = Option; @@ -743,10 +743,6 @@ impl StdLink { impl Step for StdLink { type Output = (); - fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { - run.never() - } - /// Link all libstd rlibs/dylibs into the sysroot location. /// /// Links those artifacts generated by `compiler` to the `stage` compiler's @@ -900,7 +896,7 @@ pub struct StartupObjects { pub target: TargetSelection, } -impl Step for StartupObjects { +impl CommandLineStep for StartupObjects { type Output = Vec<(PathBuf, DependencyType)>; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { @@ -1013,7 +1009,7 @@ impl Rustc { } } -impl Step for Rustc { +impl CommandLineStep for Rustc { type Output = BuiltRustc; const IS_HOST: bool = true; @@ -1535,10 +1531,6 @@ impl RustcLink { impl Step for RustcLink { type Output = (); - fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { - run.never() - } - /// Same as `StdLink`, only for librustc fn run(self, builder: &Builder<'_>) { let build_compiler = self.build_compiler; @@ -1659,7 +1651,7 @@ impl GccCodegenBackend { } } -impl Step for GccCodegenBackend { +impl CommandLineStep for GccCodegenBackend { type Output = GccCodegenBackendOutput; const IS_HOST: bool = true; @@ -1728,7 +1720,7 @@ pub struct CraneliftCodegenBackend { pub compilers: RustcPrivateCompilers, } -impl Step for CraneliftCodegenBackend { +impl CommandLineStep for CraneliftCodegenBackend { type Output = BuildStamp; const IS_HOST: bool = true; @@ -1909,10 +1901,6 @@ impl Sysroot { impl Step for Sysroot { type Output = PathBuf; - fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { - run.never() - } - /// Returns the sysroot that `compiler` is supposed to use. /// For the stage0 compiler, this is stage0-sysroot (because of the initial std build). /// For all other stages, it's the same stage directory that the compiler lives in. @@ -2078,7 +2066,7 @@ pub struct Assemble { pub target_compiler: Compiler, } -impl Step for Assemble { +impl CommandLineStep for Assemble { type Output = Compiler; const IS_HOST: bool = true; diff --git a/src/bootstrap/src/core/build_steps/dist.rs b/src/bootstrap/src/core/build_steps/dist.rs index b74dd7dc3b987..09aadee694d32 100644 --- a/src/bootstrap/src/core/build_steps/dist.rs +++ b/src/bootstrap/src/core/build_steps/dist.rs @@ -29,7 +29,9 @@ use crate::core::build_steps::tool::{ }; use crate::core::build_steps::vendor::Vendor; use crate::core::build_steps::{compile, llvm}; -use crate::core::builder::{Builder, Kind, RunConfig, ShouldRun, Step, StepMetadata}; +use crate::core::builder::{ + Builder, CommandLineStep, Kind, RunConfig, ShouldRun, Step, StepMetadata, +}; use crate::core::config::{GccCiMode, TargetSelection}; use crate::utils::build_stamp::{self, BuildStamp}; use crate::utils::channel::{self, Info}; @@ -64,7 +66,7 @@ pub struct Docs { pub host: TargetSelection, } -impl Step for Docs { +impl CommandLineStep for Docs { type Output = Option; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { @@ -116,7 +118,7 @@ pub struct JsonDocs { target: TargetSelection, } -impl Step for JsonDocs { +impl CommandLineStep for JsonDocs { type Output = Option; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { @@ -167,7 +169,7 @@ pub struct RustcDocs { target: TargetSelection, } -impl Step for RustcDocs { +impl CommandLineStep for RustcDocs { type Output = GeneratedTarball; const IS_HOST: bool = true; @@ -423,7 +425,7 @@ pub struct Mingw { target: TargetSelection, } -impl Step for Mingw { +impl CommandLineStep for Mingw { type Output = Option; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { @@ -478,7 +480,7 @@ pub struct Rustc { pub target_compiler: Compiler, } -impl Step for Rustc { +impl CommandLineStep for Rustc { type Output = GeneratedTarball; const IS_HOST: bool = true; @@ -707,10 +709,6 @@ pub struct DebuggerScripts { impl Step for DebuggerScripts { type Output = (); - fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { - run.never() - } - fn run(self, builder: &Builder<'_>) { let target = self.target; let sysroot = self.sysroot; @@ -851,7 +849,7 @@ impl Std { } } -impl Step for Std { +impl CommandLineStep for Std { type Output = Option; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { @@ -916,7 +914,7 @@ impl RustcDev { } } -impl Step for RustcDev { +impl CommandLineStep for RustcDev { type Output = Option; const IS_HOST: bool = true; @@ -984,7 +982,7 @@ pub struct Analysis { target: TargetSelection, } -impl Step for Analysis { +impl CommandLineStep for Analysis { type Output = Option; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { @@ -1157,7 +1155,7 @@ fn copy_src_dirs( #[derive(Debug, Clone, Hash, PartialEq, Eq)] pub struct Src; -impl Step for Src { +impl CommandLineStep for Src { /// The output path of the src installer tarball type Output = GeneratedTarball; const IS_HOST: bool = true; @@ -1232,7 +1230,7 @@ impl Step for Src { #[derive(Debug, Clone, Hash, PartialEq, Eq)] pub struct PlainSourceTarball; -impl Step for PlainSourceTarball { +impl CommandLineStep for PlainSourceTarball { /// Produces the location of the tarball generated type Output = GeneratedTarball; const IS_HOST: bool = true; @@ -1282,7 +1280,7 @@ impl Step for PlainSourceTarball { #[derive(Debug, Clone, Hash, PartialEq, Eq)] pub struct PlainSourceTarballGpl; -impl Step for PlainSourceTarballGpl { +impl CommandLineStep for PlainSourceTarballGpl { /// Produces the location of the tarball generated type Output = GeneratedTarball; const IS_HOST: bool = true; @@ -1417,7 +1415,7 @@ pub struct Cargo { pub target: TargetSelection, } -impl Step for Cargo { +impl CommandLineStep for Cargo { type Output = Option; const IS_HOST: bool = true; @@ -1477,7 +1475,7 @@ pub struct RustAnalyzer { pub target: TargetSelection, } -impl Step for RustAnalyzer { +impl CommandLineStep for RustAnalyzer { type Output = Option; const IS_HOST: bool = true; @@ -1522,7 +1520,7 @@ pub struct Clippy { pub target: TargetSelection, } -impl Step for Clippy { +impl CommandLineStep for Clippy { type Output = Option; const IS_HOST: bool = true; @@ -1570,7 +1568,7 @@ pub struct Miri { pub target: TargetSelection, } -impl Step for Miri { +impl CommandLineStep for Miri { type Output = Option; const IS_HOST: bool = true; @@ -1620,7 +1618,7 @@ pub struct CraneliftCodegenBackend { pub target: TargetSelection, } -impl Step for CraneliftCodegenBackend { +impl CommandLineStep for CraneliftCodegenBackend { type Output = Option; const IS_HOST: bool = true; @@ -1694,7 +1692,7 @@ pub struct GccCodegenBackend { pub target: TargetSelection, } -impl Step for GccCodegenBackend { +impl CommandLineStep for GccCodegenBackend { type Output = Option; const IS_HOST: bool = true; @@ -1798,7 +1796,7 @@ pub struct Rustfmt { pub target: TargetSelection, } -impl Step for Rustfmt { +impl CommandLineStep for Rustfmt { type Output = Option; const IS_HOST: bool = true; @@ -1842,7 +1840,7 @@ pub struct Extended { target: TargetSelection, } -impl Step for Extended { +impl CommandLineStep for Extended { type Output = (); const IS_HOST: bool = true; @@ -2616,7 +2614,7 @@ pub struct LlvmTools { pub target: TargetSelection, } -impl Step for LlvmTools { +impl CommandLineStep for LlvmTools { type Output = Option; const IS_HOST: bool = true; @@ -2721,7 +2719,7 @@ pub struct LlvmBitcodeLinker { pub target: TargetSelection, } -impl Step for LlvmBitcodeLinker { +impl CommandLineStep for LlvmBitcodeLinker { type Output = Option; const IS_HOST: bool = true; @@ -2770,7 +2768,7 @@ pub struct Enzyme { pub target: TargetSelection, } -impl Step for Enzyme { +impl CommandLineStep for Enzyme { type Output = Option; const IS_HOST: bool = true; @@ -2824,7 +2822,7 @@ pub struct RustDev { pub target: TargetSelection, } -impl Step for RustDev { +impl CommandLineStep for RustDev { type Output = Option; const IS_HOST: bool = true; @@ -2932,7 +2930,7 @@ pub struct Bootstrap { target: TargetSelection, } -impl Step for Bootstrap { +impl CommandLineStep for Bootstrap { type Output = Option; const IS_HOST: bool = true; @@ -2976,7 +2974,7 @@ pub struct BuildManifest { target: TargetSelection, } -impl Step for BuildManifest { +impl CommandLineStep for BuildManifest { type Output = GeneratedTarball; const IS_HOST: bool = true; @@ -3016,7 +3014,7 @@ pub struct ReproducibleArtifacts { target: TargetSelection, } -impl Step for ReproducibleArtifacts { +impl CommandLineStep for ReproducibleArtifacts { type Output = Option; const IS_HOST: bool = true; @@ -3065,7 +3063,7 @@ pub struct GccDev { target: TargetSelection, } -impl Step for GccDev { +impl CommandLineStep for GccDev { type Output = GeneratedTarball; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { @@ -3100,7 +3098,7 @@ pub struct Gcc { target: TargetSelection, } -impl Step for Gcc { +impl CommandLineStep for Gcc { type Output = Option; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { diff --git a/src/bootstrap/src/core/build_steps/doc.rs b/src/bootstrap/src/core/build_steps/doc.rs index 99e2c61e442ff..f7ef0a93c1446 100644 --- a/src/bootstrap/src/core/build_steps/doc.rs +++ b/src/bootstrap/src/core/build_steps/doc.rs @@ -16,7 +16,8 @@ use crate::core::build_steps::tool::{ self, RustcPrivateCompilers, SourceType, Tool, prepare_tool_cargo, }; use crate::core::builder::{ - self, Builder, Compiler, Kind, RunConfig, ShouldRun, Step, StepMetadata, crate_description, + self, Builder, CommandLineStep, Compiler, Kind, RunConfig, ShouldRun, Step, StepMetadata, + crate_description, }; use crate::core::config::{Config, TargetSelection}; use crate::helpers::{submodule_path_of, symlink_dir, t, up_to_date}; @@ -30,7 +31,7 @@ macro_rules! book { target: TargetSelection, } - impl Step for $name { + impl CommandLineStep for $name { type Output = (); fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { @@ -86,7 +87,7 @@ pub struct UnstableBook { target: TargetSelection, } -impl Step for UnstableBook { +impl CommandLineStep for UnstableBook { type Output = (); fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { @@ -128,7 +129,7 @@ impl Step for UnstableBook { } #[derive(Debug, Clone, Hash, PartialEq, Eq)] -struct RustbookSrc { +struct RustbookSrc { target: TargetSelection, name: String, src: PathBuf, @@ -138,13 +139,9 @@ struct RustbookSrc { build_compiler: Option, } -impl Step for RustbookSrc

{ +impl Step for RustbookSrc

{ type Output = (); - fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { - run.never() - } - /// Invoke `rustbook` for `target` for the doc book `name` from the `src` path. /// /// This will not actually generate any documentation if the documentation has @@ -229,7 +226,7 @@ pub struct TheBook { target: TargetSelection, } -impl Step for TheBook { +impl CommandLineStep for TheBook { type Output = (); fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { @@ -355,7 +352,7 @@ pub struct Standalone { target: TargetSelection, } -impl Step for Standalone { +impl CommandLineStep for Standalone { type Output = (); fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { @@ -467,7 +464,7 @@ pub struct Releases { target: TargetSelection, } -impl Step for Releases { +impl CommandLineStep for Releases { type Output = (); fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { @@ -577,15 +574,6 @@ pub struct SharedAssets { impl Step for SharedAssets { type Output = SharedAssetsPaths; - fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { - // Other tasks depend on this, no need to execute it on its own - run.never() - } - - fn is_default_step(_builder: &Builder<'_>) -> bool { - false - } - /// Generate shared resources used by other pieces of documentation. fn run(self, builder: &Builder<'_>) -> Self::Output { let out = builder.doc_out(self.target); @@ -654,7 +642,7 @@ impl Std { } } -impl Step for Std { +impl CommandLineStep for Std { /// Path to a directory with the built documentation. type Output = PathBuf; @@ -911,7 +899,7 @@ impl Rustc { } } -impl Step for Rustc { +impl CommandLineStep for Rustc { type Output = (); const IS_HOST: bool = true; @@ -1059,7 +1047,7 @@ macro_rules! tool_doc { target: TargetSelection, } - impl Step for $tool { + impl CommandLineStep for $tool { type Output = (); const IS_HOST: bool = true; @@ -1262,7 +1250,7 @@ pub struct ErrorIndex { compilers: RustcPrivateCompilers, } -impl Step for ErrorIndex { +impl CommandLineStep for ErrorIndex { type Output = (); const IS_HOST: bool = true; @@ -1310,7 +1298,7 @@ pub struct UnstableBookGen { target: TargetSelection, } -impl Step for UnstableBookGen { +impl CommandLineStep for UnstableBookGen { type Output = (); const IS_HOST: bool = true; @@ -1388,7 +1376,7 @@ impl RustcBook { } } -impl Step for RustcBook { +impl CommandLineStep for RustcBook { type Output = (); const IS_HOST: bool = true; @@ -1494,7 +1482,7 @@ pub struct Reference { target: TargetSelection, } -impl Step for Reference { +impl CommandLineStep for Reference { type Output = (); fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { diff --git a/src/bootstrap/src/core/build_steps/gcc.rs b/src/bootstrap/src/core/build_steps/gcc.rs index 992279fe1e133..ed0e57b884aa8 100644 --- a/src/bootstrap/src/core/build_steps/gcc.rs +++ b/src/bootstrap/src/core/build_steps/gcc.rs @@ -15,7 +15,7 @@ use std::sync::OnceLock; use build_helper::git::PathFreshness; -use crate::core::builder::{Builder, Cargo, Kind, RunConfig, ShouldRun, Step}; +use crate::core::builder::{Builder, Cargo, CommandLineStep, Kind, RunConfig, ShouldRun}; use crate::core::config::TargetSelection; use crate::utils::build_stamp::{BuildStamp, generate_smart_stamp_hash}; use crate::utils::exec::command; @@ -76,7 +76,7 @@ impl GccOutput { } } -impl Step for Gcc { +impl CommandLineStep for Gcc { type Output = GccOutput; const IS_HOST: bool = true; diff --git a/src/bootstrap/src/core/build_steps/install.rs b/src/bootstrap/src/core/build_steps/install.rs index d23fe029bcc7e..7950caa18ce71 100644 --- a/src/bootstrap/src/core/build_steps/install.rs +++ b/src/bootstrap/src/core/build_steps/install.rs @@ -8,7 +8,7 @@ use std::{env, fs}; use crate::core::build_steps::dist; use crate::core::build_steps::tool::RustcPrivateCompilers; -use crate::core::builder::{Builder, RunConfig, ShouldRun, Step}; +use crate::core::builder::{Builder, CommandLineStep, RunConfig, ShouldRun}; use crate::core::config::{Config, TargetSelection}; use crate::utils::exec::command; use crate::utils::helpers::t; @@ -178,7 +178,7 @@ macro_rules! install { } } - impl Step for $name { + impl CommandLineStep for $name { type Output = (); const IS_HOST: bool = $IS_HOST; $(const $c: bool = true;)* @@ -319,7 +319,7 @@ pub struct Src { stage: u32, } -impl Step for Src { +impl CommandLineStep for Src { type Output = (); const IS_HOST: bool = true; diff --git a/src/bootstrap/src/core/build_steps/llvm.rs b/src/bootstrap/src/core/build_steps/llvm.rs index be70d9f4f106c..ff96f341966b7 100644 --- a/src/bootstrap/src/core/build_steps/llvm.rs +++ b/src/bootstrap/src/core/build_steps/llvm.rs @@ -17,7 +17,7 @@ use std::{env, fs}; use build_helper::git::PathFreshness; use crate::core::build_steps::llvm; -use crate::core::builder::{Builder, RunConfig, ShouldRun, Step, StepMetadata}; +use crate::core::builder::{Builder, CommandLineStep, RunConfig, ShouldRun, StepMetadata}; use crate::core::config::{Config, LlvmPgoGenerationMode, TargetSelection}; use crate::utils::build_stamp::{BuildStamp, generate_smart_stamp_hash}; use crate::utils::exec::command; @@ -272,7 +272,7 @@ pub struct Llvm { pub target: TargetSelection, } -impl Step for Llvm { +impl CommandLineStep for Llvm { type Output = LlvmResult; const IS_HOST: bool = true; @@ -962,7 +962,7 @@ pub struct OmpOffload { pub target: TargetSelection, } -impl Step for OmpOffload { +impl CommandLineStep for OmpOffload { type Output = BuiltOmpOffload; const IS_HOST: bool = true; @@ -1142,7 +1142,7 @@ pub struct Enzyme { pub target: TargetSelection, } -impl Step for Enzyme { +impl CommandLineStep for Enzyme { type Output = BuiltEnzyme; const IS_HOST: bool = true; @@ -1278,7 +1278,7 @@ pub struct Lld { pub target: TargetSelection, } -impl Step for Lld { +impl CommandLineStep for Lld { type Output = PathBuf; const IS_HOST: bool = true; @@ -1402,7 +1402,7 @@ pub struct Sanitizers { pub target: TargetSelection, } -impl Step for Sanitizers { +impl CommandLineStep for Sanitizers { type Output = Vec; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { @@ -1598,7 +1598,7 @@ pub struct CrtBeginEnd { pub target: TargetSelection, } -impl Step for CrtBeginEnd { +impl CommandLineStep for CrtBeginEnd { type Output = PathBuf; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { @@ -1676,7 +1676,7 @@ pub struct Libunwind { pub target: TargetSelection, } -impl Step for Libunwind { +impl CommandLineStep for Libunwind { type Output = PathBuf; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { diff --git a/src/bootstrap/src/core/build_steps/run.rs b/src/bootstrap/src/core/build_steps/run.rs index 1d704230902e4..c062144aa5c41 100644 --- a/src/bootstrap/src/core/build_steps/run.rs +++ b/src/bootstrap/src/core/build_steps/run.rs @@ -12,7 +12,7 @@ use crate::core::build_steps::dist::distdir; use crate::core::build_steps::test; use crate::core::build_steps::tool::{self, RustcPrivateCompilers, SourceType, Tool}; use crate::core::build_steps::vendor::{VENDOR_DIR, Vendor, default_paths_to_vendor}; -use crate::core::builder::{Builder, Kind, RunConfig, ShouldRun, Step, StepMetadata}; +use crate::core::builder::{Builder, CommandLineStep, Kind, RunConfig, ShouldRun, StepMetadata}; use crate::core::config::TargetSelection; use crate::core::config::flags::{get_completion, top_level_help}; use crate::utils::exec::command; @@ -21,7 +21,7 @@ use crate::{Mode, exit, t}; #[derive(Debug, Clone, Hash, PartialEq, Eq)] pub struct BuildManifest; -impl Step for BuildManifest { +impl CommandLineStep for BuildManifest { type Output = (); const IS_HOST: bool = true; @@ -62,7 +62,7 @@ impl Step for BuildManifest { #[derive(Debug, Clone, Hash, PartialEq, Eq)] pub struct BumpStage0; -impl Step for BumpStage0 { +impl CommandLineStep for BumpStage0 { type Output = (); const IS_HOST: bool = true; @@ -84,7 +84,7 @@ impl Step for BumpStage0 { #[derive(Debug, Clone, Hash, PartialEq, Eq)] pub struct ReplaceVersionPlaceholder; -impl Step for ReplaceVersionPlaceholder { +impl CommandLineStep for ReplaceVersionPlaceholder { type Output = (); const IS_HOST: bool = true; @@ -117,7 +117,7 @@ pub struct Miri { target: TargetSelection, } -impl Step for Miri { +impl CommandLineStep for Miri { type Output = (); fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { @@ -195,7 +195,7 @@ impl Step for Miri { #[derive(Debug, Clone, Hash, PartialEq, Eq)] pub struct CollectLicenseMetadata; -impl Step for CollectLicenseMetadata { +impl CommandLineStep for CollectLicenseMetadata { type Output = PathBuf; const IS_HOST: bool = true; @@ -236,7 +236,7 @@ impl Step for CollectLicenseMetadata { #[derive(Debug, Clone, Hash, PartialEq, Eq)] pub struct GenerateCopyright; -impl Step for GenerateCopyright { +impl CommandLineStep for GenerateCopyright { type Output = Vec; const IS_HOST: bool = true; @@ -303,7 +303,7 @@ impl Step for GenerateCopyright { #[derive(Debug, Clone, Hash, PartialEq, Eq)] pub struct GenerateWindowsSys; -impl Step for GenerateWindowsSys { +impl CommandLineStep for GenerateWindowsSys { type Output = (); const IS_HOST: bool = true; @@ -339,7 +339,7 @@ pub fn get_completion_paths(builder: &Builder<'_>) -> Vec<(&'static dyn Generato #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct GenerateCompletions; -impl Step for GenerateCompletions { +impl CommandLineStep for GenerateCompletions { type Output = (); /// Uses `clap_complete` to generate shell completions. @@ -367,7 +367,7 @@ impl Step for GenerateCompletions { #[derive(Debug, Clone, Hash, PartialEq, Eq)] pub struct UnicodeTableGenerator; -impl Step for UnicodeTableGenerator { +impl CommandLineStep for UnicodeTableGenerator { type Output = (); const IS_HOST: bool = true; @@ -391,7 +391,7 @@ impl Step for UnicodeTableGenerator { #[derive(Debug, Clone, Hash, PartialEq, Eq)] pub struct FeaturesStatusDump; -impl Step for FeaturesStatusDump { +impl CommandLineStep for FeaturesStatusDump { type Output = (); const IS_HOST: bool = true; @@ -426,7 +426,7 @@ pub struct CyclicStep { n: u32, } -impl Step for CyclicStep { +impl CommandLineStep for CyclicStep { type Output = (); fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { @@ -451,7 +451,7 @@ impl Step for CyclicStep { #[derive(Debug, Clone, Hash, PartialEq, Eq)] pub struct CoverageDump; -impl Step for CoverageDump { +impl CommandLineStep for CoverageDump { type Output = (); const IS_HOST: bool = true; @@ -477,7 +477,7 @@ impl Step for CoverageDump { #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct Rustfmt; -impl Step for Rustfmt { +impl CommandLineStep for Rustfmt { type Output = (); const IS_HOST: bool = true; @@ -535,7 +535,7 @@ pub fn get_help_path(builder: &Builder<'_>) -> PathBuf { #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct GenerateHelp; -impl Step for GenerateHelp { +impl CommandLineStep for GenerateHelp { type Output = (); fn run(self, builder: &Builder<'_>) { diff --git a/src/bootstrap/src/core/build_steps/setup.rs b/src/bootstrap/src/core/build_steps/setup.rs index 8e65cb18d58fb..7b0bd1e3067fb 100644 --- a/src/bootstrap/src/core/build_steps/setup.rs +++ b/src/bootstrap/src/core/build_steps/setup.rs @@ -18,7 +18,7 @@ use std::{fmt, fs, io}; use serde_derive::{Deserialize, Serialize}; use sha2::Digest; -use crate::core::builder::{Builder, RunConfig, ShouldRun, Step}; +use crate::core::builder::{Builder, CommandLineStep, RunConfig, ShouldRun}; use crate::utils::change_tracker::CONFIG_CHANGE_HISTORY; use crate::utils::exec::command; use crate::utils::helpers::{self, hex_encode}; @@ -104,7 +104,7 @@ impl fmt::Display for Profile { } } -impl Step for Profile { +impl CommandLineStep for Profile { type Output = (); fn should_run(mut run: ShouldRun<'_>) -> ShouldRun<'_> { @@ -235,7 +235,7 @@ fn setup_config_toml(path: &Path, profile: Profile, config: &Config) { /// Creates a toolchain link for stage1 using `rustup` #[derive(Clone, Debug, Eq, PartialEq, Hash)] pub struct Link; -impl Step for Link { +impl CommandLineStep for Link { type Output = (); fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { @@ -457,7 +457,7 @@ fn prompt_user(prompt: &str) -> io::Result> { #[derive(Clone, Debug, Eq, PartialEq, Hash)] pub struct Hook; -impl Step for Hook { +impl CommandLineStep for Hook { type Output = (); fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { @@ -645,7 +645,7 @@ Select which editor you would like to set up [default: None]: "; #[derive(Clone, Debug, Eq, PartialEq, Hash)] pub struct Editor; -impl Step for Editor { +impl CommandLineStep for Editor { type Output = (); fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { diff --git a/src/bootstrap/src/core/build_steps/synthetic_targets.rs b/src/bootstrap/src/core/build_steps/synthetic_targets.rs index 964ccf1c31088..88f04dcb27c6e 100644 --- a/src/bootstrap/src/core/build_steps/synthetic_targets.rs +++ b/src/bootstrap/src/core/build_steps/synthetic_targets.rs @@ -8,7 +8,7 @@ //! that calls create_synthetic_target. use crate::Compiler; -use crate::core::builder::{Builder, ShouldRun, Step}; +use crate::core::builder::{Builder, Step}; use crate::core::config::TargetSelection; #[derive(Debug, Clone, PartialEq, Eq, Hash)] @@ -20,14 +20,6 @@ pub(crate) struct MirOptPanicAbortSyntheticTarget { impl Step for MirOptPanicAbortSyntheticTarget { type Output = TargetSelection; - fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { - run.never() - } - - fn is_default_step(_builder: &Builder<'_>) -> bool { - true - } - fn run(self, builder: &Builder<'_>) -> Self::Output { create_synthetic_target(builder, self.compiler, "miropt-abort", self.base, |spec| { spec.insert("panic-strategy".into(), "abort".into()); diff --git a/src/bootstrap/src/core/build_steps/test.rs b/src/bootstrap/src/core/build_steps/test.rs index 44bedaf878e04..6b342f0d5e6e8 100644 --- a/src/bootstrap/src/core/build_steps/test.rs +++ b/src/bootstrap/src/core/build_steps/test.rs @@ -28,8 +28,8 @@ use crate::core::build_steps::tool::{ use crate::core::build_steps::toolstate::ToolState; use crate::core::build_steps::{compile, dist, llvm}; use crate::core::builder::{ - self, Alias, Builder, Compiler, Kind, RunConfig, ShouldRun, Step, StepMetadata, - crate_description, + self, Alias, Builder, CommandLineStep, Compiler, Kind, RunConfig, ShouldRun, Step, + StepMetadata, crate_description, }; use crate::core::config::TargetSelection; use crate::core::config::flags::{Subcommand, get_completion, top_level_help}; @@ -54,7 +54,7 @@ pub struct CrateBootstrap { host: TargetSelection, } -impl Step for CrateBootstrap { +impl CommandLineStep for CrateBootstrap { type Output = (); const IS_HOST: bool = true; @@ -123,7 +123,7 @@ pub struct Linkcheck { host: TargetSelection, } -impl Step for Linkcheck { +impl CommandLineStep for Linkcheck { type Output = (); const IS_HOST: bool = true; @@ -222,7 +222,7 @@ pub struct HtmlCheck { target: TargetSelection, } -impl Step for HtmlCheck { +impl CommandLineStep for HtmlCheck { type Output = (); const IS_HOST: bool = true; @@ -275,7 +275,7 @@ pub struct Cargotest { host: TargetSelection, } -impl Step for Cargotest { +impl CommandLineStep for Cargotest { type Output = (); const IS_HOST: bool = true; @@ -352,7 +352,7 @@ impl Cargo { const CRATE_PATH: &str = "src/tools/cargo"; } -impl Step for Cargo { +impl CommandLineStep for Cargo { type Output = (); const IS_HOST: bool = true; @@ -454,7 +454,7 @@ pub struct RustAnalyzer { compilers: RustcPrivateCompilers, } -impl Step for RustAnalyzer { +impl CommandLineStep for RustAnalyzer { type Output = (); const IS_HOST: bool = true; @@ -578,7 +578,7 @@ pub struct Rustfmt { compilers: RustcPrivateCompilers, } -impl Step for Rustfmt { +impl CommandLineStep for Rustfmt { type Output = (); const IS_HOST: bool = true; @@ -683,7 +683,7 @@ impl Miri { } } -impl Step for Miri { +impl CommandLineStep for Miri { type Output = (); fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { @@ -801,7 +801,7 @@ pub struct CargoMiri { target: TargetSelection, } -impl Step for CargoMiri { +impl CommandLineStep for CargoMiri { type Output = (); fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { @@ -881,7 +881,7 @@ pub struct CompiletestTest { host: TargetSelection, } -impl Step for CompiletestTest { +impl CommandLineStep for CompiletestTest { type Output = (); fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { @@ -947,7 +947,7 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct StdarchVerify; -impl Step for StdarchVerify { +impl CommandLineStep for StdarchVerify { type Output = (); const IS_HOST: bool = true; @@ -1005,7 +1005,7 @@ pub struct IntrinsicTest { host: TargetSelection, } -impl Step for IntrinsicTest { +impl CommandLineStep for IntrinsicTest { type Output = (); const IS_HOST: bool = true; @@ -1164,7 +1164,7 @@ pub struct Clippy { compilers: RustcPrivateCompilers, } -impl Step for Clippy { +impl CommandLineStep for Clippy { type Output = (); const IS_HOST: bool = true; @@ -1281,7 +1281,7 @@ pub struct RustdocTheme { test_compiler: Compiler, } -impl Step for RustdocTheme { +impl CommandLineStep for RustdocTheme { type Output = (); const IS_HOST: bool = true; @@ -1334,7 +1334,7 @@ pub struct RustdocJSStd { target: TargetSelection, } -impl Step for RustdocJSStd { +impl CommandLineStep for RustdocJSStd { type Output = (); const IS_HOST: bool = true; @@ -1411,7 +1411,7 @@ pub struct RustdocJSNotStd { pub compiler: Compiler, } -impl Step for RustdocJSNotStd { +impl CommandLineStep for RustdocJSNotStd { type Output = (); const IS_HOST: bool = true; @@ -1479,7 +1479,7 @@ pub struct RustdocGUI { target: TargetSelection, } -impl Step for RustdocGUI { +impl CommandLineStep for RustdocGUI { type Output = (); const IS_HOST: bool = true; @@ -1584,7 +1584,7 @@ impl Step for RustdocGUI { #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct Tidy; -impl Step for Tidy { +impl CommandLineStep for Tidy { type Output = (); const IS_HOST: bool = true; @@ -1721,7 +1721,7 @@ pub struct CrateRunMakeSupport { host: TargetSelection, } -impl Step for CrateRunMakeSupport { +impl CommandLineStep for CrateRunMakeSupport { type Output = (); const IS_HOST: bool = true; @@ -1767,7 +1767,7 @@ pub struct CrateBuildHelper { host: TargetSelection, } -impl Step for CrateBuildHelper { +impl CommandLineStep for CrateBuildHelper { type Output = (); const IS_HOST: bool = true; @@ -1833,7 +1833,7 @@ macro_rules! test { target: TargetSelection, } - impl Step for $name { + impl CommandLineStep for $name { type Output = (); const IS_HOST: bool = (const { #[allow(unused_assignments, unused_mut)] @@ -1994,7 +1994,7 @@ impl Coverage { &[CompiletestMode::CoverageMap, CompiletestMode::CoverageRun]; } -impl Step for Coverage { +impl CommandLineStep for Coverage { type Output = (); /// Compiletest will automatically skip the "coverage-run" tests if necessary. const IS_HOST: bool = false; @@ -2091,7 +2091,7 @@ pub struct MirOpt { pub target: TargetSelection, } -impl Step for MirOpt { +impl CommandLineStep for MirOpt { type Output = (); fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { @@ -2164,10 +2164,6 @@ struct Compiletest { impl Step for Compiletest { type Output = (); - fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { - run.never() - } - fn run(self, builder: &Builder<'_>) { if builder.test_target == TestTarget::DocOnly { return; @@ -2888,11 +2884,6 @@ struct BookTest { impl Step for BookTest { type Output = (); - const IS_HOST: bool = true; - - fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { - run.never() - } fn run(self, builder: &Builder<'_>) { // External docs are different from local because: @@ -3051,7 +3042,7 @@ macro_rules! test_book { test_compiler: Compiler, } - impl Step for $name { + impl CommandLineStep for $name { type Output = (); const IS_HOST: bool = true; @@ -3114,7 +3105,7 @@ pub struct ErrorIndex { compilers: RustcPrivateCompilers, } -impl Step for ErrorIndex { +impl CommandLineStep for ErrorIndex { type Output = (); const IS_HOST: bool = true; @@ -3208,7 +3199,7 @@ pub struct CrateLibrustc { crates: Vec, } -impl Step for CrateLibrustc { +impl CommandLineStep for CrateLibrustc { type Output = (); const IS_HOST: bool = true; @@ -3369,7 +3360,7 @@ pub struct Crate { crates: Vec, } -impl Step for Crate { +impl CommandLineStep for Crate { type Output = (); fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { @@ -3517,7 +3508,7 @@ pub struct CrateRustdoc { host: TargetSelection, } -impl Step for CrateRustdoc { +impl CommandLineStep for CrateRustdoc { type Output = (); const IS_HOST: bool = true; @@ -3622,7 +3613,7 @@ pub struct CrateRustdocJsonTypes { target: TargetSelection, } -impl Step for CrateRustdocJsonTypes { +impl CommandLineStep for CrateRustdocJsonTypes { type Output = (); const IS_HOST: bool = true; @@ -3698,10 +3689,6 @@ pub struct RemoteCopyLibs { impl Step for RemoteCopyLibs { type Output = (); - fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { - run.never() - } - fn run(self, builder: &Builder<'_>) { let build_compiler = self.build_compiler; let target = self.target; @@ -3740,7 +3727,7 @@ impl Step for RemoteCopyLibs { #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct Distcheck; -impl Step for Distcheck { +impl CommandLineStep for Distcheck { type Output = (); fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { @@ -3864,7 +3851,7 @@ fn distcheck_rustc_dev(builder: &Builder<'_>, dir: &Path) { #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub(crate) struct BootstrapPy; -impl Step for BootstrapPy { +impl CommandLineStep for BootstrapPy { type Output = (); const IS_HOST: bool = true; @@ -3903,7 +3890,7 @@ impl Step for BootstrapPy { #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct Bootstrap; -impl Step for Bootstrap { +impl CommandLineStep for Bootstrap { type Output = (); const IS_HOST: bool = true; @@ -3973,7 +3960,7 @@ pub struct TierCheck { test_compiler: Compiler, } -impl Step for TierCheck { +impl CommandLineStep for TierCheck { type Output = (); const IS_HOST: bool = true; @@ -4025,7 +4012,7 @@ pub struct LintDocs { target: TargetSelection, } -impl Step for LintDocs { +impl CommandLineStep for LintDocs { type Output = (); const IS_HOST: bool = true; @@ -4071,7 +4058,7 @@ impl Step for LintDocs { #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct RustInstaller; -impl Step for RustInstaller { +impl CommandLineStep for RustInstaller { type Output = (); const IS_HOST: bool = true; @@ -4131,7 +4118,7 @@ pub struct TestHelpers { pub target: TargetSelection, } -impl Step for TestHelpers { +impl CommandLineStep for TestHelpers { type Output = (); fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { @@ -4215,7 +4202,7 @@ pub struct CodegenCranelift { target: TargetSelection, } -impl Step for CodegenCranelift { +impl CommandLineStep for CodegenCranelift { type Output = (); const IS_HOST: bool = true; @@ -4336,7 +4323,7 @@ pub struct CodegenGCC { target: TargetSelection, } -impl Step for CodegenGCC { +impl CommandLineStep for CodegenGCC { type Output = (); const IS_HOST: bool = true; @@ -4467,7 +4454,7 @@ pub struct TestFloatParse { target: TargetSelection, } -impl Step for TestFloatParse { +impl CommandLineStep for TestFloatParse { type Output = (); const IS_HOST: bool = true; @@ -4545,7 +4532,7 @@ impl Step for TestFloatParse { #[derive(Debug, Clone, Hash, PartialEq, Eq)] pub struct CollectLicenseMetadata; -impl Step for CollectLicenseMetadata { +impl CommandLineStep for CollectLicenseMetadata { type Output = PathBuf; const IS_HOST: bool = true; @@ -4579,7 +4566,7 @@ pub struct RemoteTestClientTests { host: TargetSelection, } -impl Step for RemoteTestClientTests { +impl CommandLineStep for RemoteTestClientTests { type Output = (); const IS_HOST: bool = true; diff --git a/src/bootstrap/src/core/build_steps/test/failed_tests.rs b/src/bootstrap/src/core/build_steps/test/failed_tests.rs index 8be6e50fd3db1..abcfbe31bb2c3 100644 --- a/src/bootstrap/src/core/build_steps/test/failed_tests.rs +++ b/src/bootstrap/src/core/build_steps/test/failed_tests.rs @@ -3,7 +3,7 @@ use std::fs::{self, File}; use std::io::{BufRead, BufReader, ErrorKind}; use std::path::{Path, PathBuf}; -use crate::core::builder::{Builder, ShouldRun, Step}; +use crate::core::builder::{Builder, Step}; use crate::t; #[derive(Clone)] @@ -32,10 +32,6 @@ pub struct SetupFailedTestsFile; impl Step for SetupFailedTestsFile { type Output = RecordFailedTests; - fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { - run.never() - } - fn run(self, builder: &Builder<'_>) -> Self::Output { if !builder.config.cmd.record() || builder.config.dry_run() { return RecordFailedTests { failed_tests_path: None }; diff --git a/src/bootstrap/src/core/build_steps/tool.rs b/src/bootstrap/src/core/build_steps/tool.rs index a6ecdea06623f..89143c8e74333 100644 --- a/src/bootstrap/src/core/build_steps/tool.rs +++ b/src/bootstrap/src/core/build_steps/tool.rs @@ -18,8 +18,8 @@ use crate::core::build_steps::toolstate::ToolState; use crate::core::build_steps::{compile, llvm}; use crate::core::builder; use crate::core::builder::{ - Builder, Cargo as CargoCommand, RunConfig, ShouldRun, Step, StepMetadata, apply_pgo, - cargo_profile_var, + Builder, Cargo as CargoCommand, CommandLineStep, RunConfig, ShouldRun, Step, StepMetadata, + apply_pgo, cargo_profile_var, }; use crate::core::config::{DebuginfoLevel, OverrideAllocator, RustcLto, TargetSelection}; use crate::utils::exec::{BootstrapCommand, command}; @@ -69,10 +69,6 @@ pub struct ToolBuildResult { impl Step for ToolBuild { type Output = ToolBuildResult; - fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { - run.never() - } - /// Builds a tool in `src/tools` /// /// This will build the specified tool with the specified `host` compiler in @@ -432,7 +428,7 @@ macro_rules! bootstrap_tool { pub target: TargetSelection, } - impl Step for $name { + impl CommandLineStep for $name { type Output = ToolBuildResult; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { @@ -535,7 +531,7 @@ pub struct RustcPerf { pub target: TargetSelection, } -impl Step for RustcPerf { +impl CommandLineStep for RustcPerf { /// Path to the built `collector` binary. type Output = ToolBuildResult; @@ -596,7 +592,7 @@ impl ErrorIndex { } } -impl Step for ErrorIndex { +impl CommandLineStep for ErrorIndex { type Output = ToolBuildResult; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { @@ -653,7 +649,7 @@ pub struct RemoteTestServer { pub target: TargetSelection, } -impl Step for RemoteTestServer { +impl CommandLineStep for RemoteTestServer { type Output = ToolBuildResult; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { @@ -701,7 +697,7 @@ pub struct Rustdoc { pub target_compiler: Compiler, } -impl Step for Rustdoc { +impl CommandLineStep for Rustdoc { /// Path to the built rustdoc binary. type Output = PathBuf; @@ -828,7 +824,7 @@ impl Cargo { } } -impl Step for Cargo { +impl CommandLineStep for Cargo { type Output = ToolBuildResult; const IS_HOST: bool = true; @@ -906,7 +902,7 @@ impl LldWrapper { } } -impl Step for LldWrapper { +impl CommandLineStep for LldWrapper { type Output = BuiltLldWrapper; const IS_HOST: bool = true; @@ -998,7 +994,7 @@ impl WasmComponentLd { } } -impl Step for WasmComponentLd { +impl CommandLineStep for WasmComponentLd { type Output = ToolBuildResult; const IS_HOST: bool = true; @@ -1052,7 +1048,7 @@ impl RustAnalyzer { pub const ALLOW_FEATURES: &'static str = "rustc_private,proc_macro_internals,proc_macro_diagnostic,proc_macro_span,proc_macro_span_shrink,proc_macro_def_site,new_zeroed_alloc"; } -impl Step for RustAnalyzer { +impl CommandLineStep for RustAnalyzer { type Output = ToolBuildResult; const IS_HOST: bool = true; @@ -1106,7 +1102,7 @@ impl RustAnalyzerProcMacroSrv { } } -impl Step for RustAnalyzerProcMacroSrv { +impl CommandLineStep for RustAnalyzerProcMacroSrv { type Output = ToolBuildResult; const IS_HOST: bool = true; @@ -1195,7 +1191,7 @@ impl LlvmBitcodeLinker { } } -impl Step for LlvmBitcodeLinker { +impl CommandLineStep for LlvmBitcodeLinker { type Output = ToolBuildResult; const IS_HOST: bool = true; @@ -1248,15 +1244,6 @@ pub enum LibcxxVersion { impl Step for LibcxxVersionTool { type Output = LibcxxVersion; - const IS_HOST: bool = true; - - fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { - run.never() - } - - fn is_default_step(_builder: &Builder<'_>) -> bool { - false - } fn run(self, builder: &Builder<'_>) -> LibcxxVersion { let out_dir = builder.out.join(self.target.to_string()).join("libcxx-version"); @@ -1312,7 +1299,7 @@ impl BuildManifest { } } -impl Step for BuildManifest { +impl CommandLineStep for BuildManifest { type Output = ToolBuildResult; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { @@ -1456,7 +1443,7 @@ macro_rules! tool_rustc_extended { } } - impl Step for $name { + impl CommandLineStep for $name { type Output = ToolBuildResult; const IS_HOST: bool = true; diff --git a/src/bootstrap/src/core/build_steps/toolstate.rs b/src/bootstrap/src/core/build_steps/toolstate.rs index fc7acd1fa149b..73b6863248df0 100644 --- a/src/bootstrap/src/core/build_steps/toolstate.rs +++ b/src/bootstrap/src/core/build_steps/toolstate.rs @@ -11,7 +11,7 @@ use std::{env, fmt, fs, time}; use serde_derive::{Deserialize, Serialize}; -use crate::core::builder::{Builder, RunConfig, ShouldRun, Step}; +use crate::core::builder::{Builder, CommandLineStep, RunConfig, ShouldRun}; use crate::utils::helpers::{self, t}; // Each cycle is 42 days long (6 weeks); the last week is 35..=42 then. @@ -122,7 +122,7 @@ fn check_changed_files(builder: &Builder<'_>, toolstates: &HashMap, Too #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub struct ToolStateCheck; -impl Step for ToolStateCheck { +impl CommandLineStep for ToolStateCheck { type Output = (); /// Checks tool state status. diff --git a/src/bootstrap/src/core/build_steps/vendor.rs b/src/bootstrap/src/core/build_steps/vendor.rs index 519f134bb8203..1bf9331500f8b 100644 --- a/src/bootstrap/src/core/build_steps/vendor.rs +++ b/src/bootstrap/src/core/build_steps/vendor.rs @@ -5,7 +5,7 @@ use std::path::PathBuf; use crate::core::build_steps::tool::SUBMODULES_FOR_RUSTBOOK; -use crate::core::builder::{Builder, RunConfig, ShouldRun, Step}; +use crate::core::builder::{Builder, CommandLineStep, RunConfig, ShouldRun}; use crate::utils::exec::command; /// The name of the directory where vendored dependencies are stored. @@ -58,7 +58,7 @@ pub(crate) struct Vendor { pub(crate) only_library_workspace: bool, } -impl Step for Vendor { +impl CommandLineStep for Vendor { type Output = VendorOutput; const IS_HOST: bool = true; diff --git a/src/bootstrap/src/core/builder/cli_paths.rs b/src/bootstrap/src/core/builder/cli_paths.rs index b645ce9f417ae..4ad76b29e5246 100644 --- a/src/bootstrap/src/core/builder/cli_paths.rs +++ b/src/bootstrap/src/core/builder/cli_paths.rs @@ -5,7 +5,7 @@ use std::fmt::{self, Debug}; use std::path::PathBuf; -use crate::core::builder::{Builder, Kind, PathSet, ShouldRun, StepDescription}; +use crate::core::builder::{Builder, CommandLineStepDescription, Kind, PathSet, ShouldRun}; #[cfg(test)] mod tests; @@ -93,21 +93,21 @@ impl From for CLIStepPath { } } -/// Combines a `StepDescription` with its corresponding `ShouldRun`. +/// Combines a [`CommandLineStepDescription`] with its corresponding [`ShouldRun`]. struct StepExtra<'a> { - desc: &'a StepDescription, + desc: &'a CommandLineStepDescription, should_run: ShouldRun<'a>, } struct StepToRun<'a> { sort_index: usize, - desc: &'a StepDescription, + desc: &'a CommandLineStepDescription, pathsets: Vec, } pub(crate) fn match_paths_to_steps_and_run( builder: &Builder<'_>, - step_descs: &[StepDescription], + step_descs: &[CommandLineStepDescription], paths: &[PathBuf], ) { // Obtain `ShouldRun` information for each step, so that we know which diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_clean.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_clean.snap index 71f12ecd501a7..30eb798f39938 100644 --- a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_clean.snap +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_clean.snap @@ -4,4 +4,4 @@ expression: clean --- [Clean] clean::CleanAll targets: [aarch64-unknown-linux-gnu] - - Set({}) + - Set({clean::default}) diff --git a/src/bootstrap/src/core/builder/cli_paths/tests.rs b/src/bootstrap/src/core/builder/cli_paths/tests.rs index 79137de12981b..465a370ad69f8 100644 --- a/src/bootstrap/src/core/builder/cli_paths/tests.rs +++ b/src/bootstrap/src/core/builder/cli_paths/tests.rs @@ -3,7 +3,7 @@ use std::path::PathBuf; use std::sync::{Arc, Mutex}; use crate::Build; -use crate::core::builder::{Builder, StepDescription}; +use crate::core::builder::{Builder, CommandLineStepDescription}; use crate::utils::tests::TestCtx; fn render_steps_for_cli_args(args_str: &str) -> String { @@ -38,7 +38,7 @@ fn render_steps_for_cli_args(args_str: &str) -> String { use std::fmt::Write; let mut buf = buf2.lock().unwrap(); - let StepDescription { name, kind, .. } = step_desc; + let CommandLineStepDescription { name, kind, .. } = step_desc; // Strip boilerplate to make step names easier to read. let name = name.strip_prefix("bootstrap::core::build_steps::").unwrap_or(name); diff --git a/src/bootstrap/src/core/builder/mod.rs b/src/bootstrap/src/core/builder/mod.rs index 02f18b43b5ba1..50188887a5314 100644 --- a/src/bootstrap/src/core/builder/mod.rs +++ b/src/bootstrap/src/core/builder/mod.rs @@ -75,7 +75,8 @@ pub struct Builder<'a> { /// executed to be logged instead. Used by snapshot tests of command-line /// paths-to-steps handling. #[expect(clippy::type_complexity)] - log_cli_step_for_tests: Option>, + log_cli_step_for_tests: + Option>, } impl Deref for Builder<'_> { @@ -101,8 +102,47 @@ impl dyn AnyDebug { // Feel free to add other `dyn Any` methods as necessary. } +/// A unit of work within bootstrap that is cached to avoid redundant execution. +/// Steps can be performed via [`Builder::ensure`]. +/// +/// Historically, steps also participated in command-line processing. +/// That responsibility has been split off into the larger [`CommandLineStep`] trait, +/// which helper steps don't need to implement. pub trait Step: 'static + Clone + Debug + PartialEq + Eq + Hash { - /// Result type of `Step::run`. + /// Result type of [`Step::run`]. Stored in the step cache for later lookup. + type Output: Clone; + + /// Executes this step. + /// + /// Called by [`Builder::ensure`] if no cached result was found for this step. + fn run(self, builder: &Builder<'_>) -> Self::Output; + + /// Returns metadata of the step, for tests. + fn metadata(&self) -> Option { + None + } +} + +/// Every [`CommandLineStep`] is also a [`Step`]. +impl Step for S { + type Output = ::Output; + + fn run(self, builder: &Builder<'_>) -> Self::Output { + ::run(self, builder) + } + + fn metadata(&self) -> Option { + ::metadata(self) + } +} + +/// A [`Step`] that can be selected by command-line arguments. +/// +/// A blanket impl allows every [`CommandLineStep`] to be used as a [`Step`]. +/// This is arguably nicer than having it be a subtrait, because it avoids the +/// need for two separate `impl` blocks per command-line-step type. +pub trait CommandLineStep: 'static + Clone + Debug + PartialEq + Eq + Hash { + /// Result type of [`Step::run`]. type Output: Clone; /// If this value is true, then the values of `run.target` passed to the `make_run` function of @@ -134,33 +174,15 @@ pub trait Step: 'static + Clone + Debug + PartialEq + Eq + Hash { false } - /// Primary function to implement `Step` logic. - /// - /// This function can be triggered in two ways: - /// 1. Directly from [`Builder::execute_cli`]. - /// 2. Indirectly by being called from other `Step`s using [`Builder::ensure`]. - /// - /// When called with [`Builder::execute_cli`] (as done by `Build::build`), this function is executed twice: - /// - First in "dry-run" mode to validate certain things (like cyclic Step invocations, - /// directory creation, etc) super quickly. - /// - Then it's called again to run the actual, very expensive process. - /// - /// When triggered indirectly from other `Step`s, it may still run twice (as dry-run and real mode) - /// depending on the `Step::run` implementation of the caller. - fn run(self, builder: &Builder<'_>) -> Self::Output; - /// Called directly by the bootstrap `Step` handler when not triggered indirectly by other `Step`s using [`Builder::ensure`]. /// For example, `./x.py test bootstrap` runs this for `test::Bootstrap`. Similarly, `./x.py test` runs it for every step /// that is listed by the `describe` macro in [`Builder::get_step_descriptions`]. - fn make_run(_run: RunConfig<'_>) { - // It is reasonable to not have an implementation of make_run for rules - // who do not want to get called from the root context. This means that - // they are likely dependencies (e.g., sysroot creation) or similar, and - // as such calling them from ./x.py isn't logical. - unimplemented!() - } + fn make_run(_run: RunConfig<'_>); + + /// Used as the implementation of [`Step::run`]. + fn run(self, builder: &Builder<'_>) -> Self::Output; - /// Returns metadata of the step, for tests + /// Used as the implementation of [`Step::metadata`]. fn metadata(&self) -> Option { None } @@ -327,7 +349,7 @@ pub fn crate_description(crates: &[impl AsRef]) -> String { descr } -struct StepDescription { +struct CommandLineStepDescription { is_host: bool, should_run: fn(ShouldRun<'_>) -> ShouldRun<'_>, is_default_step_fn: fn(&Builder<'_>) -> bool, @@ -446,9 +468,9 @@ impl PathSet { } } -impl StepDescription { - fn from(kind: Kind) -> StepDescription { - StepDescription { +impl CommandLineStepDescription { + fn from(kind: Kind) -> CommandLineStepDescription { + CommandLineStepDescription { is_host: S::IS_HOST, should_run: S::should_run, is_default_step_fn: S::is_default_step, @@ -617,12 +639,6 @@ impl<'a> ShouldRun<'a> { self } - // allows being more explicit about why should_run in Step returns the value passed to it - pub fn never(mut self) -> ShouldRun<'a> { - self.paths.insert(PathSet::empty()); - self - } - /// Given a set of requested paths, return the subset which match the Step for this `ShouldRun`, /// removing the matches from `paths`. /// @@ -747,16 +763,12 @@ struct Libdir { impl Step for Libdir { type Output = PathBuf; - fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { - run.never() - } - fn run(self, builder: &Builder<'_>) -> PathBuf { let relative_sysroot_libdir = builder.sysroot_libdir_relative(self.compiler); let sysroot = builder.sysroot(self.compiler).join(relative_sysroot_libdir).join("rustlib"); if !builder.config.dry_run() { - // Avoid deleting the `rustlib/` directory we just copied (in `impl Step for + // Avoid deleting the `rustlib/` directory we just copied (in `impl CommandLineStep for // Sysroot`). if !builder.download_rustc() { let sysroot_target_libdir = sysroot.join(self.target).join("lib"); @@ -790,10 +802,10 @@ impl Step for Libdir { pub const STEP_SPAN_TARGET: &str = "STEP"; impl<'a> Builder<'a> { - fn get_step_descriptions(kind: Kind) -> Vec { + fn get_step_descriptions(kind: Kind) -> Vec { macro_rules! describe { ($($rule:ty),+ $(,)?) => {{ - vec![$(StepDescription::from::<$rule>(kind)),+] + vec![$(CommandLineStepDescription::from::<$rule>(kind)),+] }}; } match kind { @@ -1173,7 +1185,7 @@ impl<'a> Builder<'a> { format!("https://doc.rust-lang.org/{channel}") } - fn run_step_descriptions(&self, v: &[StepDescription], paths: &[PathBuf]) { + fn run_step_descriptions(&self, v: &[CommandLineStepDescription], paths: &[PathBuf]) { cli_paths::match_paths_to_steps_and_run(self, v, paths); } @@ -1681,12 +1693,12 @@ Alternatively, you can set `build.local-rebuild=true` and use a stage0 compiler /// Ensure that a given step is built *only if it's supposed to be built by default*, returning /// its output. This will cache the step, so it's safe (and good!) to call this as often as /// needed to ensure that all dependencies are build. - pub(crate) fn ensure_if_default>( + pub(crate) fn ensure_if_default>( &'a self, step: S, kind: Kind, ) -> Option { - let desc = StepDescription::from::(kind); + let desc = CommandLineStepDescription::from::(kind); let should_run = (desc.should_run)(ShouldRun::new(self, desc.kind)); // Avoid running steps contained in --skip @@ -1701,8 +1713,8 @@ Alternatively, you can set `build.local-rebuild=true` and use a stage0 compiler } /// Checks if any of the "should_run" paths is in the `Builder` paths. - pub(crate) fn was_invoked_explicitly(&'a self, kind: Kind) -> bool { - let desc = StepDescription::from::(kind); + pub(crate) fn was_invoked_explicitly(&'a self, kind: Kind) -> bool { + let desc = CommandLineStepDescription::from::(kind); let should_run = (desc.should_run)(ShouldRun::new(self, desc.kind)); for path in &self.paths { @@ -1719,7 +1731,7 @@ Alternatively, you can set `build.local-rebuild=true` and use a stage0 compiler false } - pub(crate) fn maybe_open_in_browser(&self, path: impl AsRef) { + pub(crate) fn maybe_open_in_browser(&self, path: impl AsRef) { if self.was_invoked_explicitly::(Kind::Doc) { self.open_in_browser(path); } else {