1
1
//! Implementation of compiling the compiler and standard library, in "check"-based modes.
2
2
3
- use std:: path:: PathBuf ;
4
-
5
3
use crate :: core:: build_steps:: compile:: {
6
4
add_to_sysroot, run_cargo, rustc_cargo, rustc_cargo_env, std_cargo, std_crates_for_run_make,
7
5
} ;
@@ -10,7 +8,8 @@ use crate::core::builder::{
10
8
self , Alias , Builder , Kind , RunConfig , ShouldRun , Step , crate_description,
11
9
} ;
12
10
use crate :: core:: config:: TargetSelection ;
13
- use crate :: { Compiler , Mode , Subcommand } ;
11
+ use crate :: utils:: build_stamp:: { self , BuildStamp } ;
12
+ use crate :: { Mode , Subcommand } ;
14
13
15
14
#[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
16
15
pub struct Std {
@@ -83,22 +82,16 @@ impl Step for Std {
83
82
format_args ! ( "library artifacts{}" , crate_description( & self . crates) ) ,
84
83
target,
85
84
) ;
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 ) ;
95
88
96
89
// We skip populating the sysroot in non-zero stage because that'll lead
97
90
// to rlib/rmeta conflicts if std gets built during this session.
98
91
if compiler. stage == 0 {
99
92
let libdir = builder. sysroot_target_libdir ( compiler, target) ;
100
93
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 ) ;
102
95
}
103
96
drop ( _guard) ;
104
97
@@ -139,16 +132,9 @@ impl Step for Std {
139
132
cargo. arg ( "-p" ) . arg ( krate) ;
140
133
}
141
134
135
+ let stamp = build_stamp:: libstd_stamp ( builder, compiler, target) . with_prefix ( "check-test" ) ;
142
136
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 ) ;
152
138
}
153
139
}
154
140
@@ -249,19 +235,14 @@ impl Step for Rustc {
249
235
format_args ! ( "compiler artifacts{}" , crate_description( & self . crates) ) ,
250
236
target,
251
237
) ;
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 ) ;
261
242
262
243
let libdir = builder. sysroot_target_libdir ( compiler, target) ;
263
244
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 ) ;
265
246
}
266
247
}
267
248
@@ -315,15 +296,10 @@ impl Step for CodegenBackend {
315
296
316
297
let _guard = builder. msg_check ( backend, target) ;
317
298
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 ) ;
327
303
}
328
304
}
329
305
@@ -380,22 +356,13 @@ impl Step for RustAnalyzer {
380
356
cargo. arg ( "--benches" ) ;
381
357
}
382
358
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" ) ;
393
363
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 ) ;
399
366
}
400
367
}
401
368
@@ -469,9 +436,8 @@ fn run_tool_check_step(
469
436
cargo. arg ( "--all-targets" ) ;
470
437
}
471
438
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( ) ) ) ;
475
441
476
442
let _guard = builder. msg_check ( format ! ( "{display_name} artifacts" ) , target) ;
477
443
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
499
465
// Compiletest is implicitly "checked" when it gets built in order to run tests,
500
466
// so this is mainly for people working on compiletest to run locally.
501
467
tool_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