about summary refs log tree commit diff
diff options
context:
space:
mode:
authoronur-ozkan <work@onurozkan.dev>2025-01-09 11:03:43 +0300
committeronur-ozkan <work@onurozkan.dev>2025-01-12 08:43:08 +0300
commit9e929754b2bba1bee0431feac879fec71b525382 (patch)
tree28d864768feebbf2e7ac925cb415d279f768644c
parentc68c721b506b4dd2688eaad8dba40a0a4150a874 (diff)
downloadrust-9e929754b2bba1bee0431feac879fec71b525382.tar.gz
rust-9e929754b2bba1bee0431feac879fec71b525382.zip
migrate helper stamp functions
Signed-off-by: onur-ozkan <work@onurozkan.dev>
-rw-r--r--src/bootstrap/src/core/build_steps/check.rs118
-rw-r--r--src/bootstrap/src/core/build_steps/clippy.rs8
-rw-r--r--src/bootstrap/src/core/build_steps/compile.rs52
-rw-r--r--src/bootstrap/src/core/build_steps/dist.rs6
-rw-r--r--src/bootstrap/src/utils/build_stamp.rs36
5 files changed, 79 insertions, 141 deletions
diff --git a/src/bootstrap/src/core/build_steps/check.rs b/src/bootstrap/src/core/build_steps/check.rs
index 4681b4b83eb..d8d862caf6a 100644
--- a/src/bootstrap/src/core/build_steps/check.rs
+++ b/src/bootstrap/src/core/build_steps/check.rs
@@ -8,8 +8,8 @@ use crate::core::builder::{
     self, Alias, Builder, Kind, RunConfig, ShouldRun, Step, crate_description,
 };
 use crate::core::config::TargetSelection;
-use crate::utils::build_stamp::BuildStamp;
-use crate::{Compiler, Mode, Subcommand};
+use crate::utils::build_stamp::{self, BuildStamp};
+use crate::{Mode, Subcommand};
 
 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
 pub struct Std {
@@ -82,22 +82,16 @@ impl Step for Std {
             format_args!("library artifacts{}", crate_description(&self.crates)),
             target,
         );
-        run_cargo(
-            builder,
-            cargo,
-            builder.config.free_args.clone(),
-            &libstd_stamp(builder, compiler, target),
-            vec![],
-            true,
-            false,
-        );
+
+        let stamp = build_stamp::libstd_stamp(builder, compiler, target).with_prefix("check");
+        run_cargo(builder, cargo, builder.config.free_args.clone(), &stamp, vec![], true, false);
 
         // We skip populating the sysroot in non-zero stage because that'll lead
         // to rlib/rmeta conflicts if std gets built during this session.
         if compiler.stage == 0 {
             let libdir = builder.sysroot_target_libdir(compiler, target);
             let hostdir = builder.sysroot_target_libdir(compiler, compiler.host);
-            add_to_sysroot(builder, &libdir, &hostdir, &libstd_stamp(builder, compiler, target));
+            add_to_sysroot(builder, &libdir, &hostdir, &stamp);
         }
         drop(_guard);
 
@@ -138,16 +132,9 @@ impl Step for Std {
             cargo.arg("-p").arg(krate);
         }
 
+        let stamp = build_stamp::libstd_stamp(builder, compiler, target).with_prefix("check-test");
         let _guard = builder.msg_check("library test/bench/example targets", target);
-        run_cargo(
-            builder,
-            cargo,
-            builder.config.free_args.clone(),
-            &libstd_test_stamp(builder, compiler, target),
-            vec![],
-            true,
-            false,
-        );
+        run_cargo(builder, cargo, builder.config.free_args.clone(), &stamp, vec![], true, false);
     }
 }
 
@@ -248,19 +235,14 @@ impl Step for Rustc {
             format_args!("compiler artifacts{}", crate_description(&self.crates)),
             target,
         );
-        run_cargo(
-            builder,
-            cargo,
-            builder.config.free_args.clone(),
-            &librustc_stamp(builder, compiler, target),
-            vec![],
-            true,
-            false,
-        );
+
+        let stamp = build_stamp::librustc_stamp(builder, compiler, target).with_prefix("check");
+
+        run_cargo(builder, cargo, builder.config.free_args.clone(), &stamp, vec![], true, false);
 
         let libdir = builder.sysroot_target_libdir(compiler, target);
         let hostdir = builder.sysroot_target_libdir(compiler, compiler.host);
-        add_to_sysroot(builder, &libdir, &hostdir, &librustc_stamp(builder, compiler, target));
+        add_to_sysroot(builder, &libdir, &hostdir, &stamp);
     }
 }
 
@@ -314,15 +296,10 @@ impl Step for CodegenBackend {
 
         let _guard = builder.msg_check(backend, target);
 
-        run_cargo(
-            builder,
-            cargo,
-            builder.config.free_args.clone(),
-            &codegen_backend_stamp(builder, compiler, target, backend),
-            vec![],
-            true,
-            false,
-        );
+        let stamp = build_stamp::codegen_backend_stamp(builder, compiler, target, backend)
+            .with_prefix("check");
+
+        run_cargo(builder, cargo, builder.config.free_args.clone(), &stamp, vec![], true, false);
     }
 }
 
@@ -379,23 +356,13 @@ impl Step for RustAnalyzer {
             cargo.arg("--benches");
         }
 
-        let _guard = builder.msg_check("rust-analyzer artifacts", target);
-        run_cargo(
-            builder,
-            cargo,
-            builder.config.free_args.clone(),
-            &stamp(builder, compiler, target),
-            vec![],
-            true,
-            false,
-        );
+        // Cargo's output path in a given stage, compiled by a particular
+        // compiler for the specified target.
+        let stamp = BuildStamp::new(&builder.cargo_out(compiler, Mode::ToolRustc, target))
+            .with_prefix("rust-analyzer-check");
 
-        /// Cargo's output path in a given stage, compiled by a particular
-        /// compiler for the specified target.
-        fn stamp(builder: &Builder<'_>, compiler: Compiler, target: TargetSelection) -> BuildStamp {
-            BuildStamp::new(&builder.cargo_out(compiler, Mode::ToolRustc, target))
-                .with_prefix("rust-analyzer-check")
-        }
+        let _guard = builder.msg_check("rust-analyzer artifacts", target);
+        run_cargo(builder, cargo, builder.config.free_args.clone(), &stamp, vec![], true, false);
     }
 }
 
@@ -498,42 +465,3 @@ tool_check_step!(RunMakeSupport { path: "src/tools/run-make-support", default: f
 // Compiletest is implicitly "checked" when it gets built in order to run tests,
 // so this is mainly for people working on compiletest to run locally.
 tool_check_step!(Compiletest { path: "src/tools/compiletest", default: false });
-
-/// Cargo's output path for the standard library in a given stage, compiled
-/// by a particular compiler for the specified target.
-fn libstd_stamp(builder: &Builder<'_>, compiler: Compiler, target: TargetSelection) -> BuildStamp {
-    BuildStamp::new(&builder.cargo_out(compiler, Mode::Std, target)).with_prefix("libstd-check")
-}
-
-/// Cargo's output path for the standard library in a given stage, compiled
-/// by a particular compiler for the specified target.
-fn libstd_test_stamp(
-    builder: &Builder<'_>,
-    compiler: Compiler,
-    target: TargetSelection,
-) -> BuildStamp {
-    BuildStamp::new(&builder.cargo_out(compiler, Mode::Std, target))
-        .with_prefix("libstd-check-test")
-}
-
-/// Cargo's output path for librustc in a given stage, compiled by a particular
-/// compiler for the specified target.
-fn librustc_stamp(
-    builder: &Builder<'_>,
-    compiler: Compiler,
-    target: TargetSelection,
-) -> BuildStamp {
-    BuildStamp::new(&builder.cargo_out(compiler, Mode::Rustc, target)).with_prefix("librustc-check")
-}
-
-/// Cargo's output path for librustc_codegen_llvm in a given stage, compiled by a particular
-/// compiler for the specified target and backend.
-fn codegen_backend_stamp(
-    builder: &Builder<'_>,
-    compiler: Compiler,
-    target: TargetSelection,
-    backend: &str,
-) -> BuildStamp {
-    BuildStamp::new(&builder.cargo_out(compiler, Mode::Codegen, target))
-        .with_prefix(&format!("librustc_codegen_{backend}-check"))
-}
diff --git a/src/bootstrap/src/core/build_steps/clippy.rs b/src/bootstrap/src/core/build_steps/clippy.rs
index be65496035f..fe7e4a77f71 100644
--- a/src/bootstrap/src/core/build_steps/clippy.rs
+++ b/src/bootstrap/src/core/build_steps/clippy.rs
@@ -1,13 +1,13 @@
 //! Implementation of running clippy on the compiler, standard library and various tools.
 
-use super::compile::{librustc_stamp, libstd_stamp, run_cargo, rustc_cargo, std_cargo};
+use super::compile::{run_cargo, rustc_cargo, std_cargo};
 use super::tool::{SourceType, prepare_tool_cargo};
 use super::{check, compile};
 use crate::builder::{Builder, ShouldRun};
 use crate::core::build_steps::compile::std_crates_for_run_make;
 use crate::core::builder;
 use crate::core::builder::{Alias, Kind, RunConfig, Step, crate_description};
-use crate::utils::build_stamp::BuildStamp;
+use crate::utils::build_stamp::{self, BuildStamp};
 use crate::{Mode, Subcommand, TargetSelection};
 
 /// Disable the most spammy clippy lints
@@ -168,7 +168,7 @@ impl Step for Std {
             builder,
             cargo,
             lint_args(builder, &self.config, IGNORED_RULES_FOR_STD_AND_RUSTC),
-            &libstd_stamp(builder, compiler, target),
+            &build_stamp::libstd_stamp(builder, compiler, target),
             vec![],
             true,
             false,
@@ -244,7 +244,7 @@ impl Step for Rustc {
             builder,
             cargo,
             lint_args(builder, &self.config, IGNORED_RULES_FOR_STD_AND_RUSTC),
-            &librustc_stamp(builder, compiler, target),
+            &build_stamp::librustc_stamp(builder, compiler, target),
             vec![],
             true,
             false,
diff --git a/src/bootstrap/src/core/build_steps/compile.rs b/src/bootstrap/src/core/build_steps/compile.rs
index 8d196c321d0..9be8b9cded2 100644
--- a/src/bootstrap/src/core/build_steps/compile.rs
+++ b/src/bootstrap/src/core/build_steps/compile.rs
@@ -24,6 +24,7 @@ use crate::core::builder::{
     Builder, Cargo, Kind, PathSet, RunConfig, ShouldRun, Step, TaskPath, crate_description,
 };
 use crate::core::config::{DebuginfoLevel, LlvmLibunwind, RustcLto, TargetSelection};
+use crate::utils::build_stamp;
 use crate::utils::build_stamp::BuildStamp;
 use crate::utils::exec::command;
 use crate::utils::helpers::{
@@ -255,7 +256,7 @@ impl Step for Std {
             builder,
             cargo,
             vec![],
-            &libstd_stamp(builder, compiler, target),
+            &build_stamp::libstd_stamp(builder, compiler, target),
             target_deps,
             self.is_for_mir_opt_tests, // is_check
             false,
@@ -645,7 +646,12 @@ impl Step for StdLink {
             (libdir, hostdir)
         };
 
-        add_to_sysroot(builder, &libdir, &hostdir, &libstd_stamp(builder, compiler, target));
+        add_to_sysroot(
+            builder,
+            &libdir,
+            &hostdir,
+            &build_stamp::libstd_stamp(builder, compiler, target),
+        );
 
         // Special case for stage0, to make `rustup toolchain link` and `x dist --stage 0`
         // work for stage0-sysroot. We only do this if the stage0 compiler comes from beta,
@@ -974,7 +980,7 @@ impl Step for Rustc {
             compiler.host,
             target,
         );
-        let stamp = librustc_stamp(builder, compiler, target);
+        let stamp = build_stamp::librustc_stamp(builder, compiler, target);
         run_cargo(
             builder,
             cargo,
@@ -1330,7 +1336,7 @@ impl Step for RustcLink {
             builder,
             &builder.sysroot_target_libdir(previous_stage_compiler, target),
             &builder.sysroot_target_libdir(previous_stage_compiler, compiler.host),
-            &librustc_stamp(builder, compiler, target),
+            &build_stamp::librustc_stamp(builder, compiler, target),
         );
     }
 }
@@ -1470,7 +1476,7 @@ impl Step for CodegenBackend {
                 f.display()
             );
         }
-        let stamp = codegen_backend_stamp(builder, compiler, target, &backend);
+        let stamp = build_stamp::codegen_backend_stamp(builder, compiler, target, &backend);
         let codegen_backend = codegen_backend.to_str().unwrap();
         t!(fs::write(stamp, codegen_backend));
     }
@@ -1509,7 +1515,7 @@ fn copy_codegen_backends_to_sysroot(
             continue; // Already built as part of rustc
         }
 
-        let stamp = codegen_backend_stamp(builder, compiler, target, backend);
+        let stamp = build_stamp::codegen_backend_stamp(builder, compiler, target, backend);
         let dylib = t!(fs::read_to_string(&stamp));
         let file = Path::new(&dylib);
         let filename = file.file_name().unwrap().to_str().unwrap();
@@ -1524,38 +1530,6 @@ fn copy_codegen_backends_to_sysroot(
     }
 }
 
-/// 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: TargetSelection,
-) -> BuildStamp {
-    BuildStamp::new(&builder.cargo_out(compiler, Mode::Std, target)).with_prefix("libstd")
-}
-
-/// 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: TargetSelection,
-) -> BuildStamp {
-    BuildStamp::new(&builder.cargo_out(compiler, Mode::Rustc, target)).with_prefix("librustc")
-}
-
-/// Cargo's output path for librustc_codegen_llvm in a given stage, compiled by a particular
-/// compiler for the specified target and backend.
-fn codegen_backend_stamp(
-    builder: &Builder<'_>,
-    compiler: Compiler,
-    target: TargetSelection,
-    backend: &str,
-) -> BuildStamp {
-    BuildStamp::new(&builder.cargo_out(compiler, Mode::Codegen, target))
-        .with_prefix(&format!("librustc_codegen_{backend}"))
-}
-
 pub fn compiler_file(
     builder: &Builder<'_>,
     compiler: &Path,
@@ -1912,7 +1886,7 @@ impl Step for Assemble {
         builder.info(&msg);
 
         // Link in all dylibs to the libdir
-        let stamp = librustc_stamp(builder, build_compiler, target_compiler.host);
+        let stamp = build_stamp::librustc_stamp(builder, build_compiler, target_compiler.host);
         let proc_macros = builder
             .read_stamp_file(&stamp)
             .into_iter()
diff --git a/src/bootstrap/src/core/build_steps/dist.rs b/src/bootstrap/src/core/build_steps/dist.rs
index c6fb1424ac6..8ca087f9941 100644
--- a/src/bootstrap/src/core/build_steps/dist.rs
+++ b/src/bootstrap/src/core/build_steps/dist.rs
@@ -23,7 +23,7 @@ use crate::core::build_steps::vendor::default_paths_to_vendor;
 use crate::core::build_steps::{compile, llvm};
 use crate::core::builder::{Builder, Kind, RunConfig, ShouldRun, Step};
 use crate::core::config::TargetSelection;
-use crate::utils::build_stamp::BuildStamp;
+use crate::utils::build_stamp::{self, BuildStamp};
 use crate::utils::channel::{self, Info};
 use crate::utils::exec::{BootstrapCommand, command};
 use crate::utils::helpers::{
@@ -674,7 +674,7 @@ impl Step for Std {
         tarball.include_target_in_component_name(true);
 
         let compiler_to_use = builder.compiler_for(compiler.stage, compiler.host, target);
-        let stamp = compile::libstd_stamp(builder, compiler_to_use, target);
+        let stamp = build_stamp::libstd_stamp(builder, compiler_to_use, target);
         verify_uefi_rlib_format(builder, target, &stamp);
         copy_target_libs(builder, target, tarball.image_dir(), &stamp);
 
@@ -724,7 +724,7 @@ impl Step for RustcDev {
         let tarball = Tarball::new(builder, "rustc-dev", &target.triple);
 
         let compiler_to_use = builder.compiler_for(compiler.stage, compiler.host, target);
-        let stamp = compile::librustc_stamp(builder, compiler_to_use, target);
+        let stamp = build_stamp::librustc_stamp(builder, compiler_to_use, target);
         copy_target_libs(builder, target, tarball.image_dir(), &stamp);
 
         let src_files = &["Cargo.lock"];
diff --git a/src/bootstrap/src/utils/build_stamp.rs b/src/bootstrap/src/utils/build_stamp.rs
index 67a9e9d1204..01377957902 100644
--- a/src/bootstrap/src/utils/build_stamp.rs
+++ b/src/bootstrap/src/utils/build_stamp.rs
@@ -1,6 +1,10 @@
 use std::path::{Path, PathBuf};
 use std::{fs, io};
 
+use crate::core::builder::Builder;
+use crate::core::config::TargetSelection;
+use crate::{Compiler, Mode};
+
 #[derive(Clone)]
 pub struct BuildStamp {
     path: PathBuf,
@@ -69,3 +73,35 @@ impl BuildStamp {
         }
     }
 }
+
+/// Cargo's output path for librustc_codegen_llvm in a given stage, compiled by a particular
+/// compiler for the specified target and backend.
+pub fn codegen_backend_stamp(
+    builder: &Builder<'_>,
+    compiler: Compiler,
+    target: TargetSelection,
+    backend: &str,
+) -> BuildStamp {
+    BuildStamp::new(&builder.cargo_out(compiler, Mode::Codegen, target))
+        .with_prefix(&format!("librustc_codegen_{backend}"))
+}
+
+/// 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: TargetSelection,
+) -> BuildStamp {
+    BuildStamp::new(&builder.cargo_out(compiler, Mode::Std, target)).with_prefix("libstd")
+}
+
+/// 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: TargetSelection,
+) -> BuildStamp {
+    BuildStamp::new(&builder.cargo_out(compiler, Mode::Rustc, target)).with_prefix("librustc")
+}