@@ -73,7 +73,7 @@ impl Step for Std {
73
73
74
74
fn run ( self , builder : & Builder < ' _ > ) {
75
75
let target = self . target ;
76
- let compiler = builder. compiler ( 0 , builder. config . build ) ;
76
+ let compiler = builder. compiler ( builder . top_stage , builder. config . build ) ;
77
77
78
78
let mut cargo = builder. cargo (
79
79
compiler,
@@ -84,7 +84,10 @@ impl Step for Std {
84
84
) ;
85
85
std_cargo ( builder, target, compiler. stage , & mut cargo) ;
86
86
87
- builder. info ( & format ! ( "Checking std artifacts ({} -> {})" , & compiler. host, target) ) ;
87
+ builder. info ( & format ! (
88
+ "Checking stage{} std artifacts ({} -> {})" ,
89
+ builder. top_stage, & compiler. host, target
90
+ ) ) ;
88
91
run_cargo (
89
92
builder,
90
93
cargo,
@@ -94,9 +97,13 @@ impl Step for Std {
94
97
true ,
95
98
) ;
96
99
97
- let libdir = builder. sysroot_libdir ( compiler, target) ;
98
- let hostdir = builder. sysroot_libdir ( compiler, compiler. host ) ;
99
- add_to_sysroot ( & builder, & libdir, & hostdir, & libstd_stamp ( builder, compiler, target) ) ;
100
+ // We skip populating the sysroot in non-zero stage because that'll lead
101
+ // to rlib/rmeta conflicts if std gets built during this session.
102
+ if compiler. stage == 0 {
103
+ let libdir = builder. sysroot_libdir ( compiler, target) ;
104
+ let hostdir = builder. sysroot_libdir ( compiler, compiler. host ) ;
105
+ add_to_sysroot ( & builder, & libdir, & hostdir, & libstd_stamp ( builder, compiler, target) ) ;
106
+ }
100
107
101
108
// Then run cargo again, once we've put the rmeta files for the library
102
109
// crates into the sysroot. This is needed because e.g., core's tests
@@ -124,8 +131,8 @@ impl Step for Std {
124
131
}
125
132
126
133
builder. info ( & format ! (
127
- "Checking std test/bench/example targets ({} -> {})" ,
128
- & compiler. host, target
134
+ "Checking stage{} std test/bench/example targets ({} -> {})" ,
135
+ builder . top_stage , & compiler. host, target
129
136
) ) ;
130
137
run_cargo (
131
138
builder,
@@ -163,10 +170,20 @@ impl Step for Rustc {
163
170
/// the `compiler` targeting the `target` architecture. The artifacts
164
171
/// created will also be linked into the sysroot directory.
165
172
fn run ( self , builder : & Builder < ' _ > ) {
166
- let compiler = builder. compiler ( 0 , builder. config . build ) ;
173
+ let compiler = builder. compiler ( builder . top_stage , builder. config . build ) ;
167
174
let target = self . target ;
168
175
169
- builder. ensure ( Std { target } ) ;
176
+ if compiler. stage != 0 {
177
+ // If we're not in stage 0, then we won't have a std from the beta
178
+ // compiler around. That means we need to make sure there's one in
179
+ // the sysroot for the compiler to find. Otherwise, we're going to
180
+ // fail when building crates that need to generate code (e.g., build
181
+ // scripts and their dependencies).
182
+ builder. ensure ( crate :: compile:: Std { target : compiler. host , compiler } ) ;
183
+ builder. ensure ( crate :: compile:: Std { target, compiler } ) ;
184
+ } else {
185
+ builder. ensure ( Std { target } ) ;
186
+ }
170
187
171
188
let mut cargo = builder. cargo (
172
189
compiler,
@@ -187,7 +204,10 @@ impl Step for Rustc {
187
204
cargo. arg ( "-p" ) . arg ( krate. name ) ;
188
205
}
189
206
190
- builder. info ( & format ! ( "Checking compiler artifacts ({} -> {})" , & compiler. host, target) ) ;
207
+ builder. info ( & format ! (
208
+ "Checking stage{} compiler artifacts ({} -> {})" ,
209
+ builder. top_stage, & compiler. host, target
210
+ ) ) ;
191
211
run_cargo (
192
212
builder,
193
213
cargo,
@@ -225,7 +245,7 @@ impl Step for CodegenBackend {
225
245
}
226
246
227
247
fn run ( self , builder : & Builder < ' _ > ) {
228
- let compiler = builder. compiler ( 0 , builder. config . build ) ;
248
+ let compiler = builder. compiler ( builder . top_stage , builder. config . build ) ;
229
249
let target = self . target ;
230
250
let backend = self . backend ;
231
251
@@ -244,8 +264,8 @@ impl Step for CodegenBackend {
244
264
rustc_cargo_env ( builder, & mut cargo, target) ;
245
265
246
266
builder. info ( & format ! (
247
- "Checking {} artifacts ({} -> {})" ,
248
- backend, & compiler. host. triple, target. triple
267
+ "Checking stage{} {} artifacts ({} -> {})" ,
268
+ builder . top_stage , backend, & compiler. host. triple, target. triple
249
269
) ) ;
250
270
251
271
run_cargo (
@@ -280,7 +300,7 @@ macro_rules! tool_check_step {
280
300
}
281
301
282
302
fn run( self , builder: & Builder <' _>) {
283
- let compiler = builder. compiler( 0 , builder. config. build) ;
303
+ let compiler = builder. compiler( builder . top_stage , builder. config. build) ;
284
304
let target = self . target;
285
305
286
306
builder. ensure( Rustc { target } ) ;
@@ -301,7 +321,8 @@ macro_rules! tool_check_step {
301
321
}
302
322
303
323
builder. info( & format!(
304
- "Checking {} artifacts ({} -> {})" ,
324
+ "Checking stage{} {} artifacts ({} -> {})" ,
325
+ builder. top_stage,
305
326
stringify!( $name) . to_lowercase( ) ,
306
327
& compiler. host. triple,
307
328
target. triple
0 commit comments