Skip to content

Commit

Permalink
Update WASI SDK, create installable package on macOS (#14)
Browse files Browse the repository at this point in the history
New WASI SDK package should contain a new version of the linker. Also, the script should now create an installable package on macOS so that one could create a full SwiftWasm package later after the build.

* Update WASI SDK, create installable package on macOS

* Fix sysroot path, update wasi-sdk on Linux

* Exclude module net for wasm SDK in glibc.modulemap

* Remove module termios from glic.modulemap for wasm

* Disable _stdlib_mkstemps for wasm
  • Loading branch information
MaxDesiatov committed Nov 14, 2019
1 parent e2c69ed commit 42c6603
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 6 deletions.
2 changes: 2 additions & 0 deletions build-linux.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#/bin/bash

export sourcedir=$PWD/..

./utils/build-script --release --wasm --verbose \
--skip-build-benchmarks \
--extra-cmake-options=" \
Expand Down
8 changes: 7 additions & 1 deletion build-mac.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#/bin/bash

export sourcedir=$PWD/..

./utils/build-script --release --wasm --verbose \
--skip-build-benchmarks \
--extra-cmake-options=" \
Expand All @@ -22,4 +24,8 @@
--wasm-icu-i18n-include "$sourcedir/icu_out/include" \
--wasm-icu-uc "$sourcedir/icu_out/lib" \
--wasm-icu-uc-include "$sourcedir/icu_out/include" \
--wasm-wasi-sdk "$sourcedir/wasi-sdk"
--wasm-wasi-sdk "$sourcedir/wasi-sdk" \
--install-swift \
--install-prefix="/opt/swiftwasm-sdk" \
--install-destdir="$sourcedir/install" \
--installable-package="$sourcedir/swiftwasm-mac.tar.gz"
5 changes: 3 additions & 2 deletions ci-linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ sudo ./install_cmake.sh --skip-license --prefix=/opt/cmake
sudo ln -sf /opt/cmake/bin/* /usr/local/bin
cmake --version

wget -O wasi-sdk.tar.gz https://github.com/swiftwasm/wasi-sdk/releases/download/20190421.6/wasi-sdk-3.19gefb17cb478f9.m-linux.tar.gz
wget -O wasi-sdk.tar.gz https://github.com/swiftwasm/wasi-sdk/releases/download/20191022.1/wasi-sdk-4.39g3025a5f47c04-linux.tar.gz
tar xfz wasi-sdk.tar.gz
mv wasi-sdk-3.19gefb17cb478f9+m/opt/wasi-sdk ./wasi-sdk
mv wasi-sdk-4.39g3025a5f47c04 ./wasi-sdk
mv wasi-sdk/share/wasi-sysroot wasi-sdk/share/sysroot

wget -O icu.tar.xz "https://github.com/swiftwasm/icu4c-wasi/releases/download/20190421.3/icu4c-wasi.tar.xz"
tar xf icu.tar.xz
Expand Down
5 changes: 3 additions & 2 deletions ci-mac.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ export current_sha=`git rev-parse HEAD`
git checkout $current_sha
export sourcedir=$PWD/..
cd $sourcedir
wget -O wasi-sdk.tar.gz https://github.com/swiftwasm/wasi-sdk/releases/download/20190421.6/wasi-sdk-3.19gefb17cb478f9.m-linux.tar.gz
wget -O wasi-sdk.tar.gz https://github.com/swiftwasm/wasi-sdk/releases/download/20191022.1/wasi-sdk-4.39g3025a5f47c04-linux.tar.gz
tar xfz wasi-sdk.tar.gz
mv wasi-sdk-3.19gefb17cb478f9+m/opt/wasi-sdk ./wasi-sdk
mv wasi-sdk-4.39g3025a5f47c04 ./wasi-sdk
mv wasi-sdk/share/wasi-sysroot wasi-sdk/share/sysroot
# Link sysroot/usr/include to sysroot/include because Darwin sysroot doesn't
# find header files in sysroot/include but sysroot/usr/include
mkdir wasi-sdk/share/sysroot/usr/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import MSVCRT
#endif

public func _stdlib_mkstemps(_ template: inout String, _ suffixlen: CInt) -> CInt {
#if os(Android) || os(Haiku) || os(Windows)
#if os(Android) || os(Haiku) || os(Windows) || os(Wasm)
preconditionFailure("mkstemps doesn't work on your platform")
#else
var utf8CStr = template.utf8CString
Expand Down
4 changes: 4 additions & 0 deletions stdlib/public/Platform/glibc.modulemap.gyb
Original file line number Diff line number Diff line change
Expand Up @@ -353,12 +353,14 @@ module SwiftGlibc [system] {
header "${GLIBC_INCLUDE_PATH}/libgen.h"
export *
}
% if CMAKE_SDK != "WASM":
module net {
module if {
header "${GLIBC_INCLUDE_PATH}/net/if.h"
export *
}
}
% end
module netinet {
module in {
header "${GLIBC_INCLUDE_PATH}/netinet/in.h"
Expand Down Expand Up @@ -517,10 +519,12 @@ module SwiftGlibc [system] {
export *
}
% end
% if CMAKE_SDK != "WASM":
module termios {
header "${GLIBC_INCLUDE_PATH}/termios.h"
export *
}
% end
module unistd {
header "${GLIBC_INCLUDE_PATH}/unistd.h"
export *
Expand Down

0 comments on commit 42c6603

Please sign in to comment.