Skip to content

Commit 993c72f

Browse files
committed
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 <[email protected]>
1 parent 1280928 commit 993c72f

File tree

6 files changed

+26
-12
lines changed

6 files changed

+26
-12
lines changed

src/bootstrap/src/core/build_steps/check.rs

+4
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ impl Step for Std {
116116
SourceType::InTree,
117117
target,
118118
cargo_subcommand(builder.kind),
119+
false,
119120
);
120121
std_cargo(builder, target, compiler.stage, &mut cargo);
121122
if matches!(builder.config.cmd, Subcommand::Fix { .. }) {
@@ -168,6 +169,7 @@ impl Step for Std {
168169
SourceType::InTree,
169170
target,
170171
cargo_subcommand(builder.kind),
172+
false,
171173
);
172174

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

@@ -338,6 +341,7 @@ impl Step for CodegenBackend {
338341
SourceType::InTree,
339342
target,
340343
cargo_subcommand(builder.kind),
344+
false,
341345
);
342346
cargo
343347
.arg("--manifest-path")

src/bootstrap/src/core/build_steps/compile.rs

+13-7
Original file line numberDiff line numberDiff line change
@@ -233,21 +233,25 @@ impl Step for Std {
233233
}
234234
}
235235

236+
let mut cargo = builder.cargo(
237+
compiler,
238+
Mode::Std,
239+
SourceType::InTree,
240+
target,
241+
if self.is_for_mir_opt_tests { "check" } else { "build" },
242+
self.is_for_mir_opt_tests,
243+
);
236244
// We build a sysroot for mir-opt tests using the same trick that Miri does: A check build
237245
// with -Zalways-encode-mir. This frees us from the need to have a target linker, and the
238246
// fact that this is a check build integrates nicely with run_cargo.
239-
let mut cargo = if self.is_for_mir_opt_tests {
240-
let mut cargo = builder.cargo(compiler, Mode::Std, SourceType::InTree, target, "check");
247+
if self.is_for_mir_opt_tests {
241248
cargo.rustflag("-Zalways-encode-mir");
242249
cargo.arg("--manifest-path").arg(builder.src.join("library/sysroot/Cargo.toml"));
243-
cargo
244250
} else {
245-
let mut cargo = builder.cargo(compiler, Mode::Std, SourceType::InTree, target, "build");
246251
std_cargo(builder, target, compiler.stage, &mut cargo);
247252
for krate in &*self.crates {
248253
cargo.arg("-p").arg(krate);
249254
}
250-
cargo
251255
};
252256

253257
// See src/bootstrap/synthetic_targets.rs
@@ -911,7 +915,8 @@ impl Step for Rustc {
911915
builder.config.build,
912916
));
913917

914-
let mut cargo = builder.cargo(compiler, Mode::Rustc, SourceType::InTree, target, "build");
918+
let mut cargo =
919+
builder.cargo(compiler, Mode::Rustc, SourceType::InTree, target, "build", false);
915920
rustc_cargo(builder, &mut cargo, target, compiler.stage);
916921

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

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

1334-
let mut cargo = builder.cargo(compiler, Mode::Codegen, SourceType::InTree, target, "build");
1339+
let mut cargo =
1340+
builder.cargo(compiler, Mode::Codegen, SourceType::InTree, target, "build", false);
13351341
cargo
13361342
.arg("--manifest-path")
13371343
.arg(builder.src.join(format!("compiler/rustc_codegen_{backend}/Cargo.toml")));

src/bootstrap/src/core/build_steps/doc.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -684,7 +684,7 @@ fn doc_std(
684684
// as a function parameter.
685685
let out_dir = target_dir.join(target.triple).join("doc");
686686

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

787787
// Build cargo command.
788-
let mut cargo = builder.cargo(compiler, Mode::Rustc, SourceType::InTree, target, "doc");
788+
let mut cargo =
789+
builder.cargo(compiler, Mode::Rustc, SourceType::InTree, target, "doc", false);
789790
cargo.rustdocflag("--document-private-items");
790791
// Since we always pass --document-private-items, there's no need to warn about linking to private items.
791792
cargo.rustdocflag("-Arustdoc::private-intra-doc-links");

src/bootstrap/src/core/build_steps/test.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -2500,7 +2500,7 @@ impl Step for Crate {
25002500
let compiler = builder.compiler_for(compiler.stage, compiler.host, target);
25012501

25022502
let mut cargo =
2503-
builder.cargo(compiler, mode, SourceType::InTree, target, builder.kind.as_str());
2503+
builder.cargo(compiler, mode, SourceType::InTree, target, builder.kind.as_str(), false);
25042504
match mode {
25052505
Mode::Std => {
25062506
compile::std_cargo(builder, target, compiler.stage, &mut cargo);
@@ -3140,6 +3140,7 @@ impl Step for CodegenCranelift {
31403140
SourceType::InTree,
31413141
target,
31423142
"run",
3143+
false,
31433144
);
31443145
cargo.current_dir(&builder.src.join("compiler/rustc_codegen_cranelift"));
31453146
cargo
@@ -3266,6 +3267,7 @@ impl Step for CodegenGCC {
32663267
SourceType::InTree,
32673268
target,
32683269
"run",
3270+
false,
32693271
);
32703272
cargo.current_dir(&builder.src.join("compiler/rustc_codegen_gcc"));
32713273
cargo

src/bootstrap/src/core/build_steps/tool.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ pub fn prepare_tool_cargo(
142142
source_type: SourceType,
143143
extra_features: &[String],
144144
) -> CargoCommand {
145-
let mut cargo = builder.cargo(compiler, mode, source_type, target, command);
145+
let mut cargo = builder.cargo(compiler, mode, source_type, target, command, false);
146146
let dir = builder.src.join(path);
147147
cargo.arg("--manifest-path").arg(dir.join("Cargo.toml"));
148148

src/bootstrap/src/core/builder.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1313,6 +1313,7 @@ impl<'a> Builder<'a> {
13131313
source_type: SourceType,
13141314
target: TargetSelection,
13151315
cmd: &str,
1316+
is_for_mir_opt_tests: bool,
13161317
) -> Cargo {
13171318
let mut cargo = self.bare_cargo(compiler, mode, target, cmd);
13181319
let out_dir = self.stage_out(compiler, mode);
@@ -1872,7 +1873,7 @@ impl<'a> Builder<'a> {
18721873
rustflags.arg("-Wrustc::internal");
18731874
}
18741875

1875-
if cmd != "check" {
1876+
if !is_for_mir_opt_tests {
18761877
self.configure_linker(
18771878
compiler,
18781879
target,

0 commit comments

Comments
 (0)