Use wasi-sdk 20 pre-release for tests with threads (#2021)

`wasi-sdk-20` pre-release can be used to avoid building `wasi-libc` to enable threads.
It's not possible to use `wasi-sdk-20` pre-release on Ubuntu 20.04 because of
incompatibility with the glibc version:
```bash
/opt/wasi-sdk/bin/clang: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found
(required by /opt/wasi-sdk/bin/clang)
```
This commit is contained in:
Enrico Loparco
2023-03-17 13:02:03 +01:00
committed by GitHub
parent 23e9a356e5
commit 83659fa42a
7 changed files with 50 additions and 58 deletions

View File

@ -7,13 +7,6 @@ include(CheckPIESupported)
project(wasi_threads_sample)
if (NOT DEFINED WASI_SYSROOT)
message (WARNING "Custom sysroot with threads enabled is required to build wasi threads samples.
Please note that current wasi-sdk doesn't ship with threads enabled.
Run cmake command with -DWASI_SYSROOT=/path/to/sysroot/with/threads to compile samples.")
return ()
endif ()
################ runtime settings ################
string (TOLOWER ${CMAKE_HOST_SYSTEM_NAME} WAMR_BUILD_PLATFORM)
if (APPLE)

View File

@ -1,21 +1,13 @@
# "WASI threads" sample introduction
Currently, since the `wasi-sdk` does not have thread support in the latest release, make sure to have [wasi-libc](https://github.com/WebAssembly/wasi-libc) installed. Build it with threads enabled, e.g.
```shell
make \
AR=/opt/wasi-sdk/bin/llvm-ar \
NM=/opt/wasi-sdk/bin/llvm-nm \
CC=/opt/wasi-sdk/bin/clang \
THREAD_MODEL=posix
```
To run the sample, `wasi-sdk` >= 20 is required.
## Build and run the samples
```shell
$ mkdir build
$ cd build
$ cmake -DWASI_SYSROOT=/path/to/wasi-libc/sysroot ..
$ cmake ..
$ make
...
$ ./iwasm wasm-apps/no_pthread.wasm

View File

@ -11,7 +11,10 @@ if (NOT DEFINED WASI_SDK_DIR)
set (WASI_SDK_DIR "/opt/wasi-sdk")
endif ()
set (CMAKE_SYSROOT "${WASI_SYSROOT}")
if (DEFINED WASI_SYSROOT)
set (CMAKE_SYSROOT "${WASI_SYSROOT}")
endif ()
set (CMAKE_C_COMPILER "${WASI_SDK_DIR}/bin/clang")
set (CMAKE_ASM_COMPILER "${WASI_SDK_DIR}/bin/clang")
set (CMAKE_EXE_LINKER_FLAGS "-target wasm32-wasi-threads")