Skip to content

Commit 45b5cfa

Browse files
committed
Conditionally build wasm-component-ld
This commit updates the support for the `wasm-component-ld` tool from #126967 to conditionally build it rather than unconditionally building it when LLD is enabled. This support is disabled by default and can be enabled by one of two means: * the `extended` field in `config.toml` which dist builders use to build a complete set of tools for each host platform. * a `"wasm-component-ld"` entry in the `tools` section of `config.toml`. Neither of these are enabled by default meaning that most local builds will likely not have this new tool built. Dist builders should still, however, build the tool.
1 parent 3de0a7c commit 45b5cfa

File tree

3 files changed

+21
-5
lines changed

3 files changed

+21
-5
lines changed

config.example.toml

+1
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,7 @@
333333
# "rust-analyzer-proc-macro-srv",
334334
# "analysis",
335335
# "src",
336+
# "wasm-component-ld",
336337
#]
337338

338339
# Verbosity level: 0 == not verbose, 1 == verbose, 2 == very verbose, 3 == print environment variables on each rustc invocation

src/bootstrap/src/core/build_steps/compile.rs

+7-5
Original file line numberDiff line numberDiff line change
@@ -1820,12 +1820,14 @@ impl Step for Assemble {
18201820
&self_contained_lld_dir.join(exe(name, target_compiler.host)),
18211821
);
18221822
}
1823+
}
18231824

1824-
// In addition to `rust-lld` also install `wasm-component-ld` when
1825-
// LLD is enabled. This is a relatively small binary that primarily
1826-
// delegates to the `rust-lld` binary for linking and then runs
1827-
// logic to create the final binary. This is used by the
1828-
// `wasm32-wasip2` target of Rust.
1825+
// In addition to `rust-lld` also install `wasm-component-ld` when
1826+
// LLD is enabled. This is a relatively small binary that primarily
1827+
// delegates to the `rust-lld` binary for linking and then runs
1828+
// logic to create the final binary. This is used by the
1829+
// `wasm32-wasip2` target of Rust.
1830+
if builder.build_wasm_component_ld() {
18291831
let wasm_component_ld_exe =
18301832
builder.ensure(crate::core::build_steps::tool::WasmComponentLd {
18311833
compiler: build_compiler,

src/bootstrap/src/lib.rs

+13
Original file line numberDiff line numberDiff line change
@@ -1413,6 +1413,19 @@ Executed at: {executed_at}"#,
14131413
None
14141414
}
14151415

1416+
/// Returns whether it's requested that `wasm-component-ld` is built as part
1417+
/// of the sysroot. This is done either with the `extended` key in
1418+
/// `config.toml` or with the `tools` set.
1419+
fn build_wasm_component_ld(&self) -> bool {
1420+
if self.config.extended {
1421+
return true;
1422+
}
1423+
match &self.config.tools {
1424+
Some(set) => set.contains("wasm-component-ld"),
1425+
None => false,
1426+
}
1427+
}
1428+
14161429
/// Returns the root of the "rootfs" image that this target will be using,
14171430
/// if one was configured.
14181431
///

0 commit comments

Comments
 (0)