Skip to content

Commit a57f0ee

Browse files
committed
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.
1 parent 12e9f52 commit a57f0ee

File tree

1 file changed

+39
-2
lines changed
  • src/bootstrap/src/core/build_steps

1 file changed

+39
-2
lines changed

src/bootstrap/src/core/build_steps/tool.rs

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::env;
22
use std::fs;
3-
use std::path::PathBuf;
3+
use std::path::{Path, PathBuf};
44
use std::process::Command;
55

66
use crate::core::build_steps::compile;
@@ -313,10 +313,47 @@ bootstrap_tool!(
313313
SuggestTests, "src/tools/suggest-tests", "suggest-tests";
314314
GenerateWindowsSys, "src/tools/generate-windows-sys", "generate-windows-sys";
315315
RustdocGUITest, "src/tools/rustdoc-gui-test", "rustdoc-gui-test", is_unstable_tool = true, allow_features = "test";
316-
OptimizedDist, "src/tools/opt-dist", "opt-dist";
317316
CoverageDump, "src/tools/coverage-dump", "coverage-dump";
318317
);
319318

319+
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
320+
pub struct OptimizedDist {
321+
pub compiler: Compiler,
322+
pub target: TargetSelection,
323+
}
324+
325+
impl Step for OptimizedDist {
326+
type Output = PathBuf;
327+
328+
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
329+
run.path("src/tools/opt-dist")
330+
}
331+
332+
fn make_run(run: RunConfig<'_>) {
333+
run.builder.ensure(OptimizedDist {
334+
compiler: run.builder.compiler(0, run.builder.config.build),
335+
target: run.target,
336+
});
337+
}
338+
339+
fn run(self, builder: &Builder<'_>) -> PathBuf {
340+
// We need to ensure the rustc-perf submodule is initialized when building opt-dist since
341+
// the tool requires it to be in place to run.
342+
builder.update_submodule(Path::new("src/tools/rustc-perf"));
343+
344+
builder.ensure(ToolBuild {
345+
compiler: self.compiler,
346+
target: self.target,
347+
tool: "opt-dist",
348+
mode: Mode::ToolBootstrap,
349+
path: "src/tools/opt-dist",
350+
source_type: SourceType::InTree,
351+
extra_features: Vec::new(),
352+
allow_features: "",
353+
})
354+
}
355+
}
356+
320357
#[derive(Debug, Clone, Hash, PartialEq, Eq, Ord, PartialOrd)]
321358
pub struct ErrorIndex {
322359
pub compiler: Compiler,

0 commit comments

Comments
 (0)