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.
This commit is contained in:
Alex Crichton 2024-07-17 07:46:09 -07:00
parent 11e57241f1
commit ae82726a44
3 changed files with 21 additions and 5 deletions

View File

@ -333,6 +333,7 @@
# "rust-analyzer-proc-macro-srv",
# "analysis",
# "src",
# "wasm-component-ld",
#]
# Verbosity level: 0 == not verbose, 1 == verbose, 2 == very verbose, 3 == print environment variables on each rustc invocation

View File

@ -1820,12 +1820,14 @@ fn run(self, builder: &Builder<'_>) -> Compiler {
&self_contained_lld_dir.join(exe(name, target_compiler.host)),
);
}
}
// In addition to `rust-lld` also install `wasm-component-ld` when
// LLD is enabled. This is a relatively small binary that primarily
// delegates to the `rust-lld` binary for linking and then runs
// logic to create the final binary. This is used by the
// `wasm32-wasip2` target of Rust.
if builder.build_wasm_component_ld() {
let wasm_component_ld_exe =
builder.ensure(crate::core::build_steps::tool::WasmComponentLd {
compiler: build_compiler,

View File

@ -1414,6 +1414,19 @@ fn default_wasi_runner(&self) -> Option<String> {
None
}
/// Returns whether it's requested that `wasm-component-ld` is built as part
/// of the sysroot. This is done either with the `extended` key in
/// `config.toml` or with the `tools` set.
fn build_wasm_component_ld(&self) -> bool {
if self.config.extended {
return true;
}
match &self.config.tools {
Some(set) => set.contains("wasm-component-ld"),
None => false,
}
}
/// Returns the root of the "rootfs" image that this target will be using,
/// if one was configured.
///