summaryrefslogtreecommitdiffstats
path: root/src/bootstrap/check.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/bootstrap/check.rs')
-rw-r--r--src/bootstrap/check.rs81
1 files changed, 62 insertions, 19 deletions
diff --git a/src/bootstrap/check.rs b/src/bootstrap/check.rs
index b11be96ce..1a0f00478 100644
--- a/src/bootstrap/check.rs
+++ b/src/bootstrap/check.rs
@@ -1,8 +1,10 @@
//! Implementation of compiling the compiler and standard library, in "check"-based modes.
-use crate::builder::{Builder, Kind, RunConfig, ShouldRun, Step};
+use crate::builder::{crate_description, Builder, Kind, RunConfig, ShouldRun, Step};
use crate::cache::Interned;
-use crate::compile::{add_to_sysroot, run_cargo, rustc_cargo, rustc_cargo_env, std_cargo};
+use crate::compile::{
+ add_to_sysroot, make_run_crates, run_cargo, rustc_cargo, rustc_cargo_env, std_cargo,
+};
use crate::config::TargetSelection;
use crate::tool::{prepare_tool_cargo, SourceType};
use crate::INTERNER;
@@ -12,6 +14,12 @@ use std::path::{Path, PathBuf};
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub struct Std {
pub target: TargetSelection,
+ /// Whether to build only a subset of crates.
+ ///
+ /// This shouldn't be used from other steps; see the comment on [`compile::Rustc`].
+ ///
+ /// [`compile::Rustc`]: crate::compile::Rustc
+ crates: Interned<Vec<String>>,
}
/// Returns args for the subcommand itself (not for cargo)
@@ -66,16 +74,23 @@ fn cargo_subcommand(kind: Kind) -> &'static str {
}
}
+impl Std {
+ pub fn new(target: TargetSelection) -> Self {
+ Self { target, crates: INTERNER.intern_list(vec![]) }
+ }
+}
+
impl Step for Std {
type Output = ();
const DEFAULT: bool = true;
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
- run.all_krates("sysroot").path("library")
+ run.crate_or_deps("sysroot").path("library")
}
fn make_run(run: RunConfig<'_>) {
- run.builder.ensure(Std { target: run.target });
+ let crates = make_run_crates(&run, "library");
+ run.builder.ensure(Std { target: run.target, crates });
}
fn run(self, builder: &Builder<'_>) {
@@ -97,7 +112,14 @@ impl Step for Std {
cargo.arg("--lib");
}
- let _guard = builder.msg_check("library artifacts", target);
+ for krate in &*self.crates {
+ cargo.arg("-p").arg(krate);
+ }
+
+ let _guard = builder.msg_check(
+ format_args!("library artifacts{}", crate_description(&self.crates)),
+ target,
+ );
run_cargo(
builder,
cargo,
@@ -117,7 +139,8 @@ impl Step for Std {
}
// don't run on std twice with x.py clippy
- if builder.kind == Kind::Clippy {
+ // don't check test dependencies if we haven't built libtest
+ if builder.kind == Kind::Clippy || !self.crates.is_empty() {
return;
}
@@ -147,8 +170,8 @@ impl Step for Std {
// Explicitly pass -p for all dependencies krates -- this will force cargo
// to also check the tests/benches/examples for these crates, rather
// than just the leaf crate.
- for krate in builder.in_tree_crates("test", Some(target)) {
- cargo.arg("-p").arg(krate.name);
+ for krate in &*self.crates {
+ cargo.arg("-p").arg(krate);
}
let _guard = builder.msg_check("library test/bench/example targets", target);
@@ -167,6 +190,22 @@ impl Step for Std {
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub struct Rustc {
pub target: TargetSelection,
+ /// Whether to build only a subset of crates.
+ ///
+ /// This shouldn't be used from other steps; see the comment on [`compile::Rustc`].
+ ///
+ /// [`compile::Rustc`]: crate::compile::Rustc
+ crates: Interned<Vec<String>>,
+}
+
+impl Rustc {
+ pub fn new(target: TargetSelection, builder: &Builder<'_>) -> Self {
+ let mut crates = vec![];
+ for krate in builder.in_tree_crates("rustc-main", None) {
+ crates.push(krate.name.to_string());
+ }
+ Self { target, crates: INTERNER.intern_list(crates) }
+ }
}
impl Step for Rustc {
@@ -175,11 +214,12 @@ impl Step for Rustc {
const DEFAULT: bool = true;
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
- run.all_krates("rustc-main").path("compiler")
+ run.crate_or_deps("rustc-main").path("compiler")
}
fn make_run(run: RunConfig<'_>) {
- run.builder.ensure(Rustc { target: run.target });
+ let crates = make_run_crates(&run, "compiler");
+ run.builder.ensure(Rustc { target: run.target, crates });
}
/// Builds the compiler.
@@ -200,7 +240,7 @@ impl Step for Rustc {
builder.ensure(crate::compile::Std::new(compiler, compiler.host));
builder.ensure(crate::compile::Std::new(compiler, target));
} else {
- builder.ensure(Std { target });
+ builder.ensure(Std::new(target));
}
let mut cargo = builder.cargo(
@@ -218,14 +258,17 @@ impl Step for Rustc {
cargo.arg("--all-targets");
}
- // Explicitly pass -p for all compiler krates -- this will force cargo
+ // Explicitly pass -p for all compiler crates -- this will force cargo
// to also check the tests/benches/examples for these crates, rather
// than just the leaf crate.
- for krate in builder.in_tree_crates("rustc-main", Some(target)) {
- cargo.arg("-p").arg(krate.name);
+ for krate in &*self.crates {
+ cargo.arg("-p").arg(krate);
}
- let _guard = builder.msg_check("compiler artifacts", target);
+ let _guard = builder.msg_check(
+ format_args!("compiler artifacts{}", crate_description(&self.crates)),
+ target,
+ );
run_cargo(
builder,
cargo,
@@ -268,7 +311,7 @@ impl Step for CodegenBackend {
let target = self.target;
let backend = self.backend;
- builder.ensure(Rustc { target });
+ builder.ensure(Rustc::new(target, builder));
let mut cargo = builder.cargo(
compiler,
@@ -304,7 +347,7 @@ pub struct RustAnalyzer {
impl Step for RustAnalyzer {
type Output = ();
const ONLY_HOSTS: bool = true;
- const DEFAULT: bool = true;
+ const DEFAULT: bool = false;
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
run.path("src/tools/rust-analyzer")
@@ -318,7 +361,7 @@ impl Step for RustAnalyzer {
let compiler = builder.compiler(builder.top_stage, builder.config.build);
let target = self.target;
- builder.ensure(Std { target });
+ builder.ensure(Std::new(target));
let mut cargo = prepare_tool_cargo(
builder,
@@ -386,7 +429,7 @@ macro_rules! tool_check_step {
let compiler = builder.compiler(builder.top_stage, builder.config.build);
let target = self.target;
- builder.ensure(Rustc { target });
+ builder.ensure(Rustc::new(target, builder));
let mut cargo = prepare_tool_cargo(
builder,