@@ -34,6 +34,12 @@ pub enum SourceType {
34
34
Submodule ,
35
35
}
36
36
37
+ #[ derive( Debug , Clone , Hash , PartialEq , Eq ) ]
38
+ pub enum ToolArtifactKind {
39
+ Binary ,
40
+ Library ,
41
+ }
42
+
37
43
#[ derive( Debug , Clone , Hash , PartialEq , Eq ) ]
38
44
struct ToolBuild {
39
45
compiler : Compiler ,
@@ -47,6 +53,8 @@ struct ToolBuild {
47
53
allow_features : & ' static str ,
48
54
/// Additional arguments to pass to the `cargo` invocation.
49
55
cargo_args : Vec < String > ,
56
+ /// Whether the tool builds a binary or a library.
57
+ artifact_kind : ToolArtifactKind ,
50
58
}
51
59
52
60
impl Builder < ' _ > {
@@ -79,7 +87,7 @@ impl Builder<'_> {
79
87
/// for using this type as `type Output = ToolBuildResult;`
80
88
#[ derive( Clone ) ]
81
89
pub struct ToolBuildResult {
82
- /// Executable path of the corresponding tool that was built.
90
+ /// Artifact path of the corresponding tool that was built.
83
91
pub tool_path : PathBuf ,
84
92
/// Compiler used to build the tool. For non-`ToolRustc` tools this is equal to `target_compiler`.
85
93
/// For `ToolRustc` this is one stage before of the `target_compiler`.
@@ -179,8 +187,14 @@ impl Step for ToolBuild {
179
187
if tool == "tidy" {
180
188
tool = "rust-tidy" ;
181
189
}
182
- let tool_path =
183
- copy_link_tool_bin ( builder, self . compiler , self . target , self . mode , tool) ;
190
+ let tool_path = match self . artifact_kind {
191
+ ToolArtifactKind :: Binary => {
192
+ copy_link_tool_bin ( builder, self . compiler , self . target , self . mode , tool)
193
+ }
194
+ ToolArtifactKind :: Library => builder
195
+ . cargo_out ( self . compiler , self . mode , self . target )
196
+ . join ( format ! ( "lib{tool}.rlib" ) ) ,
197
+ } ;
184
198
185
199
ToolBuildResult { tool_path, build_compiler : self . compiler , target_compiler }
186
200
}
@@ -330,6 +344,7 @@ macro_rules! bootstrap_tool {
330
344
$( , is_unstable_tool = $unstable: expr) *
331
345
$( , allow_features = $allow_features: expr) ?
332
346
$( , submodules = $submodules: expr) ?
347
+ $( , artifact_kind = $artifact_kind: expr) ?
333
348
;
334
349
) +) => {
335
350
#[ derive( PartialEq , Eq , Clone ) ]
@@ -389,6 +404,7 @@ macro_rules! bootstrap_tool {
389
404
builder. require_submodule( submodule, None ) ;
390
405
}
391
406
) *
407
+
392
408
builder. ensure( ToolBuild {
393
409
compiler: self . compiler,
394
410
target: self . target,
@@ -407,7 +423,12 @@ macro_rules! bootstrap_tool {
407
423
} ,
408
424
extra_features: vec![ ] ,
409
425
allow_features: concat!( $( $allow_features) * ) ,
410
- cargo_args: vec![ ]
426
+ cargo_args: vec![ ] ,
427
+ artifact_kind: if false $( || $artifact_kind == ToolArtifactKind :: Library ) * {
428
+ ToolArtifactKind :: Library
429
+ } else {
430
+ ToolArtifactKind :: Binary
431
+ }
411
432
} )
412
433
}
413
434
}
@@ -445,51 +466,14 @@ bootstrap_tool!(
445
466
WasmComponentLd , "src/tools/wasm-component-ld" , "wasm-component-ld" , is_unstable_tool = true , allow_features = "min_specialization" ;
446
467
UnicodeTableGenerator , "src/tools/unicode-table-generator" , "unicode-table-generator" ;
447
468
FeaturesStatusDump , "src/tools/features-status-dump" , "features-status-dump" ;
469
+ OptimizedDist , "src/tools/opt-dist" , "opt-dist" , submodules = & [ "src/tools/rustc-perf" ] ;
470
+ RunMakeSupport , "src/tools/run-make-support" , "run_make_support" , artifact_kind = ToolArtifactKind :: Library ;
448
471
) ;
449
472
450
473
/// These are the submodules that are required for rustbook to work due to
451
474
/// depending on mdbook plugins.
452
475
pub static SUBMODULES_FOR_RUSTBOOK : & [ & str ] = & [ "src/doc/book" , "src/doc/reference" ] ;
453
476
454
- #[ derive( Debug , Clone , Hash , PartialEq , Eq ) ]
455
- pub struct OptimizedDist {
456
- pub compiler : Compiler ,
457
- pub target : TargetSelection ,
458
- }
459
-
460
- impl Step for OptimizedDist {
461
- type Output = ToolBuildResult ;
462
-
463
- fn should_run ( run : ShouldRun < ' _ > ) -> ShouldRun < ' _ > {
464
- run. path ( "src/tools/opt-dist" )
465
- }
466
-
467
- fn make_run ( run : RunConfig < ' _ > ) {
468
- run. builder . ensure ( OptimizedDist {
469
- compiler : run. builder . compiler ( 0 , run. builder . config . build ) ,
470
- target : run. target ,
471
- } ) ;
472
- }
473
-
474
- fn run ( self , builder : & Builder < ' _ > ) -> ToolBuildResult {
475
- // We need to ensure the rustc-perf submodule is initialized when building opt-dist since
476
- // the tool requires it to be in place to run.
477
- builder. require_submodule ( "src/tools/rustc-perf" , None ) ;
478
-
479
- builder. ensure ( ToolBuild {
480
- compiler : self . compiler ,
481
- target : self . target ,
482
- tool : "opt-dist" ,
483
- mode : Mode :: ToolBootstrap ,
484
- path : "src/tools/opt-dist" ,
485
- source_type : SourceType :: InTree ,
486
- extra_features : Vec :: new ( ) ,
487
- allow_features : "" ,
488
- cargo_args : Vec :: new ( ) ,
489
- } )
490
- }
491
- }
492
-
493
477
/// The [rustc-perf](https://github.com/rust-lang/rustc-perf) benchmark suite, which is added
494
478
/// as a submodule at `src/tools/rustc-perf`.
495
479
#[ derive( Debug , Clone , Hash , PartialEq , Eq ) ]
@@ -529,6 +513,7 @@ impl Step for RustcPerf {
529
513
// Only build the collector package, which is used for benchmarking through
530
514
// a CLI.
531
515
cargo_args : vec ! [ "-p" . to_string( ) , "collector" . to_string( ) ] ,
516
+ artifact_kind : ToolArtifactKind :: Binary ,
532
517
} ;
533
518
let res = builder. ensure ( tool. clone ( ) ) ;
534
519
// We also need to symlink the `rustc-fake` binary to the corresponding directory,
@@ -586,6 +571,7 @@ impl Step for ErrorIndex {
586
571
extra_features : Vec :: new ( ) ,
587
572
allow_features : "" ,
588
573
cargo_args : Vec :: new ( ) ,
574
+ artifact_kind : ToolArtifactKind :: Binary ,
589
575
} )
590
576
}
591
577
}
@@ -621,6 +607,7 @@ impl Step for RemoteTestServer {
621
607
extra_features : Vec :: new ( ) ,
622
608
allow_features : "" ,
623
609
cargo_args : Vec :: new ( ) ,
610
+ artifact_kind : ToolArtifactKind :: Binary ,
624
611
} )
625
612
}
626
613
}
@@ -725,6 +712,7 @@ impl Step for Rustdoc {
725
712
extra_features,
726
713
allow_features : "" ,
727
714
cargo_args : Vec :: new ( ) ,
715
+ artifact_kind : ToolArtifactKind :: Binary ,
728
716
} ) ;
729
717
730
718
// don't create a stage0-sysroot/bin directory.
@@ -779,6 +767,7 @@ impl Step for Cargo {
779
767
extra_features : Vec :: new ( ) ,
780
768
allow_features : "" ,
781
769
cargo_args : Vec :: new ( ) ,
770
+ artifact_kind : ToolArtifactKind :: Binary ,
782
771
} )
783
772
}
784
773
}
@@ -827,6 +816,7 @@ impl Step for LldWrapper {
827
816
extra_features : Vec :: new ( ) ,
828
817
allow_features : "" ,
829
818
cargo_args : Vec :: new ( ) ,
819
+ artifact_kind : ToolArtifactKind :: Binary ,
830
820
} ) ;
831
821
832
822
let libdir_bin = builder. sysroot_target_bindir ( self . target_compiler , target) ;
@@ -887,6 +877,7 @@ impl Step for RustAnalyzer {
887
877
source_type : SourceType :: InTree ,
888
878
allow_features : RustAnalyzer :: ALLOW_FEATURES ,
889
879
cargo_args : Vec :: new ( ) ,
880
+ artifact_kind : ToolArtifactKind :: Binary ,
890
881
} )
891
882
}
892
883
}
@@ -931,6 +922,7 @@ impl Step for RustAnalyzerProcMacroSrv {
931
922
source_type : SourceType :: InTree ,
932
923
allow_features : RustAnalyzer :: ALLOW_FEATURES ,
933
924
cargo_args : Vec :: new ( ) ,
925
+ artifact_kind : ToolArtifactKind :: Binary ,
934
926
} ) ;
935
927
936
928
// Copy `rust-analyzer-proc-macro-srv` to `<sysroot>/libexec/`
@@ -985,6 +977,7 @@ impl Step for LlvmBitcodeLinker {
985
977
extra_features : self . extra_features ,
986
978
allow_features : "" ,
987
979
cargo_args : Vec :: new ( ) ,
980
+ artifact_kind : ToolArtifactKind :: Binary ,
988
981
} ) ;
989
982
990
983
if tool_result. target_compiler . stage > 0 {
@@ -1164,6 +1157,7 @@ fn run_tool_build_step(
1164
1157
source_type : SourceType :: InTree ,
1165
1158
allow_features : "" ,
1166
1159
cargo_args : vec ! [ ] ,
1160
+ artifact_kind : ToolArtifactKind :: Binary ,
1167
1161
} ) ;
1168
1162
1169
1163
// FIXME: This should just be an if-let-chain, but those are unstable.
@@ -1242,6 +1236,7 @@ impl Step for TestFloatParse {
1242
1236
extra_features : Vec :: new ( ) ,
1243
1237
allow_features : "" ,
1244
1238
cargo_args : Vec :: new ( ) ,
1239
+ artifact_kind : ToolArtifactKind :: Binary ,
1245
1240
} )
1246
1241
}
1247
1242
}
0 commit comments