Skip to content

Commit a6b0998

Browse files
[Wasm] Update wasi-sdk to 4 to 14.0
Use the new artifact in our own fork,
1 parent 37b7c0a commit a6b0998

File tree

6 files changed

+26
-27
lines changed

6 files changed

+26
-27
lines changed

lib/ClangImporter/ClangImporter.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,10 @@ importer::getNormalInvocationArguments(
664664
}
665665

666666
if (triple.isOSWASI()) {
667-
invocationArgStrs.insert(invocationArgStrs.end(), {"-D_WASI_EMULATED_MMAN"});
667+
invocationArgStrs.insert(invocationArgStrs.end(),
668+
{"-D_WASI_EMULATED_MMAN",
669+
"-D_WASI_EMULATED_SIGNAL",
670+
"-D_WASI_EMULATED_PROCESS_CLOCKS"});
668671
SmallString<128> buffer;
669672
if (auto path = getWasiLibcModuleMapPath(searchPathOpts, triple, buffer)) {
670673
invocationArgStrs.push_back((Twine("-fmodule-map-file=") + *path).str());

stdlib/cmake/modules/AddSwiftStdlib.cmake

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ function(_add_target_variant_c_compile_flags)
284284
endif()
285285

286286
if("${CFLAGS_SDK}" STREQUAL "WASI")
287-
list(APPEND result "-D_WASI_EMULATED_MMAN")
287+
list(APPEND result "-D_WASI_EMULATED_MMAN" "-D_WASI_EMULATED_SIGNAL" "-D_WASI_EMULATED_PROCESS_CLOCKS")
288288
endif()
289289

290290
if("${CFLAGS_SDK}" STREQUAL "LINUX")
@@ -294,11 +294,7 @@ function(_add_target_variant_c_compile_flags)
294294
endif()
295295
endif()
296296

297-
if("${CFLAGS_SDK}" STREQUAL "WASI")
298-
list(APPEND result "-D_WASI_EMULATED_MMAN")
299-
endif()
300-
301-
if(SWIFT_DISABLE_OBJC_INTEROP)
297+
if(NOT SWIFT_STDLIB_ENABLE_OBJC_INTEROP)
302298
list(APPEND result "-DSWIFT_OBJC_INTEROP=0")
303299
endif()
304300

stdlib/cmake/modules/SwiftSource.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ function(_add_target_variant_swift_compile_flags
234234
endif()
235235

236236
if("${sdk}" STREQUAL "WASI")
237-
list(APPEND result "-Xcc" "-D_WASI_EMULATED_MMAN")
237+
list(APPEND result "-Xcc" "-D_WASI_EMULATED_MMAN" "-Xcc" "-D_WASI_EMULATED_SIGNAL" "-Xcc" "-D_WASI_EMULATED_PROCESS_CLOCKS")
238238
endif()
239239

240240
if(NOT BUILD_STANDALONE)

utils/webassembly/build-toolchain.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ SOURCE_PATH="$(cd "$(dirname "$0")/../../.." && pwd)"
55
UTILS_PATH="$(cd "$(dirname "$0")" && pwd)"
66

77
BUILD_SDK_PATH="$SOURCE_PATH/build-sdk"
8-
WASI_SDK_PATH="$BUILD_SDK_PATH/wasi-sdk"
9-
WASI_SYSROOT_PATH="$WASI_SDK_PATH/share/wasi-sysroot"
8+
WASI_SYSROOT_PATH="$BUILD_SDK_PATH/wasi-sysroot"
109

1110
case $(uname -s) in
1211
Darwin)
@@ -138,7 +137,7 @@ build_target_toolchain() {
138137

139138
embed_wasi_sysroot() {
140139
# Merge wasi-sdk and the toolchain
141-
cp -r "$WASI_SDK_PATH/share/wasi-sysroot" "$DIST_TOOLCHAIN_SDK/usr/share"
140+
cp -r "$WASI_SYSROOT_PATH" "$DIST_TOOLCHAIN_SDK/usr/share"
142141

143142
# Replace absolute sysroot path with relative path
144143
sed -i.bak -e "s@\".*/include@\"../../../../share/wasi-sysroot/include@g" "$DIST_TOOLCHAIN_SDK/usr/lib/swift/wasi/wasm32/wasi.modulemap"

utils/webassembly/install-build-sdk.sh

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,27 +19,27 @@ install_icu() {
1919
mv icu_out "$BUILD_SDK_PATH/icu"
2020
}
2121

22-
install_wasi-sdk() {
23-
# We only use wasi-sysroot and do not use binaries in wasi-sdk,
24-
# so build machine's os and wasi-sdk's host os don't have to be matched
25-
WASI_SDK_URL="https://github.com/swiftwasm/wasi-sdk/releases/download/0.2.2-swiftwasm/dist-ubuntu-18.04.zip"
22+
install_wasi-sysroot() {
23+
WASI_SYSROOT_URL="https://github.com/swiftwasm/wasi-sdk-build/releases/download/wasi-sdk-14%2Bswiftwasm-2022-03-13/wasi-sysroot.tar.gz"
2624

27-
curl -L -o dist-wasi-sdk.zip "$WASI_SDK_URL"
28-
unzip -u dist-wasi-sdk.zip -d .
25+
curl -L "$WASI_SYSROOT_URL" | tar xz
2926

30-
WASI_SDK_TAR_PATH=$(find . -type f -name "wasi-sdk-*")
31-
WASI_SDK_FULL_NAME=$(basename "$WASI_SDK_TAR_PATH" -linux.tar.gz)
32-
tar xfz "$WASI_SDK_TAR_PATH"
33-
34-
rm -rf "$BUILD_SDK_PATH/wasi-sdk"
35-
mv "$WASI_SDK_FULL_NAME" "$BUILD_SDK_PATH/wasi-sdk"
27+
mv "wasi-sysroot" "$BUILD_SDK_PATH/wasi-sysroot"
3628
}
3729

3830
workdir=$(mktemp -d)
3931
pushd "$workdir"
4032

4133
mkdir -p "$BUILD_SDK_PATH"
4234

43-
install_libxml2
44-
install_icu
45-
install_wasi-sdk
35+
if [ ! -e "$BUILD_SDK_PATH/libxml2" ]; then
36+
install_libxml2
37+
fi
38+
39+
if [ ! -e "$BUILD_SDK_PATH/icu" ]; then
40+
install_icu
41+
fi
42+
43+
if [ ! -e "$BUILD_SDK_PATH/wasi-sysroot" ]; then
44+
install_wasi-sysroot
45+
fi

utils/webassembly/static-executable-args.lnk

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
-lstdc++
88
-lm
99
-lwasi-emulated-mman
10+
-lwasi-emulated-signal
11+
-lwasi-emulated-process-clocks
1012
-Xlinker --error-limit=0
1113
-Xlinker --no-gc-sections
1214
-Xlinker --threads=1
13-
-D_WASI_EMULATED_MMAN

0 commit comments

Comments
 (0)