Skip to content

Commit 5de971b

Browse files
authored
Merge pull request #195828 from Homebrew/wasm-component-ld
wasm-component-ld 0.5.10 (new formula), wasi-runtimes: depend on `wasm-component-ld`
2 parents 5517273 + 7ef03f3 commit 5de971b

File tree

2 files changed

+63
-13
lines changed

2 files changed

+63
-13
lines changed

Formula/w/wasi-runtimes.rb

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,19 @@ class WasiRuntimes < Formula
1111
end
1212

1313
bottle do
14-
sha256 cellar: :any_skip_relocation, arm64_sequoia: "0f2634f91560a0537344f4c84466e06fad5061c6eaf943136ffc82f2c8e8fa58"
15-
sha256 cellar: :any_skip_relocation, arm64_sonoma: "3903b29603e9926d540312e302a5f9c1e0338587c2d9ab71b40a00a00e3c22ce"
16-
sha256 cellar: :any_skip_relocation, arm64_ventura: "27e597c06a4606f5e189a8aafe97a67d1af2b1efde5a8919a380b8a4423df319"
17-
sha256 cellar: :any_skip_relocation, sonoma: "bedd743473f5afa26709ef42f2c729f9dd7c350930fb5d47b24c2ab575cb95bf"
18-
sha256 cellar: :any_skip_relocation, ventura: "72fb97b1e58463cfa0e40625ce6028be7f4f41c19ad0455af1ad0c31521cf70b"
19-
sha256 cellar: :any_skip_relocation, x86_64_linux: "926a42b854953ac8613d97785241bbc78a2ef4190b0c6680ddcf496a9e4d0d65"
14+
rebuild 1
15+
sha256 cellar: :any_skip_relocation, arm64_sequoia: "6a416ceb547e428f6fa7ba55c1f955889504dc92ad62ad0c23d3e52c0aca4dff"
16+
sha256 cellar: :any_skip_relocation, arm64_sonoma: "827a14dab71af9ca068ebe22e3e5a8cefb87f3f69f93011d9e9c4feb36d054b2"
17+
sha256 cellar: :any_skip_relocation, arm64_ventura: "10a1a47517183e7b2e92f45dffae7142b261332a2a187c37677690684d69c30a"
18+
sha256 cellar: :any_skip_relocation, sonoma: "ada587bb34d56e564ad457584c1e100ae5b505dc16d79e9e22840353106234ff"
19+
sha256 cellar: :any_skip_relocation, ventura: "17bb1834271dbed6588418961a23891cd2682b3f717bb1d82157dbaf87fc4519"
20+
sha256 cellar: :any_skip_relocation, x86_64_linux: "cf2e167df3de25498aca9b287f2880d99a0b20de5e2710166063a8dd4ad5912f"
2021
end
2122

2223
depends_on "cmake" => :build
2324
depends_on "lld" => [:build, :test]
2425
depends_on "wasi-libc" => [:build, :test]
26+
depends_on "wasm-component-ld" => [:build, :test]
2527
depends_on "wasmtime" => :test
2628
depends_on "llvm"
2729

@@ -94,10 +96,6 @@ def install
9496
ln_s pn, target
9597
end
9698

97-
# FIXME: the build mistakenly concludes our toolchain doesn't support `-fno-exceptions`
98-
# because we have no `wasm-component-ld`. Remove the line below when
99-
# `wasm-component-ld` is merged.
100-
ENV.append_to_cflags "-fno-exceptions"
10199
target_configuration = Hash.new { |h, k| h[k] = {} }
102100

103101
targets.each do |target|
@@ -207,9 +205,6 @@ def install
207205

208206
clang = Formula["llvm"].opt_bin/"clang"
209207
targets.each do |target|
210-
# FIXME: Needs a working `wasm-component-ld`.
211-
next if target.include?("wasip2")
212-
213208
system clang, "--target=#{target}", "-v", "test.c", "-o", "test-#{target}"
214209
assert_equal "the answer is 42", shell_output("wasmtime #{testpath}/test-#{target}")
215210

Formula/w/wasm-component-ld.rb

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
class WasmComponentLd < Formula
2+
desc "Linker for creating WebAssembly components"
3+
homepage "https://wasi.dev"
4+
url "https://github.com/bytecodealliance/wasm-component-ld/archive/refs/tags/v0.5.10.tar.gz"
5+
sha256 "aa049a93da595e4dacf742865f13e7fb1cec1ab47de9258f0a11d81ad6c7a77b"
6+
license "Apache-2.0"
7+
head "https://github.com/bytecodealliance/wasm-component-ld.git", branch: "main"
8+
9+
bottle do
10+
sha256 cellar: :any_skip_relocation, arm64_sequoia: "79de06bddaa5af8534ef3e3210be559c7413e17d8f504f2ffdefeb24189f1239"
11+
sha256 cellar: :any_skip_relocation, arm64_sonoma: "f1f36e28abceafb366512a3a0235c8aa80ba3e6a3e403dc2bd78cde3b266c769"
12+
sha256 cellar: :any_skip_relocation, arm64_ventura: "8d0fca96ba4e4dacef300f1d632ebcd0fc3066daae8853d517ded1bd55766dae"
13+
sha256 cellar: :any_skip_relocation, sonoma: "2bb06da23d7c598b67d980a7c0405e83762666473b4e54c1d8bc6eef749d2ac4"
14+
sha256 cellar: :any_skip_relocation, ventura: "581b65d32016bc17e626999536900c6f5ecec015f694b75ec8eacdf34c72083f"
15+
sha256 cellar: :any_skip_relocation, x86_64_linux: "38fecd207497a23c63d145c56ff12aa25e6a692905d34087ca211185e5dc36ad"
16+
end
17+
18+
depends_on "rust" => :build
19+
depends_on "lld" => :test
20+
depends_on "llvm" => :test
21+
depends_on "wasi-libc" => :test
22+
depends_on "wasmtime" => :test
23+
24+
def install
25+
system "cargo", "install", *std_cargo_args
26+
end
27+
28+
test do
29+
resource "builtins" do
30+
url "https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-24/libclang_rt.builtins-wasm32-wasi-24.0.tar.gz"
31+
sha256 "7e33c0df758b90469b1de3ca158e2d0a7f71934d5884525ba6a372de0b3b0ec7"
32+
end
33+
34+
ENV.remove_macosxsdk if OS.mac?
35+
ENV.remove_cc_etc
36+
37+
(testpath/"test.c").write <<~C
38+
#include <stdio.h>
39+
volatile int x = 42;
40+
int main(void) {
41+
printf("the answer is %d", x);
42+
return 0;
43+
}
44+
C
45+
46+
clang = Formula["llvm"].opt_bin/"clang"
47+
clang_resource_dir = Pathname.new(shell_output("#{clang} --print-resource-dir").chomp)
48+
testpath.install_symlink clang_resource_dir/"include"
49+
resource("builtins").stage testpath/"lib/wasm32-unknown-wasip2"
50+
(testpath/"lib/wasm32-unknown-wasip2").install_symlink "libclang_rt.builtins-wasm32.a" => "libclang_rt.builtins.a"
51+
wasm_args = %W[--target=wasm32-wasip2 --sysroot=#{Formula["wasi-libc"].opt_share}/wasi-sysroot]
52+
system clang, *wasm_args, "-v", "test.c", "-o", "test", "-resource-dir=#{testpath}"
53+
assert_equal "the answer is 42", shell_output("wasmtime #{testpath}/test")
54+
end
55+
end

0 commit comments

Comments
 (0)