@@ -251,9 +251,9 @@ pub fn prepare_tool_cargo(
251
251
cargo
252
252
}
253
253
254
- macro_rules! tool {
254
+ macro_rules! bootstrap_tool {
255
255
( $(
256
- $name: ident, $path: expr, $tool_name: expr, $mode : expr
256
+ $name: ident, $path: expr, $tool_name: expr
257
257
$( , llvm_tools = $llvm: expr) *
258
258
$( , is_external_tool = $external: expr) *
259
259
;
@@ -267,10 +267,7 @@ macro_rules! tool {
267
267
268
268
impl Tool {
269
269
pub fn get_mode( & self ) -> Mode {
270
- let mode = match self {
271
- $( Tool :: $name => $mode, ) +
272
- } ;
273
- mode
270
+ Mode :: ToolBootstrap
274
271
}
275
272
276
273
/// Whether this tool requires LLVM to run
@@ -283,27 +280,15 @@ macro_rules! tool {
283
280
284
281
impl <' a> Builder <' a> {
285
282
pub fn tool_exe( & self , tool: Tool ) -> PathBuf {
286
- let stage = self . tool_default_stage( tool) ;
287
283
match tool {
288
284
$( Tool :: $name =>
289
285
self . ensure( $name {
290
- compiler: self . compiler( stage , self . config. build) ,
286
+ compiler: self . compiler( 0 , self . config. build) ,
291
287
target: self . config. build,
292
288
} ) ,
293
289
) +
294
290
}
295
291
}
296
-
297
- pub fn tool_default_stage( & self , tool: Tool ) -> u32 {
298
- // Compile the error-index in the same stage as rustdoc to avoid
299
- // recompiling rustdoc twice if we can. Otherwise compile
300
- // everything else in stage0 as there's no need to rebootstrap
301
- // everything.
302
- match tool {
303
- Tool :: ErrorIndex if self . top_stage >= 2 => self . top_stage,
304
- _ => 0 ,
305
- }
306
- }
307
292
}
308
293
309
294
$(
@@ -322,7 +307,8 @@ macro_rules! tool {
322
307
323
308
fn make_run( run: RunConfig <' _>) {
324
309
run. builder. ensure( $name {
325
- compiler: run. builder. compiler( run. builder. top_stage, run. builder. config. build) ,
310
+ // snapshot compiler
311
+ compiler: run. builder. compiler( 0 , run. builder. config. build) ,
326
312
target: run. target,
327
313
} ) ;
328
314
}
@@ -332,7 +318,7 @@ macro_rules! tool {
332
318
compiler: self . compiler,
333
319
target: self . target,
334
320
tool: $tool_name,
335
- mode: $mode ,
321
+ mode: Mode :: ToolBootstrap ,
336
322
path: $path,
337
323
is_optional_tool: false ,
338
324
source_type: if false $( || $external) * {
@@ -348,21 +334,67 @@ macro_rules! tool {
348
334
}
349
335
}
350
336
351
- tool ! (
352
- Rustbook , "src/tools/rustbook" , "rustbook" , Mode :: ToolBootstrap ;
353
- ErrorIndex , "src/tools/error_index_generator" , "error_index_generator" , Mode :: ToolRustc ;
354
- UnstableBookGen , "src/tools/unstable-book-gen" , "unstable-book-gen" , Mode :: ToolBootstrap ;
355
- Tidy , "src/tools/tidy" , "tidy" , Mode :: ToolBootstrap ;
356
- Linkchecker , "src/tools/linkchecker" , "linkchecker" , Mode :: ToolBootstrap ;
357
- CargoTest , "src/tools/cargotest" , "cargotest" , Mode :: ToolBootstrap ;
358
- Compiletest , "src/tools/compiletest" , "compiletest" , Mode :: ToolBootstrap , llvm_tools = true ;
359
- BuildManifest , "src/tools/build-manifest" , "build-manifest" , Mode :: ToolBootstrap ;
360
- RemoteTestClient , "src/tools/remote-test-client" , "remote-test-client" , Mode :: ToolBootstrap ;
361
- RustInstaller , "src/tools/rust-installer" , "fabricate" , Mode :: ToolBootstrap ,
362
- is_external_tool = true ;
363
- RustdocTheme , "src/tools/rustdoc-themes" , "rustdoc-themes" , Mode :: ToolBootstrap ;
337
+ bootstrap_tool ! (
338
+ Rustbook , "src/tools/rustbook" , "rustbook" ;
339
+ UnstableBookGen , "src/tools/unstable-book-gen" , "unstable-book-gen" ;
340
+ Tidy , "src/tools/tidy" , "tidy" ;
341
+ Linkchecker , "src/tools/linkchecker" , "linkchecker" ;
342
+ CargoTest , "src/tools/cargotest" , "cargotest" ;
343
+ Compiletest , "src/tools/compiletest" , "compiletest" , llvm_tools = true ;
344
+ BuildManifest , "src/tools/build-manifest" , "build-manifest" ;
345
+ RemoteTestClient , "src/tools/remote-test-client" , "remote-test-client" ;
346
+ RustInstaller , "src/tools/rust-installer" , "fabricate" , is_external_tool = true ;
347
+ RustdocTheme , "src/tools/rustdoc-themes" , "rustdoc-themes" ;
364
348
) ;
365
349
350
+ #[ derive( Debug , Copy , Clone , Hash , PartialEq , Eq ) ]
351
+ pub struct ErrorIndex {
352
+ pub compiler : Compiler ,
353
+ }
354
+
355
+ impl ErrorIndex {
356
+ pub fn command ( builder : & Builder < ' _ > , compiler : Compiler ) -> Command {
357
+ let mut cmd = Command :: new ( builder. ensure ( ErrorIndex {
358
+ compiler
359
+ } ) ) ;
360
+ add_lib_path (
361
+ vec ! [ PathBuf :: from( & builder. sysroot_libdir( compiler, compiler. host) ) ] ,
362
+ & mut cmd,
363
+ ) ;
364
+ cmd
365
+ }
366
+ }
367
+
368
+ impl Step for ErrorIndex {
369
+ type Output = PathBuf ;
370
+
371
+ fn should_run ( run : ShouldRun < ' _ > ) -> ShouldRun < ' _ > {
372
+ run. path ( "src/tools/error_index_generator" )
373
+ }
374
+
375
+ fn make_run ( run : RunConfig < ' _ > ) {
376
+ // Compile the error-index in the same stage as rustdoc to avoid
377
+ // recompiling rustdoc twice if we can.
378
+ let stage = if run. builder . top_stage >= 2 { run. builder . top_stage } else { 0 } ;
379
+ run. builder . ensure ( ErrorIndex {
380
+ compiler : run. builder . compiler ( stage, run. builder . config . build ) ,
381
+ } ) ;
382
+ }
383
+
384
+ fn run ( self , builder : & Builder < ' _ > ) -> PathBuf {
385
+ builder. ensure ( ToolBuild {
386
+ compiler : self . compiler ,
387
+ target : self . compiler . host ,
388
+ tool : "error_index_generator" ,
389
+ mode : Mode :: ToolRustc ,
390
+ path : "src/tools/error_index_generator" ,
391
+ is_optional_tool : false ,
392
+ source_type : SourceType :: InTree ,
393
+ extra_features : Vec :: new ( ) ,
394
+ } ) . expect ( "expected to build -- essential tool" )
395
+ }
396
+ }
397
+
366
398
#[ derive( Debug , Copy , Clone , Hash , PartialEq , Eq ) ]
367
399
pub struct RemoteTestServer {
368
400
pub compiler : Compiler ,
@@ -399,7 +431,9 @@ impl Step for RemoteTestServer {
399
431
400
432
#[ derive( Debug , Copy , Clone , Hash , PartialEq , Eq ) ]
401
433
pub struct Rustdoc {
402
- pub host : Interned < String > ,
434
+ /// This should only ever be 0 or 2.
435
+ /// We sometimes want to reference the "bootstrap" rustdoc, which is why this option is here.
436
+ pub compiler : Compiler ,
403
437
}
404
438
405
439
impl Step for Rustdoc {
@@ -413,12 +447,12 @@ impl Step for Rustdoc {
413
447
414
448
fn make_run ( run : RunConfig < ' _ > ) {
415
449
run. builder . ensure ( Rustdoc {
416
- host : run. host ,
450
+ compiler : run. builder . compiler ( run . builder . top_stage , run . host ) ,
417
451
} ) ;
418
452
}
419
453
420
454
fn run ( self , builder : & Builder < ' _ > ) -> PathBuf {
421
- let target_compiler = builder . compiler ( builder . top_stage , self . host ) ;
455
+ let target_compiler = self . compiler ;
422
456
if target_compiler. stage == 0 {
423
457
if !target_compiler. is_snapshot ( builder) {
424
458
panic ! ( "rustdoc in stage 0 must be snapshot rustdoc" ) ;
@@ -626,7 +660,7 @@ impl<'a> Builder<'a> {
626
660
/// `host`.
627
661
pub fn tool_cmd ( & self , tool : Tool ) -> Command {
628
662
let mut cmd = Command :: new ( self . tool_exe ( tool) ) ;
629
- let compiler = self . compiler ( self . tool_default_stage ( tool ) , self . config . build ) ;
663
+ let compiler = self . compiler ( 0 , self . config . build ) ;
630
664
self . prepare_tool_cmd ( compiler, tool, & mut cmd) ;
631
665
cmd
632
666
}
@@ -638,7 +672,7 @@ impl<'a> Builder<'a> {
638
672
fn prepare_tool_cmd ( & self , compiler : Compiler , tool : Tool , cmd : & mut Command ) {
639
673
let host = & compiler. host ;
640
674
let mut lib_paths: Vec < PathBuf > = vec ! [
641
- if compiler. stage == 0 && tool != Tool :: ErrorIndex {
675
+ if compiler. stage == 0 {
642
676
self . build. rustc_snapshot_libdir( )
643
677
} else {
644
678
PathBuf :: from( & self . sysroot_libdir( compiler, compiler. host) )
0 commit comments