Skip to content

Commit c0af0b0

Browse files
collin5Mark-Simulacrum
authored andcommitted
clear_if_dirty in Builder::cargo with passed mode
1 parent 6810f52 commit c0af0b0

File tree

5 files changed

+64
-52
lines changed

5 files changed

+64
-52
lines changed

src/bootstrap/builder.rs

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -708,6 +708,68 @@ impl<'a> Builder<'a> {
708708
) -> Command {
709709
let mut cargo = Command::new(&self.initial_cargo);
710710
let out_dir = self.stage_out(compiler, mode);
711+
712+
let mut my_out = match cmd {
713+
"build" => self.cargo_out(compiler, mode, target),
714+
715+
// This is the intended out directory for crate documentation.
716+
"doc" => self.crate_doc_out(target),
717+
718+
_ => self.stage_out(compiler, mode),
719+
};
720+
721+
// This is for the original compiler, but if we're forced to use stage 1, then
722+
// std/test/rustc stamps won't exist in stage 2, so we need to get those from stage 1, since
723+
// we copy the libs forward.
724+
let compiler = if self.force_use_stage1(compiler, target) {
725+
self.compiler(1, compiler.host)
726+
} else {
727+
compiler
728+
};
729+
730+
let libstd_stamp = match cmd {
731+
"check" => check::libstd_stamp(self, compiler, target),
732+
_ => compile::libstd_stamp(self, compiler, target),
733+
};
734+
735+
let libtest_stamp = match cmd {
736+
"check" => check::libtest_stamp(self, compiler, target),
737+
_ => compile::libstd_stamp(self, compiler, target),
738+
};
739+
740+
let librustc_stamp = match cmd {
741+
"check" => check::librustc_stamp(self, compiler, target),
742+
_ => compile::librustc_stamp(self, compiler, target),
743+
};
744+
745+
if cmd == "doc" {
746+
if mode == Mode::Rustc || mode == Mode::ToolRustc {
747+
// This is the intended out directory for compiler documentation.
748+
my_out = self.compiler_doc_out(target);
749+
}
750+
let rustdoc = self.rustdoc(compiler.host);
751+
self.clear_if_dirty(&my_out, &rustdoc);
752+
} else {
753+
match mode {
754+
Mode::Std => {
755+
self.clear_if_dirty(&my_out, &self.rustc(compiler));
756+
},
757+
Mode::Rustc => {
758+
self.clear_if_dirty(&my_out, &libstd_stamp);
759+
self.clear_if_dirty(&my_out, &libtest_stamp);
760+
},
761+
Mode::Test => {
762+
self.clear_if_dirty(&my_out, &libstd_stamp);
763+
},
764+
Mode::ToolRustc => {
765+
self.clear_if_dirty(&my_out, &libstd_stamp);
766+
self.clear_if_dirty(&my_out, &libtest_stamp);
767+
self.clear_if_dirty(&my_out, &librustc_stamp);
768+
}
769+
_ => { }
770+
}
771+
}
772+
711773
cargo
712774
.env("CARGO_TARGET_DIR", out_dir)
713775
.arg(cmd);

src/bootstrap/check.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,6 @@ impl Step for Std {
4040
let target = self.target;
4141
let compiler = builder.compiler(0, builder.config.build);
4242

43-
let out_dir = builder.stage_out(compiler, Mode::Std);
44-
builder.clear_if_dirty(&out_dir, &builder.rustc(compiler));
45-
4643
let mut cargo = builder.cargo(compiler, Mode::Std, target, "check");
4744
std_cargo(builder, &compiler, target, &mut cargo);
4845

@@ -88,10 +85,6 @@ impl Step for Rustc {
8885
let compiler = builder.compiler(0, builder.config.build);
8986
let target = self.target;
9087

91-
let stage_out = builder.stage_out(compiler, Mode::Rustc);
92-
builder.clear_if_dirty(&stage_out, &libstd_stamp(builder, compiler, target));
93-
builder.clear_if_dirty(&stage_out, &libtest_stamp(builder, compiler, target));
94-
9588
let mut cargo = builder.cargo(compiler, Mode::Rustc, target, "check");
9689
rustc_cargo(builder, &mut cargo);
9790

@@ -180,9 +173,6 @@ impl Step for Test {
180173
let compiler = builder.compiler(0, builder.config.build);
181174
let target = self.target;
182175

183-
let out_dir = builder.stage_out(compiler, Mode::Test);
184-
builder.clear_if_dirty(&out_dir, &libstd_stamp(builder, compiler, target));
185-
186176
let mut cargo = builder.cargo(compiler, Mode::Test, target, "check");
187177
test_cargo(builder, &compiler, target, &mut cargo);
188178

src/bootstrap/compile.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,6 @@ impl Step for Std {
107107
copy_musl_third_party_objects(builder, target, &libdir);
108108
}
109109

110-
let out_dir = builder.cargo_out(compiler, Mode::Std, target);
111-
builder.clear_if_dirty(&out_dir, &builder.rustc(compiler));
112110
let mut cargo = builder.cargo(compiler, Mode::Std, target, "build");
113111
std_cargo(builder, &compiler, target, &mut cargo);
114112

@@ -387,8 +385,6 @@ impl Step for Test {
387385
return;
388386
}
389387

390-
let out_dir = builder.cargo_out(compiler, Mode::Test, target);
391-
builder.clear_if_dirty(&out_dir, &libstd_stamp(builder, compiler, target));
392388
let mut cargo = builder.cargo(compiler, Mode::Test, target, "build");
393389
test_cargo(builder, &compiler, target, &mut cargo);
394390

@@ -519,9 +515,6 @@ impl Step for Rustc {
519515
compiler: builder.compiler(self.compiler.stage, builder.config.build),
520516
target: builder.config.build,
521517
});
522-
let cargo_out = builder.cargo_out(compiler, Mode::Rustc, target);
523-
builder.clear_if_dirty(&cargo_out, &libstd_stamp(builder, compiler, target));
524-
builder.clear_if_dirty(&cargo_out, &libtest_stamp(builder, compiler, target));
525518

526519
let mut cargo = builder.cargo(compiler, Mode::Rustc, target, "build");
527520
rustc_cargo(builder, &mut cargo);

src/bootstrap/doc.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,6 @@ impl Step for Std {
455455
let out = builder.doc_out(target);
456456
t!(fs::create_dir_all(&out));
457457
let compiler = builder.compiler(stage, builder.config.build);
458-
let rustdoc = builder.rustdoc(compiler.host);
459458
let compiler = if builder.force_use_stage1(compiler, target) {
460459
builder.compiler(1, compiler.host)
461460
} else {
@@ -480,7 +479,6 @@ impl Step for Std {
480479
// This way rustdoc generates output directly into the output, and rustdoc
481480
// will also directly handle merging.
482481
let my_out = builder.crate_doc_out(target);
483-
builder.clear_if_dirty(&my_out, &rustdoc);
484482
t!(symlink_dir_force(&builder.config, &my_out, &out_dir));
485483

486484
let mut cargo = builder.cargo(compiler, Mode::Std, target, "doc");
@@ -535,7 +533,6 @@ impl Step for Test {
535533
let out = builder.doc_out(target);
536534
t!(fs::create_dir_all(&out));
537535
let compiler = builder.compiler(stage, builder.config.build);
538-
let rustdoc = builder.rustdoc(compiler.host);
539536
let compiler = if builder.force_use_stage1(compiler, target) {
540537
builder.compiler(1, compiler.host)
541538
} else {
@@ -551,7 +548,6 @@ impl Step for Test {
551548

552549
// See docs in std above for why we symlink
553550
let my_out = builder.crate_doc_out(target);
554-
builder.clear_if_dirty(&my_out, &rustdoc);
555551
t!(symlink_dir_force(&builder.config, &my_out, &out_dir));
556552

557553
let mut cargo = builder.cargo(compiler, Mode::Test, target, "doc");
@@ -603,7 +599,6 @@ impl Step for WhitelistedRustc {
603599
let out = builder.doc_out(target);
604600
t!(fs::create_dir_all(&out));
605601
let compiler = builder.compiler(stage, builder.config.build);
606-
let rustdoc = builder.rustdoc(compiler.host);
607602
let compiler = if builder.force_use_stage1(compiler, target) {
608603
builder.compiler(1, compiler.host)
609604
} else {
@@ -619,7 +614,6 @@ impl Step for WhitelistedRustc {
619614

620615
// See docs in std above for why we symlink
621616
let my_out = builder.crate_doc_out(target);
622-
builder.clear_if_dirty(&my_out, &rustdoc);
623617
t!(symlink_dir_force(&builder.config, &my_out, &out_dir));
624618

625619
let mut cargo = builder.cargo(compiler, Mode::Rustc, target, "doc");
@@ -678,7 +672,6 @@ impl Step for Rustc {
678672

679673
// Get the correct compiler for this stage.
680674
let compiler = builder.compiler(stage, builder.config.build);
681-
let rustdoc = builder.rustdoc(compiler.host);
682675
let compiler = if builder.force_use_stage1(compiler, target) {
683676
builder.compiler(1, compiler.host)
684677
} else {
@@ -699,7 +692,6 @@ impl Step for Rustc {
699692
// We do not symlink to the same shared folder that already contains std library
700693
// documentation from previous steps as we do not want to include that.
701694
let out_dir = builder.stage_out(compiler, Mode::Rustc).join(target).join("doc");
702-
builder.clear_if_dirty(&out, &rustdoc);
703695
t!(symlink_dir_force(&builder.config, &out, &out_dir));
704696

705697
// Build cargo command.
@@ -780,7 +772,6 @@ impl Step for Rustdoc {
780772

781773
// Get the correct compiler for this stage.
782774
let compiler = builder.compiler(stage, builder.config.build);
783-
let rustdoc = builder.rustdoc(compiler.host);
784775
let compiler = if builder.force_use_stage1(compiler, target) {
785776
builder.compiler(1, compiler.host)
786777
} else {
@@ -803,7 +794,6 @@ impl Step for Rustdoc {
803794
.join(target)
804795
.join("doc");
805796
t!(fs::create_dir_all(&out_dir));
806-
builder.clear_if_dirty(&out, &rustdoc);
807797
t!(symlink_dir_force(&builder.config, &out, &out_dir));
808798

809799
// Build cargo command.

src/bootstrap/tool.rs

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use Mode;
1919
use Compiler;
2020
use builder::{Step, RunConfig, ShouldRun, Builder};
2121
use util::{exe, add_lib_path};
22-
use compile::{self, libtest_stamp, libstd_stamp, librustc_stamp};
22+
use compile;
2323
use native;
2424
use channel::GitInfo;
2525
use cache::Interned;
@@ -39,33 +39,10 @@ impl Step for CleanTools {
3939
run.never()
4040
}
4141

42-
fn run(self, builder: &Builder) {
43-
let compiler = self.compiler;
44-
let target = self.target;
42+
fn run(self, _builder: &Builder) {
4543
let cause = self.cause;
4644

47-
// This is for the original compiler, but if we're forced to use stage 1, then
48-
// std/test/rustc stamps won't exist in stage 2, so we need to get those from stage 1, since
49-
// we copy the libs forward.
50-
let tools_dir = builder.stage_out(compiler, Mode::ToolRustc);
51-
let compiler = if builder.force_use_stage1(compiler, target) {
52-
builder.compiler(1, compiler.host)
53-
} else {
54-
compiler
55-
};
56-
5745
for &cur_mode in &[Mode::Std, Mode::Test, Mode::Rustc] {
58-
let stamp = match cur_mode {
59-
Mode::Std => libstd_stamp(builder, compiler, target),
60-
Mode::Test => libtest_stamp(builder, compiler, target),
61-
Mode::Rustc => librustc_stamp(builder, compiler, target),
62-
_ => panic!(),
63-
};
64-
65-
if builder.clear_if_dirty(&tools_dir, &stamp) {
66-
break;
67-
}
68-
6946
// If we are a rustc tool, and std changed, we also need to clear ourselves out -- our
7047
// dependencies depend on std. Therefore, we iterate up until our own mode.
7148
if cause == cur_mode {

0 commit comments

Comments
 (0)