@@ -796,6 +796,7 @@ macro_rules! tool_extended {
796
796
$tool_name: expr,
797
797
stable = $stable: expr
798
798
$( , tool_std = $tool_std: literal) ?
799
+ $( , add_to_sysroot = $add_to_sysroot: literal) ?
799
800
; ) +) => {
800
801
$(
801
802
#[ derive( Debug , Clone , Hash , PartialEq , Eq ) ]
@@ -838,7 +839,7 @@ macro_rules! tool_extended {
838
839
839
840
#[ allow( unused_mut) ]
840
841
fn run( mut $sel, $builder: & Builder <' _>) -> Option <PathBuf > {
841
- $builder. ensure( ToolBuild {
842
+ let tool = $builder. ensure( ToolBuild {
842
843
compiler: $sel. compiler,
843
844
target: $sel. target,
844
845
tool: $tool_name,
@@ -847,7 +848,18 @@ macro_rules! tool_extended {
847
848
extra_features: $sel. extra_features,
848
849
is_optional_tool: true ,
849
850
source_type: SourceType :: InTree ,
850
- } )
851
+ } ) ?;
852
+
853
+ if ( false $( || $add_to_sysroot) ?) && $sel. compiler. stage > 0 {
854
+ let bin_dir = $builder. sysroot( $sel. compiler) . join( "bin" ) ;
855
+ t!( fs:: create_dir_all( & bin_dir) ) ;
856
+ let bin_tool = bin_dir. join( exe( $tool_name, $sel. compiler. host) ) ;
857
+ let _ = fs:: remove_file( & bin_tool) ;
858
+ $builder. copy( & tool, & bin_tool) ;
859
+ Some ( bin_tool)
860
+ } else {
861
+ Some ( tool)
862
+ }
851
863
}
852
864
}
853
865
) +
@@ -859,17 +871,17 @@ macro_rules! tool_extended {
859
871
// Note: Most submodule updates for tools are handled by bootstrap.py, since they're needed just to
860
872
// invoke Cargo to build bootstrap. See the comment there for more details.
861
873
tool_extended ! ( ( self , builder) ,
862
- Cargofmt , "src/tools/rustfmt" , "cargo-fmt" , stable=true ;
863
- CargoClippy , "src/tools/clippy" , "cargo-clippy" , stable=true ;
864
- Clippy , "src/tools/clippy" , "clippy-driver" , stable=true ;
865
- Miri , "src/tools/miri" , "miri" , stable=false ;
866
- CargoMiri , "src/tools/miri/cargo-miri" , "cargo-miri" , stable=true ;
874
+ Cargofmt , "src/tools/rustfmt" , "cargo-fmt" , stable=true , add_to_sysroot= true ;
875
+ CargoClippy , "src/tools/clippy" , "cargo-clippy" , stable=true , add_to_sysroot= true ;
876
+ Clippy , "src/tools/clippy" , "clippy-driver" , stable=true , add_to_sysroot= true ;
877
+ Miri , "src/tools/miri" , "miri" , stable=false , add_to_sysroot= true ;
878
+ CargoMiri , "src/tools/miri/cargo-miri" , "cargo-miri" , stable=false , add_to_sysroot= true ;
867
879
// FIXME: tool_std is not quite right, we shouldn't allow nightly features.
868
880
// But `builder.cargo` doesn't know how to handle ToolBootstrap in stages other than 0,
869
881
// and this is close enough for now.
870
882
Rls , "src/tools/rls" , "rls" , stable=true , tool_std=true ;
871
883
RustDemangler , "src/tools/rust-demangler" , "rust-demangler" , stable=false , tool_std=true ;
872
- Rustfmt , "src/tools/rustfmt" , "rustfmt" , stable=true ;
884
+ Rustfmt , "src/tools/rustfmt" , "rustfmt" , stable=true , add_to_sysroot= true ;
873
885
) ;
874
886
875
887
impl < ' a > Builder < ' a > {
0 commit comments