From cec68167fd3787500194f261e2fcbb14381cd317 Mon Sep 17 00:00:00 2001 From: Mark Simulacrum Date: Thu, 10 Aug 2017 10:12:35 +0500 Subject: [PATCH] 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. --- src/bootstrap/compile.rs | 17 +++++++++++++++++ src/bootstrap/tool.rs | 10 ++++------ 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs index a6702300c81..33c3638a894 100644 --- a/src/bootstrap/compile.rs +++ b/src/bootstrap/compile.rs @@ -32,6 +32,7 @@ use util::{exe, libdir, is_dylib, copy}; use {Build, Compiler, Mode}; use native; +use tool; use cache::{INTERNER, Interned}; use builder::{Step, RunConfig, ShouldRun, Builder}; @@ -198,6 +199,12 @@ fn run(self, builder: &Builder) { // for reason why the sanitizers are not built in stage0. copy_apple_sanitizer_dylibs(&build.native_dir(target), "osx", &libdir); } + + builder.ensure(tool::CleanTools { + compiler: target_compiler, + target: target, + mode: Mode::Libstd, + }); } } @@ -389,6 +396,11 @@ fn run(self, builder: &Builder) { target); add_to_sysroot(&builder.sysroot_libdir(target_compiler, target), &libtest_stamp(build, compiler, target)); + builder.ensure(tool::CleanTools { + compiler: target_compiler, + target: target, + mode: Mode::Libtest, + }); } } @@ -567,6 +579,11 @@ fn run(self, builder: &Builder) { target); add_to_sysroot(&builder.sysroot_libdir(target_compiler, target), &librustc_stamp(build, compiler, target)); + builder.ensure(tool::CleanTools { + compiler: target_compiler, + target: target, + mode: Mode::Librustc, + }); } } diff --git a/src/bootstrap/tool.rs b/src/bootstrap/tool.rs index 89b1b113797..7ccd527b338 100644 --- a/src/bootstrap/tool.rs +++ b/src/bootstrap/tool.rs @@ -23,10 +23,10 @@ use cache::Interned; #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] -struct CleanTools { - compiler: Compiler, - target: Interned, - mode: Mode, +pub struct CleanTools { + pub compiler: Compiler, + pub target: Interned, + pub mode: Mode, } impl Step for CleanTools { @@ -82,7 +82,6 @@ fn run(self, builder: &Builder) -> PathBuf { let target = self.target; let tool = self.tool; - builder.ensure(CleanTools { compiler, target, mode: self.mode }); match self.mode { Mode::Libstd => builder.ensure(compile::Std { compiler, target }), Mode::Libtest => builder.ensure(compile::Test { compiler, target }), @@ -271,7 +270,6 @@ fn run(self, builder: &Builder) -> PathBuf { builder.compiler(target_compiler.stage - 1, builder.build.build) }; - builder.ensure(CleanTools { compiler: build_compiler, target, mode: Mode::Librustc }); builder.ensure(compile::Rustc { compiler: build_compiler, target }); let _folder = build.fold_output(|| format!("stage{}-rustdoc", target_compiler.stage)); -- GitLab