Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 23561c6

Browse files
committedApr 18, 2018
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

Lines changed: 20 additions & 21 deletions
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

Lines changed: 30 additions & 33 deletions
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
}

‎src/bootstrap/compile.rs

Lines changed: 143 additions & 152 deletions
Large diffs are not rendered by default.

‎src/bootstrap/dist.rs

Lines changed: 298 additions & 311 deletions
Large diffs are not rendered by default.

‎src/bootstrap/doc.rs

Lines changed: 103 additions & 115 deletions
Large diffs are not rendered by default.

‎src/bootstrap/install.rs

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@ fn install_sh(
6262
stage: u32,
6363
host: Option<Interned<String>>
6464
) {
65-
let build = builder.build;
66-
build.info(&format!("Install {} stage{} ({:?})", package, stage, host));
65+
builder.info(&format!("Install {} stage{} ({:?})", package, stage, host));
6766

6867
let prefix_default = PathBuf::from("/usr/local");
6968
let sysconfdir_default = PathBuf::from("/etc");
@@ -72,15 +71,15 @@ fn install_sh(
7271
let bindir_default = PathBuf::from("bin");
7372
let libdir_default = PathBuf::from("lib");
7473
let mandir_default = datadir_default.join("man");
75-
let prefix = build.config.prefix.as_ref().map_or(prefix_default, |p| {
74+
let prefix = builder.config.prefix.as_ref().map_or(prefix_default, |p| {
7675
fs::canonicalize(p).expect(&format!("could not canonicalize {}", p.display()))
7776
});
78-
let sysconfdir = build.config.sysconfdir.as_ref().unwrap_or(&sysconfdir_default);
79-
let datadir = build.config.datadir.as_ref().unwrap_or(&datadir_default);
80-
let docdir = build.config.docdir.as_ref().unwrap_or(&docdir_default);
81-
let bindir = build.config.bindir.as_ref().unwrap_or(&bindir_default);
82-
let libdir = build.config.libdir.as_ref().unwrap_or(&libdir_default);
83-
let mandir = build.config.mandir.as_ref().unwrap_or(&mandir_default);
77+
let sysconfdir = builder.config.sysconfdir.as_ref().unwrap_or(&sysconfdir_default);
78+
let datadir = builder.config.datadir.as_ref().unwrap_or(&datadir_default);
79+
let docdir = builder.config.docdir.as_ref().unwrap_or(&docdir_default);
80+
let bindir = builder.config.bindir.as_ref().unwrap_or(&bindir_default);
81+
let libdir = builder.config.libdir.as_ref().unwrap_or(&libdir_default);
82+
let mandir = builder.config.mandir.as_ref().unwrap_or(&mandir_default);
8483

8584
let sysconfdir = prefix.join(sysconfdir);
8685
let datadir = prefix.join(datadir);
@@ -99,18 +98,18 @@ fn install_sh(
9998
let libdir = add_destdir(&libdir, &destdir);
10099
let mandir = add_destdir(&mandir, &destdir);
101100

102-
let empty_dir = build.out.join("tmp/empty_dir");
101+
let empty_dir = builder.out.join("tmp/empty_dir");
103102

104103
t!(fs::create_dir_all(&empty_dir));
105104
let package_name = if let Some(host) = host {
106-
format!("{}-{}", pkgname(build, name), host)
105+
format!("{}-{}", pkgname(builder, name), host)
107106
} else {
108-
pkgname(build, name)
107+
pkgname(builder, name)
109108
};
110109

111110
let mut cmd = Command::new("sh");
112111
cmd.current_dir(&empty_dir)
113-
.arg(sanitize_sh(&tmpdir(build).join(&package_name).join("install.sh")))
112+
.arg(sanitize_sh(&tmpdir(builder).join(&package_name).join("install.sh")))
114113
.arg(format!("--prefix={}", sanitize_sh(&prefix)))
115114
.arg(format!("--sysconfdir={}", sanitize_sh(&sysconfdir)))
116115
.arg(format!("--datadir={}", sanitize_sh(&datadir)))
@@ -119,7 +118,7 @@ fn install_sh(
119118
.arg(format!("--libdir={}", sanitize_sh(&libdir)))
120119
.arg(format!("--mandir={}", sanitize_sh(&mandir)))
121120
.arg("--disable-ldconfig");
122-
build.run(&mut cmd);
121+
builder.run(&mut cmd);
123122
t!(fs::remove_dir_all(&empty_dir));
124123
}
125124

@@ -180,7 +179,7 @@ macro_rules! install {
180179
run.builder.ensure($name {
181180
stage: run.builder.top_stage,
182181
target: run.target,
183-
host: run.builder.build.build,
182+
host: run.builder.config.build,
184183
});
185184
}
186185

@@ -197,7 +196,7 @@ install!((self, builder, _config),
197196
install_docs(builder, self.stage, self.target);
198197
};
199198
Std, "src/libstd", true, only_hosts: true, {
200-
for target in &builder.build.targets {
199+
for target in &builder.targets {
201200
builder.ensure(dist::Std {
202201
compiler: builder.compiler(self.stage, self.host),
203202
target: *target

‎src/bootstrap/native.rs

Lines changed: 69 additions & 73 deletions
Large diffs are not rendered by default.

‎src/bootstrap/test.rs

Lines changed: 153 additions & 172 deletions
Large diffs are not rendered by default.

‎src/bootstrap/tool.rs

Lines changed: 39 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,14 @@ impl Step for CleanTools {
3838
}
3939

4040
fn run(self, builder: &Builder) {
41-
let build = builder.build;
4241
let compiler = self.compiler;
4342
let target = self.target;
4443
let mode = self.mode;
4544

4645
// This is for the original compiler, but if we're forced to use stage 1, then
4746
// std/test/rustc stamps won't exist in stage 2, so we need to get those from stage 1, since
4847
// we copy the libs forward.
49-
let tools_dir = build.stage_out(compiler, Mode::Tool);
48+
let tools_dir = builder.stage_out(compiler, Mode::Tool);
5049
let compiler = if builder.force_use_stage1(compiler, target) {
5150
builder.compiler(1, compiler.host)
5251
} else {
@@ -55,13 +54,13 @@ impl Step for CleanTools {
5554

5655
for &cur_mode in &[Mode::Libstd, Mode::Libtest, Mode::Librustc] {
5756
let stamp = match cur_mode {
58-
Mode::Libstd => libstd_stamp(build, compiler, target),
59-
Mode::Libtest => libtest_stamp(build, compiler, target),
60-
Mode::Librustc => librustc_stamp(build, compiler, target),
57+
Mode::Libstd => libstd_stamp(builder, compiler, target),
58+
Mode::Libtest => libtest_stamp(builder, compiler, target),
59+
Mode::Librustc => librustc_stamp(builder, compiler, target),
6160
_ => panic!(),
6261
};
6362

64-
if build.clear_if_dirty(&tools_dir, &stamp) {
63+
if builder.clear_if_dirty(&tools_dir, &stamp) {
6564
break;
6665
}
6766

@@ -97,7 +96,6 @@ impl Step for ToolBuild {
9796
/// This will build the specified tool with the specified `host` compiler in
9897
/// `stage` into the normal cargo output directory.
9998
fn run(self, builder: &Builder) -> Option<PathBuf> {
100-
let build = builder.build;
10199
let compiler = self.compiler;
102100
let target = self.target;
103101
let tool = self.tool;
@@ -114,10 +112,10 @@ impl Step for ToolBuild {
114112
let mut cargo = prepare_tool_cargo(builder, compiler, target, "build", path);
115113
cargo.arg("--features").arg(self.extra_features.join(" "));
116114

117-
let _folder = build.fold_output(|| format!("stage{}-{}", compiler.stage, tool));
118-
build.info(&format!("Building stage{} tool {} ({})", compiler.stage, tool, target));
115+
let _folder = builder.fold_output(|| format!("stage{}-{}", compiler.stage, tool));
116+
builder.info(&format!("Building stage{} tool {} ({})", compiler.stage, tool, target));
119117
let mut duplicates = Vec::new();
120-
let is_expected = compile::stream_cargo(build, &mut cargo, &mut |msg| {
118+
let is_expected = compile::stream_cargo(builder, &mut cargo, &mut |msg| {
121119
// Only care about big things like the RLS/Cargo for now
122120
if tool != "rls" && tool != "cargo" {
123121
return
@@ -156,7 +154,7 @@ impl Step for ToolBuild {
156154
}
157155
}
158156

159-
let mut artifacts = build.tool_artifacts.borrow_mut();
157+
let mut artifacts = builder.tool_artifacts.borrow_mut();
160158
let prev_artifacts = artifacts
161159
.entry(target)
162160
.or_insert_with(Default::default);
@@ -190,7 +188,7 @@ impl Step for ToolBuild {
190188
panic!("tools should not compile multiple copies of the same crate");
191189
}
192190

193-
build.save_toolstate(tool, if is_expected {
191+
builder.save_toolstate(tool, if is_expected {
194192
ToolState::TestFail
195193
} else {
196194
ToolState::BuildFail
@@ -203,10 +201,10 @@ impl Step for ToolBuild {
203201
return None;
204202
}
205203
} else {
206-
let cargo_out = build.cargo_out(compiler, Mode::Tool, target)
204+
let cargo_out = builder.cargo_out(compiler, Mode::Tool, target)
207205
.join(exe(tool, &compiler.host));
208-
let bin = build.tools_dir(compiler).join(exe(tool, &compiler.host));
209-
build.copy(&cargo_out, &bin);
206+
let bin = builder.tools_dir(compiler).join(exe(tool, &compiler.host));
207+
builder.copy(&cargo_out, &bin);
210208
Some(bin)
211209
}
212210
}
@@ -219,16 +217,15 @@ pub fn prepare_tool_cargo(
219217
command: &'static str,
220218
path: &'static str,
221219
) -> Command {
222-
let build = builder.build;
223220
let mut cargo = builder.cargo(compiler, Mode::Tool, target, command);
224-
let dir = build.src.join(path);
221+
let dir = builder.src.join(path);
225222
cargo.arg("--manifest-path").arg(dir.join("Cargo.toml"));
226223

227224
// We don't want to build tools dynamically as they'll be running across
228225
// stages and such and it's just easier if they're not dynamically linked.
229226
cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");
230227

231-
if let Some(dir) = build.openssl_install_dir(target) {
228+
if let Some(dir) = builder.openssl_install_dir(target) {
232229
cargo.env("OPENSSL_STATIC", "1");
233230
cargo.env("OPENSSL_DIR", dir);
234231
cargo.env("LIBZ_SYS_STATIC", "1");
@@ -238,10 +235,10 @@ pub fn prepare_tool_cargo(
238235
// own copy
239236
cargo.env("LZMA_API_STATIC", "1");
240237

241-
cargo.env("CFG_RELEASE_CHANNEL", &build.config.channel);
242-
cargo.env("CFG_VERSION", build.rust_version());
238+
cargo.env("CFG_RELEASE_CHANNEL", &builder.config.channel);
239+
cargo.env("CFG_VERSION", builder.rust_version());
243240

244-
let info = GitInfo::new(&build.config, &dir);
241+
let info = GitInfo::new(&builder.config, &dir);
245242
if let Some(sha) = info.sha() {
246243
cargo.env("CFG_COMMIT_HASH", sha);
247244
}
@@ -269,8 +266,8 @@ macro_rules! tool {
269266
match tool {
270267
$(Tool::$name =>
271268
self.ensure($name {
272-
compiler: self.compiler(stage, self.build.build),
273-
target: self.build.build,
269+
compiler: self.compiler(stage, self.config.build),
270+
target: self.config.build,
274271
}),
275272
)+
276273
}
@@ -304,7 +301,7 @@ macro_rules! tool {
304301

305302
fn make_run(run: RunConfig) {
306303
run.builder.ensure($name {
307-
compiler: run.builder.compiler(run.builder.top_stage, run.builder.build.build),
304+
compiler: run.builder.compiler(run.builder.top_stage, run.builder.config.build),
308305
target: run.target,
309306
});
310307
}
@@ -354,7 +351,7 @@ impl Step for RemoteTestServer {
354351

355352
fn make_run(run: RunConfig) {
356353
run.builder.ensure(RemoteTestServer {
357-
compiler: run.builder.compiler(run.builder.top_stage, run.builder.build.build),
354+
compiler: run.builder.compiler(run.builder.top_stage, run.builder.config.build),
358355
target: run.target,
359356
});
360357
}
@@ -393,26 +390,25 @@ impl Step for Rustdoc {
393390
}
394391

395392
fn run(self, builder: &Builder) -> PathBuf {
396-
let build = builder.build;
397393
let target_compiler = builder.compiler(builder.top_stage, self.host);
398394
let target = target_compiler.host;
399395
let build_compiler = if target_compiler.stage == 0 {
400-
builder.compiler(0, builder.build.build)
396+
builder.compiler(0, builder.config.build)
401397
} else if target_compiler.stage >= 2 {
402398
// Past stage 2, we consider the compiler to be ABI-compatible and hence capable of
403399
// building rustdoc itself.
404-
builder.compiler(target_compiler.stage, builder.build.build)
400+
builder.compiler(target_compiler.stage, builder.config.build)
405401
} else {
406402
// Similar to `compile::Assemble`, build with the previous stage's compiler. Otherwise
407403
// we'd have stageN/bin/rustc and stageN/bin/rustdoc be effectively different stage
408404
// compilers, which isn't what we want.
409-
builder.compiler(target_compiler.stage - 1, builder.build.build)
405+
builder.compiler(target_compiler.stage - 1, builder.config.build)
410406
};
411407

412408
builder.ensure(compile::Rustc { compiler: build_compiler, target });
413409
builder.ensure(compile::Rustc {
414410
compiler: build_compiler,
415-
target: builder.build.build,
411+
target: builder.config.build,
416412
});
417413

418414
let mut cargo = prepare_tool_cargo(builder,
@@ -425,15 +421,15 @@ impl Step for Rustdoc {
425421
cargo.env("RUSTC_DEBUGINFO", builder.config.rust_debuginfo.to_string())
426422
.env("RUSTC_DEBUGINFO_LINES", builder.config.rust_debuginfo_lines.to_string());
427423

428-
let _folder = build.fold_output(|| format!("stage{}-rustdoc", target_compiler.stage));
429-
build.info(&format!("Building rustdoc for stage{} ({})",
424+
let _folder = builder.fold_output(|| format!("stage{}-rustdoc", target_compiler.stage));
425+
builder.info(&format!("Building rustdoc for stage{} ({})",
430426
target_compiler.stage, target_compiler.host));
431-
build.run(&mut cargo);
427+
builder.run(&mut cargo);
432428

433429
// Cargo adds a number of paths to the dylib search path on windows, which results in
434430
// the wrong rustdoc being executed. To avoid the conflicting rustdocs, we name the "tool"
435431
// rustdoc a different name.
436-
let tool_rustdoc = build.cargo_out(build_compiler, Mode::Tool, target)
432+
let tool_rustdoc = builder.cargo_out(build_compiler, Mode::Tool, target)
437433
.join(exe("rustdoc-tool-binary", &target_compiler.host));
438434

439435
// don't create a stage0-sysroot/bin directory.
@@ -443,7 +439,7 @@ impl Step for Rustdoc {
443439
t!(fs::create_dir_all(&bindir));
444440
let bin_rustdoc = bindir.join(exe("rustdoc", &*target_compiler.host));
445441
let _ = fs::remove_file(&bin_rustdoc);
446-
build.copy(&tool_rustdoc, &bin_rustdoc);
442+
builder.copy(&tool_rustdoc, &bin_rustdoc);
447443
bin_rustdoc
448444
} else {
449445
tool_rustdoc
@@ -464,12 +460,12 @@ impl Step for Cargo {
464460

465461
fn should_run(run: ShouldRun) -> ShouldRun {
466462
let builder = run.builder;
467-
run.path("src/tools/cargo").default_condition(builder.build.config.extended)
463+
run.path("src/tools/cargo").default_condition(builder.config.extended)
468464
}
469465

470466
fn make_run(run: RunConfig) {
471467
run.builder.ensure(Cargo {
472-
compiler: run.builder.compiler(run.builder.top_stage, run.builder.build.build),
468+
compiler: run.builder.compiler(run.builder.top_stage, run.builder.config.build),
473469
target: run.target,
474470
});
475471
}
@@ -482,7 +478,7 @@ impl Step for Cargo {
482478
// compiler to be available, so we need to depend on that.
483479
builder.ensure(compile::Rustc {
484480
compiler: self.compiler,
485-
target: builder.build.build,
481+
target: builder.config.build,
486482
});
487483
builder.ensure(ToolBuild {
488484
compiler: self.compiler,
@@ -518,12 +514,12 @@ macro_rules! tool_extended {
518514

519515
fn should_run(run: ShouldRun) -> ShouldRun {
520516
let builder = run.builder;
521-
run.path($path).default_condition(builder.build.config.extended)
517+
run.path($path).default_condition(builder.config.extended)
522518
}
523519

524520
fn make_run(run: RunConfig) {
525521
run.builder.ensure($name {
526-
compiler: run.builder.compiler(run.builder.top_stage, run.builder.build.build),
522+
compiler: run.builder.compiler(run.builder.top_stage, run.builder.config.build),
527523
target: run.target,
528524
extra_features: Vec::new(),
529525
});
@@ -554,7 +550,7 @@ tool_extended!((self, builder),
554550
// compiler to be available, so we need to depend on that.
555551
builder.ensure(compile::Rustc {
556552
compiler: self.compiler,
557-
target: builder.build.build,
553+
target: builder.config.build,
558554
});
559555
};
560556
Miri, miri, "src/tools/miri", "miri", {};
@@ -575,7 +571,7 @@ tool_extended!((self, builder),
575571
// compiler to be available, so we need to depend on that.
576572
builder.ensure(compile::Rustc {
577573
compiler: self.compiler,
578-
target: builder.build.build,
574+
target: builder.config.build,
579575
});
580576
};
581577
Rustfmt, rustfmt, "src/tools/rustfmt", "rustfmt", {};
@@ -586,7 +582,7 @@ impl<'a> Builder<'a> {
586582
/// `host`.
587583
pub fn tool_cmd(&self, tool: Tool) -> Command {
588584
let mut cmd = Command::new(self.tool_exe(tool));
589-
let compiler = self.compiler(self.tool_default_stage(tool), self.build.build);
585+
let compiler = self.compiler(self.tool_default_stage(tool), self.config.build);
590586
self.prepare_tool_cmd(compiler, &mut cmd);
591587
cmd
592588
}

‎src/bootstrap/util.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use std::process::Command;
2222
use std::time::{SystemTime, Instant};
2323

2424
use config::Config;
25-
use Build;
25+
use builder::Builder;
2626

2727
/// Returns the `name` as the filename of a static library for `target`.
2828
pub fn staticlib(name: &str, target: &str) -> String {
@@ -104,8 +104,8 @@ pub fn push_exe_path(mut buf: PathBuf, components: &[&str]) -> PathBuf {
104104
pub struct TimeIt(bool, Instant);
105105

106106
/// Returns an RAII structure that prints out how long it took to drop.
107-
pub fn timeit(build: &Build) -> TimeIt {
108-
TimeIt(build.config.dry_run, Instant::now())
107+
pub fn timeit(builder: &Builder) -> TimeIt {
108+
TimeIt(builder.config.dry_run, Instant::now())
109109
}
110110

111111
impl Drop for TimeIt {

0 commit comments

Comments
 (0)
Please sign in to comment.