about summary refs log tree commit diff
diff options
context:
space:
mode:
authoronur-ozkan <work@onurozkan.dev>2024-02-08 21:26:11 +0300
committeronur-ozkan <work@onurozkan.dev>2024-02-08 21:26:11 +0300
commit993c72fdf1976c86fe1dc712b75dc81df49c55b7 (patch)
treec500caa5ba3423b446e8e57d0551b5bb52cb789a
parent1280928a99ad3ef2c5735b42dc8852456ae3b974 (diff)
downloadrust-993c72fdf1976c86fe1dc712b75dc81df49c55b7.tar.gz
rust-993c72fdf1976c86fe1dc712b75dc81df49c55b7.zip
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>
-rw-r--r--src/bootstrap/src/core/build_steps/check.rs4
-rw-r--r--src/bootstrap/src/core/build_steps/compile.rs20
-rw-r--r--src/bootstrap/src/core/build_steps/doc.rs5
-rw-r--r--src/bootstrap/src/core/build_steps/test.rs4
-rw-r--r--src/bootstrap/src/core/build_steps/tool.rs2
-rw-r--r--src/bootstrap/src/core/builder.rs3
6 files changed, 26 insertions, 12 deletions
diff --git a/src/bootstrap/src/core/build_steps/check.rs b/src/bootstrap/src/core/build_steps/check.rs
index 5f0afdb1b36..11360fb7bbc 100644
--- a/src/bootstrap/src/core/build_steps/check.rs
+++ b/src/bootstrap/src/core/build_steps/check.rs
@@ -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")
diff --git a/src/bootstrap/src/core/build_steps/compile.rs b/src/bootstrap/src/core/build_steps/compile.rs
index 73f29d6bb6f..5c4b9dd2008 100644
--- a/src/bootstrap/src/core/build_steps/compile.rs
+++ b/src/bootstrap/src/core/build_steps/compile.rs
@@ -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")));
diff --git a/src/bootstrap/src/core/build_steps/doc.rs b/src/bootstrap/src/core/build_steps/doc.rs
index 57e63927c95..e42d36a60a6 100644
--- a/src/bootstrap/src/core/build_steps/doc.rs
+++ b/src/bootstrap/src/core/build_steps/doc.rs
@@ -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");
diff --git a/src/bootstrap/src/core/build_steps/test.rs b/src/bootstrap/src/core/build_steps/test.rs
index baf1b5a4a1a..8fbd64f8498 100644
--- a/src/bootstrap/src/core/build_steps/test.rs
+++ b/src/bootstrap/src/core/build_steps/test.rs
@@ -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
diff --git a/src/bootstrap/src/core/build_steps/tool.rs b/src/bootstrap/src/core/build_steps/tool.rs
index 5d8d10a7deb..9e3d019e736 100644
--- a/src/bootstrap/src/core/build_steps/tool.rs
+++ b/src/bootstrap/src/core/build_steps/tool.rs
@@ -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"));
 
diff --git a/src/bootstrap/src/core/builder.rs b/src/bootstrap/src/core/builder.rs
index 4bb8ed2fa67..10b686471aa 100644
--- a/src/bootstrap/src/core/builder.rs
+++ b/src/bootstrap/src/core/builder.rs
@@ -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,