Allow building single crates for the compiler and standard library

- Add `Interned<Vec<String>>` and use it for tail args
- Refactor `cache.rs` not to need a separate impl for each internable type
This commit is contained in:
Joshua Nelson
2022-06-26 21:07:27 -05:00
parent 0566ade0b1
commit d0011b0c05
9 changed files with 182 additions and 110 deletions

View File

@@ -13,7 +13,6 @@ use std::process::{Command, Stdio};
use std::time::{Duration, Instant}; use std::time::{Duration, Instant};
use crate::cache::{Cache, Interned, INTERNER}; use crate::cache::{Cache, Interned, INTERNER};
use crate::compile;
use crate::config::{SplitDebuginfo, TargetSelection}; use crate::config::{SplitDebuginfo, TargetSelection};
use crate::dist; use crate::dist;
use crate::doc; use crate::doc;
@@ -26,6 +25,7 @@ use crate::tool::{self, SourceType};
use crate::util::{self, add_dylib_path, add_link_lib_path, exe, libdir, output, t}; use crate::util::{self, add_dylib_path, add_link_lib_path, exe, libdir, output, t};
use crate::EXTRA_CHECK_CFGS; use crate::EXTRA_CHECK_CFGS;
use crate::{check, Config}; use crate::{check, Config};
use crate::{compile, Crate};
use crate::{Build, CLang, DocTests, GitRepo, Mode}; use crate::{Build, CLang, DocTests, GitRepo, Mode};
pub use crate::Compiler; pub use crate::Compiler;
@@ -422,8 +422,16 @@ impl<'a> ShouldRun<'a> {
/// any of its (local) dependencies. /// any of its (local) dependencies.
/// ///
/// `make_run` will be called a single time with all matching command-line paths. /// `make_run` will be called a single time with all matching command-line paths.
pub fn krate(mut self, name: &str) -> Self { pub fn crate_or_deps(self, name: &str) -> Self {
for krate in self.builder.in_tree_crates(name, None) { let crates = self.builder.in_tree_crates(name, None);
self.crates(crates)
}
/// Indicates it should run if the command-line selects any of the given crates.
///
/// `make_run` will be called a single time with all matching command-line paths.
pub(crate) fn crates(mut self, crates: Vec<&Crate>) -> Self {
for krate in crates {
let path = krate.local_path(self.builder); let path = krate.local_path(self.builder);
self.paths.insert(PathSet::one(path, self.kind)); self.paths.insert(PathSet::one(path, self.kind));
} }
@@ -579,6 +587,7 @@ impl<'a> Builder<'a> {
match kind { match kind {
Kind::Build => describe!( Kind::Build => describe!(
compile::Std, compile::Std,
compile::Rustc,
compile::Assemble, compile::Assemble,
compile::CodegenBackend, compile::CodegenBackend,
compile::StartupObjects, compile::StartupObjects,

View File

@@ -57,6 +57,24 @@ fn check_cli<const N: usize>(paths: [&str; N]) {
); );
} }
macro_rules! std {
($host:ident => $target:ident, stage = $stage:literal) => {
compile::Std::new(
Compiler { host: TargetSelection::from_user(stringify!($host)), stage: $stage },
TargetSelection::from_user(stringify!($target)),
)
};
}
macro_rules! rustc {
($host:ident => $target:ident, stage = $stage:literal) => {
compile::Rustc::new(
Compiler { host: TargetSelection::from_user(stringify!($host)), stage: $stage },
TargetSelection::from_user(stringify!($target)),
)
};
}
#[test] #[test]
fn test_valid() { fn test_valid() {
// make sure multi suite paths are accepted // make sure multi suite paths are accepted
@@ -117,6 +135,17 @@ fn test_exclude_kind() {
assert!(run_build(&[path], config).contains::<tool::CargoTest>()); assert!(run_build(&[path], config).contains::<tool::CargoTest>());
} }
/// Ensure that if someone passes both a single crate and `library`, all library crates get built.
#[test]
fn alias_and_path_for_library() {
let mut cache =
run_build(&["library".into(), "core".into()], configure("build", &["A"], &["A"]));
assert_eq!(
first(cache.all::<compile::Std>()),
&[std!(A => A, stage = 0), std!(A => A, stage = 1)]
);
}
mod defaults { mod defaults {
use super::{configure, first, run_build}; use super::{configure, first, run_build};
use crate::builder::*; use crate::builder::*;
@@ -130,10 +159,7 @@ mod defaults {
let a = TargetSelection::from_user("A"); let a = TargetSelection::from_user("A");
assert_eq!( assert_eq!(
first(cache.all::<compile::Std>()), first(cache.all::<compile::Std>()),
&[ &[std!(A => A, stage = 0), std!(A => A, stage = 1),]
compile::Std { compiler: Compiler { host: a, stage: 0 }, target: a },
compile::Std { compiler: Compiler { host: a, stage: 1 }, target: a },
]
); );
assert!(!cache.all::<compile::Assemble>().is_empty()); assert!(!cache.all::<compile::Assemble>().is_empty());
// Make sure rustdoc is only built once. // Make sure rustdoc is only built once.
@@ -143,10 +169,7 @@ mod defaults {
// - this is the compiler it's _linked_ to, not built with. // - this is the compiler it's _linked_ to, not built with.
&[tool::Rustdoc { compiler: Compiler { host: a, stage: 1 } }], &[tool::Rustdoc { compiler: Compiler { host: a, stage: 1 } }],
); );
assert_eq!( assert_eq!(first(cache.all::<compile::Rustc>()), &[rustc!(A => A, stage = 0)],);
first(cache.all::<compile::Rustc>()),
&[compile::Rustc { compiler: Compiler { host: a, stage: 0 }, target: a },]
);
} }
#[test] #[test]
@@ -155,10 +178,7 @@ mod defaults {
let mut cache = run_build(&[], config); let mut cache = run_build(&[], config);
let a = TargetSelection::from_user("A"); let a = TargetSelection::from_user("A");
assert_eq!( assert_eq!(first(cache.all::<compile::Std>()), &[std!(A => A, stage = 0)]);
first(cache.all::<compile::Std>()),
&[compile::Std { compiler: Compiler { host: a, stage: 0 }, target: a },]
);
assert!(!cache.all::<compile::Assemble>().is_empty()); assert!(!cache.all::<compile::Assemble>().is_empty());
assert_eq!( assert_eq!(
first(cache.all::<tool::Rustdoc>()), first(cache.all::<tool::Rustdoc>()),
@@ -185,10 +205,10 @@ mod defaults {
assert_eq!( assert_eq!(
first(cache.all::<compile::Std>()), first(cache.all::<compile::Std>()),
&[ &[
compile::Std { compiler: Compiler { host: a, stage: 0 }, target: a }, std!(A => A, stage = 0),
compile::Std { compiler: Compiler { host: a, stage: 1 }, target: a }, std!(A => A, stage = 1),
compile::Std { compiler: Compiler { host: a, stage: 0 }, target: b }, std!(A => B, stage = 0),
compile::Std { compiler: Compiler { host: a, stage: 1 }, target: b }, std!(A => B, stage = 1),
] ]
); );
assert_eq!( assert_eq!(
@@ -208,10 +228,7 @@ mod defaults {
); );
assert_eq!( assert_eq!(
first(cache.all::<compile::Rustc>()), first(cache.all::<compile::Rustc>()),
&[ &[rustc!(A => A, stage = 0), rustc!(A => B, stage = 0),]
compile::Rustc { compiler: Compiler { host: a, stage: 0 }, target: a },
compile::Rustc { compiler: Compiler { host: a, stage: 0 }, target: b },
]
); );
} }
@@ -334,11 +351,11 @@ mod dist {
assert_eq!( assert_eq!(
first(cache.all::<compile::Std>()), first(cache.all::<compile::Std>()),
&[ &[
compile::Std { compiler: Compiler { host: a, stage: 0 }, target: a }, std!(A => A, stage = 0),
compile::Std { compiler: Compiler { host: a, stage: 1 }, target: a }, std!(A => A, stage = 1),
compile::Std { compiler: Compiler { host: a, stage: 2 }, target: a }, std!(A => A, stage = 2),
compile::Std { compiler: Compiler { host: a, stage: 1 }, target: b }, std!(A => B, stage = 1),
compile::Std { compiler: Compiler { host: a, stage: 2 }, target: b }, std!(A => B, stage = 2),
], ],
); );
assert_eq!(first(cache.all::<dist::Src>()), &[dist::Src]); assert_eq!(first(cache.all::<dist::Src>()), &[dist::Src]);
@@ -346,7 +363,6 @@ mod dist {
#[test] #[test]
fn dist_only_cross_host() { fn dist_only_cross_host() {
let a = TargetSelection::from_user("A");
let b = TargetSelection::from_user("B"); let b = TargetSelection::from_user("B");
let mut config = configure(&["A", "B"], &["A", "B"]); let mut config = configure(&["A", "B"], &["A", "B"]);
config.docs = false; config.docs = false;
@@ -360,10 +376,7 @@ mod dist {
); );
assert_eq!( assert_eq!(
first(cache.all::<compile::Rustc>()), first(cache.all::<compile::Rustc>()),
&[ &[rustc!(A => A, stage = 0), rustc!(A => B, stage = 1),]
compile::Rustc { compiler: Compiler { host: a, stage: 0 }, target: a },
compile::Rustc { compiler: Compiler { host: a, stage: 1 }, target: b },
]
); );
} }
@@ -450,11 +463,11 @@ mod dist {
assert_eq!( assert_eq!(
first(cache.all::<compile::Std>()), first(cache.all::<compile::Std>()),
&[ &[
compile::Std { compiler: Compiler { host: a, stage: 0 }, target: a }, std!(A => A, stage = 0),
compile::Std { compiler: Compiler { host: a, stage: 1 }, target: a }, std!(A => A, stage = 1),
compile::Std { compiler: Compiler { host: a, stage: 2 }, target: a }, std!(A => A, stage = 2),
compile::Std { compiler: Compiler { host: a, stage: 1 }, target: b }, std!(A => B, stage = 1),
compile::Std { compiler: Compiler { host: a, stage: 2 }, target: b }, std!(A => B, stage = 2),
] ]
); );
assert_eq!( assert_eq!(
@@ -474,33 +487,29 @@ mod dist {
let mut builder = Builder::new(&build); let mut builder = Builder::new(&build);
builder.run_step_descriptions( builder.run_step_descriptions(
&Builder::get_step_descriptions(Kind::Build), &Builder::get_step_descriptions(Kind::Build),
&["compiler/rustc".into(), "library/std".into()], &["compiler/rustc".into(), "library".into()],
); );
let a = TargetSelection::from_user("A");
let b = TargetSelection::from_user("B");
let c = TargetSelection::from_user("C");
assert_eq!( assert_eq!(
first(builder.cache.all::<compile::Std>()), first(builder.cache.all::<compile::Std>()),
&[ &[
compile::Std { compiler: Compiler { host: a, stage: 0 }, target: a }, std!(A => A, stage = 0),
compile::Std { compiler: Compiler { host: a, stage: 1 }, target: a }, std!(A => A, stage = 1),
compile::Std { compiler: Compiler { host: a, stage: 2 }, target: a }, std!(A => A, stage = 2),
compile::Std { compiler: Compiler { host: a, stage: 1 }, target: b }, std!(A => B, stage = 1),
compile::Std { compiler: Compiler { host: a, stage: 2 }, target: b }, std!(A => B, stage = 2),
compile::Std { compiler: Compiler { host: a, stage: 2 }, target: c }, std!(A => C, stage = 2),
] ]
); );
assert!(!builder.cache.all::<compile::Assemble>().is_empty()); assert_eq!(builder.cache.all::<compile::Assemble>().len(), 5);
assert_eq!( assert_eq!(
first(builder.cache.all::<compile::Rustc>()), first(builder.cache.all::<compile::Rustc>()),
&[ &[
compile::Rustc { compiler: Compiler { host: a, stage: 0 }, target: a }, rustc!(A => A, stage = 0),
compile::Rustc { compiler: Compiler { host: a, stage: 1 }, target: a }, rustc!(A => A, stage = 1),
compile::Rustc { compiler: Compiler { host: a, stage: 2 }, target: a }, rustc!(A => A, stage = 2),
compile::Rustc { compiler: Compiler { host: a, stage: 1 }, target: b }, rustc!(A => B, stage = 1),
compile::Rustc { compiler: Compiler { host: a, stage: 2 }, target: b }, rustc!(A => B, stage = 2),
] ]
); );
} }
@@ -513,15 +522,10 @@ mod dist {
builder.run_step_descriptions(&Builder::get_step_descriptions(Kind::Build), &[]); builder.run_step_descriptions(&Builder::get_step_descriptions(Kind::Build), &[]);
let a = TargetSelection::from_user("A"); let a = TargetSelection::from_user("A");
let c = TargetSelection::from_user("C");
assert_eq!( assert_eq!(
first(builder.cache.all::<compile::Std>()), first(builder.cache.all::<compile::Std>()),
&[ &[std!(A => A, stage = 0), std!(A => A, stage = 1), std!(A => C, stage = 2),]
compile::Std { compiler: Compiler { host: a, stage: 0 }, target: a },
compile::Std { compiler: Compiler { host: a, stage: 1 }, target: a },
compile::Std { compiler: Compiler { host: a, stage: 2 }, target: c },
]
); );
assert_eq!( assert_eq!(
first(builder.cache.all::<compile::Assemble>()), first(builder.cache.all::<compile::Assemble>()),
@@ -533,10 +537,7 @@ mod dist {
); );
assert_eq!( assert_eq!(
first(builder.cache.all::<compile::Rustc>()), first(builder.cache.all::<compile::Rustc>()),
&[ &[rustc!(A => A, stage = 0), rustc!(A => A, stage = 1),]
compile::Rustc { compiler: Compiler { host: a, stage: 0 }, target: a },
compile::Rustc { compiler: Compiler { host: a, stage: 1 }, target: a },
]
); );
} }

View File

@@ -162,6 +162,7 @@ impl<T: Hash + Clone + Eq> TyIntern<T> {
pub struct Interner { pub struct Interner {
strs: Mutex<TyIntern<String>>, strs: Mutex<TyIntern<String>>,
paths: Mutex<TyIntern<PathBuf>>, paths: Mutex<TyIntern<PathBuf>>,
lists: Mutex<TyIntern<Vec<String>>>,
} }
trait Internable: Clone + Eq + Hash + 'static { trait Internable: Clone + Eq + Hash + 'static {
@@ -184,6 +185,12 @@ impl Internable for PathBuf {
} }
} }
impl Internable for Vec<String> {
fn intern_cache() -> &'static Mutex<TyIntern<Self>> {
&INTERNER.lists
}
}
impl Interner { impl Interner {
pub fn intern_str(&self, s: &str) -> Interned<String> { pub fn intern_str(&self, s: &str) -> Interned<String> {
self.strs.lock().unwrap().intern_borrow(s) self.strs.lock().unwrap().intern_borrow(s)
@@ -195,6 +202,10 @@ impl Interner {
pub fn intern_path(&self, s: PathBuf) -> Interned<PathBuf> { pub fn intern_path(&self, s: PathBuf) -> Interned<PathBuf> {
self.paths.lock().unwrap().intern(s) self.paths.lock().unwrap().intern(s)
} }
pub fn intern_list(&self, v: Vec<String>) -> Interned<Vec<String>> {
self.lists.lock().unwrap().intern(v)
}
} }
pub static INTERNER: Lazy<Interner> = Lazy::new(Interner::default); pub static INTERNER: Lazy<Interner> = Lazy::new(Interner::default);

View File

@@ -184,8 +184,8 @@ impl Step for Rustc {
// the sysroot for the compiler to find. Otherwise, we're going to // the sysroot for the compiler to find. Otherwise, we're going to
// fail when building crates that need to generate code (e.g., build // fail when building crates that need to generate code (e.g., build
// scripts and their dependencies). // scripts and their dependencies).
builder.ensure(crate::compile::Std { target: compiler.host, compiler }); builder.ensure(crate::compile::Std::new(compiler, compiler.host));
builder.ensure(crate::compile::Std { target, compiler }); builder.ensure(crate::compile::Std::new(compiler, target));
} else { } else {
builder.ensure(Std { target }); builder.ensure(Std { target });
} }

View File

@@ -29,10 +29,31 @@ use crate::util::{exe, is_debug_info, is_dylib, output, symlink_dir, t, up_to_da
use crate::LLVM_TOOLS; use crate::LLVM_TOOLS;
use crate::{CLang, Compiler, DependencyType, GitRepo, Mode}; use crate::{CLang, Compiler, DependencyType, GitRepo, Mode};
#[derive(Debug, PartialOrd, Ord, Copy, Clone, PartialEq, Eq, Hash)] #[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct Std { pub struct Std {
pub target: TargetSelection, pub target: TargetSelection,
pub compiler: Compiler, pub compiler: Compiler,
/// Whether to build only a subset of crates in the standard library.
///
/// This shouldn't be used from other steps; see the comment on [`Rustc`].
crates: Interned<Vec<String>>,
}
impl Std {
pub fn new(compiler: Compiler, target: TargetSelection) -> Self {
Self { target, compiler, crates: Default::default() }
}
}
/// Return a `-p=x -p=y` string suitable for passing to a cargo invocation.
fn build_crates_in_set(run: &RunConfig<'_>) -> Interned<Vec<String>> {
let mut crates = Vec::new();
for krate in &run.paths {
let path = krate.assert_single_path();
let crate_name = run.builder.crate_paths[&path.path];
crates.push(format!("-p={crate_name}"));
}
INTERNER.intern_list(crates)
} }
impl Step for Std { impl Step for Std {
@@ -43,15 +64,22 @@ impl Step for Std {
// When downloading stage1, the standard library has already been copied to the sysroot, so // When downloading stage1, the standard library has already been copied to the sysroot, so
// there's no need to rebuild it. // there's no need to rebuild it.
let builder = run.builder; let builder = run.builder;
run.all_krates("test") run.crate_or_deps("test")
.path("library") .path("library")
.lazy_default_condition(Box::new(|| !builder.download_rustc())) .lazy_default_condition(Box::new(|| !builder.download_rustc()))
} }
fn make_run(run: RunConfig<'_>) { fn make_run(run: RunConfig<'_>) {
// Normally, people will pass *just* library if they pass it.
// But it's possible (although strange) to pass something like `library std core`.
// Build all crates anyway, as if they hadn't passed the other args.
let has_library =
run.paths.iter().any(|set| set.assert_single_path().path.ends_with("library"));
let crates = if has_library { Default::default() } else { build_crates_in_set(&run) };
run.builder.ensure(Std { run.builder.ensure(Std {
compiler: run.builder.compiler(run.builder.top_stage, run.build_triple()), compiler: run.builder.compiler(run.builder.top_stage, run.build_triple()),
target: run.target, target: run.target,
crates,
}); });
} }
@@ -86,7 +114,7 @@ impl Step for Std {
let compiler_to_use = builder.compiler_for(compiler.stage, compiler.host, target); let compiler_to_use = builder.compiler_for(compiler.stage, compiler.host, target);
if compiler_to_use != compiler { if compiler_to_use != compiler {
builder.ensure(Std { compiler: compiler_to_use, target }); builder.ensure(Std::new(compiler_to_use, target));
builder.info(&format!("Uplifting stage1 std ({} -> {})", compiler_to_use.host, target)); builder.info(&format!("Uplifting stage1 std ({} -> {})", compiler_to_use.host, target));
// Even if we're not building std this stage, the new sysroot must // Even if we're not building std this stage, the new sysroot must
@@ -115,7 +143,7 @@ impl Step for Std {
run_cargo( run_cargo(
builder, builder,
cargo, cargo,
vec![], self.crates.to_vec(),
&libstd_stamp(builder, compiler, target), &libstd_stamp(builder, compiler, target),
target_deps, target_deps,
false, false,
@@ -524,6 +552,18 @@ impl Step for StartupObjects {
pub struct Rustc { pub struct Rustc {
pub target: TargetSelection, pub target: TargetSelection,
pub compiler: Compiler, pub compiler: Compiler,
/// Whether to build a subset of crates, rather than the whole compiler.
///
/// This should only be requested by the user, not used within rustbuild itself.
/// Using it within rustbuild can lead to confusing situation where lints are replayed
/// in two different steps.
crates: Interned<Vec<String>>,
}
impl Rustc {
pub fn new(compiler: Compiler, target: TargetSelection) -> Self {
Self { target, compiler, crates: Default::default() }
}
} }
impl Step for Rustc { impl Step for Rustc {
@@ -532,13 +572,22 @@ impl Step for Rustc {
const DEFAULT: bool = false; const DEFAULT: bool = false;
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
run.never() let mut crates = run.builder.in_tree_crates("rustc-main", None);
for (i, krate) in crates.iter().enumerate() {
if krate.name == "rustc-main" {
crates.swap_remove(i);
break;
}
}
run.crates(crates)
} }
fn make_run(run: RunConfig<'_>) { fn make_run(run: RunConfig<'_>) {
let crates = build_crates_in_set(&run);
run.builder.ensure(Rustc { run.builder.ensure(Rustc {
compiler: run.builder.compiler(run.builder.top_stage, run.build_triple()), compiler: run.builder.compiler(run.builder.top_stage, run.build_triple()),
target: run.target, target: run.target,
crates,
}); });
} }
@@ -560,7 +609,7 @@ impl Step for Rustc {
return; return;
} }
builder.ensure(Std { compiler, target }); builder.ensure(Std::new(compiler, target));
if builder.config.keep_stage.contains(&compiler.stage) { if builder.config.keep_stage.contains(&compiler.stage) {
builder.info("Warning: Using a potentially old librustc. This may not behave well."); builder.info("Warning: Using a potentially old librustc. This may not behave well.");
@@ -571,7 +620,7 @@ impl Step for Rustc {
let compiler_to_use = builder.compiler_for(compiler.stage, compiler.host, target); let compiler_to_use = builder.compiler_for(compiler.stage, compiler.host, target);
if compiler_to_use != compiler { if compiler_to_use != compiler {
builder.ensure(Rustc { compiler: compiler_to_use, target }); builder.ensure(Rustc::new(compiler_to_use, target));
builder builder
.info(&format!("Uplifting stage1 rustc ({} -> {})", builder.config.build, target)); .info(&format!("Uplifting stage1 rustc ({} -> {})", builder.config.build, target));
builder.ensure(RustcLink { builder.ensure(RustcLink {
@@ -583,10 +632,10 @@ impl Step for Rustc {
} }
// Ensure that build scripts and proc macros have a std / libproc_macro to link against. // Ensure that build scripts and proc macros have a std / libproc_macro to link against.
builder.ensure(Std { builder.ensure(Std::new(
compiler: builder.compiler(self.compiler.stage, builder.config.build), builder.compiler(self.compiler.stage, builder.config.build),
target: builder.config.build, builder.config.build,
}); ));
let mut cargo = builder.cargo(compiler, Mode::Rustc, SourceType::InTree, target, "build"); let mut cargo = builder.cargo(compiler, Mode::Rustc, SourceType::InTree, target, "build");
rustc_cargo(builder, &mut cargo, target); rustc_cargo(builder, &mut cargo, target);
@@ -633,7 +682,7 @@ impl Step for Rustc {
run_cargo( run_cargo(
builder, builder,
cargo, cargo,
vec![], self.crates.to_vec(),
&librustc_stamp(builder, compiler, target), &librustc_stamp(builder, compiler, target),
vec![], vec![],
false, false,
@@ -821,7 +870,7 @@ impl Step for CodegenBackend {
let target = self.target; let target = self.target;
let backend = self.backend; let backend = self.backend;
builder.ensure(Rustc { compiler, target }); builder.ensure(Rustc::new(compiler, target));
if builder.config.keep_stage.contains(&compiler.stage) { if builder.config.keep_stage.contains(&compiler.stage) {
builder.info( builder.info(
@@ -1103,7 +1152,7 @@ impl Step for Assemble {
// link to these. (FIXME: Is that correct? It seems to be correct most // link to these. (FIXME: Is that correct? It seems to be correct most
// of the time but I think we do link to these for stage2/bin compilers // of the time but I think we do link to these for stage2/bin compilers
// when not performing a full bootstrap). // when not performing a full bootstrap).
builder.ensure(Rustc { compiler: build_compiler, target: target_compiler.host }); builder.ensure(Rustc::new(build_compiler, target_compiler.host));
for &backend in builder.config.rust_codegen_backends.iter() { for &backend in builder.config.rust_codegen_backends.iter() {
if backend == "llvm" { if backend == "llvm" {

View File

@@ -557,7 +557,7 @@ impl Step for Std {
return None; return None;
} }
builder.ensure(compile::Std { compiler, target }); builder.ensure(compile::Std::new(compiler, target));
let mut tarball = Tarball::new(builder, "rust-std", &target.triple); let mut tarball = Tarball::new(builder, "rust-std", &target.triple);
tarball.include_target_in_component_name(true); tarball.include_target_in_component_name(true);
@@ -603,7 +603,7 @@ impl Step for RustcDev {
return None; return None;
} }
builder.ensure(compile::Rustc { compiler, target }); builder.ensure(compile::Rustc::new(compiler, target));
let tarball = Tarball::new(builder, "rustc-dev", &target.triple); let tarball = Tarball::new(builder, "rustc-dev", &target.triple);
@@ -666,7 +666,7 @@ impl Step for Analysis {
return None; return None;
} }
builder.ensure(compile::Std { compiler, target }); builder.ensure(compile::Std::new(compiler, target));
let src = builder let src = builder
.stage_out(compiler, Mode::Std) .stage_out(compiler, Mode::Std)
.join(target.triple) .join(target.triple)

View File

@@ -534,7 +534,9 @@ impl Step for Rustc {
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
let builder = run.builder; let builder = run.builder;
run.krate("rustc-main").path("compiler").default_condition(builder.config.compiler_docs) run.crate_or_deps("rustc-main")
.path("compiler")
.default_condition(builder.config.compiler_docs)
} }
fn make_run(run: RunConfig<'_>) { fn make_run(run: RunConfig<'_>) {
@@ -567,7 +569,7 @@ impl Step for Rustc {
// Build the standard library, so that proc-macros can use it. // Build the standard library, so that proc-macros can use it.
// (Normally, only the metadata would be necessary, but proc-macros are special since they run at compile-time.) // (Normally, only the metadata would be necessary, but proc-macros are special since they run at compile-time.)
let compiler = builder.compiler(stage, builder.config.build); let compiler = builder.compiler(stage, builder.config.build);
builder.ensure(compile::Std { compiler, target: builder.config.build }); builder.ensure(compile::Std::new(compiler, builder.config.build));
builder.info(&format!("Documenting stage{} compiler ({})", stage, target)); builder.info(&format!("Documenting stage{} compiler ({})", stage, target));
@@ -656,7 +658,7 @@ macro_rules! tool_doc {
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
let builder = run.builder; let builder = run.builder;
run.krate($should_run).default_condition(builder.config.compiler_docs) run.crate_or_deps($should_run).default_condition(builder.config.compiler_docs)
} }
fn make_run(run: RunConfig<'_>) { fn make_run(run: RunConfig<'_>) {
@@ -683,7 +685,7 @@ macro_rules! tool_doc {
// FIXME: is there a way to only ensure `check::Rustc` here? Last time I tried it failed // FIXME: is there a way to only ensure `check::Rustc` here? Last time I tried it failed
// with strange errors, but only on a full bors test ... // with strange errors, but only on a full bors test ...
let compiler = builder.compiler(stage, builder.config.build); let compiler = builder.compiler(stage, builder.config.build);
builder.ensure(compile::Rustc { compiler, target }); builder.ensure(compile::Rustc::new(compiler, target));
builder.info( builder.info(
&format!( &format!(
@@ -866,7 +868,7 @@ impl Step for RustcBook {
let rustc = builder.rustc(self.compiler); let rustc = builder.rustc(self.compiler);
// The tool runs `rustc` for extracting output examples, so it needs a // The tool runs `rustc` for extracting output examples, so it needs a
// functional sysroot. // functional sysroot.
builder.ensure(compile::Std { compiler: self.compiler, target: self.target }); builder.ensure(compile::Std::new(self.compiler, self.target));
let mut cmd = builder.tool_cmd(Tool::LintDocs); let mut cmd = builder.tool_cmd(Tool::LintDocs);
cmd.arg("--src"); cmd.arg("--src");
cmd.arg(builder.src.join("compiler")); cmd.arg(builder.src.join("compiler"));

View File

@@ -225,7 +225,7 @@ impl Step for Cargotest {
/// test` to ensure that we don't regress the test suites there. /// test` to ensure that we don't regress the test suites there.
fn run(self, builder: &Builder<'_>) { fn run(self, builder: &Builder<'_>) {
let compiler = builder.compiler(self.stage, self.host); let compiler = builder.compiler(self.stage, self.host);
builder.ensure(compile::Rustc { compiler, target: compiler.host }); builder.ensure(compile::Rustc::new(compiler, compiler.host));
let cargo = builder.ensure(tool::Cargo { compiler, target: compiler.host }); let cargo = builder.ensure(tool::Cargo { compiler, target: compiler.host });
// Note that this is a short, cryptic, and not scoped directory name. This // Note that this is a short, cryptic, and not scoped directory name. This
@@ -603,7 +603,7 @@ impl Step for CompiletestTest {
// We need `ToolStd` for the locally-built sysroot because // We need `ToolStd` for the locally-built sysroot because
// compiletest uses unstable features of the `test` crate. // compiletest uses unstable features of the `test` crate.
builder.ensure(compile::Std { compiler, target: host }); builder.ensure(compile::Std::new(compiler, host));
let cargo = tool::prepare_tool_cargo( let cargo = tool::prepare_tool_cargo(
builder, builder,
compiler, compiler,
@@ -896,7 +896,7 @@ impl Step for RustdocGUI {
let nodejs = builder.config.nodejs.as_ref().expect("nodejs isn't available"); let nodejs = builder.config.nodejs.as_ref().expect("nodejs isn't available");
let npm = builder.config.npm.as_ref().expect("npm isn't available"); let npm = builder.config.npm.as_ref().expect("npm isn't available");
builder.ensure(compile::Std { compiler: self.compiler, target: self.target }); builder.ensure(compile::Std::new(self.compiler, self.target));
// The goal here is to check if the necessary packages are installed, and if not, we // The goal here is to check if the necessary packages are installed, and if not, we
// panic. // panic.
@@ -1273,12 +1273,12 @@ note: if you're sure you want to do this, please open an issue as to why. In the
} }
if suite.ends_with("fulldeps") { if suite.ends_with("fulldeps") {
builder.ensure(compile::Rustc { compiler, target }); builder.ensure(compile::Rustc::new(compiler, target));
} }
builder.ensure(compile::Std { compiler, target }); builder.ensure(compile::Std::new(compiler, target));
// ensure that `libproc_macro` is available on the host. // ensure that `libproc_macro` is available on the host.
builder.ensure(compile::Std { compiler, target: compiler.host }); builder.ensure(compile::Std::new(compiler, compiler.host));
// Also provide `rust_test_helpers` for the host. // Also provide `rust_test_helpers` for the host.
builder.ensure(native::TestHelpers { target: compiler.host }); builder.ensure(native::TestHelpers { target: compiler.host });
@@ -1646,7 +1646,7 @@ impl BookTest {
fn run_ext_doc(self, builder: &Builder<'_>) { fn run_ext_doc(self, builder: &Builder<'_>) {
let compiler = self.compiler; let compiler = self.compiler;
builder.ensure(compile::Std { compiler, target: compiler.host }); builder.ensure(compile::Std::new(compiler, compiler.host));
// mdbook just executes a binary named "rustdoc", so we need to update // mdbook just executes a binary named "rustdoc", so we need to update
// PATH so that it points to our rustdoc. // PATH so that it points to our rustdoc.
@@ -1674,7 +1674,7 @@ impl BookTest {
fn run_local_doc(self, builder: &Builder<'_>) { fn run_local_doc(self, builder: &Builder<'_>) {
let compiler = self.compiler; let compiler = self.compiler;
builder.ensure(compile::Std { compiler, target: compiler.host }); builder.ensure(compile::Std::new(compiler, compiler.host));
// Do a breadth-first traversal of the `src/doc` directory and just run // Do a breadth-first traversal of the `src/doc` directory and just run
// tests for all files that end in `*.md` // tests for all files that end in `*.md`
@@ -1793,7 +1793,7 @@ impl Step for ErrorIndex {
builder.run_quiet(&mut tool); builder.run_quiet(&mut tool);
// The tests themselves need to link to std, so make sure it is // The tests themselves need to link to std, so make sure it is
// available. // available.
builder.ensure(compile::Std { compiler, target: compiler.host }); builder.ensure(compile::Std::new(compiler, compiler.host));
markdown_test(builder, compiler, &output); markdown_test(builder, compiler, &output);
} }
} }
@@ -1870,7 +1870,7 @@ impl Step for CrateLibrustc {
const ONLY_HOSTS: bool = true; const ONLY_HOSTS: bool = true;
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
run.krate("rustc-main") run.crate_or_deps("rustc-main")
} }
fn make_run(run: RunConfig<'_>) { fn make_run(run: RunConfig<'_>) {
@@ -1912,7 +1912,7 @@ impl Step for Crate {
const DEFAULT: bool = true; const DEFAULT: bool = true;
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
run.krate("test") run.crate_or_deps("test")
} }
fn make_run(run: RunConfig<'_>) { fn make_run(run: RunConfig<'_>) {
@@ -1943,7 +1943,7 @@ impl Step for Crate {
let mode = self.mode; let mode = self.mode;
let test_kind = self.test_kind; let test_kind = self.test_kind;
builder.ensure(compile::Std { compiler, target }); builder.ensure(compile::Std::new(compiler, target));
builder.ensure(RemoteCopyLibs { compiler, target }); builder.ensure(RemoteCopyLibs { compiler, target });
// If we're not doing a full bootstrap but we're testing a stage2 // If we're not doing a full bootstrap but we're testing a stage2
@@ -2065,7 +2065,7 @@ impl Step for CrateRustdoc {
// isn't really necessary. // isn't really necessary.
builder.compiler_for(builder.top_stage, target, target) builder.compiler_for(builder.top_stage, target, target)
}; };
builder.ensure(compile::Rustc { compiler, target }); builder.ensure(compile::Rustc::new(compiler, target));
let mut cargo = tool::prepare_tool_cargo( let mut cargo = tool::prepare_tool_cargo(
builder, builder,
@@ -2180,7 +2180,7 @@ impl Step for CrateRustdocJsonTypes {
// `compiler`, then it would cause rustdoc to be built *again*, which // `compiler`, then it would cause rustdoc to be built *again*, which
// isn't really necessary. // isn't really necessary.
let compiler = builder.compiler_for(builder.top_stage, target, target); let compiler = builder.compiler_for(builder.top_stage, target, target);
builder.ensure(compile::Rustc { compiler, target }); builder.ensure(compile::Rustc::new(compiler, target));
let mut cargo = tool::prepare_tool_cargo( let mut cargo = tool::prepare_tool_cargo(
builder, builder,
@@ -2248,7 +2248,7 @@ impl Step for RemoteCopyLibs {
return; return;
} }
builder.ensure(compile::Std { compiler, target }); builder.ensure(compile::Std::new(compiler, target));
builder.info(&format!("REMOTE copy libs to emulator ({})", target)); builder.info(&format!("REMOTE copy libs to emulator ({})", target));
@@ -2418,7 +2418,7 @@ impl Step for TierCheck {
/// Tests the Platform Support page in the rustc book. /// Tests the Platform Support page in the rustc book.
fn run(self, builder: &Builder<'_>) { fn run(self, builder: &Builder<'_>) {
builder.ensure(compile::Std { compiler: self.compiler, target: self.compiler.host }); builder.ensure(compile::Std::new(self.compiler, self.compiler.host));
let mut cargo = tool::prepare_tool_cargo( let mut cargo = tool::prepare_tool_cargo(
builder, builder,
self.compiler, self.compiler,

View File

@@ -51,10 +51,10 @@ impl Step for ToolBuild {
match self.mode { match self.mode {
Mode::ToolRustc => { Mode::ToolRustc => {
builder.ensure(compile::Std { compiler, target: compiler.host }); builder.ensure(compile::Std::new(compiler, compiler.host));
builder.ensure(compile::Rustc { compiler, target }); builder.ensure(compile::Rustc::new(compiler, target));
} }
Mode::ToolStd => builder.ensure(compile::Std { compiler, target }), Mode::ToolStd => builder.ensure(compile::Std::new(compiler, target)),
Mode::ToolBootstrap => {} // uses downloaded stage0 compiler libs Mode::ToolBootstrap => {} // uses downloaded stage0 compiler libs
_ => panic!("unexpected Mode for tool build"), _ => panic!("unexpected Mode for tool build"),
} }
@@ -512,8 +512,8 @@ impl Step for Rustdoc {
// When using `download-rustc` and a stage0 build_compiler, copying rustc doesn't actually // When using `download-rustc` and a stage0 build_compiler, copying rustc doesn't actually
// build stage0 libstd (because the libstd in sysroot has the wrong ABI). Explicitly build // build stage0 libstd (because the libstd in sysroot has the wrong ABI). Explicitly build
// it. // it.
builder.ensure(compile::Std { compiler: build_compiler, target: target_compiler.host }); builder.ensure(compile::Std::new(build_compiler, target_compiler.host));
builder.ensure(compile::Rustc { compiler: build_compiler, target: target_compiler.host }); builder.ensure(compile::Rustc::new(build_compiler, target_compiler.host));
// NOTE: this implies that `download-rustc` is pretty useless when compiling with the stage0 // NOTE: this implies that `download-rustc` is pretty useless when compiling with the stage0
// compiler, since you do just as much work. // compiler, since you do just as much work.
if !builder.config.dry_run && builder.download_rustc() && build_compiler.stage == 0 { if !builder.config.dry_run && builder.download_rustc() && build_compiler.stage == 0 {