Skip to content

Commit

Permalink
Merge pull request dockcross#822 from thewtex/wasi-threads
Browse files Browse the repository at this point in the history
Wasi threads
  • Loading branch information
thewtex committed Apr 4, 2024
2 parents 8106a3b + d4e7c0a commit 2c6c0a5
Show file tree
Hide file tree
Showing 8 changed files with 87 additions and 8 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1039,6 +1039,25 @@ jobs:
cpython: "no",
cpython_arg: "",
}
- {
image: "web-wasi-threads",
stockfish: "no",
stockfish_arg: "",
ninja: "no",
ninja_arg: "",
openssl: "no",
openssl_arg: "linux-generic64 no-asm no-threads no-engine no-hw no-weak-ssl-ciphers no-dtls no-shared no-dso",
C: "no",
C_arg: "",
C-Plus-Plus: "no",
C-Plus-Plus_arg: "",
fmt: "no",
fmt_arg: "",
raylib: "no",
raylib_arg: "",
cpython: "no",
cpython_arg: "",
}
# Bare metal images
- {
image: "bare-armv7emhf-nano_newlib",
Expand Down
24 changes: 22 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ GEN_IMAGES := android-arm android-arm64 \
manylinux_2_28-x64 \
manylinux2014-x64 manylinux2014-x86 \
manylinux2014-aarch64 linux-arm64-lts \
web-wasm web-wasi linux-mips linux-mips-uclibc linux-mips-lts windows-arm64 windows-armv7 \
web-wasm web-wasi web-wasi-threads linux-mips linux-mips-uclibc linux-mips-lts windows-arm64 windows-armv7 \
windows-static-x86 windows-static-x64 windows-static-x64-posix \
windows-shared-x86 windows-shared-x64 windows-shared-x64-posix \
linux-armv7 linux-armv7a linux-armv7l-musl linux-armv7-lts linux-armv7a-lts linux-x86_64-full \
Expand All @@ -50,7 +50,7 @@ GEN_IMAGE_DOCKERFILES = $(addsuffix /Dockerfile,$(GEN_IMAGES))

# These images are expected to have explicit rules for *both* build and testing
NON_STANDARD_IMAGES := manylinux_2_28-x64 manylinux2014-x64 manylinux2014-x86 \
manylinux2014-aarch64 web-wasm
manylinux2014-aarch64 web-wasm web-wasi-threads

# Docker composite files
DOCKER_COMPOSITE_SOURCES = common.docker common.debian common.manylinux2014 common.manylinux_2_28 common.buildroot \
Expand Down Expand Up @@ -143,6 +143,26 @@ web-wasm.test: web-wasm
rm -rf web-wasm/test

#
# web-wasi-threads
#
web-wasi-threads: web-wasi web-wasi-threads/Dockerfile
mkdir -p $@/imagefiles && cp -r imagefiles $@/
cp -r test web-wasi-threads/
$(DOCKER) $(BUILD_CMD) -t $(ORG)/web-wasi-threads:$(TAG) \
-t $(ORG)/web-wasi-threads:latest \
--build-arg IMAGE=$(ORG)/web-wasi-threads \
--build-arg VERSION=$(TAG) \
--build-arg VCS_REF=`git rev-parse --short HEAD` \
--build-arg VCS_URL=`git config --get remote.origin.url` \
--build-arg BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` \
web-wasi-threads

web-wasi-threads.test: web-wasi-threads
$(DOCKER) run $(RM) $(ORG)/web-wasi-threads:latest > $(BIN)/dockcross-web-wasi-threads \
&& chmod +x $(BIN)/dockcross-web-wasi-threads
$(BIN)/dockcross-web-wasi-threads -i $(ORG)/web-wasi-threads:latest python3 test/run.py
rm -rf web-wasi-threads/test
#
# manylinux2014-aarch64
#
manylinux2014-aarch64: manylinux2014-aarch64/Dockerfile
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ The dockcross script will execute the given command-line inside the container, a
| dockcross/linux-x64-tinycc | x86_64 | tinycc + GCC | Linux |
| dockcross/web-wasm | Wasm | LLVM | Web (JS) |
| dockcross/web-wasi | Wasm | LLVM | Web (Universal) |
| dockcross/web-wasi-threads | Wasm | LLVM | Web (Universal) |
| dockcross/windows-shared-x86 | x86 | GCC | Windows |
| dockcross/windows-shared-x64 | x86_64 | GCC | Windows |
| dockcross/windows-shared-x64-posix | x86_64 | GCC | Windows |
Expand Down Expand Up @@ -403,6 +404,12 @@ The [Emscripten](https://emscripten.org/) [WebAssembly](https://webassembly.org/

The [WebAssembly System Interface (WASI)](https://wasi.dev/) SDK LLVM/Clang/WASI Sysroot cross compiler.

### dockcross/web-wasi-threads

![Docker Image Size (tag)](https://img.shields.io/docker/image-size/dockcross/web-wasi-threads/latest) ![Docker Pulls](https://img.shields.io/docker/pulls/dockcross/web-wasi-threads)

The [WebAssembly System Interface (WASI)](https://wasi.dev/) SDK LLVM/Clang/WASI Sysroot cross compiler with the toolchain configured to enable the wasm threading proposal.

### dockcross/windows-static-x64

![Docker Image Size (tag)](https://img.shields.io/docker/image-size/dockcross/windows-static-x64/latest) ![Docker Pulls](https://img.shields.io/docker/pulls/dockcross/windows-static-x64)
Expand Down
9 changes: 5 additions & 4 deletions common/common.webassembly
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
#
# Common WebAssembly tools.

# main 2022-12-27
ENV BINARYEN_GIT_TAG cec66beba45668dbad74abd2396bb80d33595ff0
# main 2024-04-02
ENV BINARYEN_GIT_TAG 4e2ebbd6de6f99e5972654b3f50ddbc1c6839a73
RUN git clone --recursive https://github.com/WebAssembly/binaryen.git && \
cd binaryen && \
git checkout ${BINARYEN_GIT_TAG} && \
Expand All @@ -22,8 +22,8 @@ RUN git clone --recursive https://github.com/WebAssembly/binaryen.git && \
cd ../ && \
rm -rf binaryen*

# main 2023-03-16
ENV WABT_GIT_TAG 090d4674c86b00e31d18e77f2c8f8570a68e1cf1
# main 2024-04-02
ENV WABT_GIT_TAG 356931a867c7d642bc282fff46a1c95ab0e843f3
RUN git clone --recurse-submodules https://github.com/WebAssembly/wabt.git && \
cd wabt && \
git checkout ${WABT_GIT_TAG} && \
Expand All @@ -47,6 +47,7 @@ RUN mkdir /wasi-runtimes
ENV WASMTIME_HOME /wasi-runtimes/wasmtime
RUN mkdir ${WASMTIME_HOME} && curl https://wasmtime.dev/install.sh -sSf | bash
COPY imagefiles/wasmtime-pwd.sh ${WASMTIME_HOME}/bin/
COPY imagefiles/wasmtime-pwd-threads.sh ${WASMTIME_HOME}/bin/
ENV PATH "$WASMTIME_HOME/bin:$PATH"

# For wasmer
Expand Down
4 changes: 4 additions & 0 deletions imagefiles/wasmtime-pwd-threads.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env bash

# Mount the PWD and the /work mount dir to enable access in try_run commands
exec ${WASMTIME_HOME}/bin/wasmtime -S threads=y run --dir=. --dir=$PWD --dir=/work/ "$@"
11 changes: 11 additions & 0 deletions web-wasi-threads/Dockerfile.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
ARG ORG=dockcross
FROM ${ORG}/web-wasi:latest

LABEL maintainer="Matt McCormick matt.mccormick@kitware.com"

ENV CROSS_TRIPLE=wasm32-wasi-threads

COPY Toolchain.cmake ${CROSS_ROOT}/
ENV CMAKE_TOOLCHAIN_FILE ${CROSS_ROOT}/Toolchain.cmake

#include "common.label-and-env"
17 changes: 17 additions & 0 deletions web-wasi-threads/Toolchain.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
set(WASI_SDK_PREFIX $ENV{WASI_SDK_PATH})
include($ENV{WASI_SDK_PATH}/share/cmake/wasi-sdk-pthread.cmake)

set(CMAKE_FIND_ROOT_PATH $ENV{CROSS_ROOT})
set(CMAKE_SYSROOT $ENV{WASI_SYSROOT})

set(CMAKE_C_COMPILER /usr/local/bin/clang-wasi-sysroot.sh)
set(CMAKE_CXX_COMPILER /usr/local/bin/clang++-wasi-sysroot.sh)
set(CMAKE_AR llvm-ar-$ENV{LLVM_VERSION})
set(CMAKE_RANLIB llvm-ranlib-$ENV{LLVM_VERSION})
set(CMAKE_ASM_COMPILER clang-$ENV{LLVM_VERSION})

set(CMAKE_C_COMPILER_TARGET $ENV{CROSS_TRIPLE})
set(CMAKE_CXX_COMPILER_TARGET $ENV{CROSS_TRIPLE})
set(CMAKE_ASM_COMPILER_TARGET $ENV{CROSS_TRIPLE})

set(CMAKE_CROSSCOMPILING_EMULATOR /wasi-runtimes/wasmtime/bin/wasmtime-pwd-threads.sh)
4 changes: 2 additions & 2 deletions web-wasi/Dockerfile.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ FROM ${ORG}/base:latest

LABEL maintainer="Matt McCormick matt.mccormick@kitware.com"

ENV LLVM_VERSION 16
ENV LLVM_VERSION 17

# Build LLVM / Clang that supports our glibc
RUN apt-get update && \
Expand All @@ -18,7 +18,7 @@ RUN apt-get update && \
apt-get install -y clang-${LLVM_VERSION} lld-${LLVM_VERSION} && \
rm -rf /var/lib/apt/lists/*

ENV WASI_VERSION 20
ENV WASI_VERSION 21
ENV WASI_VERSION_FULL ${WASI_VERSION}.0
RUN cd /usr/ && \
curl -L -O https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${WASI_VERSION}/wasi-sdk-${WASI_VERSION_FULL}-linux.tar.gz && \
Expand Down

0 comments on commit 2c6c0a5

Please sign in to comment.