@@ -136,19 +136,6 @@ impl Step for ToolBuild {
136136 _ => panic ! ( "unexpected Mode for tool build" ) ,
137137 }
138138
139- // build.tool.TOOL_NAME.features in bootstrap.toml allows specifying which features to
140- // enable for a specific tool. `extra_features` instead is not controlled by the toml and
141- // provides features that are always enabled for a specific tool (e.g. "in-rust-tree" for
142- // rust-analyzer). Finally, `prepare_tool_cargo` might add more features to adapt the build
143- // to the chosen flags (e.g. "all-static" for cargo if `cargo_native_static` is true).
144- let mut features = builder
145- . config
146- . tool
147- . get ( self . tool )
148- . and_then ( |tool| tool. features . clone ( ) )
149- . unwrap_or_default ( ) ;
150- features. extend ( self . extra_features . clone ( ) ) ;
151-
152139 let mut cargo = prepare_tool_cargo (
153140 builder,
154141 self . compiler ,
@@ -157,7 +144,7 @@ impl Step for ToolBuild {
157144 Kind :: Build ,
158145 path,
159146 self . source_type ,
160- & features ,
147+ & self . extra_features ,
161148 ) ;
162149
163150 // The stage0 compiler changes infrequently and does not directly depend on code
@@ -244,7 +231,8 @@ pub fn prepare_tool_cargo(
244231) -> CargoCommand {
245232 let mut cargo = builder:: Cargo :: new ( builder, compiler, mode, source_type, target, cmd_kind) ;
246233
247- let dir = builder. src . join ( path) ;
234+ let path = PathBuf :: from ( path) ;
235+ let dir = builder. src . join ( & path) ;
248236 cargo. arg ( "--manifest-path" ) . arg ( dir. join ( "Cargo.toml" ) ) ;
249237
250238 let mut features = extra_features. to_vec ( ) ;
@@ -261,6 +249,18 @@ pub fn prepare_tool_cargo(
261249 }
262250 }
263251
252+ // build.tool.TOOL_NAME.features in bootstrap.toml allows specifying which features to enable
253+ // for a specific tool. `extra_features` instead is not controlled by the toml and provides
254+ // features that are always enabled for a specific tool (e.g. "in-rust-tree" for rust-analyzer).
255+ // Finally, `prepare_tool_cargo` above here might add more features to adapt the build
256+ // to the chosen flags (e.g. "all-static" for cargo if `cargo_native_static` is true).
257+ builder
258+ . config
259+ . tool
260+ . iter ( )
261+ . filter ( |( tool_name, _) | path. ends_with ( tool_name) )
262+ . for_each ( |( _, tool) | features. extend ( tool. features . clone ( ) . unwrap_or_default ( ) ) ) ;
263+
264264 // clippy tests need to know about the stage sysroot. Set them consistently while building to
265265 // avoid rebuilding when running tests.
266266 cargo. env ( "SYSROOT" , builder. sysroot ( compiler) ) ;
0 commit comments