web-wasi-threads: initial addition

This is a different toolchain following how wasi-sdk defines the
platform triple and how builds are configured -- everything should be
built with the flags defined in the toolchain file.

We build from web-wasi:latest, and that is built first.
This commit is contained in:
Matt McCormick 2024-04-02 13:32:34 -04:00
parent f52fb3821a
commit d4e7c0aff2
7 changed files with 81 additions and 2 deletions

View File

@ -1039,6 +1039,25 @@ jobs:
cpython: "no", cpython: "no",
cpython_arg: "", 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 # Bare metal images
- { - {
image: "bare-armv7emhf-nano_newlib", image: "bare-armv7emhf-nano_newlib",

View File

@ -37,7 +37,7 @@ GEN_IMAGES := android-arm android-arm64 \
manylinux_2_28-x64 \ manylinux_2_28-x64 \
manylinux2014-x64 manylinux2014-x86 \ manylinux2014-x64 manylinux2014-x86 \
manylinux2014-aarch64 linux-arm64-lts \ 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-static-x86 windows-static-x64 windows-static-x64-posix \
windows-shared-x86 windows-shared-x64 windows-shared-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 \ linux-armv7 linux-armv7a linux-armv7l-musl linux-armv7-lts linux-armv7a-lts linux-x86_64-full \
@ -50,7 +50,7 @@ GEN_IMAGE_DOCKERFILES = $(addsuffix /Dockerfile,$(GEN_IMAGES))
# These images are expected to have explicit rules for *both* build and testing # These images are expected to have explicit rules for *both* build and testing
NON_STANDARD_IMAGES := manylinux_2_28-x64 manylinux2014-x64 manylinux2014-x86 \ 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 files
DOCKER_COMPOSITE_SOURCES = common.docker common.debian common.manylinux2014 common.manylinux_2_28 common.buildroot \ DOCKER_COMPOSITE_SOURCES = common.docker common.debian common.manylinux2014 common.manylinux_2_28 common.buildroot \
@ -143,6 +143,26 @@ web-wasm.test: web-wasm
rm -rf web-wasm/test 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: manylinux2014-aarch64/Dockerfile manylinux2014-aarch64: manylinux2014-aarch64/Dockerfile

View File

@ -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/linux-x64-tinycc | x86_64 | tinycc + GCC | Linux |
| dockcross/web-wasm | Wasm | LLVM | Web (JS) | | dockcross/web-wasm | Wasm | LLVM | Web (JS) |
| dockcross/web-wasi | Wasm | LLVM | Web (Universal) | | 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-x86 | x86 | GCC | Windows |
| dockcross/windows-shared-x64 | x86_64 | GCC | Windows | | dockcross/windows-shared-x64 | x86_64 | GCC | Windows |
| dockcross/windows-shared-x64-posix | x86_64 | GCC | Windows | | dockcross/windows-shared-x64-posix | x86_64 | GCC | Windows |
@ -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. 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 ### 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) ![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)

View File

@ -47,6 +47,7 @@ RUN mkdir /wasi-runtimes
ENV WASMTIME_HOME /wasi-runtimes/wasmtime ENV WASMTIME_HOME /wasi-runtimes/wasmtime
RUN mkdir ${WASMTIME_HOME} && curl https://wasmtime.dev/install.sh -sSf | bash RUN mkdir ${WASMTIME_HOME} && curl https://wasmtime.dev/install.sh -sSf | bash
COPY imagefiles/wasmtime-pwd.sh ${WASMTIME_HOME}/bin/ COPY imagefiles/wasmtime-pwd.sh ${WASMTIME_HOME}/bin/
COPY imagefiles/wasmtime-pwd-threads.sh ${WASMTIME_HOME}/bin/
ENV PATH "$WASMTIME_HOME/bin:$PATH" ENV PATH "$WASMTIME_HOME/bin:$PATH"
# For wasmer # For wasmer

View File

@ -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/ "$@"

View File

@ -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"

View File

@ -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)