Skip to content

Commit 5fd5c7a

Browse files
Clean tools after building libstd/libtest/librustc.
This fixes the bug we previously had where we'd build a libtest tool after building a libstd tool and clear out the libstd tool. Since we clear out all tools for a given stage on invocations of CleanTools after lib{std, test, rustc} change, we need to make sure that all tools built with that stage will be built after the clearing is done. The fix contained here technically isn't perfect; there is still an edge case of compiling a libstd tool, then compiling libtest, which will clear out the libstd tool and it won't ever get rebuilt within that session of rustbuild. This is where the caching system used today shows it's problems -- in effect, all tools depend on a global counter of the stage being cleared out. We can implement such a counter in a future patch to ensure that tools are rebuilt as needed, but it is deemed unlikely that it will be required in practice, since most if not all tools are built after the relevant stage's std/test/rustc are built, though this is only an opinion and hasn't been verified.
1 parent a296b82 commit 5fd5c7a

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

src/bootstrap/compile.rs

+17
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ use serde_json;
3232
use util::{exe, libdir, is_dylib, copy};
3333
use {Build, Compiler, Mode};
3434
use native;
35+
use tool;
3536

3637
use cache::{INTERNER, Interned};
3738
use builder::{Step, RunConfig, ShouldRun, Builder};
@@ -198,6 +199,12 @@ impl Step for StdLink {
198199
// for reason why the sanitizers are not built in stage0.
199200
copy_apple_sanitizer_dylibs(&build.native_dir(target), "osx", &libdir);
200201
}
202+
203+
builder.ensure(tool::CleanTools {
204+
compiler: target_compiler,
205+
target: target,
206+
mode: Mode::Libstd,
207+
});
201208
}
202209
}
203210

@@ -389,6 +396,11 @@ impl Step for TestLink {
389396
target);
390397
add_to_sysroot(&builder.sysroot_libdir(target_compiler, target),
391398
&libtest_stamp(build, compiler, target));
399+
builder.ensure(tool::CleanTools {
400+
compiler: target_compiler,
401+
target: target,
402+
mode: Mode::Libtest,
403+
});
392404
}
393405
}
394406

@@ -567,6 +579,11 @@ impl Step for RustcLink {
567579
target);
568580
add_to_sysroot(&builder.sysroot_libdir(target_compiler, target),
569581
&librustc_stamp(build, compiler, target));
582+
builder.ensure(tool::CleanTools {
583+
compiler: target_compiler,
584+
target: target,
585+
mode: Mode::Librustc,
586+
});
570587
}
571588
}
572589

src/bootstrap/tool.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ use channel::GitInfo;
2323
use cache::Interned;
2424

2525
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
26-
struct CleanTools {
27-
compiler: Compiler,
28-
target: Interned<String>,
29-
mode: Mode,
26+
pub struct CleanTools {
27+
pub compiler: Compiler,
28+
pub target: Interned<String>,
29+
pub mode: Mode,
3030
}
3131

3232
impl Step for CleanTools {
@@ -82,7 +82,6 @@ impl Step for ToolBuild {
8282
let target = self.target;
8383
let tool = self.tool;
8484

85-
builder.ensure(CleanTools { compiler, target, mode: self.mode });
8685
match self.mode {
8786
Mode::Libstd => builder.ensure(compile::Std { compiler, target }),
8887
Mode::Libtest => builder.ensure(compile::Test { compiler, target }),
@@ -271,7 +270,6 @@ impl Step for Rustdoc {
271270
builder.compiler(target_compiler.stage - 1, builder.build.build)
272271
};
273272

274-
builder.ensure(CleanTools { compiler: build_compiler, target, mode: Mode::Librustc });
275273
builder.ensure(compile::Rustc { compiler: build_compiler, target });
276274

277275
let _folder = build.fold_output(|| format!("stage{}-rustdoc", target_compiler.stage));

0 commit comments

Comments
 (0)