Finish fixing warnings and errors. Bootstrap builds.

This commit is contained in:
Mark Simulacrum
2017-07-05 11:21:33 -06:00
parent 7db49fb467
commit c114fe576f
7 changed files with 51 additions and 79 deletions

View File

@@ -187,22 +187,6 @@ impl<'a> Builder<'a> {
self.ensure(compile::Assemble { target_compiler: Compiler { stage, host } }) self.ensure(compile::Assemble { target_compiler: Compiler { stage, host } })
} }
pub fn rustc(&self, compiler: Compiler) -> PathBuf {
if compiler.is_snapshot(self) {
self.build.initial_rustc.clone()
} else {
self.compiler(compiler.stage, compiler.host);
self.sysroot(compiler).join("bin").join(exe("rustc", compiler.host))
}
}
pub fn rustdoc(&self, compiler: Compiler) -> PathBuf {
let mut rustdoc = self.rustc(compiler);
rustdoc.pop();
rustdoc.push(exe("rustdoc", compiler.host));
rustdoc
}
pub fn sysroot(&self, compiler: Compiler<'a>) -> PathBuf { pub fn sysroot(&self, compiler: Compiler<'a>) -> PathBuf {
self.ensure(compile::Sysroot { compiler }) self.ensure(compile::Sysroot { compiler })
} }
@@ -254,6 +238,23 @@ impl<'a> Builder<'a> {
add_lib_path(vec![self.rustc_libdir(compiler)], cmd); add_lib_path(vec![self.rustc_libdir(compiler)], cmd);
} }
/// Get a path to the compiler specified.
pub fn rustc(&self, compiler: Compiler) -> PathBuf {
if compiler.is_snapshot(self) {
self.initial_rustc.clone()
} else {
self.sysroot(compiler).join("bin").join(exe("rustc", compiler.host))
}
}
/// Get the `rustdoc` executable next to the specified compiler
pub fn rustdoc(&self, compiler: Compiler) -> PathBuf {
let mut rustdoc = self.rustc(compiler);
rustdoc.pop();
rustdoc.push(exe("rustdoc", compiler.host));
rustdoc
}
/// Prepares an invocation of `cargo` to be run. /// Prepares an invocation of `cargo` to be run.
/// ///
/// This will create a `Command` that represents a pending execution of /// This will create a `Command` that represents a pending execution of
@@ -261,7 +262,7 @@ impl<'a> Builder<'a> {
/// rustc compiler, its output will be scoped by `mode`'s output directory, /// rustc compiler, its output will be scoped by `mode`'s output directory,
/// it will pass the `--target` flag for the specified `target`, and will be /// it will pass the `--target` flag for the specified `target`, and will be
/// executing the Cargo command `cmd`. /// executing the Cargo command `cmd`.
fn cargo(&self, pub fn cargo(&self,
compiler: Compiler, compiler: Compiler,
mode: Mode, mode: Mode,
target: &str, target: &str,
@@ -293,7 +294,7 @@ impl<'a> Builder<'a> {
// src/bootstrap/bin/{rustc.rs,rustdoc.rs} // src/bootstrap/bin/{rustc.rs,rustdoc.rs}
cargo.env("RUSTBUILD_NATIVE_DIR", self.native_dir(target)) cargo.env("RUSTBUILD_NATIVE_DIR", self.native_dir(target))
.env("RUSTC", self.out.join("bootstrap/debug/rustc")) .env("RUSTC", self.out.join("bootstrap/debug/rustc"))
.env("RUSTC_REAL", self.compiler_path(compiler)) .env("RUSTC_REAL", self.rustc(compiler))
.env("RUSTC_STAGE", stage.to_string()) .env("RUSTC_STAGE", stage.to_string())
.env("RUSTC_CODEGEN_UNITS", .env("RUSTC_CODEGEN_UNITS",
self.config.rust_codegen_units.to_string()) self.config.rust_codegen_units.to_string())
@@ -353,7 +354,7 @@ impl<'a> Builder<'a> {
cargo.env("RUSTC_SNAPSHOT", &self.initial_rustc) cargo.env("RUSTC_SNAPSHOT", &self.initial_rustc)
.env("RUSTC_SNAPSHOT_LIBDIR", self.rustc_snapshot_libdir()); .env("RUSTC_SNAPSHOT_LIBDIR", self.rustc_snapshot_libdir());
} else { } else {
cargo.env("RUSTC_SNAPSHOT", self.compiler_path(compiler)) cargo.env("RUSTC_SNAPSHOT", self.rustc(compiler))
.env("RUSTC_SNAPSHOT_LIBDIR", self.rustc_libdir(compiler)); .env("RUSTC_SNAPSHOT_LIBDIR", self.rustc_libdir(compiler));
} }

View File

@@ -170,8 +170,8 @@ impl<'a> Step<'a> for Cargotest<'a> {
let mut cmd = builder.tool_cmd(Tool::CargoTest); let mut cmd = builder.tool_cmd(Tool::CargoTest);
try_run(build, cmd.arg(&build.initial_cargo) try_run(build, cmd.arg(&build.initial_cargo)
.arg(&out_dir) .arg(&out_dir)
.env("RUSTC", build.compiler_path(compiler)) .env("RUSTC", builder.rustc(compiler))
.env("RUSTDOC", build.rustdoc(compiler))); .env("RUSTDOC", builder.rustdoc(compiler)));
} }
} }
@@ -215,7 +215,7 @@ impl<'a> Step<'a> for Cargo<'a> {
iter::once(path).chain(env::split_paths(&old_path)) iter::once(path).chain(env::split_paths(&old_path))
).expect(""); ).expect("");
let mut cargo = build.cargo(compiler, Mode::Tool, self.host, "test"); let mut cargo = builder.cargo(compiler, Mode::Tool, self.host, "test");
cargo.arg("--manifest-path").arg(build.src.join("src/tools/cargo/Cargo.toml")); cargo.arg("--manifest-path").arg(build.src.join("src/tools/cargo/Cargo.toml"));
if !build.fail_fast { if !build.fail_fast {
cargo.arg("--no-fail-fast"); cargo.arg("--no-fail-fast");
@@ -584,10 +584,10 @@ impl<'a> Step<'a> for Compiletest<'a> {
// compiletest currently has... a lot of arguments, so let's just pass all // compiletest currently has... a lot of arguments, so let's just pass all
// of them! // of them!
cmd.arg("--compile-lib-path").arg(build.rustc_libdir(compiler)); cmd.arg("--compile-lib-path").arg(builder.rustc_libdir(compiler));
cmd.arg("--run-lib-path").arg(builder.sysroot_libdir(compiler, target)); cmd.arg("--run-lib-path").arg(builder.sysroot_libdir(compiler, target));
cmd.arg("--rustc-path").arg(build.compiler_path(compiler)); cmd.arg("--rustc-path").arg(builder.rustc(compiler));
cmd.arg("--rustdoc-path").arg(build.rustdoc(compiler)); cmd.arg("--rustdoc-path").arg(builder.rustdoc(compiler));
cmd.arg("--src-base").arg(build.src.join("src/test").join(suite)); cmd.arg("--src-base").arg(build.src.join("src/test").join(suite));
cmd.arg("--build-base").arg(testdir(build, compiler.host).join(suite)); cmd.arg("--build-base").arg(testdir(build, compiler.host).join(suite));
cmd.arg("--stage-id").arg(format!("stage{}-{}", compiler.stage, target)); cmd.arg("--stage-id").arg(format!("stage{}-{}", compiler.stage, target));
@@ -806,11 +806,12 @@ impl<'a> Step<'a> for ErrorIndex<'a> {
.arg(&output) .arg(&output)
.env("CFG_BUILD", &build.build)); .env("CFG_BUILD", &build.build));
markdown_test(build, compiler, &output); markdown_test(builder, compiler, &output);
} }
} }
fn markdown_test(build: &Build, compiler: Compiler, markdown: &Path) { fn markdown_test(builder: &Builder, compiler: Compiler, markdown: &Path) {
let build = builder.build;
let mut file = t!(File::open(markdown)); let mut file = t!(File::open(markdown));
let mut contents = String::new(); let mut contents = String::new();
t!(file.read_to_string(&mut contents)); t!(file.read_to_string(&mut contents));
@@ -819,8 +820,8 @@ fn markdown_test(build: &Build, compiler: Compiler, markdown: &Path) {
} }
println!("doc tests for: {}", markdown.display()); println!("doc tests for: {}", markdown.display());
let mut cmd = Command::new(build.rustdoc(compiler)); let mut cmd = Command::new(builder.rustdoc(compiler));
build.add_rustc_lib_path(compiler, &mut cmd); builder.add_rustc_lib_path(compiler, &mut cmd);
build.add_rust_test_threads(&mut cmd); build.add_rust_test_threads(&mut cmd);
cmd.arg("--test"); cmd.arg("--test");
cmd.arg(markdown); cmd.arg(markdown);
@@ -1071,7 +1072,7 @@ impl<'a> Step<'a> for Krate<'a> {
// Pass in some standard flags then iterate over the graph we've discovered // Pass in some standard flags then iterate over the graph we've discovered
// in `cargo metadata` with the maps above and figure out what `-p` // in `cargo metadata` with the maps above and figure out what `-p`
// arguments need to get passed. // arguments need to get passed.
let mut cargo = build.cargo(compiler, mode, target, test_kind.subcommand()); let mut cargo = builder.cargo(compiler, mode, target, test_kind.subcommand());
cargo.arg("--manifest-path") cargo.arg("--manifest-path")
.arg(build.src.join(path).join("Cargo.toml")) .arg(build.src.join(path).join("Cargo.toml"))
.arg("--features").arg(features); .arg("--features").arg(features);

View File

@@ -196,7 +196,7 @@ impl<'a> Step<'a> for Std<'a> {
compiler.host, target); compiler.host, target);
let out_dir = build.cargo_out(compiler, Mode::Libstd, target); let out_dir = build.cargo_out(compiler, Mode::Libstd, target);
build.clear_if_dirty(&out_dir, &build.compiler_path(compiler)); build.clear_if_dirty(&out_dir, &builder.rustc(compiler));
let mut cargo = builder.cargo(compiler, Mode::Libstd, target, "build"); let mut cargo = builder.cargo(compiler, Mode::Libstd, target, "build");
let mut features = build.std_features(); let mut features = build.std_features();
@@ -365,7 +365,7 @@ impl<'a> Step<'a> for StartupObjects<'a> {
} }
let compiler = builder.compiler(0, &build.build); let compiler = builder.compiler(0, &build.build);
let compiler_path = build.compiler_path(compiler); let compiler_path = builder.rustc(compiler);
let src_dir = &build.src.join("src/rtstartup"); let src_dir = &build.src.join("src/rtstartup");
let dst_dir = &build.native_dir(target).join("rtstartup"); let dst_dir = &build.native_dir(target).join("rtstartup");
let sysroot_dir = &builder.sysroot_libdir(for_compiler, target); let sysroot_dir = &builder.sysroot_libdir(for_compiler, target);
@@ -454,7 +454,7 @@ impl<'a> Step<'a> for Test<'a> {
compiler.host, target); compiler.host, target);
let out_dir = build.cargo_out(compiler, Mode::Libtest, target); let out_dir = build.cargo_out(compiler, Mode::Libtest, target);
build.clear_if_dirty(&out_dir, &libstd_stamp(build, compiler, target)); build.clear_if_dirty(&out_dir, &libstd_stamp(build, compiler, target));
let mut cargo = build.cargo(compiler, Mode::Libtest, target, "build"); let mut cargo = builder.cargo(compiler, Mode::Libtest, target, "build");
if let Some(target) = env::var_os("MACOSX_STD_DEPLOYMENT_TARGET") { if let Some(target) = env::var_os("MACOSX_STD_DEPLOYMENT_TARGET") {
cargo.env("MACOSX_DEPLOYMENT_TARGET", target); cargo.env("MACOSX_DEPLOYMENT_TARGET", target);
} }
@@ -465,7 +465,7 @@ impl<'a> Step<'a> for Test<'a> {
&libtest_stamp(build, compiler, target)); &libtest_stamp(build, compiler, target));
builder.ensure(TestLink { builder.ensure(TestLink {
compiler: builder.compiler(1, &build.build), compiler: builder.compiler(compiler.stage, &build.build),
target_compiler: compiler, target_compiler: compiler,
target: target, target: target,
}); });
@@ -583,7 +583,7 @@ impl<'a> Step<'a> for Rustc<'a> {
let out_dir = build.cargo_out(compiler, Mode::Librustc, target); let out_dir = build.cargo_out(compiler, Mode::Librustc, target);
build.clear_if_dirty(&out_dir, &libtest_stamp(build, compiler, target)); build.clear_if_dirty(&out_dir, &libtest_stamp(build, compiler, target));
let mut cargo = build.cargo(compiler, Mode::Librustc, target, "build"); let mut cargo = builder.cargo(compiler, Mode::Librustc, target, "build");
cargo.arg("--features").arg(build.rustc_features()) cargo.arg("--features").arg(build.rustc_features())
.arg("--manifest-path") .arg("--manifest-path")
.arg(build.src.join("src/rustc/Cargo.toml")); .arg(build.src.join("src/rustc/Cargo.toml"));
@@ -838,7 +838,7 @@ impl<'a> Step<'a> for Assemble<'a> {
let rustc = out_dir.join(exe("rustc", host)); let rustc = out_dir.join(exe("rustc", host));
let bindir = sysroot.join("bin"); let bindir = sysroot.join("bin");
t!(fs::create_dir_all(&bindir)); t!(fs::create_dir_all(&bindir));
let compiler = build.compiler_path(target_compiler); let compiler = builder.rustc(target_compiler);
let _ = fs::remove_file(&compiler); let _ = fs::remove_file(&compiler);
copy(&rustc, &compiler); copy(&rustc, &compiler);

View File

@@ -998,7 +998,7 @@ impl<'a> Step<'a> for Cargo<'a> {
let etc = src.join("src/etc"); let etc = src.join("src/etc");
let release_num = build.release_num("cargo"); let release_num = build.release_num("cargo");
let name = pkgname(build, "cargo"); let name = pkgname(build, "cargo");
let version = build.cargo_info.version(build, &release_num); let version = builder.cargo_info.version(build, &release_num);
let tmp = tmpdir(build); let tmp = tmpdir(build);
let image = tmp.join("cargo-image"); let image = tmp.join("cargo-image");

View File

@@ -271,7 +271,7 @@ fn invoke_rustdoc(builder: &Builder, target: &str, markdown: &str) {
let path = build.src.join("src/doc").join(markdown); let path = build.src.join("src/doc").join(markdown);
let rustdoc = build.rustdoc(compiler); let rustdoc = builder.rustdoc(compiler);
let favicon = build.src.join("src/doc/favicon.inc"); let favicon = build.src.join("src/doc/favicon.inc");
let footer = build.src.join("src/doc/footer.inc"); let footer = build.src.join("src/doc/footer.inc");
@@ -290,7 +290,7 @@ fn invoke_rustdoc(builder: &Builder, target: &str, markdown: &str) {
let mut cmd = Command::new(&rustdoc); let mut cmd = Command::new(&rustdoc);
build.add_rustc_lib_path(compiler, &mut cmd); builder.add_rustc_lib_path(compiler, &mut cmd);
let out = out.join("book"); let out = out.join("book");
@@ -386,7 +386,7 @@ impl<'a> Step<'a> for Standalone<'a> {
} }
let html = out.join(filename).with_extension("html"); let html = out.join(filename).with_extension("html");
let rustdoc = build.rustdoc(compiler); let rustdoc = builder.rustdoc(compiler);
if up_to_date(&path, &html) && if up_to_date(&path, &html) &&
up_to_date(&footer, &html) && up_to_date(&footer, &html) &&
up_to_date(&favicon, &html) && up_to_date(&favicon, &html) &&
@@ -397,7 +397,7 @@ impl<'a> Step<'a> for Standalone<'a> {
} }
let mut cmd = Command::new(&rustdoc); let mut cmd = Command::new(&rustdoc);
build.add_rustc_lib_path(compiler, &mut cmd); builder.add_rustc_lib_path(compiler, &mut cmd);
cmd.arg("--html-after-content").arg(&footer) cmd.arg("--html-after-content").arg(&footer)
.arg("--html-before-content").arg(&version_info) .arg("--html-before-content").arg(&version_info)
.arg("--html-in-header").arg(&favicon) .arg("--html-in-header").arg(&favicon)
@@ -483,7 +483,7 @@ impl<'a> Step<'a> for Std<'a> {
builder.ensure(compile::Std { compiler, target }); builder.ensure(compile::Std { compiler, target });
let out_dir = build.stage_out(compiler, Mode::Libstd) let out_dir = build.stage_out(compiler, Mode::Libstd)
.join(target).join("doc"); .join(target).join("doc");
let rustdoc = build.rustdoc(compiler); let rustdoc = builder.rustdoc(compiler);
// Here what we're doing is creating a *symlink* (directory junction on // Here what we're doing is creating a *symlink* (directory junction on
// Windows) to the final output location. This is not done as an // Windows) to the final output location. This is not done as an
@@ -502,7 +502,7 @@ impl<'a> Step<'a> for Std<'a> {
build.clear_if_dirty(&my_out, &rustdoc); build.clear_if_dirty(&my_out, &rustdoc);
t!(symlink_dir_force(&my_out, &out_dir)); t!(symlink_dir_force(&my_out, &out_dir));
let mut cargo = build.cargo(compiler, Mode::Libstd, target, "doc"); let mut cargo = builder.cargo(compiler, Mode::Libstd, target, "doc");
cargo.arg("--manifest-path") cargo.arg("--manifest-path")
.arg(build.src.join("src/libstd/Cargo.toml")) .arg(build.src.join("src/libstd/Cargo.toml"))
.arg("--features").arg(build.std_features()); .arg("--features").arg(build.std_features());
@@ -597,14 +597,14 @@ impl<'a> Step<'a> for Test<'a> {
builder.ensure(compile::Test { compiler, target }); builder.ensure(compile::Test { compiler, target });
let out_dir = build.stage_out(compiler, Mode::Libtest) let out_dir = build.stage_out(compiler, Mode::Libtest)
.join(target).join("doc"); .join(target).join("doc");
let rustdoc = build.rustdoc(compiler); let rustdoc = builder.rustdoc(compiler);
// See docs in std above for why we symlink // See docs in std above for why we symlink
let my_out = build.crate_doc_out(target); let my_out = build.crate_doc_out(target);
build.clear_if_dirty(&my_out, &rustdoc); build.clear_if_dirty(&my_out, &rustdoc);
t!(symlink_dir_force(&my_out, &out_dir)); t!(symlink_dir_force(&my_out, &out_dir));
let mut cargo = build.cargo(compiler, Mode::Libtest, target, "doc"); let mut cargo = builder.cargo(compiler, Mode::Libtest, target, "doc");
cargo.arg("--manifest-path") cargo.arg("--manifest-path")
.arg(build.src.join("src/libtest/Cargo.toml")); .arg(build.src.join("src/libtest/Cargo.toml"));
build.run(&mut cargo); build.run(&mut cargo);
@@ -685,14 +685,14 @@ impl<'a> Step<'a> for Rustc<'a> {
builder.ensure(compile::Rustc { compiler, target }); builder.ensure(compile::Rustc { compiler, target });
let out_dir = build.stage_out(compiler, Mode::Librustc) let out_dir = build.stage_out(compiler, Mode::Librustc)
.join(target).join("doc"); .join(target).join("doc");
let rustdoc = build.rustdoc(compiler); let rustdoc = builder.rustdoc(compiler);
// See docs in std above for why we symlink // See docs in std above for why we symlink
let my_out = build.crate_doc_out(target); let my_out = build.crate_doc_out(target);
build.clear_if_dirty(&my_out, &rustdoc); build.clear_if_dirty(&my_out, &rustdoc);
t!(symlink_dir_force(&my_out, &out_dir)); t!(symlink_dir_force(&my_out, &out_dir));
let mut cargo = build.cargo(compiler, Mode::Librustc, target, "doc"); let mut cargo = builder.cargo(compiler, Mode::Librustc, target, "doc");
cargo.arg("--manifest-path") cargo.arg("--manifest-path")
.arg(build.src.join("src/rustc/Cargo.toml")) .arg(build.src.join("src/rustc/Cargo.toml"))
.arg("--features").arg(build.rustc_features()); .arg("--features").arg(build.rustc_features());

View File

@@ -96,7 +96,7 @@ use std::process::Command;
use build_helper::{run_silent, run_suppressed, try_run_silent, try_run_suppressed, output, mtime}; use build_helper::{run_silent, run_suppressed, try_run_silent, try_run_suppressed, output, mtime};
use util::{exe, libdir, add_lib_path, OutputFolder, CiEnv}; use util::{exe, libdir, OutputFolder, CiEnv};
mod cc; mod cc;
mod channel; mod channel;
@@ -352,23 +352,6 @@ impl Build {
t!(File::create(stamp)); t!(File::create(stamp));
} }
/// Get a path to the compiler specified.
fn compiler_path(&self, compiler: Compiler) -> PathBuf {
if compiler.is_snapshot(self) {
self.initial_rustc.clone()
} else {
self.sysroot(compiler).join("bin").join(exe("rustc", compiler.host))
}
}
/// Get the `rustdoc` executable next to the specified compiler
fn rustdoc(&self, compiler: Compiler) -> PathBuf {
let mut rustdoc = self.compiler_path(compiler);
rustdoc.pop();
rustdoc.push(exe("rustdoc", compiler.host));
rustdoc
}
/// Get the space-separated set of activated features for the standard /// Get the space-separated set of activated features for the standard
/// library. /// library.
fn std_features(&self) -> String { fn std_features(&self) -> String {
@@ -532,19 +515,6 @@ impl Build {
} }
} }
/// Returns the compiler's libdir where it stores the dynamic libraries that
/// it itself links against.
///
/// For example this returns `<sysroot>/lib` on Unix and `<sysroot>/bin` on
/// Windows.
fn rustc_libdir(&self, compiler: Compiler) -> PathBuf {
if compiler.is_snapshot(self) {
self.rustc_snapshot_libdir()
} else {
self.sysroot(compiler).join(libdir(compiler.host))
}
}
/// Returns the libdir of the snapshot compiler. /// Returns the libdir of the snapshot compiler.
fn rustc_snapshot_libdir(&self) -> PathBuf { fn rustc_snapshot_libdir(&self) -> PathBuf {
self.initial_rustc.parent().unwrap().parent().unwrap() self.initial_rustc.parent().unwrap().parent().unwrap()

View File

@@ -110,7 +110,7 @@ impl<'a> Step<'a> for ToolBuild<'a> {
let _folder = build.fold_output(|| format!("stage{}-{}", stage, tool)); let _folder = build.fold_output(|| format!("stage{}-{}", stage, tool));
println!("Building stage{} tool {} ({})", stage, tool, target); println!("Building stage{} tool {} ({})", stage, tool, target);
let mut cargo = build.cargo(compiler, Mode::Tool, target, "build"); let mut cargo = builder.cargo(compiler, Mode::Tool, target, "build");
let dir = build.src.join("src/tools").join(tool); let dir = build.src.join("src/tools").join(tool);
cargo.arg("--manifest-path").arg(dir.join("Cargo.toml")); cargo.arg("--manifest-path").arg(dir.join("Cargo.toml"));