Skip to content

Commit

Permalink
always run configure_linker except for mir-opt tests
Browse files Browse the repository at this point in the history
`configure_linker` now runs consistently unless it's for mir-opt tests.
 Previously `!= "check"` condition was causing dirt in the cargo cache between
 runs of `x anything-but-not-check` and `x check`

Signed-off-by: onur-ozkan <work@onurozkan.dev>
  • Loading branch information
onur-ozkan committed Feb 8, 2024
1 parent 1280928 commit 993c72f
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 12 deletions.
4 changes: 4 additions & 0 deletions src/bootstrap/src/core/build_steps/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ impl Step for Std {
SourceType::InTree,
target,
cargo_subcommand(builder.kind),
false,
);
std_cargo(builder, target, compiler.stage, &mut cargo);
if matches!(builder.config.cmd, Subcommand::Fix { .. }) {
Expand Down Expand Up @@ -168,6 +169,7 @@ impl Step for Std {
SourceType::InTree,
target,
cargo_subcommand(builder.kind),
false,
);

// If we're not in stage 0, tests and examples will fail to compile
Expand Down Expand Up @@ -262,6 +264,7 @@ impl Step for Rustc {
SourceType::InTree,
target,
cargo_subcommand(builder.kind),
false,
);
rustc_cargo(builder, &mut cargo, target, compiler.stage);

Expand Down Expand Up @@ -338,6 +341,7 @@ impl Step for CodegenBackend {
SourceType::InTree,
target,
cargo_subcommand(builder.kind),
false,
);
cargo
.arg("--manifest-path")
Expand Down
20 changes: 13 additions & 7 deletions src/bootstrap/src/core/build_steps/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,21 +233,25 @@ impl Step for Std {
}
}

let mut cargo = builder.cargo(
compiler,
Mode::Std,
SourceType::InTree,
target,
if self.is_for_mir_opt_tests { "check" } else { "build" },
self.is_for_mir_opt_tests,
);
// We build a sysroot for mir-opt tests using the same trick that Miri does: A check build
// with -Zalways-encode-mir. This frees us from the need to have a target linker, and the
// fact that this is a check build integrates nicely with run_cargo.
let mut cargo = if self.is_for_mir_opt_tests {
let mut cargo = builder.cargo(compiler, Mode::Std, SourceType::InTree, target, "check");
if self.is_for_mir_opt_tests {
cargo.rustflag("-Zalways-encode-mir");
cargo.arg("--manifest-path").arg(builder.src.join("library/sysroot/Cargo.toml"));
cargo
} else {
let mut cargo = builder.cargo(compiler, Mode::Std, SourceType::InTree, target, "build");
std_cargo(builder, target, compiler.stage, &mut cargo);
for krate in &*self.crates {
cargo.arg("-p").arg(krate);
}
cargo
};

// See src/bootstrap/synthetic_targets.rs
Expand Down Expand Up @@ -911,7 +915,8 @@ impl Step for Rustc {
builder.config.build,
));

let mut cargo = builder.cargo(compiler, Mode::Rustc, SourceType::InTree, target, "build");
let mut cargo =
builder.cargo(compiler, Mode::Rustc, SourceType::InTree, target, "build", false);
rustc_cargo(builder, &mut cargo, target, compiler.stage);

if builder.config.rust_profile_use.is_some()
Expand Down Expand Up @@ -1331,7 +1336,8 @@ impl Step for CodegenBackend {

let out_dir = builder.cargo_out(compiler, Mode::Codegen, target);

let mut cargo = builder.cargo(compiler, Mode::Codegen, SourceType::InTree, target, "build");
let mut cargo =
builder.cargo(compiler, Mode::Codegen, SourceType::InTree, target, "build", false);
cargo
.arg("--manifest-path")
.arg(builder.src.join(format!("compiler/rustc_codegen_{backend}/Cargo.toml")));
Expand Down
5 changes: 3 additions & 2 deletions src/bootstrap/src/core/build_steps/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,7 @@ fn doc_std(
// as a function parameter.
let out_dir = target_dir.join(target.triple).join("doc");

let mut cargo = builder.cargo(compiler, Mode::Std, SourceType::InTree, target, "doc");
let mut cargo = builder.cargo(compiler, Mode::Std, SourceType::InTree, target, "doc", false);
compile::std_cargo(builder, target, compiler.stage, &mut cargo);
cargo
.arg("--no-deps")
Expand Down Expand Up @@ -785,7 +785,8 @@ impl Step for Rustc {
);

// Build cargo command.
let mut cargo = builder.cargo(compiler, Mode::Rustc, SourceType::InTree, target, "doc");
let mut cargo =
builder.cargo(compiler, Mode::Rustc, SourceType::InTree, target, "doc", false);
cargo.rustdocflag("--document-private-items");
// Since we always pass --document-private-items, there's no need to warn about linking to private items.
cargo.rustdocflag("-Arustdoc::private-intra-doc-links");
Expand Down
4 changes: 3 additions & 1 deletion src/bootstrap/src/core/build_steps/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2500,7 +2500,7 @@ impl Step for Crate {
let compiler = builder.compiler_for(compiler.stage, compiler.host, target);

let mut cargo =
builder.cargo(compiler, mode, SourceType::InTree, target, builder.kind.as_str());
builder.cargo(compiler, mode, SourceType::InTree, target, builder.kind.as_str(), false);
match mode {
Mode::Std => {
compile::std_cargo(builder, target, compiler.stage, &mut cargo);
Expand Down Expand Up @@ -3140,6 +3140,7 @@ impl Step for CodegenCranelift {
SourceType::InTree,
target,
"run",
false,
);
cargo.current_dir(&builder.src.join("compiler/rustc_codegen_cranelift"));
cargo
Expand Down Expand Up @@ -3266,6 +3267,7 @@ impl Step for CodegenGCC {
SourceType::InTree,
target,
"run",
false,
);
cargo.current_dir(&builder.src.join("compiler/rustc_codegen_gcc"));
cargo
Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/src/core/build_steps/tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ pub fn prepare_tool_cargo(
source_type: SourceType,
extra_features: &[String],
) -> CargoCommand {
let mut cargo = builder.cargo(compiler, mode, source_type, target, command);
let mut cargo = builder.cargo(compiler, mode, source_type, target, command, false);
let dir = builder.src.join(path);
cargo.arg("--manifest-path").arg(dir.join("Cargo.toml"));

Expand Down
3 changes: 2 additions & 1 deletion src/bootstrap/src/core/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1313,6 +1313,7 @@ impl<'a> Builder<'a> {
source_type: SourceType,
target: TargetSelection,
cmd: &str,
is_for_mir_opt_tests: bool,
) -> Cargo {
let mut cargo = self.bare_cargo(compiler, mode, target, cmd);
let out_dir = self.stage_out(compiler, mode);
Expand Down Expand Up @@ -1872,7 +1873,7 @@ impl<'a> Builder<'a> {
rustflags.arg("-Wrustc::internal");
}

if cmd != "check" {
if !is_for_mir_opt_tests {
self.configure_linker(
compiler,
target,
Expand Down

0 comments on commit 993c72f

Please sign in to comment.