Skip to content

Commit a930388

Browse files
committed
Conditionally build wasm-component-ld when lld is enabled
This commit updates the support for the `wasm-component-ld` tool from #126967 to conditionally build it when LLD is enabled 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 a930388

File tree

4 files changed

+31
-9
lines changed

4 files changed

+31
-9
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

+11-9
Original file line numberDiff line numberDiff line change
@@ -1826,15 +1826,17 @@ impl Step for Assemble {
18261826
// delegates to the `rust-lld` binary for linking and then runs
18271827
// logic to create the final binary. This is used by the
18281828
// `wasm32-wasip2` target of Rust.
1829-
let wasm_component_ld_exe =
1830-
builder.ensure(crate::core::build_steps::tool::WasmComponentLd {
1831-
compiler: build_compiler,
1832-
target: target_compiler.host,
1833-
});
1834-
builder.copy_link(
1835-
&wasm_component_ld_exe,
1836-
&libdir_bin.join(wasm_component_ld_exe.file_name().unwrap()),
1837-
);
1829+
if builder.build_wasm_component_ld() {
1830+
let wasm_component_ld_exe =
1831+
builder.ensure(crate::core::build_steps::tool::WasmComponentLd {
1832+
compiler: build_compiler,
1833+
target: target_compiler.host,
1834+
});
1835+
builder.copy_link(
1836+
&wasm_component_ld_exe,
1837+
&libdir_bin.join(wasm_component_ld_exe.file_name().unwrap()),
1838+
);
1839+
}
18381840
}
18391841

18401842
if builder.config.llvm_enabled(target_compiler.host) {

src/bootstrap/src/core/sanity.rs

+6
Original file line numberDiff line numberDiff line change
@@ -375,4 +375,10 @@ $ pacman -R cmake && pacman -S mingw-w64-x86_64-cmake
375375
if let Some(ref s) = build.config.ccache {
376376
cmd_finder.must_have(s);
377377
}
378+
379+
// Verify that if the `wasm-component-ld` tool is requested to be built that
380+
// it's dependency, lld, is also being built.
381+
if build.build_wasm_component_ld() && !build.config.lld_enabled {
382+
panic!("when wasm-component-ld is requested to be built LLD must be enabled as well");
383+
}
378384
}

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)