Skip to content

Commit b99f303

Browse files
Merge pull request #4360 from swiftwasm/katei/update-wasi-sdk
Update wasi-sdk to 4 to 14.0
2 parents 3d4401c + ff8547c commit b99f303

File tree

7 files changed

+17
-25
lines changed

7 files changed

+17
-25
lines changed

lib/ClangImporter/ClangImporter.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -690,7 +690,10 @@ importer::getNormalInvocationArguments(
690690
}
691691

692692
if (triple.isOSWASI()) {
693-
invocationArgStrs.insert(invocationArgStrs.end(), {"-D_WASI_EMULATED_MMAN"});
693+
invocationArgStrs.insert(invocationArgStrs.end(),
694+
{"-D_WASI_EMULATED_MMAN",
695+
"-D_WASI_EMULATED_SIGNAL",
696+
"-D_WASI_EMULATED_PROCESS_CLOCKS"});
694697
SmallString<128> buffer;
695698
if (auto path = getWasiLibcModuleMapPath(searchPathOpts, triple, buffer)) {
696699
invocationArgStrs.push_back((Twine("-fmodule-map-file=") + *path).str());

stdlib/cmake/modules/AddSwiftStdlib.cmake

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ function(_add_target_variant_c_compile_flags)
288288
endif()
289289

290290
if("${CFLAGS_SDK}" STREQUAL "WASI")
291-
list(APPEND result "-D_WASI_EMULATED_MMAN")
291+
list(APPEND result "-D_WASI_EMULATED_MMAN" "-D_WASI_EMULATED_SIGNAL" "-D_WASI_EMULATED_PROCESS_CLOCKS")
292292
endif()
293293

294294
if("${CFLAGS_SDK}" STREQUAL "LINUX")
@@ -298,10 +298,6 @@ function(_add_target_variant_c_compile_flags)
298298
endif()
299299
endif()
300300

301-
if("${CFLAGS_SDK}" STREQUAL "WASI")
302-
list(APPEND result "-D_WASI_EMULATED_MMAN")
303-
endif()
304-
305301
if(NOT SWIFT_STDLIB_ENABLE_OBJC_INTEROP)
306302
list(APPEND result "-DSWIFT_OBJC_INTEROP=0")
307303
endif()

stdlib/cmake/modules/SwiftSource.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ function(_add_target_variant_swift_compile_flags
243243
endif()
244244

245245
if("${sdk}" STREQUAL "WASI")
246-
list(APPEND result "-Xcc" "-D_WASI_EMULATED_MMAN")
246+
list(APPEND result "-Xcc" "-D_WASI_EMULATED_MMAN" "-Xcc" "-D_WASI_EMULATED_SIGNAL" "-Xcc" "-D_WASI_EMULATED_PROCESS_CLOCKS")
247247
endif()
248248

249249
if(NOT BUILD_STANDALONE)

utils/webassembly/build-presets.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ install-prefix=/usr
2424
[preset: webassembly-host]
2525

2626
mixin-preset=webassembly
27+
sccache
2728
extra-cmake-options=
2829
-DSWIFT_BUILD_SOURCEKIT=FALSE
2930
-DSWIFT_ENABLE_SOURCEKIT_TESTS=FALSE

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)
@@ -155,7 +154,7 @@ build_target_toolchain() {
155154

156155
embed_wasi_sysroot() {
157156
# Merge wasi-sdk and the toolchain
158-
cp -r "$WASI_SDK_PATH/share/wasi-sysroot" "$DIST_TOOLCHAIN_SDK/usr/share"
157+
cp -r "$WASI_SYSROOT_PATH" "$DIST_TOOLCHAIN_SDK/usr/share"
159158

160159
# Replace absolute sysroot path with relative path
161160
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: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,12 @@ 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)
@@ -48,6 +40,6 @@ if [ ! -e "$BUILD_SDK_PATH/icu" ]; then
4840
install_icu
4941
fi
5042

51-
if [ ! -e "$BUILD_SDK_PATH/wasi-sdk" ]; then
52-
install_wasi-sdk
43+
if [ ! -e "$BUILD_SDK_PATH/wasi-sysroot" ]; then
44+
install_wasi-sysroot
5345
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)