Skip to content

Commit 12c179f

Browse files
committed
Bootstrap's tool.TOOL_NAME.features now works on any subcommand
1 parent 32cd911 commit 12c179f

File tree

2 files changed

+20
-15
lines changed

2 files changed

+20
-15
lines changed

src/bootstrap/src/core/build_steps/tool.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -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));

src/bootstrap/src/utils/change_tracker.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,4 +461,9 @@ pub const CONFIG_CHANGE_HISTORY: &[ChangeInfo] = &[
461461
severity: ChangeSeverity::Warning,
462462
summary: "`download-rustc` has been temporarily disabled for the library profile due to implementation bugs (see #142505).",
463463
},
464+
ChangeInfo {
465+
change_id: 143733,
466+
severity: ChangeSeverity::Info,
467+
summary: "Option `tool.TOOL_NAME.features` now works on any subcommand, not just `build`.",
468+
},
464469
];

0 commit comments

Comments
 (0)