Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up dependency tracking in Rustbuild [1/2] #50904

Merged
merged 5 commits into from
Jun 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/bootstrap/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -806,7 +806,7 @@ impl<'a> Builder<'a> {
);
}

if mode == Mode::Tool {
if mode.is_tool() {
// Tools like cargo and rls don't get debuginfo by default right now, but this can be
// enabled in the config. Adding debuginfo makes them several times larger.
if self.config.rust_debuginfo_tools {
Expand Down Expand Up @@ -871,7 +871,7 @@ impl<'a> Builder<'a> {
//
// If LLVM support is disabled we need to use the snapshot compiler to compile
// build scripts, as the new compiler doesn't support executables.
if mode == Mode::Libstd || !self.config.llvm_enabled {
if mode == Mode::Std || !self.config.llvm_enabled {
cargo
.env("RUSTC_SNAPSHOT", &self.initial_rustc)
.env("RUSTC_SNAPSHOT_LIBDIR", self.rustc_snapshot_libdir());
Expand Down Expand Up @@ -903,7 +903,7 @@ impl<'a> Builder<'a> {
cargo.env("RUSTC_VERBOSE", format!("{}", self.verbosity));

// in std, we want to avoid denying warnings for stage 0 as that makes cfg's painful.
if self.config.deny_warnings && !(mode == Mode::Libstd && stage == 0) {
if self.config.deny_warnings && !(mode == Mode::Std && stage == 0) {
cargo.env("RUSTC_DENY_WARNINGS", "1");
}

Expand Down Expand Up @@ -963,7 +963,7 @@ impl<'a> Builder<'a> {
}

if cmd == "build"
&& mode == Mode::Libstd
&& mode == Mode::Std
&& self.config.extended
&& compiler.is_final_stage(self)
{
Expand Down Expand Up @@ -1012,7 +1012,7 @@ impl<'a> Builder<'a> {
// be resolved because MinGW has the import library. The downside is we
// don't get newer functions from Windows, but we don't use any of them
// anyway.
if mode != Mode::Tool {
if !mode.is_tool() {
cargo.env("WINAPI_NO_BUNDLED_LIBRARIES", "1");
}

Expand Down Expand Up @@ -1751,7 +1751,7 @@ mod __test {
&[test::Crate {
compiler: Compiler { host, stage: 0 },
target: host,
mode: Mode::Libstd,
mode: Mode::Std,
test_kind: test::TestKind::Test,
krate: INTERNER.intern_str("std"),
},]
Expand Down
27 changes: 14 additions & 13 deletions src/bootstrap/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ impl Step for Std {
let target = self.target;
let compiler = builder.compiler(0, builder.config.build);

let out_dir = builder.stage_out(compiler, Mode::Libstd);
let out_dir = builder.stage_out(compiler, Mode::Std);
builder.clear_if_dirty(&out_dir, &builder.rustc(compiler));

let mut cargo = builder.cargo(compiler, Mode::Libstd, target, "check");
let mut cargo = builder.cargo(compiler, Mode::Std, target, "check");
std_cargo(builder, &compiler, target, &mut cargo);

let _folder = builder.fold_output(|| format!("stage{}-std", compiler.stage));
Expand Down Expand Up @@ -87,11 +87,11 @@ impl Step for Rustc {
let compiler = builder.compiler(0, builder.config.build);
let target = self.target;

let stage_out = builder.stage_out(compiler, Mode::Librustc);
let stage_out = builder.stage_out(compiler, Mode::Rustc);
builder.clear_if_dirty(&stage_out, &libstd_stamp(builder, compiler, target));
builder.clear_if_dirty(&stage_out, &libtest_stamp(builder, compiler, target));

let mut cargo = builder.cargo(compiler, Mode::Librustc, target, "check");
let mut cargo = builder.cargo(compiler, Mode::Rustc, target, "check");
rustc_cargo(builder, &mut cargo);

let _folder = builder.fold_output(|| format!("stage{}-rustc", compiler.stage));
Expand Down Expand Up @@ -137,7 +137,7 @@ impl Step for CodegenBackend {
let target = self.target;
let backend = self.backend;

let mut cargo = builder.cargo(compiler, Mode::Librustc, target, "check");
let mut cargo = builder.cargo(compiler, Mode::Codegen, target, "check");
let features = builder.rustc_features().to_string();
cargo.arg("--manifest-path").arg(builder.src.join("src/librustc_codegen_llvm/Cargo.toml"));
rustc_cargo_env(builder, &mut cargo);
Expand Down Expand Up @@ -175,10 +175,10 @@ impl Step for Test {
let compiler = builder.compiler(0, builder.config.build);
let target = self.target;

let out_dir = builder.stage_out(compiler, Mode::Libtest);
let out_dir = builder.stage_out(compiler, Mode::Test);
builder.clear_if_dirty(&out_dir, &libstd_stamp(builder, compiler, target));

let mut cargo = builder.cargo(compiler, Mode::Libtest, target, "check");
let mut cargo = builder.cargo(compiler, Mode::Test, target, "check");
test_cargo(builder, &compiler, target, &mut cargo);

let _folder = builder.fold_output(|| format!("stage{}-test", compiler.stage));
Expand Down Expand Up @@ -219,6 +219,7 @@ impl Step for Rustdoc {

let mut cargo = prepare_tool_cargo(builder,
compiler,
Mode::ToolRustc,
target,
"check",
"src/tools/rustdoc");
Expand All @@ -236,27 +237,27 @@ impl Step for Rustdoc {
builder.ensure(tool::CleanTools {
compiler,
target,
mode: Mode::Tool,
cause: Mode::Rustc,
});
}
}

/// Cargo's output path for the standard library in a given stage, compiled
/// by a particular compiler for the specified target.
pub fn libstd_stamp(builder: &Builder, compiler: Compiler, target: Interned<String>) -> PathBuf {
builder.cargo_out(compiler, Mode::Libstd, target).join(".libstd-check.stamp")
builder.cargo_out(compiler, Mode::Std, target).join(".libstd-check.stamp")
}

/// Cargo's output path for libtest in a given stage, compiled by a particular
/// compiler for the specified target.
pub fn libtest_stamp(builder: &Builder, compiler: Compiler, target: Interned<String>) -> PathBuf {
builder.cargo_out(compiler, Mode::Libtest, target).join(".libtest-check.stamp")
builder.cargo_out(compiler, Mode::Test, target).join(".libtest-check.stamp")
}

/// Cargo's output path for librustc in a given stage, compiled by a particular
/// compiler for the specified target.
pub fn librustc_stamp(builder: &Builder, compiler: Compiler, target: Interned<String>) -> PathBuf {
builder.cargo_out(compiler, Mode::Librustc, target).join(".librustc-check.stamp")
builder.cargo_out(compiler, Mode::Rustc, target).join(".librustc-check.stamp")
}

/// Cargo's output path for librustc_codegen_llvm in a given stage, compiled by a particular
Expand All @@ -265,12 +266,12 @@ fn codegen_backend_stamp(builder: &Builder,
compiler: Compiler,
target: Interned<String>,
backend: Interned<String>) -> PathBuf {
builder.cargo_out(compiler, Mode::Librustc, target)
builder.cargo_out(compiler, Mode::Codegen, target)
.join(format!(".librustc_codegen_llvm-{}-check.stamp", backend))
}

/// 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::Tool, target).join(".rustdoc-check.stamp")
builder.cargo_out(compiler, Mode::ToolRustc, target).join(".rustdoc-check.stamp")
}
32 changes: 16 additions & 16 deletions src/bootstrap/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ impl Step for Std {
copy_musl_third_party_objects(builder, target, &libdir);
}

let out_dir = builder.cargo_out(compiler, Mode::Libstd, target);
let out_dir = builder.cargo_out(compiler, Mode::Std, target);
builder.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::Std, target, "build");
std_cargo(builder, &compiler, target, &mut cargo);

let _folder = builder.fold_output(|| format!("stage{}-std", compiler.stage));
Expand Down Expand Up @@ -240,7 +240,7 @@ impl Step for StdLink {
builder.ensure(tool::CleanTools {
compiler: target_compiler,
target,
mode: Mode::Libstd,
cause: Mode::Std,
});
}
}
Expand Down Expand Up @@ -368,9 +368,9 @@ impl Step for Test {
return;
}

let out_dir = builder.cargo_out(compiler, Mode::Libtest, target);
let out_dir = builder.cargo_out(compiler, Mode::Test, target);
builder.clear_if_dirty(&out_dir, &libstd_stamp(builder, compiler, target));
let mut cargo = builder.cargo(compiler, Mode::Libtest, target, "build");
let mut cargo = builder.cargo(compiler, Mode::Test, target, "build");
test_cargo(builder, &compiler, target, &mut cargo);

let _folder = builder.fold_output(|| format!("stage{}-test", compiler.stage));
Expand Down Expand Up @@ -431,7 +431,7 @@ impl Step for TestLink {
builder.ensure(tool::CleanTools {
compiler: target_compiler,
target,
mode: Mode::Libtest,
cause: Mode::Test,
});
}
}
Expand Down Expand Up @@ -489,11 +489,11 @@ impl Step for Rustc {
compiler: builder.compiler(self.compiler.stage, builder.config.build),
target: builder.config.build,
});
let cargo_out = builder.cargo_out(compiler, Mode::Librustc, target);
let cargo_out = builder.cargo_out(compiler, Mode::Rustc, target);
builder.clear_if_dirty(&cargo_out, &libstd_stamp(builder, compiler, target));
builder.clear_if_dirty(&cargo_out, &libtest_stamp(builder, compiler, target));

let mut cargo = builder.cargo(compiler, Mode::Librustc, target, "build");
let mut cargo = builder.cargo(compiler, Mode::Rustc, target, "build");
rustc_cargo(builder, &mut cargo);

let _folder = builder.fold_output(|| format!("stage{}-rustc", compiler.stage));
Expand Down Expand Up @@ -585,7 +585,7 @@ impl Step for RustcLink {
builder.ensure(tool::CleanTools {
compiler: target_compiler,
target,
mode: Mode::Librustc,
cause: Mode::Rustc,
});
}
}
Expand Down Expand Up @@ -634,15 +634,15 @@ impl Step for CodegenBackend {
return;
}

let mut cargo = builder.cargo(compiler, Mode::Librustc, target, "build");
let mut cargo = builder.cargo(compiler, Mode::Codegen, target, "build");
let mut features = builder.rustc_features().to_string();
cargo.arg("--manifest-path")
.arg(builder.src.join("src/librustc_codegen_llvm/Cargo.toml"));
rustc_cargo_env(builder, &mut cargo);

features += &build_codegen_backend(&builder, &mut cargo, &compiler, target, backend);

let tmp_stamp = builder.cargo_out(compiler, Mode::Librustc, target)
let tmp_stamp = builder.cargo_out(compiler, Mode::Codegen, target)
.join(".tmp.stamp");

let _folder = builder.fold_output(|| format!("stage{}-rustc_codegen_llvm", compiler.stage));
Expand Down Expand Up @@ -793,19 +793,19 @@ fn copy_lld_to_sysroot(builder: &Builder,
/// Cargo's output path for the standard library in a given stage, compiled
/// by a particular compiler for the specified target.
pub fn libstd_stamp(builder: &Builder, compiler: Compiler, target: Interned<String>) -> PathBuf {
builder.cargo_out(compiler, Mode::Libstd, target).join(".libstd.stamp")
builder.cargo_out(compiler, Mode::Std, target).join(".libstd.stamp")
}

/// Cargo's output path for libtest in a given stage, compiled by a particular
/// compiler for the specified target.
pub fn libtest_stamp(builder: &Builder, compiler: Compiler, target: Interned<String>) -> PathBuf {
builder.cargo_out(compiler, Mode::Libtest, target).join(".libtest.stamp")
builder.cargo_out(compiler, Mode::Test, target).join(".libtest.stamp")
}

/// Cargo's output path for librustc in a given stage, compiled by a particular
/// compiler for the specified target.
pub fn librustc_stamp(builder: &Builder, compiler: Compiler, target: Interned<String>) -> PathBuf {
builder.cargo_out(compiler, Mode::Librustc, target).join(".librustc.stamp")
builder.cargo_out(compiler, Mode::Rustc, target).join(".librustc.stamp")
}

/// Cargo's output path for librustc_codegen_llvm in a given stage, compiled by a particular
Expand All @@ -814,7 +814,7 @@ fn codegen_backend_stamp(builder: &Builder,
compiler: Compiler,
target: Interned<String>,
backend: Interned<String>) -> PathBuf {
builder.cargo_out(compiler, Mode::Librustc, target)
builder.cargo_out(compiler, Mode::Codegen, target)
.join(format!(".librustc_codegen_llvm-{}.stamp", backend))
}

Expand Down Expand Up @@ -971,7 +971,7 @@ impl Step for Assemble {
}

// Link the compiler binary itself into place
let out_dir = builder.cargo_out(build_compiler, Mode::Librustc, host);
let out_dir = builder.cargo_out(build_compiler, Mode::Rustc, host);
let rustc = out_dir.join(exe("rustc_binary", &*host));
let bindir = sysroot.join("bin");
t!(fs::create_dir_all(&bindir));
Expand Down
4 changes: 2 additions & 2 deletions src/bootstrap/dist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -722,7 +722,7 @@ impl Step for Analysis {

let image = tmpdir(builder).join(format!("{}-{}-image", name, target));

let src = builder.stage_out(compiler, Mode::Libstd)
let src = builder.stage_out(compiler, Mode::Std)
.join(target).join(builder.cargo_dir()).join("deps");

let image_src = src.join("save-analysis");
Expand Down Expand Up @@ -953,7 +953,7 @@ impl Step for PlainSourceTarball {
if !has_cargo_vendor {
let mut cmd = builder.cargo(
builder.compiler(0, builder.config.build),
Mode::Tool,
Mode::ToolRustc,
builder.config.build,
"install"
);
Expand Down
22 changes: 12 additions & 10 deletions src/bootstrap/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ impl Step for Std {
};

builder.ensure(compile::Std { compiler, target });
let out_dir = builder.stage_out(compiler, Mode::Libstd)
let out_dir = builder.stage_out(compiler, Mode::Std)
.join(target).join("doc");

// Here what we're doing is creating a *symlink* (directory junction on
Expand All @@ -483,7 +483,7 @@ impl Step for Std {
builder.clear_if_dirty(&my_out, &rustdoc);
t!(symlink_dir_force(&builder.config, &my_out, &out_dir));

let mut cargo = builder.cargo(compiler, Mode::Libstd, target, "doc");
let mut cargo = builder.cargo(compiler, Mode::Std, target, "doc");
compile::std_cargo(builder, &compiler, target, &mut cargo);

// Keep a whitelist so we do not build internal stdlib crates, these will be
Expand Down Expand Up @@ -546,15 +546,15 @@ impl Step for Test {
builder.ensure(Std { stage, target });

builder.ensure(compile::Test { compiler, target });
let out_dir = builder.stage_out(compiler, Mode::Libtest)
let out_dir = builder.stage_out(compiler, Mode::Test)
.join(target).join("doc");

// See docs in std above for why we symlink
let my_out = builder.crate_doc_out(target);
builder.clear_if_dirty(&my_out, &rustdoc);
t!(symlink_dir_force(&builder.config, &my_out, &out_dir));

let mut cargo = builder.cargo(compiler, Mode::Libtest, target, "doc");
let mut cargo = builder.cargo(compiler, Mode::Test, target, "doc");
compile::test_cargo(builder, &compiler, target, &mut cargo);

cargo.arg("--no-deps").arg("-p").arg("test");
Expand Down Expand Up @@ -614,15 +614,15 @@ impl Step for WhitelistedRustc {
builder.ensure(Std { stage, target });

builder.ensure(compile::Rustc { compiler, target });
let out_dir = builder.stage_out(compiler, Mode::Librustc)
let out_dir = builder.stage_out(compiler, Mode::Rustc)
.join(target).join("doc");

// See docs in std above for why we symlink
let my_out = builder.crate_doc_out(target);
builder.clear_if_dirty(&my_out, &rustdoc);
t!(symlink_dir_force(&builder.config, &my_out, &out_dir));

let mut cargo = builder.cargo(compiler, Mode::Librustc, target, "doc");
let mut cargo = builder.cargo(compiler, Mode::Rustc, target, "doc");
compile::rustc_cargo(builder, &mut cargo);

// We don't want to build docs for internal compiler dependencies in this
Expand Down Expand Up @@ -698,12 +698,12 @@ impl Step for Rustc {

// We do not symlink to the same shared folder that already contains std library
// documentation from previous steps as we do not want to include that.
let out_dir = builder.stage_out(compiler, Mode::Librustc).join(target).join("doc");
let out_dir = builder.stage_out(compiler, Mode::Rustc).join(target).join("doc");
builder.clear_if_dirty(&out, &rustdoc);
t!(symlink_dir_force(&builder.config, &out, &out_dir));

// Build cargo command.
let mut cargo = builder.cargo(compiler, Mode::Librustc, target, "doc");
let mut cargo = builder.cargo(compiler, Mode::Rustc, target, "doc");
cargo.env("RUSTDOCFLAGS", "--document-private-items");
compile::rustc_cargo(builder, &mut cargo);

Expand Down Expand Up @@ -799,13 +799,15 @@ 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::Tool).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, target, "doc", "src/tools/rustdoc");
let mut cargo = prepare_tool_cargo(
builder, compiler, Mode::ToolRustc, target, "doc", "src/tools/rustdoc");

cargo.env("RUSTDOCFLAGS", "--document-private-items");
builder.run(&mut cargo);
}
Expand Down
Loading