From 32fd96c410439651599f3a05700218f88cf1e098 Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Sat, 5 Jun 2021 08:53:15 -0400 Subject: [PATCH 1/7] Give dynamically generated instructions on how to replicate errors during the build progress --- src/bootstrap/builder.rs | 57 +++++++++++++++++++++++++++++++++- src/bootstrap/builder/tests.rs | 3 +- src/bootstrap/cache.rs | 4 +-- src/bootstrap/compile.rs | 9 +++--- src/bootstrap/test.rs | 30 +++++++++++++----- 5 files changed, 87 insertions(+), 16 deletions(-) diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index 56ecc6e68a98c..6a8100f3a17a3 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -3,7 +3,7 @@ use std::cell::{Cell, RefCell}; use std::collections::BTreeSet; use std::env; use std::ffi::OsStr; -use std::fmt::Debug; +use std::fmt::{self, Debug, Display}; use std::fs; use std::hash::Hash; use std::ops::Deref; @@ -62,6 +62,17 @@ pub trait Step: 'static + Clone + Debug + PartialEq + Eq + Hash { /// If true, then this rule should be skipped if --target was specified, but --host was not const ONLY_HOSTS: bool = false; + /// A user-visible name to display if this step fails. + fn name(&self) -> &'static str { + std::any::type_name::() + } + + /// The path that should be used on the command line to run this step. + fn path(&self, builder: &Builder<'_>) -> PathBuf { + let paths = Self::should_run(ShouldRun::new(builder)).paths; + paths.iter().map(|pathset| pathset.path(builder)).next().expect("no paths for step") + } + /// Primary function to execute this rule. Can call `builder.ensure()` /// with other steps to run those. fn run(self, builder: &Builder<'_>) -> Self::Output; @@ -351,6 +362,26 @@ pub enum Kind { Run, } +impl Display for Kind { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + use Kind::*; + let s = match self { + Build => "build", + Check => "check", + Clippy => "clippy", + Fix => "fix", + Format => "fmt", + Test => "test", + Bench => "bench", + Dist => "dist", + Doc => "doc", + Install => "install", + Run => "run", + }; + f.write_str(s) + } +} + impl<'a> Builder<'a> { fn get_step_descriptions(kind: Kind) -> Vec { macro_rules! describe { @@ -610,6 +641,29 @@ impl<'a> Builder<'a> { StepDescription::run(v, self, paths); } + /// Print a command that will run the current step. + /// + /// This serves two purposes: + /// 1. Describe what step is currently being run. + /// 2. Describe how to run only this step in case it fails. + pub(crate) fn step_info(&self, step: &impl Step) { + if self.config.dry_run { + return; + } + print!( + "{} {} --stage {}", + // TODO: this is wrong, e.g. `check --stage 1` runs build commands first + self.kind, + step.path(self).display(), + // FIXME: top_stage might be higher than the stage of the step + self.top_stage, + ); + for arg in self.config.cmd.test_args() { + print!(" --test-args \"{}\"", arg); + } + println!(); + } + /// Obtain a compiler at a given stage and for a given host. Explicitly does /// not take `Compiler` since all `Compiler` instances are meant to be /// obtained through this function, since it ensures that they are valid @@ -1563,6 +1617,7 @@ impl<'a> Builder<'a> { let out = step.clone().run(self); let dur = start.elapsed(); let deps = self.time_spent_on_dependencies.replace(parent + dur); + (out, dur - deps) }; diff --git a/src/bootstrap/builder/tests.rs b/src/bootstrap/builder/tests.rs index e7fb8c0d4d5d2..c4d0d48a6d844 100644 --- a/src/bootstrap/builder/tests.rs +++ b/src/bootstrap/builder/tests.rs @@ -511,7 +511,8 @@ mod dist { target: host, mode: Mode::Std, test_kind: test::TestKind::Test, - krate: INTERNER.intern_str("std"), + krate_name: INTERNER.intern_str("std"), + krate_path: "library/std".into(), },] ); } diff --git a/src/bootstrap/cache.rs b/src/bootstrap/cache.rs index 0c16fae01bca7..2c74fbd6b0c07 100644 --- a/src/bootstrap/cache.rs +++ b/src/bootstrap/cache.rs @@ -271,7 +271,7 @@ impl Cache { #[cfg(test)] impl Cache { - pub fn all(&mut self) -> Vec<(S, S::Output)> { + pub fn all(&mut self) -> Vec<(S, S::Output)> { let cache = self.0.get_mut(); let type_id = TypeId::of::(); let mut v = cache @@ -279,7 +279,7 @@ impl Cache { .map(|b| b.downcast::>().expect("correct type")) .map(|m| m.into_iter().collect::>()) .unwrap_or_default(); - v.sort_by_key(|&(a, _)| a); + v.sort_by_key(|(a, _)| a.clone()); v } diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs index 78c9a25262243..573f44cbf2ce3 100644 --- a/src/bootstrap/compile.rs +++ b/src/bootstrap/compile.rs @@ -107,10 +107,11 @@ impl Step for Std { let mut cargo = builder.cargo(compiler, Mode::Std, SourceType::InTree, target, "build"); std_cargo(builder, target, compiler.stage, &mut cargo); - builder.info(&format!( - "Building stage{} std artifacts ({} -> {})", - compiler.stage, &compiler.host, target - )); + builder.step_info(&self); + // builder.info(&format!( + // "Building stage{} std artifacts ({} -> {})", + // compiler.stage, &compiler.host, target + // )); run_cargo( builder, cargo, diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs index 31f18d81c7c0f..e643fbd84f309 100644 --- a/src/bootstrap/test.rs +++ b/src/bootstrap/test.rs @@ -1215,6 +1215,11 @@ impl Step for Compiletest { run.never() } + fn path(&self, _builder: &Builder<'_>) -> PathBuf { + // FIXME: it would be nice to suggest exactly the tests that fail, but that info isn't known without first running compiletest. + self.path.into() + } + /// Executes the `compiletest` tool to run a suite of tests. /// /// Compiles all tests with `compiler` for `target` with the specified @@ -1856,12 +1861,13 @@ impl Step for RustcGuide { } } -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct CrateLibrustc { compiler: Compiler, target: TargetSelection, test_kind: TestKind, - krate: Interned, + krate_name: Interned, + krate_path: PathBuf, } impl Step for CrateLibrustc { @@ -1885,7 +1891,8 @@ impl Step for CrateLibrustc { compiler, target: run.target, test_kind, - krate: krate.name, + krate_name: krate.name, + krate_path: krate.local_path(builder.build), }); } } @@ -1897,18 +1904,20 @@ impl Step for CrateLibrustc { target: self.target, mode: Mode::Rustc, test_kind: self.test_kind, - krate: self.krate, + krate_name: self.krate_name, + krate_path: self.krate_path.clone(), }); } } -#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct Crate { pub compiler: Compiler, pub target: TargetSelection, pub mode: Mode, pub test_kind: TestKind, - pub krate: Interned, + pub krate_name: Interned, + pub krate_path: PathBuf, } impl Step for Crate { @@ -1931,7 +1940,8 @@ impl Step for Crate { target: run.target, mode, test_kind, - krate: krate.name, + krate_name: krate.name, + krate_path: krate.local_path(builder.build), }); }; @@ -1942,6 +1952,10 @@ impl Step for Crate { } } + fn path(&self, _builder: &Builder<'_>) -> PathBuf { + self.krate_path.file_name().expect("top-level directory is not a crate").into() + } + /// Runs all unit tests plus documentation tests for a given crate defined /// by a `Cargo.toml` (single manifest) /// @@ -1955,7 +1969,7 @@ impl Step for Crate { let target = self.target; let mode = self.mode; let test_kind = self.test_kind; - let krate = self.krate; + let krate = self.krate_name; builder.ensure(compile::Std { compiler, target }); builder.ensure(RemoteCopyLibs { compiler, target }); From 35b167324fae74c26a667bec236386686be6d446 Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Tue, 15 Jun 2021 07:32:23 -0400 Subject: [PATCH 2/7] more progress - add stage override - switch more things to step_info --- src/bootstrap/builder.rs | 8 ++++++-- src/bootstrap/check.rs | 33 ++++++++++++++++++--------------- src/bootstrap/compile.rs | 13 +++++++++---- src/bootstrap/tool.rs | 8 ++++++++ 4 files changed, 41 insertions(+), 21 deletions(-) diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index 6a8100f3a17a3..a12fe98aaeb45 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -73,6 +73,11 @@ pub trait Step: 'static + Clone + Debug + PartialEq + Eq + Hash { paths.iter().map(|pathset| pathset.path(builder)).next().expect("no paths for step") } + /// The stage that should be passed to x.py to run this step. + fn stage(&self, builder: &Builder<'_>) -> u32 { + builder.top_stage + } + /// Primary function to execute this rule. Can call `builder.ensure()` /// with other steps to run those. fn run(self, builder: &Builder<'_>) -> Self::Output; @@ -655,8 +660,7 @@ impl<'a> Builder<'a> { // TODO: this is wrong, e.g. `check --stage 1` runs build commands first self.kind, step.path(self).display(), - // FIXME: top_stage might be higher than the stage of the step - self.top_stage, + step.stage(self), ); for arg in self.config.cmd.test_args() { print!(" --test-args \"{}\"", arg); diff --git a/src/bootstrap/check.rs b/src/bootstrap/check.rs index bc106746e57e0..05d2f00411603 100644 --- a/src/bootstrap/check.rs +++ b/src/bootstrap/check.rs @@ -86,10 +86,11 @@ impl Step for Std { ); std_cargo(builder, target, compiler.stage, &mut cargo); - builder.info(&format!( - "Checking stage{} std artifacts ({} -> {})", - builder.top_stage, &compiler.host, target - )); + builder.step_info(&self); + // builder.info(&format!( + // "Checking stage{} std artifacts ({} -> {})", + // builder.top_stage, &compiler.host, target + // )); run_cargo( builder, cargo, @@ -206,10 +207,11 @@ impl Step for Rustc { cargo.arg("-p").arg(krate.name); } - builder.info(&format!( - "Checking stage{} compiler artifacts ({} -> {})", - builder.top_stage, &compiler.host, target - )); + builder.step_info(&self); + // builder.info(&format!( + // "Checking stage{} compiler artifacts ({} -> {})", + // builder.top_stage, &compiler.host, target + // )); run_cargo( builder, cargo, @@ -328,13 +330,14 @@ macro_rules! tool_check_step { // See https://github.com/rust-lang/rust/pull/80573#issuecomment-754010776 cargo.rustflag("-Zunstable-options"); - builder.info(&format!( - "Checking stage{} {} artifacts ({} -> {})", - builder.top_stage, - stringify!($name).to_lowercase(), - &compiler.host.triple, - target.triple - )); + builder.step_info(&self); + // builder.info(&format!( + // "Checking stage{} {} artifacts ({} -> {})", + // builder.top_stage, + // stringify!($name).to_lowercase(), + // &compiler.host.triple, + // target.triple + // )); run_cargo( builder, cargo, diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs index 573f44cbf2ce3..c497f624aac52 100644 --- a/src/bootstrap/compile.rs +++ b/src/bootstrap/compile.rs @@ -519,6 +519,10 @@ impl Step for Rustc { }); } + fn stage(&self, _builder: &Builder<'_>) -> u32 { + self.compiler.stage + } + /// Builds the compiler. /// /// This will build the compiler for a particular stage of the build using @@ -603,10 +607,11 @@ impl Step for Rustc { )); } - builder.info(&format!( - "Building stage{} compiler artifacts ({} -> {})", - compiler.stage, &compiler.host, target - )); + builder.step_info(&self); + // builder.info(&format!( + // "Building stage{} compiler artifacts ({} -> {})", + // compiler.stage, &compiler.host, target + // )); run_cargo( builder, cargo, diff --git a/src/bootstrap/tool.rs b/src/bootstrap/tool.rs index f5e3f61dcc88f..c21744cfdd57b 100644 --- a/src/bootstrap/tool.rs +++ b/src/bootstrap/tool.rs @@ -319,6 +319,10 @@ macro_rules! bootstrap_tool { impl Step for $name { type Output = PathBuf; + fn stage(&self, _builder: &Builder<'_>) -> u32 { + self.compiler.stage + } + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.path($path) } @@ -595,6 +599,10 @@ impl Step for Cargo { const DEFAULT: bool = true; const ONLY_HOSTS: bool = true; + fn stage(&self, _builder: &Builder<'_>) -> u32 { + self.compiler.stage + } + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { let builder = run.builder; run.path("src/tools/cargo").default_condition( From 95d407190a3a8d9fe2f8b2c5e59483437599d270 Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Tue, 15 Jun 2021 07:49:45 -0400 Subject: [PATCH 3/7] Use compiler() instead of stage() --- src/bootstrap/builder.rs | 31 ++++++++++++++++++++++++++----- src/bootstrap/compile.rs | 16 ++++++++++++++-- src/bootstrap/tool.rs | 24 ++++++++++++++++++++---- src/bootstrap/toolstate.rs | 6 +++++- 4 files changed, 65 insertions(+), 12 deletions(-) diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index a12fe98aaeb45..f1f5cb6079ca4 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -67,16 +67,26 @@ pub trait Step: 'static + Clone + Debug + PartialEq + Eq + Hash { std::any::type_name::() } + // fn kind(&self) -> Kind; + + fn compiler(&self) -> Option<&Compiler> { + None + } + + fn target(&self) -> Option<&TargetSelection> { + None + } + /// The path that should be used on the command line to run this step. fn path(&self, builder: &Builder<'_>) -> PathBuf { let paths = Self::should_run(ShouldRun::new(builder)).paths; paths.iter().map(|pathset| pathset.path(builder)).next().expect("no paths for step") } - /// The stage that should be passed to x.py to run this step. - fn stage(&self, builder: &Builder<'_>) -> u32 { - builder.top_stage - } + // /// The stage that should be passed to x.py to run this step. + // fn stage(&self, builder: &Builder<'_>) -> u32 { + // builder.top_stage + // } /// Primary function to execute this rule. Can call `builder.ensure()` /// with other steps to run those. @@ -655,13 +665,24 @@ impl<'a> Builder<'a> { if self.config.dry_run { return; } + let (stage, host) = if let Some(compiler) = step.compiler() { + (compiler.stage, Some(compiler.host)) + } else { + (self.top_stage, None) + }; print!( "{} {} --stage {}", // TODO: this is wrong, e.g. `check --stage 1` runs build commands first self.kind, step.path(self).display(), - step.stage(self), + stage, ); + if let Some(host) = host { + print!(" --host {}", host); + } + if let Some(target) = step.target() { + print!(" --target {}", target); + } for arg in self.config.cmd.test_args() { print!(" --test-args \"{}\"", arg); } diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs index c497f624aac52..ab6cf6dbc1562 100644 --- a/src/bootstrap/compile.rs +++ b/src/bootstrap/compile.rs @@ -54,6 +54,14 @@ impl Step for Std { }); } + fn compiler(&self) -> Option<&Compiler> { + Some(&self.compiler) + } + + fn target(&self) -> Option<&TargetSelection> { + Some(&self.target) + } + /// Builds the standard library. /// /// This will build the standard library for a particular stage of the build @@ -519,10 +527,14 @@ impl Step for Rustc { }); } - fn stage(&self, _builder: &Builder<'_>) -> u32 { - self.compiler.stage + fn compiler(&self) -> Option<&Compiler> { + Some(&self.compiler) } + // fn stage(&self, _builder: &Builder<'_>) -> u32 { + // self.compiler.stage + // } + /// Builds the compiler. /// /// This will build the compiler for a particular stage of the build using diff --git a/src/bootstrap/tool.rs b/src/bootstrap/tool.rs index c21744cfdd57b..cbb491e046a43 100644 --- a/src/bootstrap/tool.rs +++ b/src/bootstrap/tool.rs @@ -319,8 +319,16 @@ macro_rules! bootstrap_tool { impl Step for $name { type Output = PathBuf; - fn stage(&self, _builder: &Builder<'_>) -> u32 { - self.compiler.stage + // fn stage(&self, _builder: &Builder<'_>) -> u32 { + // self.compiler.stage + // } + + fn compiler(&self) -> Option<&Compiler> { + Some(&self.compiler) + } + + fn target(&self) -> Option<&TargetSelection> { + Some(&self.target) } fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { @@ -599,8 +607,16 @@ impl Step for Cargo { const DEFAULT: bool = true; const ONLY_HOSTS: bool = true; - fn stage(&self, _builder: &Builder<'_>) -> u32 { - self.compiler.stage + // fn stage(&self, _builder: &Builder<'_>) -> u32 { + // self.compiler.stage + // } + + fn compiler(&self) -> Option<&Compiler> { + Some(&self.compiler) + } + + fn target(&self) -> Option<&TargetSelection> { + Some(&self.target) } fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { diff --git a/src/bootstrap/toolstate.rs b/src/bootstrap/toolstate.rs index 2394c5e020d2b..c09b03960fff4 100644 --- a/src/bootstrap/toolstate.rs +++ b/src/bootstrap/toolstate.rs @@ -1,4 +1,4 @@ -use crate::builder::{Builder, RunConfig, ShouldRun, Step}; +use crate::builder::{Builder, Kind, RunConfig, ShouldRun, Step}; use build_helper::t; use serde::{Deserialize, Serialize}; use std::collections::HashMap; @@ -141,6 +141,10 @@ pub struct ToolStateCheck; impl Step for ToolStateCheck { type Output = (); + // fn kind(&self) -> Kind { + // Kind::Test + // } + /// Checks tool state status. /// /// This is intended to be used in the `checktools.sh` script. To use From c55e2bd9dbe105b45171e6b9b49822b348565be8 Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Sat, 24 Jul 2021 03:29:32 +0000 Subject: [PATCH 4/7] rewrite some more code --- src/bootstrap/builder.rs | 150 +++++++++++++++++++++++++++---------- src/bootstrap/cache.rs | 4 +- src/bootstrap/check.rs | 16 +++- src/bootstrap/compile.rs | 20 ++--- src/bootstrap/tool.rs | 28 ++----- src/bootstrap/toolstate.rs | 6 +- src/doc/book | 2 +- src/doc/edition-guide | 2 +- src/doc/embedded-book | 2 +- src/doc/nomicon | 2 +- src/doc/reference | 2 +- src/doc/rust-by-example | 2 +- src/doc/rustc-dev-guide | 2 +- src/tools/rust-analyzer | 2 +- 14 files changed, 149 insertions(+), 91 deletions(-) diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index f1f5cb6079ca4..c32677454f436 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -1,4 +1,5 @@ use std::any::Any; +use std::borrow::Cow; use std::cell::{Cell, RefCell}; use std::collections::BTreeSet; use std::env; @@ -50,7 +51,7 @@ impl<'a> Deref for Builder<'a> { } } -pub trait Step: 'static + Clone + Debug + PartialEq + Eq + Hash { +pub(crate) trait Step: 'static + Clone + Debug + PartialEq + Eq + Hash { /// `PathBuf` when directories are created or to return a `Compiler` once /// it's been assembled. type Output: Clone; @@ -67,15 +68,7 @@ pub trait Step: 'static + Clone + Debug + PartialEq + Eq + Hash { std::any::type_name::() } - // fn kind(&self) -> Kind; - - fn compiler(&self) -> Option<&Compiler> { - None - } - - fn target(&self) -> Option<&TargetSelection> { - None - } + fn info(_step_info: &mut StepInfo<'_, '_, Self>) {} /// The path that should be used on the command line to run this step. fn path(&self, builder: &Builder<'_>) -> PathBuf { @@ -656,37 +649,10 @@ impl<'a> Builder<'a> { StepDescription::run(v, self, paths); } - /// Print a command that will run the current step. - /// - /// This serves two purposes: - /// 1. Describe what step is currently being run. - /// 2. Describe how to run only this step in case it fails. pub(crate) fn step_info(&self, step: &impl Step) { - if self.config.dry_run { - return; - } - let (stage, host) = if let Some(compiler) = step.compiler() { - (compiler.stage, Some(compiler.host)) - } else { - (self.top_stage, None) - }; - print!( - "{} {} --stage {}", - // TODO: this is wrong, e.g. `check --stage 1` runs build commands first - self.kind, - step.path(self).display(), - stage, - ); - if let Some(host) = host { - print!(" --host {}", host); - } - if let Some(target) = step.target() { - print!(" --target {}", target); - } - for arg in self.config.cmd.test_args() { - print!(" --test-args \"{}\"", arg); - } - println!(); + let mut info = StepInfo::new(self, step); + Step::info(&mut info); + info.print(); } /// Obtain a compiler at a given stage and for a given host. Explicitly does @@ -1611,7 +1577,7 @@ impl<'a> Builder<'a> { /// Ensure that a given step is built, returning its output. This will /// cache the step, so it is safe (and good!) to call this as often as /// needed to ensure that all dependencies are built. - pub fn ensure(&'a self, step: S) -> S::Output { + pub(crate) fn ensure(&'a self, step: S) -> S::Output { { let mut stack = self.stack.borrow_mut(); for stack_step in stack.iter() { @@ -1772,3 +1738,105 @@ impl From for Command { cargo.command } } + +pub(crate) struct StepInfo<'a, 'b, S> { + pub(crate) builder: &'a Builder<'b>, + pub(crate) step: &'a S, + compiler: Option>, + stage: Option, + host: Option, + target: Option, + cmd: Option, +} + +impl<'a> From for Cow<'a, Compiler> { + fn from(val: Compiler) -> Self { + Self::Owned(val) + } +} + +impl<'a> From<&'a Compiler> for Cow<'a, Compiler> { + fn from(val: &'a Compiler) -> Self { + Self::Borrowed(val) + } +} + +impl<'a, 'b, S> StepInfo<'a, 'b, S> { + pub(crate) fn new(builder: &'a Builder<'b>, step: &'a S) -> Self { + Self { builder, step, compiler: None, stage: None, host: None, target: None, cmd: None } + } + + pub(crate) fn compiler(&mut self, val: impl Into>) -> &mut Self { + if self.compiler.is_some() { + panic!("cannot overwrite compiler"); + } + let val = val.into(); + self.stage(val.stage).host(val.host); + self.compiler = Some(val); + self + } + + pub(crate) fn stage(&mut self, stage: u32) -> &mut Self { + if self.stage.is_some() { + panic!("cannot overwrite stage"); + } + self.stage = Some(stage); + self + } + + pub(crate) fn host(&mut self, host: TargetSelection) -> &mut Self { + if self.host.is_some() { + panic!("cannot overwrite host"); + } + self.host = Some(host); + self + } + + pub(crate) fn target(&mut self, target: TargetSelection) -> &mut Self { + if self.target.is_some() { + panic!("cannot overwrite target"); + } + self.target = Some(target); + self + } + + pub(crate) fn cmd(&mut self, val: Kind) -> &mut Self { + if self.cmd.is_some() { + panic!("cannot overwrite cmd"); + } + self.cmd = Some(val); + self + } + + /// Print a command that will run the current step. + /// + /// This serves two purposes: + /// 1. Describe what step is currently being run. + /// 2. Describe how to run only this step in case it fails. + pub(crate) fn print(&self) + where + S: Step, + { + if self.builder.config.dry_run { + return; + } + // let stage = self.stage.unwrap_or(self.builder.top_stage); + let stage = self.stage.expect("missing stage"); + let host = self.host; + let kind = self.cmd.unwrap_or(self.builder.kind); + let target = self.target; + print!("{} {} --stage {}", kind, self.step.path(self.builder).display(), stage,); + if let Some(host) = host { + print!(" --host {}", host); + } + if let Some(target) = target { + print!(" --target {}", target); + } + if kind == Kind::Test { + for arg in self.builder.config.cmd.test_args() { + print!(" --test-args \"{}\"", arg); + } + } + println!(); + } +} diff --git a/src/bootstrap/cache.rs b/src/bootstrap/cache.rs index 2c74fbd6b0c07..a211eee688fa8 100644 --- a/src/bootstrap/cache.rs +++ b/src/bootstrap/cache.rs @@ -245,7 +245,7 @@ impl Cache { Cache(RefCell::new(HashMap::new())) } - pub fn put(&self, step: S, value: S::Output) { + pub(crate) fn put(&self, step: S, value: S::Output) { let mut cache = self.0.borrow_mut(); let type_id = TypeId::of::(); let stepcache = cache @@ -257,7 +257,7 @@ impl Cache { stepcache.insert(step, value); } - pub fn get(&self, step: &S) -> Option { + pub(crate) fn get(&self, step: &S) -> Option { let mut cache = self.0.borrow_mut(); let type_id = TypeId::of::(); let stepcache = cache diff --git a/src/bootstrap/check.rs b/src/bootstrap/check.rs index 05d2f00411603..4ce791b203f5c 100644 --- a/src/bootstrap/check.rs +++ b/src/bootstrap/check.rs @@ -1,6 +1,6 @@ //! Implementation of compiling the compiler and standard library, in "check"-based modes. -use crate::builder::{Builder, Kind, RunConfig, ShouldRun, Step}; +use crate::builder::{Builder, Kind, RunConfig, ShouldRun, Step, StepInfo}; use crate::cache::Interned; use crate::compile::{add_to_sysroot, run_cargo, rustc_cargo, rustc_cargo_env, std_cargo}; use crate::config::TargetSelection; @@ -71,6 +71,13 @@ impl Step for Std { run.builder.ensure(Std { target: run.target }); } + fn info(step_info: &mut StepInfo<'_, '_, Self>) { + let step = step_info.step; + let builder = step_info.builder; + let compiler = builder.compiler(builder.top_stage, builder.config.build); + step_info.compiler(compiler).target(step.target).cmd(Kind::Check); + } + fn run(self, builder: &Builder<'_>) { builder.update_submodule(&Path::new("library").join("stdarch")); @@ -167,6 +174,13 @@ impl Step for Rustc { run.builder.ensure(Rustc { target: run.target }); } + fn info(step_info: &mut StepInfo<'_, '_, Self>) { + let step = step_info.step; + let builder = step_info.builder; + let compiler = builder.compiler(builder.top_stage, builder.config.build); + step_info.compiler(compiler).target(step.target).cmd(Kind::Check); + } + /// Builds the compiler. /// /// This will build the compiler for a particular stage of the build using diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs index ab6cf6dbc1562..605e5b283c59a 100644 --- a/src/bootstrap/compile.rs +++ b/src/bootstrap/compile.rs @@ -21,7 +21,7 @@ use filetime::FileTime; use serde::Deserialize; use crate::builder::Cargo; -use crate::builder::{Builder, Kind, RunConfig, ShouldRun, Step}; +use crate::builder::{Builder, Kind, RunConfig, ShouldRun, Step, StepInfo}; use crate::cache::{Interned, INTERNER}; use crate::config::TargetSelection; use crate::dist; @@ -54,12 +54,9 @@ impl Step for Std { }); } - fn compiler(&self) -> Option<&Compiler> { - Some(&self.compiler) - } - - fn target(&self) -> Option<&TargetSelection> { - Some(&self.target) + fn info(step_info: &mut StepInfo<'_, '_, Self>) { + let step = step_info.step; + step_info.compiler(&step.compiler).target(step.target).cmd(Kind::Build); } /// Builds the standard library. @@ -527,14 +524,11 @@ impl Step for Rustc { }); } - fn compiler(&self) -> Option<&Compiler> { - Some(&self.compiler) + fn info(step_info: &mut StepInfo<'_, '_, Self>) { + let step = step_info.step; + step_info.compiler(&step.compiler).target(step.target).cmd(Kind::Build); } - // fn stage(&self, _builder: &Builder<'_>) -> u32 { - // self.compiler.stage - // } - /// Builds the compiler. /// /// This will build the compiler for a particular stage of the build using diff --git a/src/bootstrap/tool.rs b/src/bootstrap/tool.rs index cbb491e046a43..005edad500f3e 100644 --- a/src/bootstrap/tool.rs +++ b/src/bootstrap/tool.rs @@ -6,7 +6,7 @@ use std::process::{exit, Command}; use build_helper::t; -use crate::builder::{Builder, Cargo as CargoCommand, RunConfig, ShouldRun, Step}; +use crate::builder::{Builder, Cargo as CargoCommand, Kind, RunConfig, ShouldRun, Step, StepInfo}; use crate::channel::GitInfo; use crate::compile; use crate::config::TargetSelection; @@ -319,16 +319,9 @@ macro_rules! bootstrap_tool { impl Step for $name { type Output = PathBuf; - // fn stage(&self, _builder: &Builder<'_>) -> u32 { - // self.compiler.stage - // } - - fn compiler(&self) -> Option<&Compiler> { - Some(&self.compiler) - } - - fn target(&self) -> Option<&TargetSelection> { - Some(&self.target) + fn info(step_info: &mut StepInfo<'_, '_, Self>) { + let step = step_info.step; + step_info.compiler(&step.compiler).target(step.target).cmd(Kind::Build); } fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { @@ -607,16 +600,9 @@ impl Step for Cargo { const DEFAULT: bool = true; const ONLY_HOSTS: bool = true; - // fn stage(&self, _builder: &Builder<'_>) -> u32 { - // self.compiler.stage - // } - - fn compiler(&self) -> Option<&Compiler> { - Some(&self.compiler) - } - - fn target(&self) -> Option<&TargetSelection> { - Some(&self.target) + fn info(step_info: &mut StepInfo<'_, '_, Self>) { + let step = step_info.step; + step_info.compiler(&step.compiler).target(step.target).cmd(Kind::Build); } fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { diff --git a/src/bootstrap/toolstate.rs b/src/bootstrap/toolstate.rs index c09b03960fff4..2394c5e020d2b 100644 --- a/src/bootstrap/toolstate.rs +++ b/src/bootstrap/toolstate.rs @@ -1,4 +1,4 @@ -use crate::builder::{Builder, Kind, RunConfig, ShouldRun, Step}; +use crate::builder::{Builder, RunConfig, ShouldRun, Step}; use build_helper::t; use serde::{Deserialize, Serialize}; use std::collections::HashMap; @@ -141,10 +141,6 @@ pub struct ToolStateCheck; impl Step for ToolStateCheck { type Output = (); - // fn kind(&self) -> Kind { - // Kind::Test - // } - /// Checks tool state status. /// /// This is intended to be used in the `checktools.sh` script. To use diff --git a/src/doc/book b/src/doc/book index eac5531421051..55a26488ddefc 160000 --- a/src/doc/book +++ b/src/doc/book @@ -1 +1 @@ -Subproject commit eac55314210519238652f12b30fec9daea61f7fe +Subproject commit 55a26488ddefc8433e73a2e8352d70f7a5c7fc2b diff --git a/src/doc/edition-guide b/src/doc/edition-guide index af696ce8ea526..302a115e8f718 160000 --- a/src/doc/edition-guide +++ b/src/doc/edition-guide @@ -1 +1 @@ -Subproject commit af696ce8ea526445590ae0ca66a8128d2a95a69a +Subproject commit 302a115e8f71876dfc884aebb0ca5ccb02b8a962 diff --git a/src/doc/embedded-book b/src/doc/embedded-book index 09986cd352404..7349d173fa28a 160000 --- a/src/doc/embedded-book +++ b/src/doc/embedded-book @@ -1 +1 @@ -Subproject commit 09986cd352404eb4659db44613b27cac9aa652fc +Subproject commit 7349d173fa28a0bb834cf0264a05286620ef0923 diff --git a/src/doc/nomicon b/src/doc/nomicon index 7a13537f96af4..55de6fa3c1f33 160000 --- a/src/doc/nomicon +++ b/src/doc/nomicon @@ -1 +1 @@ -Subproject commit 7a13537f96af4b9b8e3ea296d6e5c3c7ab72ce9f +Subproject commit 55de6fa3c1f331774da19472c9ee57d2ae9eb039 diff --git a/src/doc/reference b/src/doc/reference index 82d75cf423e4a..9c68af3ce6ccc 160000 --- a/src/doc/reference +++ b/src/doc/reference @@ -1 +1 @@ -Subproject commit 82d75cf423e4a7824fb36e73ccb18519d6900610 +Subproject commit 9c68af3ce6ccca2395e1868addef26a0542e9ddd diff --git a/src/doc/rust-by-example b/src/doc/rust-by-example index 1db6bb483cc87..805e016c5792a 160000 --- a/src/doc/rust-by-example +++ b/src/doc/rust-by-example @@ -1 +1 @@ -Subproject commit 1db6bb483cc87ad3b424d9aba764fe622960a1be +Subproject commit 805e016c5792ad2adabb66e348233067d5ea9f10 diff --git a/src/doc/rustc-dev-guide b/src/doc/rustc-dev-guide index 93422c21baca5..50de7f0682adc 160000 --- a/src/doc/rustc-dev-guide +++ b/src/doc/rustc-dev-guide @@ -1 +1 @@ -Subproject commit 93422c21baca585dc88357ec886a48f6ddc7d665 +Subproject commit 50de7f0682adc5d95ce858fe6318d19b4b951553 diff --git a/src/tools/rust-analyzer b/src/tools/rust-analyzer index ea105f9396a9d..f4383981249d3 160000 --- a/src/tools/rust-analyzer +++ b/src/tools/rust-analyzer @@ -1 +1 @@ -Subproject commit ea105f9396a9dab68e71efb06016b7c76c83ba7c +Subproject commit f4383981249d3f2964f2c667f3349f8ff15b77c4 From e24f28aa377b059f7e09b972d2fa4ad32020cafb Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Sat, 24 Jul 2021 15:31:40 +0000 Subject: [PATCH 5/7] Add StepInfo --- src/bootstrap/builder.rs | 35 +++++++--- src/bootstrap/check.rs | 21 ++++-- src/bootstrap/compile.rs | 26 ++++--- src/bootstrap/dist.rs | 89 +++++++++++++++++++++++- src/bootstrap/doc.rs | 50 +++++++++++++- src/bootstrap/install.rs | 17 ++++- src/bootstrap/native.rs | 20 +++++- src/bootstrap/run.rs | 10 ++- src/bootstrap/test.rs | 135 ++++++++++++++++++++++++++++++++++++- src/bootstrap/tool.rs | 26 +++++++ src/bootstrap/toolstate.rs | 4 +- 11 files changed, 404 insertions(+), 29 deletions(-) diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index c32677454f436..2236755109a52 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -68,7 +68,7 @@ pub(crate) trait Step: 'static + Clone + Debug + PartialEq + Eq + Hash { std::any::type_name::() } - fn info(_step_info: &mut StepInfo<'_, '_, Self>) {} + fn info(_step_info: &mut StepInfo<'_, '_, Self>); /// The path that should be used on the command line to run this step. fn path(&self, builder: &Builder<'_>) -> PathBuf { @@ -706,6 +706,11 @@ impl<'a> Builder<'a> { run.never() } + fn info(step_info: &mut StepInfo<'_, '_, Self>) { + let step = step_info.step; + step_info.compiler(&step.compiler).target(step.target).cmd(Kind::Check); + } + fn run(self, builder: &Builder<'_>) -> Interned { let lib = builder.sysroot_libdir_relative(self.compiler); let sysroot = builder @@ -1822,15 +1827,25 @@ impl<'a, 'b, S> StepInfo<'a, 'b, S> { } // let stage = self.stage.unwrap_or(self.builder.top_stage); let stage = self.stage.expect("missing stage"); - let host = self.host; - let kind = self.cmd.unwrap_or(self.builder.kind); - let target = self.target; - print!("{} {} --stage {}", kind, self.step.path(self.builder).display(), stage,); - if let Some(host) = host { - print!(" --host {}", host); - } - if let Some(target) = target { - print!(" --target {}", target); + // let kind = self.cmd.unwrap_or(self.builder.kind); + let kind = self.cmd.expect("missing kind"); + print!( + "{} {} --stage {}", + kind, + self.step.path(self.builder).display(), + stage, + ); + if let Some(host) = self.host { + // Almost always, this will be the same as build. Don't print it if so. + if host != self.builder.config.build { + print!(" --host {}", host); + } + } + if let Some(target) = self.target { + let different_from_host = self.host.map_or(false, |h| h != target); + if target != self.builder.config.build || different_from_host { + print!(" --target {}", target); + } } if kind == Kind::Test { for arg in self.builder.config.cmd.test_args() { diff --git a/src/bootstrap/check.rs b/src/bootstrap/check.rs index 4ce791b203f5c..e6ce76416b0da 100644 --- a/src/bootstrap/check.rs +++ b/src/bootstrap/check.rs @@ -262,6 +262,11 @@ impl Step for CodegenBackend { } } + fn info(step_info: &mut StepInfo<'_, '_, Self>) { + let step = step_info.step; + step_info.target(step.target).cmd(Kind::Check); + } + fn run(self, builder: &Builder<'_>) { let compiler = builder.compiler(builder.top_stage, builder.config.build); let target = self.target; @@ -281,10 +286,11 @@ impl Step for CodegenBackend { .arg(builder.src.join(format!("compiler/rustc_codegen_{}/Cargo.toml", backend))); rustc_cargo_env(builder, &mut cargo, target); - builder.info(&format!( - "Checking stage{} {} artifacts ({} -> {})", - builder.top_stage, backend, &compiler.host.triple, target.triple - )); + builder.step_info(&self); + // builder.info(&format!( + // "Checking stage{} {} artifacts ({} -> {})", + // builder.top_stage, backend, &compiler.host.triple, target.triple + // )); run_cargo( builder, @@ -318,6 +324,13 @@ macro_rules! tool_check_step { run.builder.ensure($name { target: run.target }); } + fn info(step_info: &mut StepInfo<'_, '_, Self>) { + let step = step_info.step; + let builder = step_info.builder; + let compiler = builder.compiler(builder.top_stage, builder.config.build); + step_info.compiler(compiler).target(step.target).cmd(Kind::Check); + } + fn run(self, builder: &Builder<'_>) { let compiler = builder.compiler(builder.top_stage, builder.config.build); let target = self.target; diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs index 605e5b283c59a..2bb1f747594e6 100644 --- a/src/bootstrap/compile.rs +++ b/src/bootstrap/compile.rs @@ -113,10 +113,6 @@ impl Step for Std { std_cargo(builder, target, compiler.stage, &mut cargo); builder.step_info(&self); - // builder.info(&format!( - // "Building stage{} std artifacts ({} -> {})", - // compiler.stage, &compiler.host, target - // )); run_cargo( builder, cargo, @@ -357,6 +353,8 @@ impl Step for StdLink { run.never() } + fn info(_step_info: &mut StepInfo<'_, '_, Self>) {} + /// Link all libstd rlibs/dylibs into the sysroot location. /// /// Links those artifacts generated by `compiler` to the `stage` compiler's @@ -453,6 +451,11 @@ impl Step for StartupObjects { }); } + fn info(step_info: &mut StepInfo<'_, '_, Self>) { + let step = step_info.step; + step_info.compiler(&step.compiler).cmd(Kind::Build); + } + /// Builds and prepare startup objects like rsbegin.o and rsend.o /// /// These are primarily used on Windows right now for linking executables/dlls. @@ -614,10 +617,6 @@ impl Step for Rustc { } builder.step_info(&self); - // builder.info(&format!( - // "Building stage{} compiler artifacts ({} -> {})", - // compiler.stage, &compiler.host, target - // )); run_cargo( builder, cargo, @@ -735,6 +734,8 @@ impl Step for RustcLink { run.never() } + fn info(_step_info: &mut StepInfo<'_, '_, Self>) {} + /// Same as `std_link`, only for librustc fn run(self, builder: &Builder<'_>) { let compiler = self.compiler; @@ -784,6 +785,11 @@ impl Step for CodegenBackend { } } + fn info(step_info: &mut StepInfo<'_, '_, Self>) { + let step = step_info.step; + step_info.compiler(&step.compiler).target(step.target).cmd(Kind::Build); + } + fn run(self, builder: &Builder<'_>) { let compiler = self.compiler; let target = self.target; @@ -945,6 +951,8 @@ impl Step for Sysroot { run.never() } + fn info(_step_info: &mut StepInfo<'_, '_, Self>) {} + /// Returns the sysroot for the `compiler` specified that *this build system /// generates*. /// @@ -1017,6 +1025,8 @@ impl Step for Assemble { run.never() } + fn info(_step_info: &mut StepInfo<'_, '_, Self>) {} + /// Prepare a new compiler from the artifacts in `stage` /// /// This will assemble a compiler in `build/$host/stage$stage`. The compiler diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs index c37763243c0a5..361182fdc2e61 100644 --- a/src/bootstrap/dist.rs +++ b/src/bootstrap/dist.rs @@ -15,7 +15,7 @@ use std::process::Command; use build_helper::{output, t}; -use crate::builder::{Builder, RunConfig, ShouldRun, Step}; +use crate::builder::{Builder, Kind, RunConfig, ShouldRun, Step, StepInfo}; use crate::cache::{Interned, INTERNER}; use crate::compile; use crate::config::TargetSelection; @@ -45,6 +45,15 @@ fn missing_tool(tool_name: &str, skip: bool) { } } +macro_rules! compiler_target_info { + () => { + fn info(step_info: &mut StepInfo<'_, '_, Self>) { + let step = step_info.step; + step_info.compiler(&step.compiler).target(step.target).cmd(Kind::Dist); + } + } +} + #[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)] pub struct Docs { pub host: TargetSelection, @@ -62,6 +71,11 @@ impl Step for Docs { run.builder.ensure(Docs { host: run.target }); } + fn info(step_info: &mut StepInfo<'_, '_, Self>) { + let step = step_info.step; + step_info.target(step.host).cmd(Kind::Dist); + } + /// Builds the `rust-docs` installer component. fn run(self, builder: &Builder<'_>) -> Option { let host = self.host; @@ -97,6 +111,11 @@ impl Step for RustcDocs { run.builder.ensure(RustcDocs { host: run.target }); } + fn info(step_info: &mut StepInfo<'_, '_, Self>) { + let step = step_info.step; + step_info.target(step.host).cmd(Kind::Dist); + } + /// Builds the `rustc-docs` installer component. fn run(self, builder: &Builder<'_>) -> Option { let host = self.host; @@ -278,6 +297,11 @@ impl Step for Mingw { run.builder.ensure(Mingw { host: run.target }); } + fn info(step_info: &mut StepInfo<'_, '_, Self>) { + let step = step_info.step; + step_info.target(step.host).cmd(Kind::Dist); + } + /// Builds the `rust-mingw` installer component. /// /// This contains all the bits and pieces to run the MinGW Windows targets @@ -320,6 +344,11 @@ impl Step for Rustc { .ensure(Rustc { compiler: run.builder.compiler(run.builder.top_stage, run.target) }); } + fn info(step_info: &mut StepInfo<'_, '_, Self>) { + let step = step_info.step; + step_info.compiler(&step.compiler).cmd(Kind::Dist); + } + /// Creates the `rustc` installer component. fn run(self, builder: &Builder<'_>) -> GeneratedTarball { let compiler = self.compiler; @@ -484,6 +513,11 @@ impl Step for DebuggerScripts { }); } + fn info(step_info: &mut StepInfo<'_, '_, Self>) { + let step = step_info.step; + step_info.target(step.host).cmd(Kind::Dist); + } + /// Copies debugger scripts for `target` into the `sysroot` specified. fn run(self, builder: &Builder<'_>) { let host = self.host; @@ -577,6 +611,8 @@ impl Step for Std { }); } + compiler_target_info!(); + fn run(self, builder: &Builder<'_>) -> Option { let compiler = self.compiler; let target = self.target; @@ -624,6 +660,8 @@ impl Step for RustcDev { }); } + compiler_target_info!(); + fn run(self, builder: &Builder<'_>) -> Option { let compiler = self.compiler; let target = self.target; @@ -694,6 +732,8 @@ impl Step for Analysis { }); } + compiler_target_info!(); + /// Creates a tarball of save-analysis metadata, if available. fn run(self, builder: &Builder<'_>) -> Option { let compiler = self.compiler; @@ -820,6 +860,10 @@ impl Step for Src { run.builder.ensure(Src); } + fn info(step_info: &mut StepInfo<'_, '_, Self>) { + step_info.cmd(Kind::Dist); + } + /// Creates the `rust-src` installer component fn run(self, builder: &Builder<'_>) -> GeneratedTarball { let tarball = Tarball::new_targetless(builder, "rust-src"); @@ -873,6 +917,10 @@ impl Step for PlainSourceTarball { run.builder.ensure(PlainSourceTarball); } + fn info(step_info: &mut StepInfo<'_, '_, Self>) { + step_info.cmd(Kind::Dist); + } + /// Creates the plain source tarball fn run(self, builder: &Builder<'_>) -> GeneratedTarball { let tarball = Tarball::new(builder, "rustc", "src"); @@ -971,6 +1019,8 @@ impl Step for Cargo { }); } + compiler_target_info!(); + fn run(self, builder: &Builder<'_>) -> GeneratedTarball { let compiler = self.compiler; let target = self.target; @@ -1025,6 +1075,8 @@ impl Step for Rls { }); } + compiler_target_info!(); + fn run(self, builder: &Builder<'_>) -> Option { let compiler = self.compiler; let target = self.target; @@ -1071,6 +1123,8 @@ impl Step for RustAnalyzer { }); } + compiler_target_info!(); + fn run(self, builder: &Builder<'_>) -> Option { // This prevents rust-analyzer from being built for "dist" or "install" // on the stable/beta channels. It is a nightly-only tool and should @@ -1126,6 +1180,8 @@ impl Step for Clippy { }); } + compiler_target_info!(); + fn run(self, builder: &Builder<'_>) -> GeneratedTarball { let compiler = self.compiler; let target = self.target; @@ -1176,6 +1232,8 @@ impl Step for Miri { }); } + compiler_target_info!(); + fn run(self, builder: &Builder<'_>) -> Option { // This prevents miri from being built for "dist" or "install" // on the stable/beta channels. It is a nightly-only tool and should @@ -1235,6 +1293,8 @@ impl Step for Rustfmt { }); } + compiler_target_info!(); + fn run(self, builder: &Builder<'_>) -> Option { let compiler = self.compiler; let target = self.target; @@ -1287,6 +1347,8 @@ impl Step for RustDemangler { }); } + compiler_target_info!(); + fn run(self, builder: &Builder<'_>) -> Option { let compiler = self.compiler; let target = self.target; @@ -1337,6 +1399,11 @@ impl Step for Extended { }); } + fn info(step_info: &mut StepInfo<'_, '_, Self>) { + let step = step_info.step; + step_info.stage(step.stage).host(step.host).target(step.target).cmd(Kind::Dist); + } + /// Creates a combined installer for the specified target in the provided stage. fn run(self, builder: &Builder<'_>) { let target = self.target; @@ -2012,6 +2079,11 @@ impl Step for LlvmTools { run.builder.ensure(LlvmTools { target: run.target }); } + fn info(step_info: &mut StepInfo<'_, '_, Self>) { + let step = step_info.step; + step_info.target(step.target).cmd(Kind::Dist); + } + fn run(self, builder: &Builder<'_>) -> Option { let target = self.target; assert!(builder.config.extended); @@ -2067,6 +2139,11 @@ impl Step for RustDev { run.builder.ensure(RustDev { target: run.target }); } + fn info(step_info: &mut StepInfo<'_, '_, Self>) { + let step = step_info.step; + step_info.target(step.target).cmd(Kind::Dist); + } + fn run(self, builder: &Builder<'_>) -> Option { let target = self.target; @@ -2135,6 +2212,11 @@ impl Step for BuildManifest { run.builder.ensure(BuildManifest { target: run.target }); } + fn info(step_info: &mut StepInfo<'_, '_, Self>) { + let step = step_info.step; + step_info.target(step.target).cmd(Kind::Dist); + } + fn run(self, builder: &Builder<'_>) -> GeneratedTarball { let build_manifest = builder.tool_exe(Tool::BuildManifest); @@ -2167,6 +2249,11 @@ impl Step for ReproducibleArtifacts { run.builder.ensure(ReproducibleArtifacts { target: run.target }); } + fn info(step_info: &mut StepInfo<'_, '_, Self>) { + let step = step_info.step; + step_info.target(step.target).cmd(Kind::Dist); + } + fn run(self, builder: &Builder<'_>) -> Self::Output { let path = builder.config.rust_profile_use.as_ref()?; diff --git a/src/bootstrap/doc.rs b/src/bootstrap/doc.rs index 9ec5d4d8ccdb4..d893674d031d2 100644 --- a/src/bootstrap/doc.rs +++ b/src/bootstrap/doc.rs @@ -15,7 +15,7 @@ use std::path::{Path, PathBuf}; use crate::Mode; use build_helper::{t, up_to_date}; -use crate::builder::{Builder, Compiler, RunConfig, ShouldRun, Step}; +use crate::builder::{Builder, Compiler, Kind, RunConfig, ShouldRun, Step, StepInfo}; use crate::cache::{Interned, INTERNER}; use crate::compile; use crate::config::{Config, TargetSelection}; @@ -31,6 +31,32 @@ macro_rules! submodule_helper { }; } +macro_rules! target_info { + () => { + fn info(step_info: &mut StepInfo<'_, '_, Self>) { + step_info.target(step_info.step.target).cmd(Kind::Doc); + } + } +} + +macro_rules! compiler_target_info { + () => { + fn info(step_info: &mut StepInfo<'_, '_, Self>) { + let step = step_info.step; + step_info.compiler(&step.compiler).target(step.target).cmd(Kind::Doc); + } + } +} + +macro_rules! stage_target_info { + () => { + fn info(step_info: &mut StepInfo<'_, '_, Self>) { + let step = step_info.step; + step_info.stage(step.stage).target(step.target).cmd(Kind::Doc); + } + } +} + macro_rules! book { ($($name:ident, $path:expr, $book_name:expr $(, submodule $(= $submodule:literal)? )? ;)+) => { $( @@ -54,6 +80,8 @@ macro_rules! book { }); } + target_info!(); + fn run(self, builder: &Builder<'_>) { $( let path = Path::new(submodule_helper!( $path, submodule $( = $submodule )? )); @@ -132,6 +160,8 @@ impl Step for UnstableBook { run.builder.ensure(UnstableBook { target: run.target }); } + target_info!(); + fn run(self, builder: &Builder<'_>) { builder.ensure(UnstableBookGen { target: self.target }); builder.ensure(RustbookSrc { @@ -156,6 +186,8 @@ impl Step for RustbookSrc { run.never() } + target_info!(); + /// Invoke `rustbook` for `target` for the doc book `name` from the `src` path. /// /// This will not actually generate any documentation if the documentation has @@ -203,6 +235,8 @@ impl Step for TheBook { }); } + compiler_target_info!(); + /// Builds the book and associated stuff. /// /// We need to build: @@ -318,6 +352,8 @@ impl Step for Standalone { }); } + compiler_target_info!(); + /// Generates all standalone documentation as compiled by the rustdoc in `stage` /// for the `target` into `out`. /// @@ -434,6 +470,8 @@ impl Step for Std { run.builder.ensure(Std { stage: run.builder.top_stage, target: run.target }); } + stage_target_info!(); + /// Compile all standard library documentation. /// /// This will generate all documentation for the standard library and its @@ -544,6 +582,8 @@ impl Step for Rustc { run.builder.ensure(Rustc { stage: run.builder.top_stage, target: run.target }); } + stage_target_info!(); + /// Generates compiler documentation. /// /// This will generate all documentation for compiler and dependencies. @@ -639,6 +679,8 @@ macro_rules! tool_doc { run.builder.ensure($tool { stage: run.builder.top_stage, target: run.target }); } + stage_target_info!(); + /// Generates compiler documentation. /// /// This will generate all documentation for compiler and dependencies. @@ -735,6 +777,8 @@ impl Step for ErrorIndex { run.builder.ensure(ErrorIndex { target }); } + target_info!(); + /// Generates the HTML rendered error-index by running the /// `error_index_generator` tool. fn run(self, builder: &Builder<'_>) { @@ -769,6 +813,8 @@ impl Step for UnstableBookGen { run.builder.ensure(UnstableBookGen { target: run.target }); } + target_info!(); + fn run(self, builder: &Builder<'_>) { let target = self.target; @@ -828,6 +874,8 @@ impl Step for RustcBook { }); } + compiler_target_info!(); + /// Builds the rustc book. /// /// The lints are auto-generated by a tool, and then merged into the book diff --git a/src/bootstrap/install.rs b/src/bootstrap/install.rs index 8a1b6df0dafe3..10a3221d9992d 100644 --- a/src/bootstrap/install.rs +++ b/src/bootstrap/install.rs @@ -14,7 +14,7 @@ use crate::dist::{self, sanitize_sh}; use crate::tarball::GeneratedTarball; use crate::Compiler; -use crate::builder::{Builder, RunConfig, ShouldRun, Step}; +use crate::builder::{Builder, Kind, RunConfig, ShouldRun, Step, StepInfo}; use crate::config::{Config, TargetSelection}; #[cfg(target_os = "illumos")] @@ -90,6 +90,15 @@ fn prepare_dir(mut path: PathBuf) -> String { sanitize_sh(&path) } +macro_rules! compiler_target_info { + () => { + fn info(step_info: &mut StepInfo<'_, '_, Self>) { + let step = step_info.step; + step_info.compiler(&step.compiler).target(step.target).cmd(Kind::Install); + } + } +} + macro_rules! install { (($sel:ident, $builder:ident, $_config:ident), $($name:ident, @@ -130,6 +139,8 @@ macro_rules! install { }); } + compiler_target_info!(); + fn run($sel, $builder: &Builder<'_>) { $run_item } @@ -262,6 +273,10 @@ impl Step for Src { run.builder.ensure(Src { stage: run.builder.top_stage }); } + fn info(step_info: &mut StepInfo<'_, '_, Self>) { + step_info.stage(step_info.step.stage).cmd(Kind::Install); + } + fn run(self, builder: &Builder<'_>) { let tarball = builder.ensure(dist::Src); install_sh(builder, "src", self.stage, None, &tarball); diff --git a/src/bootstrap/native.rs b/src/bootstrap/native.rs index 1be414b29a1ae..907f8580f673d 100644 --- a/src/bootstrap/native.rs +++ b/src/bootstrap/native.rs @@ -18,12 +18,20 @@ use std::process::Command; use build_helper::{output, t}; -use crate::builder::{Builder, RunConfig, ShouldRun, Step}; +use crate::builder::{Builder, Kind, RunConfig, ShouldRun, Step, StepInfo}; use crate::config::TargetSelection; use crate::util::{self, exe}; use crate::GitRepo; use build_helper::up_to_date; +macro_rules! target_info { + () => { + fn info(step_info: &mut StepInfo<'_, '_, Self>) { + step_info.target(step_info.step.target).cmd(Kind::Build); + } + } +} + pub struct Meta { stamp: HashStamp, build_llvm_config: PathBuf, @@ -109,6 +117,8 @@ impl Step for Llvm { run.builder.ensure(Llvm { target: run.target }); } + target_info!(); + /// Compile LLVM for `target`. fn run(self, builder: &Builder<'_>) -> PathBuf { let target = self.target; @@ -539,6 +549,8 @@ impl Step for Lld { run.builder.ensure(Lld { target: run.target }); } + target_info!(); + /// Compile LLD for `target`. fn run(self, builder: &Builder<'_>) -> PathBuf { if builder.config.dry_run { @@ -632,6 +644,8 @@ impl Step for TestHelpers { run.builder.ensure(TestHelpers { target: run.target }) } + target_info!(); + /// Compiles the `rust_test_helpers.c` library which we used in various /// `run-pass` tests for ABI testing. fn run(self, builder: &Builder<'_>) { @@ -697,6 +711,8 @@ impl Step for Sanitizers { run.builder.ensure(Sanitizers { target: run.target }); } + target_info!(); + /// Builds sanitizer runtime libraries. fn run(self, builder: &Builder<'_>) -> Self::Output { let compiler_rt_dir = builder.src.join("src/llvm-project/compiler-rt"); @@ -876,6 +892,8 @@ impl Step for CrtBeginEnd { run.builder.ensure(CrtBeginEnd { target: run.target }); } + target_info!(); + /// Build crtbegin.o/crtend.o for musl target. fn run(self, builder: &Builder<'_>) -> Self::Output { let out_dir = builder.native_dir(self.target).join("crt"); diff --git a/src/bootstrap/run.rs b/src/bootstrap/run.rs index 7c64e5a0aadc8..92ec8fe46302f 100644 --- a/src/bootstrap/run.rs +++ b/src/bootstrap/run.rs @@ -1,4 +1,4 @@ -use crate::builder::{Builder, RunConfig, ShouldRun, Step}; +use crate::builder::{Builder, Kind, RunConfig, ShouldRun, Step, StepInfo}; use crate::dist::distdir; use crate::tool::Tool; use build_helper::output; @@ -22,6 +22,10 @@ impl Step for ExpandYamlAnchors { ); } + fn info(step_info: &mut StepInfo<'_, '_, Self>) { + step_info.cmd(Kind::Run); + } + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.path("src/tools/expand-yaml-anchors") } @@ -59,6 +63,10 @@ impl Step for BuildManifest { run.builder.ensure(BuildManifest); } + fn info(step_info: &mut StepInfo<'_, '_, Self>) { + step_info.cmd(Kind::Run); + } + fn run(self, builder: &Builder<'_>) { // This gets called by `promote-release` // (https://github.com/rust-lang/promote-release). diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs index e643fbd84f309..46dc3e053a9ab 100644 --- a/src/bootstrap/test.rs +++ b/src/bootstrap/test.rs @@ -13,7 +13,7 @@ use std::process::{Command, Stdio}; use build_helper::{self, output, t}; -use crate::builder::{Builder, Compiler, Kind, RunConfig, ShouldRun, Step}; +use crate::builder::{Builder, Compiler, Kind, RunConfig, ShouldRun, Step, StepInfo}; use crate::cache::Interned; use crate::compile; use crate::config::TargetSelection; @@ -26,6 +26,33 @@ use crate::util::{self, add_link_lib_path, dylib_path, dylib_path_var}; use crate::Crate as CargoCrate; use crate::{envify, DocTests, GitRepo, Mode}; +macro_rules! host_info { + () => { + fn info(step_info: &mut StepInfo<'_, '_, Self>) { + let step = step_info.step; + step_info.host(step.host).cmd(Kind::Test); + } + } +} + +macro_rules! stage_host_info { + () => { + fn info(step_info: &mut StepInfo<'_, '_, Self>) { + let step = step_info.step; + step_info.stage(step.stage).host(step.host).cmd(Kind::Test); + } + } +} + +macro_rules! compiler_target_info { + () => { + fn info(step_info: &mut StepInfo<'_, '_, Self>) { + let step = step_info.step; + step_info.compiler(&step.compiler).target(step.target).cmd(Kind::Test); + } + } +} + const ADB_TEST_DIR: &str = "/data/tmp/work"; /// The two modes of the test runner; tests or benchmarks. @@ -150,6 +177,11 @@ You can skip linkcheck with --exclude src/tools/linkchecker" ); } + fn info(step_info: &mut StepInfo<'_, '_, Self>) { + let step = step_info.step; + step_info.host(step.host).cmd(Kind::Test); + } + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { let builder = run.builder; let run = run.path("src/tools/linkchecker"); @@ -188,6 +220,10 @@ impl Step for HtmlCheck { run.builder.ensure(HtmlCheck { target: run.target }); } + fn info(step_info: &mut StepInfo<'_, '_, Self>) { + step_info.target(step_info.step.target).cmd(Kind::Test); + } + fn run(self, builder: &Builder<'_>) { if !check_if_tidy_is_installed() { eprintln!("not running HTML-check tool because `tidy` is missing"); @@ -222,6 +258,8 @@ impl Step for Cargotest { run.builder.ensure(Cargotest { stage: run.builder.top_stage, host: run.target }); } + stage_host_info!(); + /// Runs the `cargotest` tool as compiled in `stage` by the `host` compiler. /// /// This tool in `src/tools` will check out a few Rust projects and run `cargo @@ -268,6 +306,8 @@ impl Step for Cargo { run.builder.ensure(Cargo { stage: run.builder.top_stage, host: run.target }); } + stage_host_info!(); + /// Runs `cargo test` for `cargo` packaged with Rust. fn run(self, builder: &Builder<'_>) { let compiler = builder.compiler(self.stage, self.host); @@ -322,6 +362,8 @@ impl Step for Rls { run.builder.ensure(Rls { stage: run.builder.top_stage, host: run.target }); } + stage_host_info!(); + /// Runs `cargo test` for the rls. fn run(self, builder: &Builder<'_>) { let stage = self.stage; @@ -373,6 +415,8 @@ impl Step for Rustfmt { run.builder.ensure(Rustfmt { stage: run.builder.top_stage, host: run.target }); } + stage_host_info!(); + /// Runs `cargo test` for rustfmt. fn run(self, builder: &Builder<'_>) { let stage = self.stage; @@ -422,6 +466,8 @@ impl Step for RustDemangler { run.builder.ensure(RustDemangler { stage: run.builder.top_stage, host: run.target }); } + stage_host_info!(); + /// Runs `cargo test` for rust-demangler. fn run(self, builder: &Builder<'_>) { let stage = self.stage; @@ -473,6 +519,8 @@ impl Step for Miri { run.builder.ensure(Miri { stage: run.builder.top_stage, host: run.target }); } + stage_host_info!(); + /// Runs `cargo test` for miri. fn run(self, builder: &Builder<'_>) { let stage = self.stage; @@ -605,6 +653,8 @@ impl Step for CompiletestTest { run.builder.ensure(CompiletestTest { host: run.target }); } + host_info!(); + /// Runs `cargo test` for compiletest. fn run(self, builder: &Builder<'_>) { let host = self.host; @@ -647,6 +697,8 @@ impl Step for Clippy { run.builder.ensure(Clippy { stage: run.builder.top_stage, host: run.target }); } + stage_host_info!(); + /// Runs `cargo test` for clippy. fn run(self, builder: &Builder<'_>) { let stage = self.stage; @@ -738,6 +790,11 @@ impl Step for RustdocTheme { run.builder.ensure(RustdocTheme { compiler }); } + fn info(step_info: &mut StepInfo<'_, '_, Self>) { + let step = step_info.step; + step_info.compiler(step.compiler).cmd(Kind::Test); + } + fn run(self, builder: &Builder<'_>) { let rustdoc = builder.out.join("bootstrap/debug/rustdoc"); let mut cmd = builder.tool_cmd(Tool::RustdocTheme); @@ -777,6 +834,11 @@ impl Step for RustdocJSStd { run.builder.ensure(RustdocJSStd { target: run.target }); } + fn info(step_info: &mut StepInfo<'_, '_, Self>) { + let step = step_info.step; + step_info.target(step.target).cmd(Kind::Test); + } + fn run(self, builder: &Builder<'_>) { if let Some(ref nodejs) = builder.config.nodejs { let mut command = Command::new(nodejs); @@ -818,6 +880,8 @@ impl Step for RustdocJSNotStd { run.builder.ensure(RustdocJSNotStd { target: run.target, compiler }); } + compiler_target_info!(); + fn run(self, builder: &Builder<'_>) { if builder.config.nodejs.is_some() { builder.ensure(Compiletest { @@ -882,6 +946,8 @@ impl Step for RustdocGUI { run.builder.ensure(RustdocGUI { target: run.target, compiler }); } + compiler_target_info!(); + fn run(self, builder: &Builder<'_>) { let nodejs = builder.config.nodejs.as_ref().expect("nodejs isn't available"); let npm = builder.config.npm.as_ref().expect("npm isn't available"); @@ -999,6 +1065,10 @@ help: to skip test's attempt to check tidiness, pass `--exclude src/tools/tidy` } } + fn info(step_info: &mut StepInfo<'_, '_, Self>) { + step_info.cmd(Kind::Test); + } + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.path("src/tools/tidy") } @@ -1028,6 +1098,10 @@ impl Step for ExpandYamlAnchors { ); } + fn info(step_info: &mut StepInfo<'_, '_, Self>) { + step_info.cmd(Kind::Test); + } + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.path("src/tools/expand-yaml-anchors") } @@ -1125,6 +1199,8 @@ macro_rules! test_definitions { run.builder.ensure($name { compiler, target: run.target }); } + compiler_target_info!(); + fn run(self, builder: &Builder<'_>) { builder.ensure(Compiletest { compiler: self.compiler, @@ -1215,6 +1291,8 @@ impl Step for Compiletest { run.never() } + compiler_target_info!(); + fn path(&self, _builder: &Builder<'_>) -> PathBuf { // FIXME: it would be nice to suggest exactly the tests that fail, but that info isn't known without first running compiletest. self.path.into() @@ -1624,6 +1702,12 @@ impl Step for BookTest { run.never() } + fn info(step_info: &mut StepInfo<'_, '_, Self>) { + let step = step_info.step; + todo!("path"); + step_info.compiler(&step.compiler).cmd(Kind::Test); + } + /// Runs the documentation tests for a book in `src/doc`. /// /// This uses the `rustdoc` that sits next to `compiler`. @@ -1730,6 +1814,11 @@ macro_rules! test_book { }); } + fn info(step_info: &mut StepInfo<'_, '_, Self>) { + let step = step_info.step; + step_info.compiler(&step.compiler).cmd(Kind::Test); + } + fn run(self, builder: &Builder<'_>) { builder.ensure(BookTest { compiler: self.compiler, @@ -1777,6 +1866,11 @@ impl Step for ErrorIndex { run.builder.ensure(ErrorIndex { compiler }); } + fn info(step_info: &mut StepInfo<'_, '_, Self>) { + let step = step_info.step; + step_info.compiler(&step.compiler).cmd(Kind::Test); + } + /// Runs the error index generator tool to execute the tests located in the error /// index. /// @@ -1846,6 +1940,10 @@ impl Step for RustcGuide { run.builder.ensure(RustcGuide); } + fn info(step_info: &mut StepInfo<'_, '_, Self>) { + step_info.cmd(Kind::Test); + } + fn run(self, builder: &Builder<'_>) { let relative_path = Path::new("src").join("doc").join("rustc-dev-guide"); builder.update_submodule(&relative_path); @@ -1898,6 +1996,12 @@ impl Step for CrateLibrustc { } } + fn info(step_info: &mut StepInfo<'_, '_, Self>) { + let step = step_info.step; + step_info.path(step.krate_path.clone()); + step_info.compiler(&step.compiler).target(step.target).cmd(Kind::Test); + } + fn run(self, builder: &Builder<'_>) { builder.ensure(Crate { compiler: self.compiler, @@ -1952,6 +2056,8 @@ impl Step for Crate { } } + compiler_target_info!(); + fn path(&self, _builder: &Builder<'_>) -> PathBuf { self.krate_path.file_name().expect("top-level directory is not a crate").into() } @@ -2078,6 +2184,11 @@ impl Step for CrateRustdoc { builder.ensure(CrateRustdoc { host: run.target, test_kind }); } + fn info(step_info: &mut StepInfo<'_, '_, Self>) { + let step = step_info.step; + step_info.host(step.host).cmd(Kind::Test); + } + fn run(self, builder: &Builder<'_>) { let test_kind = self.test_kind; let target = self.host; @@ -2175,6 +2286,11 @@ impl Step for CrateRustdocJsonTypes { builder.ensure(CrateRustdocJsonTypes { host: run.target, test_kind }); } + fn info(step_info: &mut StepInfo<'_, '_, Self>) { + let step = step_info.step; + step_info.host(step.host).cmd(Kind::Test); + } + fn run(self, builder: &Builder<'_>) { let test_kind = self.test_kind; let target = self.host; @@ -2245,6 +2361,8 @@ impl Step for RemoteCopyLibs { run.never() } + compiler_target_info!(); + fn run(self, builder: &Builder<'_>) { let compiler = self.compiler; let target = self.target; @@ -2293,6 +2411,10 @@ impl Step for Distcheck { run.builder.ensure(Distcheck); } + fn info(step_info: &mut StepInfo<'_, '_, Self>) { + step_info.cmd(Kind::Test); + } + /// Runs "distcheck", a 'make check' from a tarball fn run(self, builder: &Builder<'_>) { builder.info("Distcheck"); @@ -2381,6 +2503,10 @@ impl Step for Bootstrap { try_run(builder, &mut cmd); } + fn info(step_info: &mut StepInfo<'_, '_, Self>) { + step_info.cmd(Kind::Test); + } + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.path("src/bootstrap") } @@ -2410,6 +2536,11 @@ impl Step for TierCheck { run.builder.ensure(TierCheck { compiler }); } + fn info(step_info: &mut StepInfo<'_, '_, Self>) { + let step = step_info.step; + step_info.compiler(step.compiler).cmd(Kind::Test); + } + /// Tests the Platform Support page in the rustc book. fn run(self, builder: &Builder<'_>) { builder.ensure(compile::Std { compiler: self.compiler, target: self.compiler.host }); @@ -2456,6 +2587,8 @@ impl Step for LintDocs { }); } + compiler_target_info!(); + /// Tests that the lint examples in the rustc book generate the correct /// lints and have the expected format. fn run(self, builder: &Builder<'_>) { diff --git a/src/bootstrap/tool.rs b/src/bootstrap/tool.rs index 005edad500f3e..a5b1689d65f96 100644 --- a/src/bootstrap/tool.rs +++ b/src/bootstrap/tool.rs @@ -40,6 +40,12 @@ impl Step for ToolBuild { run.never() } + fn info(step_info: &mut StepInfo<'_, '_, Self>) { + let step = step_info.step; + todo!("path"); + step_info.compiler(&step.compiler).target(step.target).cmd(Kind::Build); + } + /// Builds a tool in `src/tools` /// /// This will build the specified tool with the specified `host` compiler in @@ -432,6 +438,11 @@ impl Step for ErrorIndex { run.builder.ensure(ErrorIndex { compiler }); } + fn info(step_info: &mut StepInfo<'_, '_, Self>) { + let step = step_info.step; + step_info.compiler(&step.compiler).cmd(Kind::Build); + } + fn run(self, builder: &Builder<'_>) -> PathBuf { builder .ensure(ToolBuild { @@ -468,6 +479,11 @@ impl Step for RemoteTestServer { }); } + fn info(step_info: &mut StepInfo<'_, '_, Self>) { + let step = step_info.step; + step_info.compiler(&step.compiler).target(step.target).cmd(Kind::Build); + } + fn run(self, builder: &Builder<'_>) -> PathBuf { builder .ensure(ToolBuild { @@ -500,6 +516,11 @@ impl Step for Rustdoc { run.path("src/tools/rustdoc").path("src/librustdoc") } + fn info(step_info: &mut StepInfo<'_, '_, Self>) { + let step = step_info.step; + step_info.compiler(&step.compiler).cmd(Kind::Build); + } + fn make_run(run: RunConfig<'_>) { run.builder.ensure(Rustdoc { // Note: this is somewhat unique in that we actually want a *target* @@ -722,6 +743,11 @@ macro_rules! tool_extended { }); } + fn info(step_info: &mut StepInfo<'_, '_, Self>) { + let step = step_info.step; + step_info.compiler(&step.compiler).target(step.target).cmd(Kind::Check); + } + #[allow(unused_mut)] fn run(mut $sel, $builder: &Builder<'_>) -> Option { $extra_deps diff --git a/src/bootstrap/toolstate.rs b/src/bootstrap/toolstate.rs index 2394c5e020d2b..4292d7fee9a59 100644 --- a/src/bootstrap/toolstate.rs +++ b/src/bootstrap/toolstate.rs @@ -1,4 +1,4 @@ -use crate::builder::{Builder, RunConfig, ShouldRun, Step}; +use crate::builder::{Builder, RunConfig, ShouldRun, Step, StepInfo}; use build_helper::t; use serde::{Deserialize, Serialize}; use std::collections::HashMap; @@ -141,6 +141,8 @@ pub struct ToolStateCheck; impl Step for ToolStateCheck { type Output = (); + fn info(_step_info: &mut StepInfo<'_, '_, Self>) {} + /// Checks tool state status. /// /// This is intended to be used in the `checktools.sh` script. To use From a6f8a1d40971d1a7936c54e47f213f26748d751b Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Sat, 24 Jul 2021 18:26:38 +0000 Subject: [PATCH 6/7] Change some things to use step_info --- src/bootstrap/native.rs | 10 +++++----- src/bootstrap/test.rs | 2 +- src/bootstrap/tool.rs | 9 +++------ 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/src/bootstrap/native.rs b/src/bootstrap/native.rs index 907f8580f673d..df7910d6220ae 100644 --- a/src/bootstrap/native.rs +++ b/src/bootstrap/native.rs @@ -145,7 +145,7 @@ impl Step for Llvm { panic!("shared linking to LLVM is not currently supported on {}", target.triple); } - builder.info(&format!("Building LLVM for {}", target)); + builder.step_info(&self); t!(stamp.remove()); let _time = util::timeit(&builder); t!(fs::create_dir_all(&out_dir)); @@ -566,7 +566,7 @@ impl Step for Lld { return out_dir; } - builder.info(&format!("Building LLD for {}", target)); + builder.step_info(&self); let _time = util::timeit(&builder); t!(fs::create_dir_all(&out_dir)); @@ -666,7 +666,7 @@ impl Step for TestHelpers { return; } - builder.info("Building test helpers"); + builder.step_info(&self); t!(fs::create_dir_all(&dst)); let mut cfg = cc::Build::new(); // FIXME: Workaround for https://github.com/emscripten-core/emscripten/issues/9013 @@ -744,7 +744,7 @@ impl Step for Sanitizers { return runtimes; } - builder.info(&format!("Building sanitizers for {}", self.target)); + builder.step_info(&self); t!(stamp.remove()); let _time = util::timeit(&builder); @@ -910,7 +910,7 @@ impl Step for CrtBeginEnd { return out_dir; } - builder.info("Building crtbegin.o and crtend.o"); + builder.step_info(&self); t!(fs::create_dir_all(&out_dir)); let mut cfg = cc::Build::new(); diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs index 46dc3e053a9ab..e1fc3c49b8e32 100644 --- a/src/bootstrap/test.rs +++ b/src/bootstrap/test.rs @@ -1043,7 +1043,7 @@ impl Step for Tidy { cmd.arg("--verbose"); } - builder.info("tidy check"); + builder.step_info(&self); try_run(builder, &mut cmd); if builder.config.channel == "dev" || builder.config.channel == "nightly" { diff --git a/src/bootstrap/tool.rs b/src/bootstrap/tool.rs index a5b1689d65f96..f0f4a5e7ac428 100644 --- a/src/bootstrap/tool.rs +++ b/src/bootstrap/tool.rs @@ -42,7 +42,7 @@ impl Step for ToolBuild { fn info(step_info: &mut StepInfo<'_, '_, Self>) { let step = step_info.step; - todo!("path"); + // todo!("path"); step_info.compiler(&step.compiler).target(step.target).cmd(Kind::Build); } @@ -78,7 +78,7 @@ impl Step for ToolBuild { &self.extra_features, ); - builder.info(&format!("Building stage{} tool {} ({})", compiler.stage, tool, target)); + builder.step_info(&self); let mut duplicates = Vec::new(); let is_expected = compile::stream_cargo(builder, cargo, vec![], &mut |msg| { // Only care about big things like the RLS/Cargo for now @@ -582,10 +582,7 @@ impl Step for Rustdoc { features.as_slice(), ); - builder.info(&format!( - "Building rustdoc for stage{} ({})", - target_compiler.stage, target_compiler.host - )); + builder.step_info(&self); builder.run(&mut cargo.into()); // Cargo adds a number of paths to the dylib search path on windows, which results in From c47f73bbe1306d1571292ca126c31f8514a1d8e6 Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Sat, 24 Jul 2021 19:01:04 +0000 Subject: [PATCH 7/7] cleanup --- src/bootstrap/builder.rs | 57 ++++++++++++++++++++++------------------ src/bootstrap/check.rs | 21 +-------------- src/bootstrap/dist.rs | 2 +- src/bootstrap/doc.rs | 8 +++--- src/bootstrap/install.rs | 2 +- src/bootstrap/native.rs | 2 +- src/bootstrap/test.rs | 37 +++++++++++++------------- src/bootstrap/tool.rs | 1 + 8 files changed, 59 insertions(+), 71 deletions(-) diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index 2236755109a52..88c6501c858be 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -70,17 +70,6 @@ pub(crate) trait Step: 'static + Clone + Debug + PartialEq + Eq + Hash { fn info(_step_info: &mut StepInfo<'_, '_, Self>); - /// The path that should be used on the command line to run this step. - fn path(&self, builder: &Builder<'_>) -> PathBuf { - let paths = Self::should_run(ShouldRun::new(builder)).paths; - paths.iter().map(|pathset| pathset.path(builder)).next().expect("no paths for step") - } - - // /// The stage that should be passed to x.py to run this step. - // fn stage(&self, builder: &Builder<'_>) -> u32 { - // builder.top_stage - // } - /// Primary function to execute this rule. Can call `builder.ensure()` /// with other steps to run those. fn run(self, builder: &Builder<'_>) -> Self::Output; @@ -1752,6 +1741,7 @@ pub(crate) struct StepInfo<'a, 'b, S> { host: Option, target: Option, cmd: Option, + path: Option, } impl<'a> From for Cow<'a, Compiler> { @@ -1768,7 +1758,16 @@ impl<'a> From<&'a Compiler> for Cow<'a, Compiler> { impl<'a, 'b, S> StepInfo<'a, 'b, S> { pub(crate) fn new(builder: &'a Builder<'b>, step: &'a S) -> Self { - Self { builder, step, compiler: None, stage: None, host: None, target: None, cmd: None } + Self { + builder, + step, + compiler: None, + stage: None, + host: None, + target: None, + cmd: None, + path: None, + } } pub(crate) fn compiler(&mut self, val: impl Into>) -> &mut Self { @@ -1813,6 +1812,14 @@ impl<'a, 'b, S> StepInfo<'a, 'b, S> { self } + pub(crate) fn path(&mut self, val: PathBuf) -> &mut Self { + if self.path.is_some() { + panic!("cannot overwrite path"); + } + self.path = Some(val); + self + } + /// Print a command that will run the current step. /// /// This serves two purposes: @@ -1822,33 +1829,31 @@ impl<'a, 'b, S> StepInfo<'a, 'b, S> { where S: Step, { - if self.builder.config.dry_run { + let builder = self.builder; + if builder.config.dry_run { return; } - // let stage = self.stage.unwrap_or(self.builder.top_stage); - let stage = self.stage.expect("missing stage"); - // let kind = self.cmd.unwrap_or(self.builder.kind); - let kind = self.cmd.expect("missing kind"); - print!( - "{} {} --stage {}", - kind, - self.step.path(self.builder).display(), - stage, - ); + let stage = self.stage.unwrap_or(self.builder.top_stage); + let kind = self.cmd.unwrap_or_else(|| panic!("missing kind for {}", self.step.name())); + let path = self.path.clone().unwrap_or_else(|| { + let paths = S::should_run(ShouldRun::new(builder)).paths; + paths.iter().map(|pathset| pathset.path(builder)).next().expect("no paths for step") + }); + print!("{} {} --stage {}", kind, path.display(), stage,); if let Some(host) = self.host { // Almost always, this will be the same as build. Don't print it if so. - if host != self.builder.config.build { + if host != builder.config.build { print!(" --host {}", host); } } if let Some(target) = self.target { let different_from_host = self.host.map_or(false, |h| h != target); - if target != self.builder.config.build || different_from_host { + if target != builder.config.build || different_from_host { print!(" --target {}", target); } } if kind == Kind::Test { - for arg in self.builder.config.cmd.test_args() { + for arg in builder.config.cmd.test_args() { print!(" --test-args \"{}\"", arg); } } diff --git a/src/bootstrap/check.rs b/src/bootstrap/check.rs index e6ce76416b0da..e3e11a004b7f3 100644 --- a/src/bootstrap/check.rs +++ b/src/bootstrap/check.rs @@ -94,10 +94,6 @@ impl Step for Std { std_cargo(builder, target, compiler.stage, &mut cargo); builder.step_info(&self); - // builder.info(&format!( - // "Checking stage{} std artifacts ({} -> {})", - // builder.top_stage, &compiler.host, target - // )); run_cargo( builder, cargo, @@ -141,7 +137,7 @@ impl Step for Std { } builder.info(&format!( - "Checking stage{} std test/bench/example targets ({} -> {})", + "check library/alloc --stage {} --all-targets --host {} --target {}", builder.top_stage, &compiler.host, target )); run_cargo( @@ -222,10 +218,6 @@ impl Step for Rustc { } builder.step_info(&self); - // builder.info(&format!( - // "Checking stage{} compiler artifacts ({} -> {})", - // builder.top_stage, &compiler.host, target - // )); run_cargo( builder, cargo, @@ -287,10 +279,6 @@ impl Step for CodegenBackend { rustc_cargo_env(builder, &mut cargo, target); builder.step_info(&self); - // builder.info(&format!( - // "Checking stage{} {} artifacts ({} -> {})", - // builder.top_stage, backend, &compiler.host.triple, target.triple - // )); run_cargo( builder, @@ -358,13 +346,6 @@ macro_rules! tool_check_step { cargo.rustflag("-Zunstable-options"); builder.step_info(&self); - // builder.info(&format!( - // "Checking stage{} {} artifacts ({} -> {})", - // builder.top_stage, - // stringify!($name).to_lowercase(), - // &compiler.host.triple, - // target.triple - // )); run_cargo( builder, cargo, diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs index 361182fdc2e61..3ba425eb1cdcf 100644 --- a/src/bootstrap/dist.rs +++ b/src/bootstrap/dist.rs @@ -51,7 +51,7 @@ macro_rules! compiler_target_info { let step = step_info.step; step_info.compiler(&step.compiler).target(step.target).cmd(Kind::Dist); } - } + }; } #[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)] diff --git a/src/bootstrap/doc.rs b/src/bootstrap/doc.rs index d893674d031d2..b0ca86147a15f 100644 --- a/src/bootstrap/doc.rs +++ b/src/bootstrap/doc.rs @@ -36,7 +36,7 @@ macro_rules! target_info { fn info(step_info: &mut StepInfo<'_, '_, Self>) { step_info.target(step_info.step.target).cmd(Kind::Doc); } - } + }; } macro_rules! compiler_target_info { @@ -45,7 +45,7 @@ macro_rules! compiler_target_info { let step = step_info.step; step_info.compiler(&step.compiler).target(step.target).cmd(Kind::Doc); } - } + }; } macro_rules! stage_target_info { @@ -54,7 +54,7 @@ macro_rules! stage_target_info { let step = step_info.step; step_info.stage(step.stage).target(step.target).cmd(Kind::Doc); } - } + }; } macro_rules! book { @@ -818,7 +818,7 @@ impl Step for UnstableBookGen { fn run(self, builder: &Builder<'_>) { let target = self.target; - builder.info(&format!("Generating unstable book md files ({})", target)); + builder.step_info(&self); let out = builder.md_doc_out(target).join("unstable-book"); builder.create_dir(&out); builder.remove_dir(&out); diff --git a/src/bootstrap/install.rs b/src/bootstrap/install.rs index 10a3221d9992d..ed42a203a398e 100644 --- a/src/bootstrap/install.rs +++ b/src/bootstrap/install.rs @@ -96,7 +96,7 @@ macro_rules! compiler_target_info { let step = step_info.step; step_info.compiler(&step.compiler).target(step.target).cmd(Kind::Install); } - } + }; } macro_rules! install { diff --git a/src/bootstrap/native.rs b/src/bootstrap/native.rs index df7910d6220ae..695c159ffc832 100644 --- a/src/bootstrap/native.rs +++ b/src/bootstrap/native.rs @@ -29,7 +29,7 @@ macro_rules! target_info { fn info(step_info: &mut StepInfo<'_, '_, Self>) { step_info.target(step_info.step.target).cmd(Kind::Build); } - } + }; } pub struct Meta { diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs index e1fc3c49b8e32..243bb95597410 100644 --- a/src/bootstrap/test.rs +++ b/src/bootstrap/test.rs @@ -32,7 +32,7 @@ macro_rules! host_info { let step = step_info.step; step_info.host(step.host).cmd(Kind::Test); } - } + }; } macro_rules! stage_host_info { @@ -41,7 +41,7 @@ macro_rules! stage_host_info { let step = step_info.step; step_info.stage(step.stage).host(step.host).cmd(Kind::Test); } - } + }; } macro_rules! compiler_target_info { @@ -50,7 +50,7 @@ macro_rules! compiler_target_info { let step = step_info.step; step_info.compiler(&step.compiler).target(step.target).cmd(Kind::Test); } - } + }; } const ADB_TEST_DIR: &str = "/data/tmp/work"; @@ -1047,7 +1047,7 @@ impl Step for Tidy { try_run(builder, &mut cmd); if builder.config.channel == "dev" || builder.config.channel == "nightly" { - builder.info("fmt check"); + builder.info("fmt --check"); if builder.config.initial_rustfmt.is_none() { let inferred_rustfmt_dir = builder.config.initial_rustc.parent().unwrap(); eprintln!( @@ -1291,11 +1291,14 @@ impl Step for Compiletest { run.never() } - compiler_target_info!(); - - fn path(&self, _builder: &Builder<'_>) -> PathBuf { + fn info(step_info: &mut StepInfo<'_, '_, Self>) { + let step = step_info.step; // FIXME: it would be nice to suggest exactly the tests that fail, but that info isn't known without first running compiletest. - self.path.into() + step_info + .path(step.path.into()) + .compiler(&step.compiler) + .target(step.target) + .cmd(Kind::Test); } /// Executes the `compiletest` tool to run a suite of tests. @@ -1667,10 +1670,7 @@ note: if you're sure you want to do this, please open an issue as to why. In the builder.ci_env.force_coloring_in_ci(&mut cmd); - builder.info(&format!( - "Check compiletest suite={} mode={} ({} -> {})", - suite, mode, &compiler.host, target - )); + builder.step_info(&self); let _time = util::timeit(&builder); try_run(builder, &mut cmd); @@ -1704,8 +1704,7 @@ impl Step for BookTest { fn info(step_info: &mut StepInfo<'_, '_, Self>) { let step = step_info.step; - todo!("path"); - step_info.compiler(&step.compiler).cmd(Kind::Test); + step_info.path(step.path.clone()).compiler(&step.compiler).cmd(Kind::Test); } /// Runs the documentation tests for a book in `src/doc`. @@ -2056,10 +2055,12 @@ impl Step for Crate { } } - compiler_target_info!(); - - fn path(&self, _builder: &Builder<'_>) -> PathBuf { - self.krate_path.file_name().expect("top-level directory is not a crate").into() + fn info(step_info: &mut StepInfo<'_, '_, Self>) { + let step = step_info.step; + // FIXME: it would be nice to suggest exactly the tests that fail, but that info isn't known without first running compiletest. + step_info + .path(step.krate_path.file_name().expect("top-level directory is not a crate").into()); + step_info.compiler(&step.compiler).target(step.target).cmd(Kind::Test); } /// Runs all unit tests plus documentation tests for a given crate defined diff --git a/src/bootstrap/tool.rs b/src/bootstrap/tool.rs index f0f4a5e7ac428..0638dc45f3079 100644 --- a/src/bootstrap/tool.rs +++ b/src/bootstrap/tool.rs @@ -43,6 +43,7 @@ impl Step for ToolBuild { fn info(step_info: &mut StepInfo<'_, '_, Self>) { let step = step_info.step; // todo!("path"); + step_info.path(step.path.into()); step_info.compiler(&step.compiler).target(step.target).cmd(Kind::Build); }