From 54a4417c3d8fc4e87d01fc72508144b3f295a54b Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Mon, 6 Jan 2025 15:21:00 -0500 Subject: [PATCH 1/3] wasi: fix threads option specification for wasmtime In recent wasmtime, `-S` flags need to come after `run`. Also add `-W threads=y` following the wasmtime test suite, - https://github.com/bytecodealliance/wasmtime/blob/fc3c868b13bccf5d7ed26de4cfd1a2dc4c689360/tests/all/cli_tests.rs#L580-L581 Also explicity enable the `cli` feature because this is used for CMake try_run. --- imagefiles/wasmtime-pwd-threads.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/imagefiles/wasmtime-pwd-threads.sh b/imagefiles/wasmtime-pwd-threads.sh index b9f8a98..62b160c 100755 --- a/imagefiles/wasmtime-pwd-threads.sh +++ b/imagefiles/wasmtime-pwd-threads.sh @@ -1,4 +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/ "$@" +exec ${WASMTIME_HOME}/bin/wasmtime run -W threads=y -S threads=y,cli=y --dir=. --dir=$PWD --dir=/work/ "$@" From f5b3739d8d6f6f083c1777edf15c15ca736b5d03 Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Tue, 7 Jan 2025 10:59:10 -0500 Subject: [PATCH 2/3] web-wasi-threads: use target wasm32-wasi-threads in sysroot wrapper And add -pthread flag. --- web-wasi-threads/Dockerfile.in | 4 ++++ web-wasi-threads/Toolchain.cmake | 4 ++-- web-wasi-threads/clang++-wasi-threads-sysroot.sh | 3 +++ web-wasi-threads/clang-wasi-threads-sysroot.sh | 3 +++ 4 files changed, 12 insertions(+), 2 deletions(-) create mode 100755 web-wasi-threads/clang++-wasi-threads-sysroot.sh create mode 100755 web-wasi-threads/clang-wasi-threads-sysroot.sh diff --git a/web-wasi-threads/Dockerfile.in b/web-wasi-threads/Dockerfile.in index 5f75c21..163fd27 100644 --- a/web-wasi-threads/Dockerfile.in +++ b/web-wasi-threads/Dockerfile.in @@ -3,7 +3,11 @@ FROM ${ORG}/web-wasi:latest LABEL maintainer="Matt McCormick matt@mmmccormick.com" +COPY clang-wasi-threads-sysroot.sh clang++-wasi-threads-sysroot.sh /usr/local/bin/ + ENV CROSS_TRIPLE=wasm32-wasi-threads +ENV CC=clang-wasi-threads-sysroot.sh \ + CXX=clang++-wasi-threads-sysroot.sh COPY Toolchain.cmake ${CROSS_ROOT}/ ENV CMAKE_TOOLCHAIN_FILE ${CROSS_ROOT}/Toolchain.cmake diff --git a/web-wasi-threads/Toolchain.cmake b/web-wasi-threads/Toolchain.cmake index 53985b4..326702c 100644 --- a/web-wasi-threads/Toolchain.cmake +++ b/web-wasi-threads/Toolchain.cmake @@ -4,7 +4,7 @@ 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_C_COMPILER /usr/local/bin/clang-wasi-threads-sysroot.sh) +set(CMAKE_CXX_COMPILER /usr/local/bin/clang++-wasi-threads-sysroot.sh) set(CMAKE_CROSSCOMPILING_EMULATOR /wasi-runtimes/wasmtime/bin/wasmtime-pwd-threads.sh) diff --git a/web-wasi-threads/clang++-wasi-threads-sysroot.sh b/web-wasi-threads/clang++-wasi-threads-sysroot.sh new file mode 100755 index 0000000..1d9cdff --- /dev/null +++ b/web-wasi-threads/clang++-wasi-threads-sysroot.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env sh + +exec ${WASI_SDK_PATH}/bin/clang++ -pthread --target=wasm32-wasi-threads --sysroot=${WASI_SYSROOT} "$@" diff --git a/web-wasi-threads/clang-wasi-threads-sysroot.sh b/web-wasi-threads/clang-wasi-threads-sysroot.sh new file mode 100755 index 0000000..8728f23 --- /dev/null +++ b/web-wasi-threads/clang-wasi-threads-sysroot.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env sh + +exec ${WASI_SDK_PATH}/bin/clang -pthread --target=wasm32-wasi-threads --sysroot=${WASI_SYSROOT} "$@" From 456e7e049461c7de721d91c7b1dcc07511517610 Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Mon, 10 Feb 2025 14:43:58 -0500 Subject: [PATCH 3/3] ci: use versioned build image Make CI more reproducible and prevent non-explicit changes from breaking builds. --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f1a49d5..dea9750 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -12,7 +12,7 @@ on: jobs: base: name: base - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 steps: - name: checkout code uses: actions/checkout@v4 @@ -55,7 +55,7 @@ jobs: image: name: ${{ matrix.arch_name.image }} needs: base - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 env: OCI_EXE: docker strategy: