Skip to content

Commit 23561c6

Browse files
committed
Auto merge of #49972 - Mark-Simulacrum:remove-build, r=alexcrichton
Remove uses of Build across Builder steps This is purely a code cleanup; there should be no functional changes. r? @alexcrichton
2 parents dcb44ca + be1e789 commit 23561c6

File tree

10 files changed

+873
-939
lines changed

10 files changed

+873
-939
lines changed

src/bootstrap/builder.rs

+20-21
Original file line numberDiff line numberDiff line change
@@ -154,18 +154,17 @@ impl StepDescription {
154154
eprintln!("{:?} not skipped for {:?} -- not in {:?}", pathset,
155155
self.name, builder.config.exclude);
156156
}
157-
let build = builder.build;
158-
let hosts = &build.hosts;
157+
let hosts = &builder.hosts;
159158

160159
// Determine the targets participating in this rule.
161160
let targets = if self.only_hosts {
162-
if !build.config.run_host_only {
161+
if !builder.config.run_host_only {
163162
return; // don't run anything
164163
} else {
165-
&build.hosts
164+
&builder.hosts
166165
}
167166
} else {
168-
&build.targets
167+
&builder.targets
169168
};
170169

171170
for host in hosts {
@@ -476,7 +475,7 @@ impl<'a> Builder<'a> {
476475

477476
pub fn sysroot_codegen_backends(&self, compiler: Compiler) -> PathBuf {
478477
self.sysroot_libdir(compiler, compiler.host)
479-
.with_file_name(self.build.config.rust_codegen_backends_dir.clone())
478+
.with_file_name(self.config.rust_codegen_backends_dir.clone())
480479
}
481480

482481
/// Returns the compiler's libdir where it stores the dynamic libraries that
@@ -486,7 +485,7 @@ impl<'a> Builder<'a> {
486485
/// Windows.
487486
pub fn rustc_libdir(&self, compiler: Compiler) -> PathBuf {
488487
if compiler.is_snapshot(self) {
489-
self.build.rustc_snapshot_libdir()
488+
self.rustc_snapshot_libdir()
490489
} else {
491490
self.sysroot(compiler).join(libdir(&compiler.host))
492491
}
@@ -523,12 +522,12 @@ impl<'a> Builder<'a> {
523522
let compiler = self.compiler(self.top_stage, host);
524523
cmd.env("RUSTC_STAGE", compiler.stage.to_string())
525524
.env("RUSTC_SYSROOT", self.sysroot(compiler))
526-
.env("RUSTDOC_LIBDIR", self.sysroot_libdir(compiler, self.build.build))
527-
.env("CFG_RELEASE_CHANNEL", &self.build.config.channel)
525+
.env("RUSTDOC_LIBDIR", self.sysroot_libdir(compiler, self.config.build))
526+
.env("CFG_RELEASE_CHANNEL", &self.config.channel)
528527
.env("RUSTDOC_REAL", self.rustdoc(host))
529-
.env("RUSTDOC_CRATE_VERSION", self.build.rust_version())
528+
.env("RUSTDOC_CRATE_VERSION", self.rust_version())
530529
.env("RUSTC_BOOTSTRAP", "1");
531-
if let Some(linker) = self.build.linker(host) {
530+
if let Some(linker) = self.linker(host) {
532531
cmd.env("RUSTC_TARGET_LINKER", linker);
533532
}
534533
cmd
@@ -609,17 +608,17 @@ impl<'a> Builder<'a> {
609608
.env("TEST_MIRI", self.config.test_miri.to_string())
610609
.env("RUSTC_ERROR_METADATA_DST", self.extended_error_dir());
611610

612-
if let Some(host_linker) = self.build.linker(compiler.host) {
611+
if let Some(host_linker) = self.linker(compiler.host) {
613612
cargo.env("RUSTC_HOST_LINKER", host_linker);
614613
}
615-
if let Some(target_linker) = self.build.linker(target) {
614+
if let Some(target_linker) = self.linker(target) {
616615
cargo.env("RUSTC_TARGET_LINKER", target_linker);
617616
}
618617
if let Some(ref error_format) = self.config.rustc_error_format {
619618
cargo.env("RUSTC_ERROR_FORMAT", error_format);
620619
}
621620
if cmd != "build" && cmd != "check" {
622-
cargo.env("RUSTDOC_LIBDIR", self.rustc_libdir(self.compiler(2, self.build.build)));
621+
cargo.env("RUSTDOC_LIBDIR", self.rustc_libdir(self.compiler(2, self.config.build)));
623622
}
624623

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

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

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

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

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

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

870869
return out;
871870
}
872-
self.build.verbose(&format!("{}> {:?}", " ".repeat(stack.len()), step));
871+
self.verbose(&format!("{}> {:?}", " ".repeat(stack.len()), step));
873872
stack.push(Box::new(step.clone()));
874873
}
875874

@@ -899,7 +898,7 @@ impl<'a> Builder<'a> {
899898

900899
self.parent.set(prev_parent);
901900

902-
if self.build.config.print_step_timings && dur > Duration::from_millis(100) {
901+
if self.config.print_step_timings && dur > Duration::from_millis(100) {
903902
println!("[TIMING] {:?} -- {}.{:03}",
904903
step,
905904
dur.as_secs(),
@@ -911,7 +910,7 @@ impl<'a> Builder<'a> {
911910
let cur_step = stack.pop().expect("step stack empty");
912911
assert_eq!(cur_step.downcast_ref(), Some(&step));
913912
}
914-
self.build.verbose(&format!("{}< {:?}", " ".repeat(self.stack.borrow().len()), step));
913+
self.verbose(&format!("{}< {:?}", " ".repeat(self.stack.borrow().len()), step));
915914
self.cache.put(step, out.clone());
916915
out
917916
}

src/bootstrap/check.rs

+30-33
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
1313
use compile::{run_cargo, std_cargo, test_cargo, rustc_cargo, add_to_sysroot};
1414
use builder::{RunConfig, Builder, ShouldRun, Step};
15-
use {Build, Compiler, Mode};
15+
use {Compiler, Mode};
1616
use cache::Interned;
1717
use std::path::PathBuf;
1818

@@ -36,24 +36,23 @@ impl Step for Std {
3636
}
3737

3838
fn run(self, builder: &Builder) {
39-
let build = builder.build;
4039
let target = self.target;
41-
let compiler = builder.compiler(0, build.build);
40+
let compiler = builder.compiler(0, builder.config.build);
4241

43-
let out_dir = build.stage_out(compiler, Mode::Libstd);
44-
build.clear_if_dirty(&out_dir, &builder.rustc(compiler));
42+
let out_dir = builder.stage_out(compiler, Mode::Libstd);
43+
builder.clear_if_dirty(&out_dir, &builder.rustc(compiler));
4544
let mut cargo = builder.cargo(compiler, Mode::Libstd, target, "check");
4645
std_cargo(builder, &compiler, target, &mut cargo);
4746

48-
let _folder = build.fold_output(|| format!("stage{}-std", compiler.stage));
47+
let _folder = builder.fold_output(|| format!("stage{}-std", compiler.stage));
4948
println!("Checking std artifacts ({} -> {})", &compiler.host, target);
50-
run_cargo(build,
49+
run_cargo(builder,
5150
&mut cargo,
52-
&libstd_stamp(build, compiler, target),
51+
&libstd_stamp(builder, compiler, target),
5352
true);
5453

5554
let libdir = builder.sysroot_libdir(compiler, target);
56-
add_to_sysroot(&build, &libdir, &libstd_stamp(build, compiler, target));
55+
add_to_sysroot(&builder, &libdir, &libstd_stamp(builder, compiler, target));
5756
}
5857
}
5958

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

9088
let stage_out = builder.stage_out(compiler, Mode::Librustc);
91-
build.clear_if_dirty(&stage_out, &libstd_stamp(build, compiler, target));
92-
build.clear_if_dirty(&stage_out, &libtest_stamp(build, compiler, target));
89+
builder.clear_if_dirty(&stage_out, &libstd_stamp(builder, compiler, target));
90+
builder.clear_if_dirty(&stage_out, &libtest_stamp(builder, compiler, target));
9391

9492
let mut cargo = builder.cargo(compiler, Mode::Librustc, target, "check");
95-
rustc_cargo(build, &mut cargo);
93+
rustc_cargo(builder, &mut cargo);
9694

97-
let _folder = build.fold_output(|| format!("stage{}-rustc", compiler.stage));
95+
let _folder = builder.fold_output(|| format!("stage{}-rustc", compiler.stage));
9896
println!("Checking compiler artifacts ({} -> {})", &compiler.host, target);
99-
run_cargo(build,
97+
run_cargo(builder,
10098
&mut cargo,
101-
&librustc_stamp(build, compiler, target),
99+
&librustc_stamp(builder, compiler, target),
102100
true);
103101

104102
let libdir = builder.sysroot_libdir(compiler, target);
105-
add_to_sysroot(&build, &libdir, &librustc_stamp(build, compiler, target));
103+
add_to_sysroot(&builder, &libdir, &librustc_stamp(builder, compiler, target));
106104
}
107105
}
108106

@@ -126,41 +124,40 @@ impl Step for Test {
126124
}
127125

128126
fn run(self, builder: &Builder) {
129-
let build = builder.build;
130127
let target = self.target;
131-
let compiler = builder.compiler(0, build.build);
128+
let compiler = builder.compiler(0, builder.config.build);
132129

133-
let out_dir = build.stage_out(compiler, Mode::Libtest);
134-
build.clear_if_dirty(&out_dir, &libstd_stamp(build, compiler, target));
130+
let out_dir = builder.stage_out(compiler, Mode::Libtest);
131+
builder.clear_if_dirty(&out_dir, &libstd_stamp(builder, compiler, target));
135132
let mut cargo = builder.cargo(compiler, Mode::Libtest, target, "check");
136-
test_cargo(build, &compiler, target, &mut cargo);
133+
test_cargo(builder, &compiler, target, &mut cargo);
137134

138-
let _folder = build.fold_output(|| format!("stage{}-test", compiler.stage));
135+
let _folder = builder.fold_output(|| format!("stage{}-test", compiler.stage));
139136
println!("Checking test artifacts ({} -> {})", &compiler.host, target);
140-
run_cargo(build,
137+
run_cargo(builder,
141138
&mut cargo,
142-
&libtest_stamp(build, compiler, target),
139+
&libtest_stamp(builder, compiler, target),
143140
true);
144141

145142
let libdir = builder.sysroot_libdir(compiler, target);
146-
add_to_sysroot(&build, &libdir, &libtest_stamp(build, compiler, target));
143+
add_to_sysroot(builder, &libdir, &libtest_stamp(builder, compiler, target));
147144
}
148145
}
149146

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

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

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

0 commit comments

Comments
 (0)