@@ -64,8 +64,15 @@ impl Builder<'_> {
64
64
}
65
65
}
66
66
67
+ #[derive(Clone)]
68
+ struct ToolBuildResult {
69
+ tool_path: PathBuf,
70
+ build_compiler: Compiler,
71
+ target_compiler: Compiler,
72
+ }
73
+
67
74
impl Step for ToolBuild {
68
- type Output = PathBuf ;
75
+ type Output = ToolBuildResult ;
69
76
70
77
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
71
78
run.never()
@@ -75,30 +82,31 @@ impl Step for ToolBuild {
75
82
///
76
83
/// This will build the specified tool with the specified `host` compiler in
77
84
/// `stage` into the normal cargo output directory.
78
- fn run(self, builder: &Builder<'_>) -> PathBuf {
85
+ fn run(mut self, builder: &Builder<'_>) -> ToolBuildResult {
79
86
let target = self.target;
80
87
let mut tool = self.tool;
81
88
let path = self.path;
82
89
83
- let compiler = if self.mode == Mode::ToolRustc {
90
+ let target_compiler = self.compiler;
91
+ self.compiler = if self.mode == Mode::ToolRustc {
84
92
get_tool_rustc_compiler(builder, self.compiler)
85
93
} else {
86
94
self.compiler
87
95
};
88
96
89
97
match self.mode {
90
98
Mode::ToolRustc => {
91
- builder.ensure(compile::Std::new(compiler, compiler.host));
92
- builder.ensure(compile::Rustc::new(compiler, target));
99
+ builder.ensure(compile::Std::new(self. compiler, self. compiler.host));
100
+ builder.ensure(compile::Rustc::new(self. compiler, target));
93
101
}
94
- Mode::ToolStd => builder.ensure(compile::Std::new(compiler, target)),
102
+ Mode::ToolStd => builder.ensure(compile::Std::new(self. compiler, target)),
95
103
Mode::ToolBootstrap => {} // uses downloaded stage0 compiler libs
96
104
_ => panic!("unexpected Mode for tool build"),
97
105
}
98
106
99
107
let mut cargo = prepare_tool_cargo(
100
108
builder,
101
- compiler,
109
+ self. compiler,
102
110
self.mode,
103
111
target,
104
112
Kind::Build,
@@ -136,7 +144,10 @@ impl Step for ToolBuild {
136
144
if tool == "tidy" {
137
145
tool = "rust-tidy";
138
146
}
139
- copy_link_tool_bin(builder, self.compiler, self.target, self.mode, tool)
147
+ let tool_path =
148
+ copy_link_tool_bin(builder, target_compiler, self.target, self.mode, tool);
149
+
150
+ ToolBuildResult { tool_path, build_compiler: self.compiler, target_compiler }
140
151
}
141
152
}
142
153
}
@@ -361,7 +372,7 @@ macro_rules! bootstrap_tool {
361
372
extra_features: vec![],
362
373
allow_features: concat!($($allow_features)*),
363
374
cargo_args: vec![]
364
- })
375
+ }).tool_path
365
376
}
366
377
}
367
378
)+
@@ -429,17 +440,19 @@ impl Step for OptimizedDist {
429
440
// the tool requires it to be in place to run.
430
441
builder.require_submodule("src/tools/rustc-perf", None);
431
442
432
- builder.ensure(ToolBuild {
433
- compiler: self.compiler,
434
- target: self.target,
435
- tool: "opt-dist",
436
- mode: Mode::ToolBootstrap,
437
- path: "src/tools/opt-dist",
438
- source_type: SourceType::InTree,
439
- extra_features: Vec::new(),
440
- allow_features: "",
441
- cargo_args: Vec::new(),
442
- })
443
+ builder
444
+ .ensure(ToolBuild {
445
+ compiler: self.compiler,
446
+ target: self.target,
447
+ tool: "opt-dist",
448
+ mode: Mode::ToolBootstrap,
449
+ path: "src/tools/opt-dist",
450
+ source_type: SourceType::InTree,
451
+ extra_features: Vec::new(),
452
+ allow_features: "",
453
+ cargo_args: Vec::new(),
454
+ })
455
+ .tool_path
443
456
}
444
457
}
445
458
@@ -483,7 +496,7 @@ impl Step for RustcPerf {
483
496
// a CLI.
484
497
cargo_args: vec!["-p".to_string(), "collector".to_string()],
485
498
};
486
- let collector_bin = builder.ensure(tool.clone());
499
+ let collector_bin = builder.ensure(tool.clone()).tool_path ;
487
500
// We also need to symlink the `rustc-fake` binary to the corresponding directory,
488
501
// because `collector` expects it in the same directory.
489
502
copy_link_tool_bin(builder, tool.compiler, tool.target, tool.mode, "rustc-fake");
@@ -533,17 +546,19 @@ impl Step for ErrorIndex {
533
546
}
534
547
535
548
fn run(self, builder: &Builder<'_>) -> PathBuf {
536
- builder.ensure(ToolBuild {
537
- compiler: self.compiler,
538
- target: self.compiler.host,
539
- tool: "error_index_generator",
540
- mode: Mode::ToolRustc,
541
- path: "src/tools/error_index_generator",
542
- source_type: SourceType::InTree,
543
- extra_features: Vec::new(),
544
- allow_features: "",
545
- cargo_args: Vec::new(),
546
- })
549
+ builder
550
+ .ensure(ToolBuild {
551
+ compiler: self.compiler,
552
+ target: self.compiler.host,
553
+ tool: "error_index_generator",
554
+ mode: Mode::ToolRustc,
555
+ path: "src/tools/error_index_generator",
556
+ source_type: SourceType::InTree,
557
+ extra_features: Vec::new(),
558
+ allow_features: "",
559
+ cargo_args: Vec::new(),
560
+ })
561
+ .tool_path
547
562
}
548
563
}
549
564
@@ -568,17 +583,19 @@ impl Step for RemoteTestServer {
568
583
}
569
584
570
585
fn run(self, builder: &Builder<'_>) -> PathBuf {
571
- builder.ensure(ToolBuild {
572
- compiler: self.compiler,
573
- target: self.target,
574
- tool: "remote-test-server",
575
- mode: Mode::ToolStd,
576
- path: "src/tools/remote-test-server",
577
- source_type: SourceType::InTree,
578
- extra_features: Vec::new(),
579
- allow_features: "",
580
- cargo_args: Vec::new(),
581
- })
586
+ builder
587
+ .ensure(ToolBuild {
588
+ compiler: self.compiler,
589
+ target: self.target,
590
+ tool: "remote-test-server",
591
+ mode: Mode::ToolStd,
592
+ path: "src/tools/remote-test-server",
593
+ source_type: SourceType::InTree,
594
+ extra_features: Vec::new(),
595
+ allow_features: "",
596
+ cargo_args: Vec::new(),
597
+ })
598
+ .tool_path
582
599
}
583
600
}
584
601
@@ -754,17 +771,19 @@ impl Step for Cargo {
754
771
fn run(self, builder: &Builder<'_>) -> PathBuf {
755
772
builder.build.require_submodule("src/tools/cargo", None);
756
773
757
- builder.ensure(ToolBuild {
758
- compiler: self.compiler,
759
- target: self.target,
760
- tool: "cargo",
761
- mode: Mode::ToolRustc,
762
- path: "src/tools/cargo",
763
- source_type: SourceType::Submodule,
764
- extra_features: Vec::new(),
765
- allow_features: "",
766
- cargo_args: Vec::new(),
767
- })
774
+ builder
775
+ .ensure(ToolBuild {
776
+ compiler: self.compiler,
777
+ target: self.target,
778
+ tool: "cargo",
779
+ mode: Mode::ToolRustc,
780
+ path: "src/tools/cargo",
781
+ source_type: SourceType::Submodule,
782
+ extra_features: Vec::new(),
783
+ allow_features: "",
784
+ cargo_args: Vec::new(),
785
+ })
786
+ .tool_path
768
787
}
769
788
}
770
789
@@ -797,17 +816,19 @@ impl Step for LldWrapper {
797
816
798
817
let target = self.target_compiler.host;
799
818
800
- let executable = builder.ensure(ToolBuild {
801
- compiler: self.build_compiler,
802
- target,
803
- tool: "lld-wrapper",
804
- mode: Mode::ToolStd,
805
- path: "src/tools/lld-wrapper",
806
- source_type: SourceType::InTree,
807
- extra_features: Vec::new(),
808
- allow_features: "",
809
- cargo_args: Vec::new(),
810
- });
819
+ let executable = builder
820
+ .ensure(ToolBuild {
821
+ compiler: self.build_compiler,
822
+ target,
823
+ tool: "lld-wrapper",
824
+ mode: Mode::ToolStd,
825
+ path: "src/tools/lld-wrapper",
826
+ source_type: SourceType::InTree,
827
+ extra_features: Vec::new(),
828
+ allow_features: "",
829
+ cargo_args: Vec::new(),
830
+ })
831
+ .tool_path;
811
832
812
833
let libdir_bin = builder.sysroot_target_bindir(self.target_compiler, target);
813
834
t!(fs::create_dir_all(&libdir_bin));
@@ -854,17 +875,19 @@ impl Step for RustAnalyzer {
854
875
}
855
876
856
877
fn run(self, builder: &Builder<'_>) -> PathBuf {
857
- builder.ensure(ToolBuild {
858
- compiler: self.compiler,
859
- target: self.target,
860
- tool: "rust-analyzer",
861
- mode: Mode::ToolRustc,
862
- path: "src/tools/rust-analyzer",
863
- extra_features: vec!["in-rust-tree".to_owned()],
864
- source_type: SourceType::InTree,
865
- allow_features: RustAnalyzer::ALLOW_FEATURES,
866
- cargo_args: Vec::new(),
867
- })
878
+ builder
879
+ .ensure(ToolBuild {
880
+ compiler: self.compiler,
881
+ target: self.target,
882
+ tool: "rust-analyzer",
883
+ mode: Mode::ToolRustc,
884
+ path: "src/tools/rust-analyzer",
885
+ extra_features: vec!["in-rust-tree".to_owned()],
886
+ source_type: SourceType::InTree,
887
+ allow_features: RustAnalyzer::ALLOW_FEATURES,
888
+ cargo_args: Vec::new(),
889
+ })
890
+ .tool_path
868
891
}
869
892
}
870
893
@@ -898,17 +921,19 @@ impl Step for RustAnalyzerProcMacroSrv {
898
921
}
899
922
900
923
fn run(self, builder: &Builder<'_>) -> Option<PathBuf> {
901
- let path = builder.ensure(ToolBuild {
902
- compiler: self.compiler,
903
- target: self.target,
904
- tool: "rust-analyzer-proc-macro-srv",
905
- mode: Mode::ToolRustc,
906
- path: "src/tools/rust-analyzer/crates/proc-macro-srv-cli",
907
- extra_features: vec!["in-rust-tree".to_owned()],
908
- source_type: SourceType::InTree,
909
- allow_features: RustAnalyzer::ALLOW_FEATURES,
910
- cargo_args: Vec::new(),
911
- });
924
+ let path = builder
925
+ .ensure(ToolBuild {
926
+ compiler: self.compiler,
927
+ target: self.target,
928
+ tool: "rust-analyzer-proc-macro-srv",
929
+ mode: Mode::ToolRustc,
930
+ path: "src/tools/rust-analyzer/crates/proc-macro-srv-cli",
931
+ extra_features: vec!["in-rust-tree".to_owned()],
932
+ source_type: SourceType::InTree,
933
+ allow_features: RustAnalyzer::ALLOW_FEATURES,
934
+ cargo_args: Vec::new(),
935
+ })
936
+ .tool_path;
912
937
913
938
// Copy `rust-analyzer-proc-macro-srv` to `<sysroot>/libexec/`
914
939
// so that r-a can use it.
@@ -1146,17 +1171,19 @@ fn run_tool_build_step(
1146
1171
path: &'static str,
1147
1172
add_bins_to_sysroot: Option<&[&str]>,
1148
1173
) -> PathBuf {
1149
- let tool = builder.ensure(ToolBuild {
1150
- compiler,
1151
- target,
1152
- tool: tool_name,
1153
- mode: Mode::ToolRustc,
1154
- path,
1155
- extra_features: vec![],
1156
- source_type: SourceType::InTree,
1157
- allow_features: "",
1158
- cargo_args: vec![],
1159
- });
1174
+ let tool = builder
1175
+ .ensure(ToolBuild {
1176
+ compiler,
1177
+ target,
1178
+ tool: tool_name,
1179
+ mode: Mode::ToolRustc,
1180
+ path,
1181
+ extra_features: vec![],
1182
+ source_type: SourceType::InTree,
1183
+ allow_features: "",
1184
+ cargo_args: vec![],
1185
+ })
1186
+ .tool_path;
1160
1187
1161
1188
// FIXME: This should just be an if-let-chain, but those are unstable.
1162
1189
if let Some(add_bins_to_sysroot) =
0 commit comments