Skip to content

Commit 83f36a3

Browse files
[wasm] fix Cxx.swiftmodule build on macOS by patching wasi-sysroot
1 parent 3a413c4 commit 83f36a3

File tree

2 files changed

+77
-0
lines changed

2 files changed

+77
-0
lines changed

utils/webassembly/install-build-sdk.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ set -eux
44

55
SOURCE_PATH="$( cd "$(dirname "$0")/../../../" && pwd )"
66
BUILD_SDK_PATH="$SOURCE_PATH/build-sdk"
7+
PATCHES="$(cd "$(dirname "$0")/patches" && pwd)"
78

89
install_libxml2() {
910
LIBXML2_URL="https://github.com/swiftwasm/libxml2-wasm/releases/download/1.0.0/libxml2-wasm32-unknown-wasi.tar.gz"
@@ -25,6 +26,7 @@ install_wasi-sysroot() {
2526
curl -L "$WASI_SYSROOT_URL" | tar xz
2627

2728
mv "wasi-sysroot" "$BUILD_SDK_PATH/wasi-sysroot"
29+
patch -p1 -d "$BUILD_SDK_PATH/wasi-sysroot" < "$PATCHES/wasi-sysroot"/*.patch
2830
}
2931

3032
workdir=$(mktemp -d)
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
Author: Yuta Saito <[email protected]>
2+
Date: Thu Dec 29 10:50:33 2022 +0000
3+
4+
Without this patch, Cxx.swiftmodule build fails on macOS host environments
5+
6+
diff --git a/include/c++/v1/module.modulemap b/include/c++/v1/module.modulemap
7+
index b5781b0..af10440 100644
8+
--- a/include/c++/v1/module.modulemap
9+
+++ b/include/c++/v1/module.modulemap
10+
@@ -44,10 +44,12 @@ module std [system] {
11+
header "math.h"
12+
export *
13+
}
14+
+ /* XXX(swiftwasm): setjmp.h is unavailable in wasi-libc
15+
module setjmp_h {
16+
header "setjmp.h"
17+
export *
18+
}
19+
+ */
20+
// FIXME: <stdalign.h> is missing.
21+
// <signal.h> provided by C library.
22+
// <stdarg.h> provided by compiler.
23+
@@ -153,10 +155,12 @@ module std [system] {
24+
header "cmath"
25+
export *
26+
}
27+
+ /* XXX(swiftwasm): setjmp.h is unavailable in wasi-libc
28+
module csetjmp {
29+
header "csetjmp"
30+
export *
31+
}
32+
+ */
33+
module csignal {
34+
header "csignal"
35+
export *
36+
@@ -384,10 +388,12 @@ module std [system] {
37+
header "execution"
38+
export *
39+
}
40+
+ /* XXX(swiftwasm): wasi-sdk configures with LIBCXX_ENABLE_FILESYSTEM=OFF
41+
module filesystem {
42+
header "filesystem"
43+
export *
44+
}
45+
+ */
46+
module format {
47+
header "format"
48+
export *
49+
@@ -645,11 +651,13 @@ module std [system] {
50+
header "scoped_allocator"
51+
export *
52+
}
53+
+ /* XXX(swiftwasm): semaphore is unavailable due to lack of thread
54+
module semaphore {
55+
requires cplusplus14
56+
header "semaphore"
57+
export *
58+
}
59+
+ */
60+
module set {
61+
header "set"
62+
export initializer_list
63+
@@ -816,10 +824,12 @@ module std [system] {
64+
header "experimental/deque"
65+
export *
66+
}
67+
+ /* XXX(swiftwasm): wasi-sdk configures with LIBCXX_ENABLE_FILESYSTEM=OFF
68+
module filesystem {
69+
header "experimental/filesystem"
70+
export *
71+
}
72+
+ */
73+
module forward_list {
74+
header "experimental/forward_list"
75+
export *

0 commit comments

Comments
 (0)