mirror of
https://github.com/archlinuxarm/PKGBUILDs.git
synced 2024-11-08 22:45:43 +00:00
145 lines
6.3 KiB
Diff
145 lines
6.3 KiB
Diff
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||
|
From: Alex Crichton <alex@alexcrichton.com>
|
||
|
Date: Fri, 6 Sep 2024 09:21:33 -0700
|
||
|
Subject: [PATCH] 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`.
|
||
|
|
||
|
[comment]: https://github.com/rust-lang/rust/pull/127866#issuecomment-2333434720
|
||
|
---
|
||
|
src/bootstrap/src/core/build_steps/compile.rs | 2 +-
|
||
|
src/bootstrap/src/core/build_steps/dist.rs | 2 +-
|
||
|
src/bootstrap/src/core/build_steps/tool.rs | 38 +++----------------
|
||
|
src/bootstrap/src/lib.rs | 17 +++++----
|
||
|
4 files changed, 17 insertions(+), 42 deletions(-)
|
||
|
|
||
|
diff --git a/src/bootstrap/src/core/build_steps/compile.rs b/src/bootstrap/src/core/build_steps/compile.rs
|
||
|
index edf18e2ebf33..596e1eb358fa 100644
|
||
|
--- a/src/bootstrap/src/core/build_steps/compile.rs
|
||
|
+++ b/src/bootstrap/src/core/build_steps/compile.rs
|
||
|
@@ -1892,7 +1892,7 @@ fn run(self, builder: &Builder<'_>) -> Compiler {
|
||
|
// 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() {
|
||
|
+ if builder.tool_enabled("wasm-component-ld") {
|
||
|
let wasm_component_ld_exe =
|
||
|
builder.ensure(crate::core::build_steps::tool::WasmComponentLd {
|
||
|
compiler: build_compiler,
|
||
|
diff --git a/src/bootstrap/src/core/build_steps/dist.rs b/src/bootstrap/src/core/build_steps/dist.rs
|
||
|
index 31d55542ec64..74a230416bde 100644
|
||
|
--- a/src/bootstrap/src/core/build_steps/dist.rs
|
||
|
+++ b/src/bootstrap/src/core/build_steps/dist.rs
|
||
|
@@ -473,7 +473,7 @@ fn prepare_image(builder: &Builder<'_>, compiler: Compiler, image: &Path) {
|
||
|
);
|
||
|
}
|
||
|
}
|
||
|
- 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 ld = exe("wasm-component-ld", compiler.host);
|
||
|
builder.copy_link(&src_dir.join(&ld), &dst_dir.join(&ld));
|
||
|
diff --git a/src/bootstrap/src/core/build_steps/tool.rs b/src/bootstrap/src/core/build_steps/tool.rs
|
||
|
index 3acd3c7881eb..bb9d380fb6b2 100644
|
||
|
--- a/src/bootstrap/src/core/build_steps/tool.rs
|
||
|
+++ b/src/bootstrap/src/core/build_steps/tool.rs
|
||
|
@@ -693,14 +693,7 @@ impl Step for Cargo {
|
||
|
|
||
|
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
|
||
|
let builder = run.builder;
|
||
|
- run.path("src/tools/cargo").default_condition(
|
||
|
- 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"),
|
||
|
- ),
|
||
|
- )
|
||
|
+ run.path("src/tools/cargo").default_condition(builder.tool_enabled("cargo"))
|
||
|
}
|
||
|
|
||
|
fn make_run(run: RunConfig<'_>) {
|
||
|
@@ -772,14 +765,7 @@ impl Step for RustAnalyzer {
|
||
|
|
||
|
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
|
||
|
let builder = run.builder;
|
||
|
- run.path("src/tools/rust-analyzer").default_condition(
|
||
|
- builder.config.extended
|
||
|
- && builder
|
||
|
- .config
|
||
|
- .tools
|
||
|
- .as_ref()
|
||
|
- .map_or(true, |tools| tools.iter().any(|tool| tool == "rust-analyzer")),
|
||
|
- )
|
||
|
+ run.path("src/tools/rust-analyzer").default_condition(builder.tool_enabled("rust-analyzer"))
|
||
|
}
|
||
|
|
||
|
fn make_run(run: RunConfig<'_>) {
|
||
|
@@ -821,12 +807,8 @@ fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
|
||
|
run.path("src/tools/rust-analyzer")
|
||
|
.path("src/tools/rust-analyzer/crates/proc-macro-srv-cli")
|
||
|
.default_condition(
|
||
|
- builder.config.extended
|
||
|
- && builder.config.tools.as_ref().map_or(true, |tools| {
|
||
|
- tools.iter().any(|tool| {
|
||
|
- tool == "rust-analyzer" || tool == "rust-analyzer-proc-macro-srv"
|
||
|
- })
|
||
|
- }),
|
||
|
+ builder.tool_enabled("rust-analyzer")
|
||
|
+ || builder.tool_enabled("rust-analyzer-proc-macro-srv"),
|
||
|
)
|
||
|
}
|
||
|
|
||
|
@@ -874,16 +856,8 @@ impl Step for LlvmBitcodeLinker {
|
||
|
|
||
|
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
|
||
|
let builder = run.builder;
|
||
|
- run.path("src/tools/llvm-bitcode-linker").default_condition(
|
||
|
- builder.config.extended
|
||
|
- && builder
|
||
|
- .config
|
||
|
- .tools
|
||
|
- .as_ref()
|
||
|
- .map_or(builder.build.unstable_features(), |tools| {
|
||
|
- tools.iter().any(|tool| tool == "llvm-bitcode-linker")
|
||
|
- }),
|
||
|
- )
|
||
|
+ run.path("src/tools/llvm-bitcode-linker")
|
||
|
+ .default_condition(builder.tool_enabled("llvm-bitcode-linker"))
|
||
|
}
|
||
|
|
||
|
fn make_run(run: RunConfig<'_>) {
|
||
|
diff --git a/src/bootstrap/src/lib.rs b/src/bootstrap/src/lib.rs
|
||
|
index 82b640f54234..fb73c5ff799a 100644
|
||
|
--- a/src/bootstrap/src/lib.rs
|
||
|
+++ b/src/bootstrap/src/lib.rs
|
||
|
@@ -1379,16 +1379,17 @@ 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;
|
||
|
+ /// Returns whether the specified tool is configured as part of this build.
|
||
|
+ ///
|
||
|
+ /// This requires that both the `extended` key is set and the `tools` key is
|
||
|
+ /// either unset or specifically contains the specified tool.
|
||
|
+ fn tool_enabled(&self, tool: &str) -> bool {
|
||
|
+ if !self.config.extended {
|
||
|
+ return false;
|
||
|
}
|
||
|
match &self.config.tools {
|
||
|
- Some(set) => set.contains("wasm-component-ld"),
|
||
|
- None => false,
|
||
|
+ Some(set) => set.contains(tool),
|
||
|
+ None => true,
|
||
|
}
|
||
|
}
|
||
|
|