Rollup merge of #130034 - alexcrichton:fix-some-wasm-component-ld-comments, r=onur-ozkan
Fix enabling wasm-component-ld to match other tools It was [pointed out recently][comment] that enabling `wasm-component-ld` as a host tool is different from other host tools. This commit refactors the logic to match by deduplicating selection of when to build other tools and then using the same logic for `wasm-component-ld`. While here I also fixed a typo pointed out in https://github.com/rust-lang/rust/pull/126967#pullrequestreview-2285267534 [comment]: https://github.com/rust-lang/rust/pull/127866#issuecomment-2333434720
This commit is contained in:
commit
c21d31a61a
@ -1912,7 +1912,7 @@ impl Step for Assemble {
|
|||||||
// delegates to the `rust-lld` binary for linking and then runs
|
// delegates to the `rust-lld` binary for linking and then runs
|
||||||
// logic to create the final binary. This is used by the
|
// logic to create the final binary. This is used by the
|
||||||
// `wasm32-wasip2` target of Rust.
|
// `wasm32-wasip2` target of Rust.
|
||||||
if builder.build_wasm_component_ld() {
|
if builder.tool_enabled("wasm-component-ld") {
|
||||||
let wasm_component_ld_exe =
|
let wasm_component_ld_exe =
|
||||||
builder.ensure(crate::core::build_steps::tool::WasmComponentLd {
|
builder.ensure(crate::core::build_steps::tool::WasmComponentLd {
|
||||||
compiler: build_compiler,
|
compiler: build_compiler,
|
||||||
|
@ -473,7 +473,7 @@ impl Step for Rustc {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if builder.build_wasm_component_ld() {
|
if builder.tool_enabled("wasm-component-ld") {
|
||||||
let src_dir = builder.sysroot_libdir(compiler, host).parent().unwrap().join("bin");
|
let src_dir = builder.sysroot_libdir(compiler, host).parent().unwrap().join("bin");
|
||||||
let ld = exe("wasm-component-ld", compiler.host);
|
let ld = exe("wasm-component-ld", compiler.host);
|
||||||
builder.copy_link(&src_dir.join(&ld), &dst_dir.join(&ld));
|
builder.copy_link(&src_dir.join(&ld), &dst_dir.join(&ld));
|
||||||
|
@ -693,14 +693,7 @@ impl Step for Cargo {
|
|||||||
|
|
||||||
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
|
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
|
||||||
let builder = run.builder;
|
let builder = run.builder;
|
||||||
run.path("src/tools/cargo").default_condition(
|
run.path("src/tools/cargo").default_condition(builder.tool_enabled("cargo"))
|
||||||
builder.config.extended
|
|
||||||
&& builder.config.tools.as_ref().map_or(
|
|
||||||
true,
|
|
||||||
// If `tools` is set, search list for this tool.
|
|
||||||
|tools| tools.iter().any(|tool| tool == "cargo"),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn make_run(run: RunConfig<'_>) {
|
fn make_run(run: RunConfig<'_>) {
|
||||||
@ -772,14 +765,7 @@ impl Step for RustAnalyzer {
|
|||||||
|
|
||||||
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
|
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
|
||||||
let builder = run.builder;
|
let builder = run.builder;
|
||||||
run.path("src/tools/rust-analyzer").default_condition(
|
run.path("src/tools/rust-analyzer").default_condition(builder.tool_enabled("rust-analyzer"))
|
||||||
builder.config.extended
|
|
||||||
&& builder
|
|
||||||
.config
|
|
||||||
.tools
|
|
||||||
.as_ref()
|
|
||||||
.map_or(true, |tools| tools.iter().any(|tool| tool == "rust-analyzer")),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn make_run(run: RunConfig<'_>) {
|
fn make_run(run: RunConfig<'_>) {
|
||||||
@ -821,12 +807,8 @@ impl Step for RustAnalyzerProcMacroSrv {
|
|||||||
run.path("src/tools/rust-analyzer")
|
run.path("src/tools/rust-analyzer")
|
||||||
.path("src/tools/rust-analyzer/crates/proc-macro-srv-cli")
|
.path("src/tools/rust-analyzer/crates/proc-macro-srv-cli")
|
||||||
.default_condition(
|
.default_condition(
|
||||||
builder.config.extended
|
builder.tool_enabled("rust-analyzer")
|
||||||
&& builder.config.tools.as_ref().map_or(true, |tools| {
|
|| builder.tool_enabled("rust-analyzer-proc-macro-srv"),
|
||||||
tools.iter().any(|tool| {
|
|
||||||
tool == "rust-analyzer" || tool == "rust-analyzer-proc-macro-srv"
|
|
||||||
})
|
|
||||||
}),
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -874,16 +856,8 @@ impl Step for LlvmBitcodeLinker {
|
|||||||
|
|
||||||
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
|
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
|
||||||
let builder = run.builder;
|
let builder = run.builder;
|
||||||
run.path("src/tools/llvm-bitcode-linker").default_condition(
|
run.path("src/tools/llvm-bitcode-linker")
|
||||||
builder.config.extended
|
.default_condition(builder.tool_enabled("llvm-bitcode-linker"))
|
||||||
&& builder
|
|
||||||
.config
|
|
||||||
.tools
|
|
||||||
.as_ref()
|
|
||||||
.map_or(builder.build.unstable_features(), |tools| {
|
|
||||||
tools.iter().any(|tool| tool == "llvm-bitcode-linker")
|
|
||||||
}),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn make_run(run: RunConfig<'_>) {
|
fn make_run(run: RunConfig<'_>) {
|
||||||
|
@ -1407,16 +1407,17 @@ Executed at: {executed_at}"#,
|
|||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns whether it's requested that `wasm-component-ld` is built as part
|
/// Returns whether the specified tool is configured as part of this build.
|
||||||
/// of the sysroot. This is done either with the `extended` key in
|
///
|
||||||
/// `config.toml` or with the `tools` set.
|
/// This requires that both the `extended` key is set and the `tools` key is
|
||||||
fn build_wasm_component_ld(&self) -> bool {
|
/// either unset or specifically contains the specified tool.
|
||||||
if self.config.extended {
|
fn tool_enabled(&self, tool: &str) -> bool {
|
||||||
return true;
|
if !self.config.extended {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
match &self.config.tools {
|
match &self.config.tools {
|
||||||
Some(set) => set.contains("wasm-component-ld"),
|
Some(set) => set.contains(tool),
|
||||||
None => false,
|
None => true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
# `wasm-component-ld`
|
# `wasm-component-ld`
|
||||||
|
|
||||||
This wrapper is a wrapper around the [`wasm-component-ld`] crates.io crate. That
|
This wrapper is a wrapper around the [`wasm-component-ld`] crates.io crate.
|
||||||
crate. That crate is itself a thin wrapper around two pieces:
|
That crate is itself a thin wrapper around two pieces:
|
||||||
|
|
||||||
* `wasm-ld` - the LLVM-based linker distributed as part of LLD and packaged in
|
* `wasm-ld` - the LLVM-based linker distributed as part of LLD and packaged in
|
||||||
Rust as `rust-lld`.
|
Rust as `rust-lld`.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user