Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Mark-Simulacrum committed Aug 13, 2017
1 parent facf5a9 commit cec6816
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
17 changes: 17 additions & 0 deletions src/bootstrap/compile.rs
Expand Up @@ -32,6 +32,7 @@ use serde_json;
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};
Expand Down Expand Up @@ -198,6 +199,12 @@ impl Step for StdLink {
// 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,
});
}
}

Expand Down Expand Up @@ -389,6 +396,11 @@ impl Step for TestLink {
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,
});
}
}

Expand Down Expand Up @@ -567,6 +579,11 @@ impl Step for RustcLink {
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,
});
}
}

Expand Down
10 changes: 4 additions & 6 deletions src/bootstrap/tool.rs
Expand Up @@ -23,10 +23,10 @@ use channel::GitInfo;
use cache::Interned;

#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
struct CleanTools {
compiler: Compiler,
target: Interned<String>,
mode: Mode,
pub struct CleanTools {
pub compiler: Compiler,
pub target: Interned<String>,
pub mode: Mode,
}

impl Step for CleanTools {
Expand Down Expand Up @@ -82,7 +82,6 @@ impl Step for ToolBuild {
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 }),
Expand Down Expand Up @@ -271,7 +270,6 @@ impl Step for Rustdoc {
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));
Expand Down

0 comments on commit cec6816

Please sign in to comment.