Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove uses of Build across Builder steps #49972

Merged
merged 1 commit into from
Apr 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 20 additions & 21 deletions src/bootstrap/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,18 +154,17 @@ impl StepDescription {
eprintln!("{:?} not skipped for {:?} -- not in {:?}", pathset,
self.name, builder.config.exclude);
}
let build = builder.build;
let hosts = &build.hosts;
let hosts = &builder.hosts;

// Determine the targets participating in this rule.
let targets = if self.only_hosts {
if !build.config.run_host_only {
if !builder.config.run_host_only {
return; // don't run anything
} else {
&build.hosts
&builder.hosts
}
} else {
&build.targets
&builder.targets
};

for host in hosts {
Expand Down Expand Up @@ -476,7 +475,7 @@ impl<'a> Builder<'a> {

pub fn sysroot_codegen_backends(&self, compiler: Compiler) -> PathBuf {
self.sysroot_libdir(compiler, compiler.host)
.with_file_name(self.build.config.rust_codegen_backends_dir.clone())
.with_file_name(self.config.rust_codegen_backends_dir.clone())
}

/// Returns the compiler's libdir where it stores the dynamic libraries that
Expand All @@ -486,7 +485,7 @@ impl<'a> Builder<'a> {
/// Windows.
pub fn rustc_libdir(&self, compiler: Compiler) -> PathBuf {
if compiler.is_snapshot(self) {
self.build.rustc_snapshot_libdir()
self.rustc_snapshot_libdir()
} else {
self.sysroot(compiler).join(libdir(&compiler.host))
}
Expand Down Expand Up @@ -523,12 +522,12 @@ impl<'a> Builder<'a> {
let compiler = self.compiler(self.top_stage, host);
cmd.env("RUSTC_STAGE", compiler.stage.to_string())
.env("RUSTC_SYSROOT", self.sysroot(compiler))
.env("RUSTDOC_LIBDIR", self.sysroot_libdir(compiler, self.build.build))
.env("CFG_RELEASE_CHANNEL", &self.build.config.channel)
.env("RUSTDOC_LIBDIR", self.sysroot_libdir(compiler, self.config.build))
.env("CFG_RELEASE_CHANNEL", &self.config.channel)
.env("RUSTDOC_REAL", self.rustdoc(host))
.env("RUSTDOC_CRATE_VERSION", self.build.rust_version())
.env("RUSTDOC_CRATE_VERSION", self.rust_version())
.env("RUSTC_BOOTSTRAP", "1");
if let Some(linker) = self.build.linker(host) {
if let Some(linker) = self.linker(host) {
cmd.env("RUSTC_TARGET_LINKER", linker);
}
cmd
Expand Down Expand Up @@ -609,17 +608,17 @@ impl<'a> Builder<'a> {
.env("TEST_MIRI", self.config.test_miri.to_string())
.env("RUSTC_ERROR_METADATA_DST", self.extended_error_dir());

if let Some(host_linker) = self.build.linker(compiler.host) {
if let Some(host_linker) = self.linker(compiler.host) {
cargo.env("RUSTC_HOST_LINKER", host_linker);
}
if let Some(target_linker) = self.build.linker(target) {
if let Some(target_linker) = self.linker(target) {
cargo.env("RUSTC_TARGET_LINKER", target_linker);
}
if let Some(ref error_format) = self.config.rustc_error_format {
cargo.env("RUSTC_ERROR_FORMAT", error_format);
}
if cmd != "build" && cmd != "check" {
cargo.env("RUSTDOC_LIBDIR", self.rustc_libdir(self.compiler(2, self.build.build)));
cargo.env("RUSTDOC_LIBDIR", self.rustc_libdir(self.compiler(2, self.config.build)));
}

if mode == Mode::Tool {
Expand Down Expand Up @@ -677,7 +676,7 @@ impl<'a> Builder<'a> {
//
// If LLVM support is disabled we need to use the snapshot compiler to compile
// build scripts, as the new compiler doesn't support executables.
if mode == Mode::Libstd || !self.build.config.llvm_enabled {
if mode == Mode::Libstd || !self.config.llvm_enabled {
cargo.env("RUSTC_SNAPSHOT", &self.initial_rustc)
.env("RUSTC_SNAPSHOT_LIBDIR", self.rustc_snapshot_libdir());
} else {
Expand Down Expand Up @@ -761,15 +760,15 @@ impl<'a> Builder<'a> {
}

// For `cargo doc` invocations, make rustdoc print the Rust version into the docs
cargo.env("RUSTDOC_CRATE_VERSION", self.build.rust_version());
cargo.env("RUSTDOC_CRATE_VERSION", self.rust_version());

// Environment variables *required* throughout the build
//
// FIXME: should update code to not require this env var
cargo.env("CFG_COMPILER_HOST_TRIPLE", target);

// Set this for all builds to make sure doc builds also get it.
cargo.env("CFG_RELEASE_CHANNEL", &self.build.config.channel);
cargo.env("CFG_RELEASE_CHANNEL", &self.config.channel);

// This one's a bit tricky. As of the time of this writing the compiler
// links to the `winapi` crate on crates.io. This crate provides raw
Expand Down Expand Up @@ -854,7 +853,7 @@ impl<'a> Builder<'a> {
panic!(out);
}
if let Some(out) = self.cache.get(&step) {
self.build.verbose(&format!("{}c {:?}", " ".repeat(stack.len()), step));
self.verbose(&format!("{}c {:?}", " ".repeat(stack.len()), step));

{
let mut graph = self.graph.borrow_mut();
Expand All @@ -869,7 +868,7 @@ impl<'a> Builder<'a> {

return out;
}
self.build.verbose(&format!("{}> {:?}", " ".repeat(stack.len()), step));
self.verbose(&format!("{}> {:?}", " ".repeat(stack.len()), step));
stack.push(Box::new(step.clone()));
}

Expand Down Expand Up @@ -899,7 +898,7 @@ impl<'a> Builder<'a> {

self.parent.set(prev_parent);

if self.build.config.print_step_timings && dur > Duration::from_millis(100) {
if self.config.print_step_timings && dur > Duration::from_millis(100) {
println!("[TIMING] {:?} -- {}.{:03}",
step,
dur.as_secs(),
Expand All @@ -911,7 +910,7 @@ impl<'a> Builder<'a> {
let cur_step = stack.pop().expect("step stack empty");
assert_eq!(cur_step.downcast_ref(), Some(&step));
}
self.build.verbose(&format!("{}< {:?}", " ".repeat(self.stack.borrow().len()), step));
self.verbose(&format!("{}< {:?}", " ".repeat(self.stack.borrow().len()), step));
self.cache.put(step, out.clone());
out
}
Expand Down
63 changes: 30 additions & 33 deletions src/bootstrap/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

use compile::{run_cargo, std_cargo, test_cargo, rustc_cargo, add_to_sysroot};
use builder::{RunConfig, Builder, ShouldRun, Step};
use {Build, Compiler, Mode};
use {Compiler, Mode};
use cache::Interned;
use std::path::PathBuf;

Expand All @@ -36,24 +36,23 @@ impl Step for Std {
}

fn run(self, builder: &Builder) {
let build = builder.build;
let target = self.target;
let compiler = builder.compiler(0, build.build);
let compiler = builder.compiler(0, builder.config.build);

let out_dir = build.stage_out(compiler, Mode::Libstd);
build.clear_if_dirty(&out_dir, &builder.rustc(compiler));
let out_dir = builder.stage_out(compiler, Mode::Libstd);
builder.clear_if_dirty(&out_dir, &builder.rustc(compiler));
let mut cargo = builder.cargo(compiler, Mode::Libstd, target, "check");
std_cargo(builder, &compiler, target, &mut cargo);

let _folder = build.fold_output(|| format!("stage{}-std", compiler.stage));
let _folder = builder.fold_output(|| format!("stage{}-std", compiler.stage));
println!("Checking std artifacts ({} -> {})", &compiler.host, target);
run_cargo(build,
run_cargo(builder,
&mut cargo,
&libstd_stamp(build, compiler, target),
&libstd_stamp(builder, compiler, target),
true);

let libdir = builder.sysroot_libdir(compiler, target);
add_to_sysroot(&build, &libdir, &libstd_stamp(build, compiler, target));
add_to_sysroot(&builder, &libdir, &libstd_stamp(builder, compiler, target));
}
}

Expand Down Expand Up @@ -83,26 +82,25 @@ impl Step for Rustc {
/// the `compiler` targeting the `target` architecture. The artifacts
/// created will also be linked into the sysroot directory.
fn run(self, builder: &Builder) {
let build = builder.build;
let compiler = builder.compiler(0, build.build);
let compiler = builder.compiler(0, builder.config.build);
let target = self.target;

let stage_out = builder.stage_out(compiler, Mode::Librustc);
build.clear_if_dirty(&stage_out, &libstd_stamp(build, compiler, target));
build.clear_if_dirty(&stage_out, &libtest_stamp(build, compiler, target));
builder.clear_if_dirty(&stage_out, &libstd_stamp(builder, compiler, target));
builder.clear_if_dirty(&stage_out, &libtest_stamp(builder, compiler, target));

let mut cargo = builder.cargo(compiler, Mode::Librustc, target, "check");
rustc_cargo(build, &mut cargo);
rustc_cargo(builder, &mut cargo);

let _folder = build.fold_output(|| format!("stage{}-rustc", compiler.stage));
let _folder = builder.fold_output(|| format!("stage{}-rustc", compiler.stage));
println!("Checking compiler artifacts ({} -> {})", &compiler.host, target);
run_cargo(build,
run_cargo(builder,
&mut cargo,
&librustc_stamp(build, compiler, target),
&librustc_stamp(builder, compiler, target),
true);

let libdir = builder.sysroot_libdir(compiler, target);
add_to_sysroot(&build, &libdir, &librustc_stamp(build, compiler, target));
add_to_sysroot(&builder, &libdir, &librustc_stamp(builder, compiler, target));
}
}

Expand All @@ -126,41 +124,40 @@ impl Step for Test {
}

fn run(self, builder: &Builder) {
let build = builder.build;
let target = self.target;
let compiler = builder.compiler(0, build.build);
let compiler = builder.compiler(0, builder.config.build);

let out_dir = build.stage_out(compiler, Mode::Libtest);
build.clear_if_dirty(&out_dir, &libstd_stamp(build, compiler, target));
let out_dir = builder.stage_out(compiler, Mode::Libtest);
builder.clear_if_dirty(&out_dir, &libstd_stamp(builder, compiler, target));
let mut cargo = builder.cargo(compiler, Mode::Libtest, target, "check");
test_cargo(build, &compiler, target, &mut cargo);
test_cargo(builder, &compiler, target, &mut cargo);

let _folder = build.fold_output(|| format!("stage{}-test", compiler.stage));
let _folder = builder.fold_output(|| format!("stage{}-test", compiler.stage));
println!("Checking test artifacts ({} -> {})", &compiler.host, target);
run_cargo(build,
run_cargo(builder,
&mut cargo,
&libtest_stamp(build, compiler, target),
&libtest_stamp(builder, compiler, target),
true);

let libdir = builder.sysroot_libdir(compiler, target);
add_to_sysroot(&build, &libdir, &libtest_stamp(build, compiler, target));
add_to_sysroot(builder, &libdir, &libtest_stamp(builder, compiler, target));
}
}

/// Cargo's output path for the standard library in a given stage, compiled
/// by a particular compiler for the specified target.
pub fn libstd_stamp(build: &Build, compiler: Compiler, target: Interned<String>) -> PathBuf {
build.cargo_out(compiler, Mode::Libstd, target).join(".libstd-check.stamp")
pub fn libstd_stamp(builder: &Builder, compiler: Compiler, target: Interned<String>) -> PathBuf {
builder.cargo_out(compiler, Mode::Libstd, target).join(".libstd-check.stamp")
}

/// Cargo's output path for libtest in a given stage, compiled by a particular
/// compiler for the specified target.
pub fn libtest_stamp(build: &Build, compiler: Compiler, target: Interned<String>) -> PathBuf {
build.cargo_out(compiler, Mode::Libtest, target).join(".libtest-check.stamp")
pub fn libtest_stamp(builder: &Builder, compiler: Compiler, target: Interned<String>) -> PathBuf {
builder.cargo_out(compiler, Mode::Libtest, target).join(".libtest-check.stamp")
}

/// Cargo's output path for librustc in a given stage, compiled by a particular
/// compiler for the specified target.
pub fn librustc_stamp(build: &Build, compiler: Compiler, target: Interned<String>) -> PathBuf {
build.cargo_out(compiler, Mode::Librustc, target).join(".librustc-check.stamp")
pub fn librustc_stamp(builder: &Builder, compiler: Compiler, target: Interned<String>) -> PathBuf {
builder.cargo_out(compiler, Mode::Librustc, target).join(".librustc-check.stamp")
}
Loading