diff options
| author | Bernardo Meurer Costa <bemeurer@amazon.com> | 2024-05-14 21:18:31 +0000 |
|---|---|---|
| committer | Bernardo Meurer Costa <bemeurer@amazon.com> | 2024-05-20 14:56:50 +0000 |
| commit | 4c075c622cd929c1561fcbfc369813aceefb86f1 (patch) | |
| tree | e73e6bd9b6391ae7db560dd1c34cb9addf2b157a | |
| parent | e287044149edf039ffd584557b4bf05507a9f213 (diff) | |
| download | rust-4c075c622cd929c1561fcbfc369813aceefb86f1.tar.gz rust-4c075c622cd929c1561fcbfc369813aceefb86f1.zip | |
refactor(bootstrap): update rustc-perf submodule when building opt-dist
This avoids having normal builds pay the cost of initializing that submodule, while still ensuring it's available whenever `opt-dist` is built. Note that, at this point, `opt-dist` will not yet use the submodule, that will be handled in a subsequent commit.
| -rw-r--r-- | src/bootstrap/src/core/build_steps/tool.rs | 41 |
1 files changed, 39 insertions, 2 deletions
diff --git a/src/bootstrap/src/core/build_steps/tool.rs b/src/bootstrap/src/core/build_steps/tool.rs index 21344a4224e..2db3f8f7936 100644 --- a/src/bootstrap/src/core/build_steps/tool.rs +++ b/src/bootstrap/src/core/build_steps/tool.rs @@ -1,6 +1,6 @@ use std::env; use std::fs; -use std::path::PathBuf; +use std::path::{Path, PathBuf}; use std::process::Command; use crate::core::build_steps::compile; @@ -313,10 +313,47 @@ bootstrap_tool!( SuggestTests, "src/tools/suggest-tests", "suggest-tests"; GenerateWindowsSys, "src/tools/generate-windows-sys", "generate-windows-sys"; RustdocGUITest, "src/tools/rustdoc-gui-test", "rustdoc-gui-test", is_unstable_tool = true, allow_features = "test"; - OptimizedDist, "src/tools/opt-dist", "opt-dist"; CoverageDump, "src/tools/coverage-dump", "coverage-dump"; ); +#[derive(Debug, Clone, Hash, PartialEq, Eq)] +pub struct OptimizedDist { + pub compiler: Compiler, + pub target: TargetSelection, +} + +impl Step for OptimizedDist { + type Output = PathBuf; + + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { + run.path("src/tools/opt-dist") + } + + fn make_run(run: RunConfig<'_>) { + run.builder.ensure(OptimizedDist { + compiler: run.builder.compiler(0, run.builder.config.build), + target: run.target, + }); + } + + fn run(self, builder: &Builder<'_>) -> PathBuf { + // We need to ensure the rustc-perf submodule is initialized when building opt-dist since + // the tool requires it to be in place to run. + builder.update_submodule(Path::new("src/tools/rustc-perf")); + + builder.ensure(ToolBuild { + compiler: self.compiler, + target: self.target, + tool: "opt-dist", + mode: Mode::ToolBootstrap, + path: "src/tools/opt-dist", + source_type: SourceType::InTree, + extra_features: Vec::new(), + allow_features: "", + }) + } +} + #[derive(Debug, Clone, Hash, PartialEq, Eq, Ord, PartialOrd)] pub struct ErrorIndex { pub compiler: Compiler, |
