@@ -31,6 +31,8 @@ pub struct Std {
31
31
}
32
32
33
33
impl Std {
34
+ const CRATE_OR_DEPS : & [ & str ] = & [ "sysroot" , "coretests" , "alloctests" ] ;
35
+
34
36
pub fn new ( target : TargetSelection ) -> Self {
35
37
Self { target, crates : vec ! [ ] , override_build_kind : None }
36
38
}
@@ -47,11 +49,13 @@ impl Step for Std {
47
49
48
50
fn should_run ( run : ShouldRun < ' _ > ) -> ShouldRun < ' _ > {
49
51
let stage = run. builder . top_stage ;
50
- run. crate_or_deps ( "sysroot" )
51
- . crate_or_deps ( "coretests" )
52
- . crate_or_deps ( "alloctests" )
53
- . path ( "library" )
54
- . default_condition ( stage != 0 )
52
+
53
+ let mut run = run;
54
+ for c in Std :: CRATE_OR_DEPS {
55
+ run = run. crate_or_deps ( c) ;
56
+ }
57
+
58
+ run. path ( "library" ) . default_condition ( stage != 0 )
55
59
}
56
60
57
61
fn make_run ( run : RunConfig < ' _ > ) {
@@ -66,6 +70,26 @@ impl Step for Std {
66
70
let compiler = builder. compiler ( builder. top_stage , builder. config . build ) ;
67
71
68
72
if builder. top_stage == 0 {
73
+ let mut is_explicitly_called =
74
+ builder. paths . iter ( ) . any ( |p| p. starts_with ( "library" ) || p. starts_with ( "std" ) ) ;
75
+
76
+ if !is_explicitly_called {
77
+ for c in Std :: CRATE_OR_DEPS {
78
+ is_explicitly_called = builder. paths . iter ( ) . any ( |p| p. starts_with ( c) ) ;
79
+ }
80
+ }
81
+
82
+ if is_explicitly_called {
83
+ eprintln ! ( "WARNING: stage 0 std is precompiled and does nothing during `x check`." ) ;
84
+
85
+ if builder. config . explicit_stage_from_cli {
86
+ eprintln ! (
87
+ "ERROR: Cannot call `x check` on the library tree explicitly with the `--stage 0` flag."
88
+ ) ;
89
+ std:: process:: exit ( 1 ) ;
90
+ }
91
+ }
92
+
69
93
// Reuse the stage0 libstd
70
94
builder. ensure ( compile:: Std :: new ( compiler, target) ) ;
71
95
return ;
0 commit comments