@@ -22,6 +22,7 @@ class WasiRuntimes < Formula
22
22
depends_on "cmake" => :build
23
23
depends_on "lld" => [ :build , :test ]
24
24
depends_on "wasi-libc" => [ :build , :test ]
25
+ depends_on "wasm-component-ld" => [ :build , :test ]
25
26
depends_on "wasmtime" => :test
26
27
depends_on "llvm"
27
28
@@ -53,6 +54,9 @@ def install
53
54
-DCMAKE_C_COMPILER_WORKS=ON
54
55
-DCMAKE_CXX_COMPILER_WORKS=ON
55
56
-DCMAKE_SYSROOT=#{ wasi_libc . opt_share } /wasi-sysroot
57
+ -DCMAKE_FIND_FRAMEWORK=NEVER
58
+ -DCMAKE_VERBOSE_MAKEFILE=ON
59
+ -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=#{ HOMEBREW_LIBRARY_PATH } /cmake/trap_fetchcontent_provider.cmake
56
60
]
57
61
# Compiler flags taken from:
58
62
# https://github.com/WebAssembly/wasi-sdk/blob/5e04cd81eb749edb5642537d150ab1ab7aedabe9/cmake/wasi-sdk-sysroot.cmake#L65-L75
@@ -75,7 +79,9 @@ def install
75
79
( pkgshare /"lib" ) . install_symlink "wasi" => "wasip1"
76
80
( pkgshare /"lib" ) . install_symlink "wasi" => "wasip2"
77
81
78
- clang_resource_dir = Pathname . new ( Utils . safe_popen_read ( llvm . opt_bin /"clang" , "-print-resource-dir" ) . chomp )
82
+ clang_resource_dir = Utils . safe_popen_read ( llvm . opt_bin /"clang" , "-print-resource-dir" ) . chomp
83
+ clang_resource_dir . sub! llvm . prefix . realpath , llvm . opt_prefix
84
+ clang_resource_dir = Pathname . new ( clang_resource_dir )
79
85
clang_resource_include_dir = clang_resource_dir /"include"
80
86
clang_resource_include_dir . find do |pn |
81
87
next unless pn . file?
@@ -84,7 +90,8 @@ def install
84
90
target = pkgshare /relative_path
85
91
next if target . exist?
86
92
87
- target . parent . install_symlink pn
93
+ target . parent . mkpath
94
+ ln_s pn , target
88
95
end
89
96
90
97
target_configuration = Hash . new { |h , k | h [ k ] = { } }
@@ -93,7 +100,8 @@ def install
93
100
# Configuration taken from:
94
101
# https://github.com/WebAssembly/wasi-sdk/blob/5e04cd81eb749edb5642537d150ab1ab7aedabe9/cmake/wasi-sdk-sysroot.cmake#L227-L271
95
102
configuration = target_configuration [ target ]
96
- configuration [ :threads ] = configuration [ :pic ] = target . end_with? ( "-threads" ) ? "ON" : "OFF"
103
+ configuration [ :threads ] = target . end_with? ( "-threads" ) ? "ON" : "OFF"
104
+ configuration [ :pic ] = target . end_with? ( "-threads" ) ? "OFF" : "ON"
97
105
configuration [ :flags ] = target . end_with? ( "-threads" ) ? [ "-pthread" ] : [ ]
98
106
99
107
cflags = ENV . cflags &.split || [ ]
@@ -130,7 +138,7 @@ def install
130
138
-DLIBCXX_ENABLE_FILESYSTEM:BOOL=ON
131
139
-DLIBCXX_ENABLE_ABI_LINKER_SCRIPT:BOOL=OFF
132
140
-DLIBCXX_CXX_ABI=libcxxabi
133
- -DLIBCXX_CXX_ABI_INCLUDE_PATHS=#{ testpath } /libcxxabi/include
141
+ -DLIBCXX_CXX_ABI_INCLUDE_PATHS=#{ buildpath } /libcxxabi/include
134
142
-DLIBCXX_HAS_MUSL_LIBC:BOOL=ON
135
143
-DLIBCXX_ABI_VERSION=2
136
144
-DLIBCXXABI_ENABLE_EXCEPTIONS:BOOL=OFF
@@ -189,9 +197,6 @@ def install
189
197
-resource-dir=#{ HOMEBREW_PREFIX } /share/wasi-runtimes
190
198
]
191
199
targets . each do |target |
192
- # FIXME: Needs a working `wasm-component-ld`.
193
- next if target . include? ( "wasip2" )
194
-
195
200
system clang , "--target=#{ target } " , *wasm_args , "-v" , "test.c" , "-o" , "test-#{ target } "
196
201
assert_equal "the answer is 42" , shell_output ( "wasmtime #{ testpath } /test-#{ target } " )
197
202
0 commit comments