always run configure_linker except for mir-opt tests

`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>
This commit is contained in:
onur-ozkan 2024-02-08 21:26:11 +03:00
parent 1280928a99
commit 993c72fdf1
6 changed files with 26 additions and 12 deletions

View file

@ -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 { .. }) {
@ -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
@ -262,6 +264,7 @@ impl Step for Rustc {
SourceType::InTree,
target,
cargo_subcommand(builder.kind),
false,
);
rustc_cargo(builder, &mut cargo, target, compiler.stage);
@ -338,6 +341,7 @@ impl Step for CodegenBackend {
SourceType::InTree,
target,
cargo_subcommand(builder.kind),
false,
);
cargo
.arg("--manifest-path")

View file

@ -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
@ -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()
@ -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")));

View file

@ -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")
@ -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");

View file

@ -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);
@ -3140,6 +3140,7 @@ impl Step for CodegenCranelift {
SourceType::InTree,
target,
"run",
false,
);
cargo.current_dir(&builder.src.join("compiler/rustc_codegen_cranelift"));
cargo
@ -3266,6 +3267,7 @@ impl Step for CodegenGCC {
SourceType::InTree,
target,
"run",
false,
);
cargo.current_dir(&builder.src.join("compiler/rustc_codegen_gcc"));
cargo

View file

@ -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"));

View file

@ -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);
@ -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,