Skip to content

Commit

Permalink
Rename wasm32-wasi-threads target to wasm32-wasi-preview1-threads
Browse files Browse the repository at this point in the history
Threading support is based on the [wasi-threads](https://github.com/WebAssembly/wasi-threads/) proposal. It was agreed that the proposal will not be included in any of the WASI releases; instead, there's [another proposal](https://github.com/abrown/thread-spawn) which adds spawning threads functionality to the WASM core.
`wasm32-wasi-threads` is quite a nice name for the long-term solution, therefore I think it should be reserved for the `thread-spawn` proposal and use it once the proposal is ready. Given we'd like to support both `wasi-threads` and `thread-spawn` (at least for some time), I'm proposing adding another target specifically for wasi threads.

I used the `wasm32-wasi-preview1-threads` target as the proposal kind of builds on top of wsp1. It's also the same as the [Rust target](https://github.com/rust-lang/rust/blob/master/src/doc/rustc/src/platform-support/wasm32-wasi-preview1-threads.md). I don't have strong opininion about the name and I'm open for suggestions; if there's a better name for that target, I'd be happy to update the PR.

I keep both `wasm32-wasi-threads` and `wasm32-wasi-preview1-threads` for backward/forward compatibility. I know that `wasm32-wasi-threads` was considered experimental and would probably be safe to delete, but at the same time I think keeping it around is very little effort and can be re-used for thread-spawn in the future. If anybody thinks it's confusing and not worth it, happy to remove it.

I also updated the `thread-spawn` import to be consistent with other wsp1 imports.
  • Loading branch information
loganek committed Sep 18, 2023
1 parent ec4566b commit 4b08dc6
Show file tree
Hide file tree
Showing 7 changed files with 5,023 additions and 3 deletions.
10 changes: 9 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,15 @@ jobs:
name: ${{ format( 'sysroot-{0}.tgz', matrix.os) }}
path: sysroot

- name: Build libc + threads
- name: Build libc + threads (wasm32-wasi-preview1-threads)
# Only build the thread-capable wasi-libc in the latest supported Clang
# version; the earliest version does not have all necessary builtins
# (e.g., `__builtin_wasm_memory_atomic_notify`).
if: matrix.clang_version != '10.0.0'
shell: bash
run: make -j4 THREAD_MODEL=posix THREAD_IMPL=wasi-threads

- name: Build libc + threads (wasm32-wasi-threads)
# Only build the thread-capable wasi-libc in the latest supported Clang
# version; the earliest version does not have all necessary builtins
# (e.g., `__builtin_wasm_memory_atomic_notify`).
Expand Down
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,15 @@ TARGET_TRIPLE = wasm32-wasi
# Threaded version necessitates a different traget, as objects from different
# targets can't be mixed together while linking.
ifeq ($(THREAD_MODEL), posix)
ifeq ($(THREAD_IMPL), wasi-threads)
TARGET_TRIPLE = wasm32-wasi-preview1-threads
else
# The target tripple is deprecated and only kept for backward compatibility.
# This target will most likely be re-used for implementing thread-spawn proposal
# in the future.
TARGET_TRIPLE = wasm32-wasi-threads
endif
endif

# These variables describe the locations of various files and directories in
# the source tree.
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ cross-compiled builds of compiler-rt, `libc++.a`, and `libc++abi.a`.

To enable pthreads support via the [wasi-threads] proposal, follow the above
build directions with one addition: `make ... THREAD_MODEL=posix`. This creates
additional artifacts in `sysroot/lib/wasm32-wasi-threads` to support `--target
wasm32-wasi-threads`.
additional artifacts in `sysroot/lib/wasm32-wasi-preview1-threads` to support `--target
wasm32-wasi-preview1-threads`.

## Arch Linux AUR package

Expand Down
Loading

0 comments on commit 4b08dc6

Please sign in to comment.