11//! Implementation of compiling the compiler and standard library, in "check"-based modes.
22
3- use std:: path:: PathBuf ;
4-
53use crate :: core:: build_steps:: compile:: {
64 add_to_sysroot, run_cargo, rustc_cargo, rustc_cargo_env, std_cargo, std_crates_for_run_make,
75} ;
@@ -10,7 +8,8 @@ use crate::core::builder::{
108 self , Alias , Builder , Kind , RunConfig , ShouldRun , Step , crate_description,
119} ;
1210use crate :: core:: config:: TargetSelection ;
13- use crate :: { Compiler , Mode , Subcommand } ;
11+ use crate :: utils:: build_stamp:: { self , BuildStamp } ;
12+ use crate :: { Mode , Subcommand } ;
1413
1514#[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
1615pub struct Std {
@@ -83,22 +82,16 @@ impl Step for Std {
8382 format_args ! ( "library artifacts{}" , crate_description( & self . crates) ) ,
8483 target,
8584 ) ;
86- run_cargo (
87- builder,
88- cargo,
89- builder. config . free_args . clone ( ) ,
90- & libstd_stamp ( builder, compiler, target) ,
91- vec ! [ ] ,
92- true ,
93- false ,
94- ) ;
85+
86+ let stamp = build_stamp:: libstd_stamp ( builder, compiler, target) . with_prefix ( "check" ) ;
87+ run_cargo ( builder, cargo, builder. config . free_args . clone ( ) , & stamp, vec ! [ ] , true , false ) ;
9588
9689 // We skip populating the sysroot in non-zero stage because that'll lead
9790 // to rlib/rmeta conflicts if std gets built during this session.
9891 if compiler. stage == 0 {
9992 let libdir = builder. sysroot_target_libdir ( compiler, target) ;
10093 let hostdir = builder. sysroot_target_libdir ( compiler, compiler. host ) ;
101- add_to_sysroot ( builder, & libdir, & hostdir, & libstd_stamp ( builder , compiler , target ) ) ;
94+ add_to_sysroot ( builder, & libdir, & hostdir, & stamp ) ;
10295 }
10396 drop ( _guard) ;
10497
@@ -139,16 +132,9 @@ impl Step for Std {
139132 cargo. arg ( "-p" ) . arg ( krate) ;
140133 }
141134
135+ let stamp = build_stamp:: libstd_stamp ( builder, compiler, target) . with_prefix ( "check-test" ) ;
142136 let _guard = builder. msg_check ( "library test/bench/example targets" , target) ;
143- run_cargo (
144- builder,
145- cargo,
146- builder. config . free_args . clone ( ) ,
147- & libstd_test_stamp ( builder, compiler, target) ,
148- vec ! [ ] ,
149- true ,
150- false ,
151- ) ;
137+ run_cargo ( builder, cargo, builder. config . free_args . clone ( ) , & stamp, vec ! [ ] , true , false ) ;
152138 }
153139}
154140
@@ -249,19 +235,14 @@ impl Step for Rustc {
249235 format_args ! ( "compiler artifacts{}" , crate_description( & self . crates) ) ,
250236 target,
251237 ) ;
252- run_cargo (
253- builder,
254- cargo,
255- builder. config . free_args . clone ( ) ,
256- & librustc_stamp ( builder, compiler, target) ,
257- vec ! [ ] ,
258- true ,
259- false ,
260- ) ;
238+
239+ let stamp = build_stamp:: librustc_stamp ( builder, compiler, target) . with_prefix ( "check" ) ;
240+
241+ run_cargo ( builder, cargo, builder. config . free_args . clone ( ) , & stamp, vec ! [ ] , true , false ) ;
261242
262243 let libdir = builder. sysroot_target_libdir ( compiler, target) ;
263244 let hostdir = builder. sysroot_target_libdir ( compiler, compiler. host ) ;
264- add_to_sysroot ( builder, & libdir, & hostdir, & librustc_stamp ( builder , compiler , target ) ) ;
245+ add_to_sysroot ( builder, & libdir, & hostdir, & stamp ) ;
265246 }
266247}
267248
@@ -315,15 +296,10 @@ impl Step for CodegenBackend {
315296
316297 let _guard = builder. msg_check ( backend, target) ;
317298
318- run_cargo (
319- builder,
320- cargo,
321- builder. config . free_args . clone ( ) ,
322- & codegen_backend_stamp ( builder, compiler, target, backend) ,
323- vec ! [ ] ,
324- true ,
325- false ,
326- ) ;
299+ let stamp = build_stamp:: codegen_backend_stamp ( builder, compiler, target, backend)
300+ . with_prefix ( "check" ) ;
301+
302+ run_cargo ( builder, cargo, builder. config . free_args . clone ( ) , & stamp, vec ! [ ] , true , false ) ;
327303 }
328304}
329305
@@ -380,22 +356,13 @@ impl Step for RustAnalyzer {
380356 cargo. arg ( "--benches" ) ;
381357 }
382358
383- let _guard = builder. msg_check ( "rust-analyzer artifacts" , target) ;
384- run_cargo (
385- builder,
386- cargo,
387- builder. config . free_args . clone ( ) ,
388- & stamp ( builder, compiler, target) ,
389- vec ! [ ] ,
390- true ,
391- false ,
392- ) ;
359+ // Cargo's output path in a given stage, compiled by a particular
360+ // compiler for the specified target.
361+ let stamp = BuildStamp :: new ( & builder. cargo_out ( compiler, Mode :: ToolRustc , target) )
362+ . with_prefix ( "rust-analyzer-check" ) ;
393363
394- /// Cargo's output path in a given stage, compiled by a particular
395- /// compiler for the specified target.
396- fn stamp ( builder : & Builder < ' _ > , compiler : Compiler , target : TargetSelection ) -> PathBuf {
397- builder. cargo_out ( compiler, Mode :: ToolRustc , target) . join ( ".rust-analyzer-check.stamp" )
398- }
364+ let _guard = builder. msg_check ( "rust-analyzer artifacts" , target) ;
365+ run_cargo ( builder, cargo, builder. config . free_args . clone ( ) , & stamp, vec ! [ ] , true , false ) ;
399366 }
400367}
401368
@@ -469,9 +436,8 @@ fn run_tool_check_step(
469436 cargo. arg ( "--all-targets" ) ;
470437 }
471438
472- let stamp = builder
473- . cargo_out ( compiler, Mode :: ToolRustc , target)
474- . join ( format ! ( ".{}-check.stamp" , step_type_name. to_lowercase( ) ) ) ;
439+ let stamp = BuildStamp :: new ( & builder. cargo_out ( compiler, Mode :: ToolRustc , target) )
440+ . with_prefix ( & format ! ( "{}-check" , step_type_name. to_lowercase( ) ) ) ;
475441
476442 let _guard = builder. msg_check ( format ! ( "{display_name} artifacts" ) , target) ;
477443 run_cargo ( builder, cargo, builder. config . free_args . clone ( ) , & stamp, vec ! [ ] , true , false ) ;
@@ -499,38 +465,3 @@ tool_check_step!(RunMakeSupport { path: "src/tools/run-make-support", default: f
499465// Compiletest is implicitly "checked" when it gets built in order to run tests,
500466// so this is mainly for people working on compiletest to run locally.
501467tool_check_step ! ( Compiletest { path: "src/tools/compiletest" , default : false } ) ;
502-
503- /// Cargo's output path for the standard library in a given stage, compiled
504- /// by a particular compiler for the specified target.
505- fn libstd_stamp ( builder : & Builder < ' _ > , compiler : Compiler , target : TargetSelection ) -> PathBuf {
506- builder. cargo_out ( compiler, Mode :: Std , target) . join ( ".libstd-check.stamp" )
507- }
508-
509- /// Cargo's output path for the standard library in a given stage, compiled
510- /// by a particular compiler for the specified target.
511- fn libstd_test_stamp (
512- builder : & Builder < ' _ > ,
513- compiler : Compiler ,
514- target : TargetSelection ,
515- ) -> PathBuf {
516- builder. cargo_out ( compiler, Mode :: Std , target) . join ( ".libstd-check-test.stamp" )
517- }
518-
519- /// Cargo's output path for librustc in a given stage, compiled by a particular
520- /// compiler for the specified target.
521- fn librustc_stamp ( builder : & Builder < ' _ > , compiler : Compiler , target : TargetSelection ) -> PathBuf {
522- builder. cargo_out ( compiler, Mode :: Rustc , target) . join ( ".librustc-check.stamp" )
523- }
524-
525- /// Cargo's output path for librustc_codegen_llvm in a given stage, compiled by a particular
526- /// compiler for the specified target and backend.
527- fn codegen_backend_stamp (
528- builder : & Builder < ' _ > ,
529- compiler : Compiler ,
530- target : TargetSelection ,
531- backend : & str ,
532- ) -> PathBuf {
533- builder
534- . cargo_out ( compiler, Mode :: Codegen , target)
535- . join ( format ! ( ".librustc_codegen_{backend}-check.stamp" ) )
536- }
0 commit comments