Compile stage0 tools with the raw bootstrap compiler
This commit updates the stage0 build of tools to use the libraries of the stage0 compiler instead of the compiled libraries by the stage0 compiler. This should enable us to avoid any stage0 hacks (like missing SIMD).
This commit is contained in:
parent
fb97bb50d1
commit
ef41cf0288
7 changed files with 73 additions and 29 deletions
|
|
@ -769,6 +769,22 @@ impl<'a> Builder<'a> {
|
|||
|
||||
let want_rustdoc = self.doc_tests != DocTests::No;
|
||||
|
||||
// We synthetically interpret a stage0 compiler used to build tools as a
|
||||
// "raw" compiler in that it's the exact snapshot we download. Normally
|
||||
// the stage0 build means it uses libraries build by the stage0
|
||||
// compiler, but for tools we just use the precompiled libraries that
|
||||
// we've downloaded
|
||||
let use_snapshot = mode == Mode::ToolBootstrap;
|
||||
assert!(!use_snapshot || stage == 0);
|
||||
|
||||
let maybe_sysroot = self.sysroot(compiler);
|
||||
let sysroot = if use_snapshot {
|
||||
self.rustc_snapshot_sysroot()
|
||||
} else {
|
||||
&maybe_sysroot
|
||||
};
|
||||
let libdir = sysroot.join(libdir(&compiler.host));
|
||||
|
||||
// Customize the compiler we're running. Specify the compiler to cargo
|
||||
// as our shim and then pass it some various options used to configure
|
||||
// how the actual compiler itself is called.
|
||||
|
|
@ -784,8 +800,8 @@ impl<'a> Builder<'a> {
|
|||
"RUSTC_DEBUG_ASSERTIONS",
|
||||
self.config.rust_debug_assertions.to_string(),
|
||||
)
|
||||
.env("RUSTC_SYSROOT", self.sysroot(compiler))
|
||||
.env("RUSTC_LIBDIR", self.rustc_libdir(compiler))
|
||||
.env("RUSTC_SYSROOT", &sysroot)
|
||||
.env("RUSTC_LIBDIR", &libdir)
|
||||
.env("RUSTC_RPATH", self.config.rust_rpath.to_string())
|
||||
.env("RUSTDOC", self.out.join("bootstrap/debug/rustdoc"))
|
||||
.env(
|
||||
|
|
@ -809,7 +825,7 @@ impl<'a> Builder<'a> {
|
|||
cargo.env("RUSTC_ERROR_FORMAT", error_format);
|
||||
}
|
||||
if cmd != "build" && cmd != "check" && want_rustdoc {
|
||||
cargo.env("RUSTDOC_LIBDIR", self.sysroot_libdir(compiler, self.config.build));
|
||||
cargo.env("RUSTDOC_LIBDIR", &libdir);
|
||||
}
|
||||
|
||||
if mode.is_tool() {
|
||||
|
|
|
|||
|
|
@ -273,5 +273,6 @@ fn codegen_backend_stamp(builder: &Builder,
|
|||
/// Cargo's output path for rustdoc in a given stage, compiled by a particular
|
||||
/// compiler for the specified target.
|
||||
pub fn rustdoc_stamp(builder: &Builder, compiler: Compiler, target: Interned<String>) -> PathBuf {
|
||||
builder.cargo_out(compiler, Mode::ToolRustc, target).join(".rustdoc-check.stamp")
|
||||
builder.cargo_out(compiler, Mode::ToolRustc, target)
|
||||
.join(".rustdoc-check.stamp")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -957,7 +957,7 @@ impl Step for PlainSourceTarball {
|
|||
if !has_cargo_vendor {
|
||||
let mut cmd = builder.cargo(
|
||||
builder.compiler(0, builder.config.build),
|
||||
Mode::ToolRustc,
|
||||
Mode::ToolBootstrap,
|
||||
builder.config.build,
|
||||
"install"
|
||||
);
|
||||
|
|
|
|||
|
|
@ -799,14 +799,22 @@ impl Step for Rustdoc {
|
|||
builder.ensure(tool::Rustdoc { host: compiler.host });
|
||||
|
||||
// Symlink compiler docs to the output directory of rustdoc documentation.
|
||||
let out_dir = builder.stage_out(compiler, Mode::ToolRustc).join(target).join("doc");
|
||||
let out_dir = builder.stage_out(compiler, Mode::ToolRustc)
|
||||
.join(target)
|
||||
.join("doc");
|
||||
t!(fs::create_dir_all(&out_dir));
|
||||
builder.clear_if_dirty(&out, &rustdoc);
|
||||
t!(symlink_dir_force(&builder.config, &out, &out_dir));
|
||||
|
||||
// Build cargo command.
|
||||
let mut cargo = prepare_tool_cargo(
|
||||
builder, compiler, Mode::ToolRustc, target, "doc", "src/tools/rustdoc");
|
||||
builder,
|
||||
compiler,
|
||||
Mode::ToolRustc,
|
||||
target,
|
||||
"doc",
|
||||
"src/tools/rustdoc",
|
||||
);
|
||||
|
||||
cargo.env("RUSTDOCFLAGS", "--document-private-items");
|
||||
builder.run(&mut cargo);
|
||||
|
|
|
|||
|
|
@ -328,16 +328,22 @@ pub enum Mode {
|
|||
/// Build codegen libraries, placing output in the "stageN-codegen" directory
|
||||
Codegen,
|
||||
|
||||
/// Build some tools, placing output in the "stageN-tools" directory.
|
||||
ToolStd,
|
||||
ToolTest,
|
||||
/// Build some tools, placing output in the "stageN-tools" directory. The
|
||||
/// "other" here is for miscellaneous sets of tools that are built using the
|
||||
/// bootstrap compiler in its entirety (target libraries and all).
|
||||
/// Typically these tools compile with stable Rust.
|
||||
ToolBootstrap,
|
||||
|
||||
/// Compile a tool which uses all libraries we compile (up to rustc).
|
||||
/// Doesn't use the stage0 compiler libraries like "other", and includes
|
||||
/// tools like rustdoc, cargo, rls, etc.
|
||||
ToolRustc,
|
||||
}
|
||||
|
||||
impl Mode {
|
||||
pub fn is_tool(&self) -> bool {
|
||||
match self {
|
||||
Mode::ToolStd | Mode::ToolTest | Mode::ToolRustc => true,
|
||||
Mode::ToolBootstrap | Mode::ToolRustc => true,
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
|
|
@ -547,7 +553,8 @@ impl Build {
|
|||
Mode::Test => "-test",
|
||||
Mode::Codegen => "-rustc",
|
||||
Mode::Rustc => "-rustc",
|
||||
Mode::ToolStd | Mode::ToolTest | Mode::ToolRustc => "-tools",
|
||||
Mode::ToolBootstrap => "-bootstrap-tools",
|
||||
Mode::ToolRustc => "-tools",
|
||||
};
|
||||
self.out.join(&*compiler.host)
|
||||
.join(format!("stage{}{}", compiler.stage, suffix))
|
||||
|
|
@ -656,8 +663,12 @@ impl Build {
|
|||
|
||||
/// Returns the libdir of the snapshot compiler.
|
||||
fn rustc_snapshot_libdir(&self) -> PathBuf {
|
||||
self.rustc_snapshot_sysroot().join(libdir(&self.config.build))
|
||||
}
|
||||
|
||||
/// Returns the sysroot of the snapshot compiler.
|
||||
fn rustc_snapshot_sysroot(&self) -> &Path {
|
||||
self.initial_rustc.parent().unwrap().parent().unwrap()
|
||||
.join(libdir(&self.config.build))
|
||||
}
|
||||
|
||||
/// Runs a command, printing out nice contextual information if it fails.
|
||||
|
|
|
|||
|
|
@ -1806,7 +1806,10 @@ impl Step for RemoteCopyLibs {
|
|||
builder.info(&format!("REMOTE copy libs to emulator ({})", target));
|
||||
t!(fs::create_dir_all(builder.out.join("tmp")));
|
||||
|
||||
let server = builder.ensure(tool::RemoteTestServer { compiler, target });
|
||||
let server = builder.ensure(tool::RemoteTestServer {
|
||||
compiler: compiler.with_stage(0),
|
||||
target,
|
||||
});
|
||||
|
||||
// Spawn the emulator and wait for it to come online
|
||||
let tool = builder.tool_exe(Tool::RemoteTestClient);
|
||||
|
|
|
|||
|
|
@ -104,9 +104,10 @@ impl Step for ToolBuild {
|
|||
let is_ext_tool = self.is_ext_tool;
|
||||
|
||||
match self.mode {
|
||||
Mode::ToolStd => builder.ensure(compile::Std { compiler, target }),
|
||||
Mode::ToolTest => builder.ensure(compile::Test { compiler, target }),
|
||||
Mode::ToolRustc => builder.ensure(compile::Rustc { compiler, target }),
|
||||
Mode::ToolRustc => {
|
||||
builder.ensure(compile::Rustc { compiler, target })
|
||||
}
|
||||
Mode::ToolBootstrap => {} // uses downloaded stage0 compiler libs
|
||||
_ => panic!("unexpected Mode for tool build")
|
||||
}
|
||||
|
||||
|
|
@ -341,17 +342,17 @@ macro_rules! tool {
|
|||
}
|
||||
|
||||
tool!(
|
||||
Rustbook, "src/tools/rustbook", "rustbook", Mode::ToolRustc;
|
||||
Rustbook, "src/tools/rustbook", "rustbook", Mode::ToolBootstrap;
|
||||
ErrorIndex, "src/tools/error_index_generator", "error_index_generator", Mode::ToolRustc;
|
||||
UnstableBookGen, "src/tools/unstable-book-gen", "unstable-book-gen", Mode::ToolStd;
|
||||
Tidy, "src/tools/tidy", "tidy", Mode::ToolStd;
|
||||
Linkchecker, "src/tools/linkchecker", "linkchecker", Mode::ToolStd;
|
||||
CargoTest, "src/tools/cargotest", "cargotest", Mode::ToolStd;
|
||||
Compiletest, "src/tools/compiletest", "compiletest", Mode::ToolTest, llvm_tools = true;
|
||||
BuildManifest, "src/tools/build-manifest", "build-manifest", Mode::ToolStd;
|
||||
RemoteTestClient, "src/tools/remote-test-client", "remote-test-client", Mode::ToolStd;
|
||||
RustInstaller, "src/tools/rust-installer", "fabricate", Mode::ToolStd;
|
||||
RustdocTheme, "src/tools/rustdoc-themes", "rustdoc-themes", Mode::ToolStd;
|
||||
UnstableBookGen, "src/tools/unstable-book-gen", "unstable-book-gen", Mode::ToolBootstrap;
|
||||
Tidy, "src/tools/tidy", "tidy", Mode::ToolBootstrap;
|
||||
Linkchecker, "src/tools/linkchecker", "linkchecker", Mode::ToolBootstrap;
|
||||
CargoTest, "src/tools/cargotest", "cargotest", Mode::ToolBootstrap;
|
||||
Compiletest, "src/tools/compiletest", "compiletest", Mode::ToolBootstrap, llvm_tools = true;
|
||||
BuildManifest, "src/tools/build-manifest", "build-manifest", Mode::ToolBootstrap;
|
||||
RemoteTestClient, "src/tools/remote-test-client", "remote-test-client", Mode::ToolBootstrap;
|
||||
RustInstaller, "src/tools/rust-installer", "fabricate", Mode::ToolBootstrap;
|
||||
RustdocTheme, "src/tools/rustdoc-themes", "rustdoc-themes", Mode::ToolBootstrap;
|
||||
);
|
||||
|
||||
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
|
||||
|
|
@ -379,7 +380,7 @@ impl Step for RemoteTestServer {
|
|||
compiler: self.compiler,
|
||||
target: self.target,
|
||||
tool: "remote-test-server",
|
||||
mode: Mode::ToolStd,
|
||||
mode: Mode::ToolBootstrap,
|
||||
path: "src/tools/remote-test-server",
|
||||
is_ext_tool: false,
|
||||
extra_features: Vec::new(),
|
||||
|
|
@ -604,7 +605,11 @@ impl<'a> Builder<'a> {
|
|||
fn prepare_tool_cmd(&self, compiler: Compiler, tool: Tool, cmd: &mut Command) {
|
||||
let host = &compiler.host;
|
||||
let mut lib_paths: Vec<PathBuf> = vec![
|
||||
PathBuf::from(&self.sysroot_libdir(compiler, compiler.host)),
|
||||
if compiler.stage == 0 {
|
||||
self.build.rustc_snapshot_libdir()
|
||||
} else {
|
||||
PathBuf::from(&self.sysroot_libdir(compiler, compiler.host))
|
||||
},
|
||||
self.cargo_out(compiler, tool.get_mode(), *host).join("deps"),
|
||||
];
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue