-
Notifications
You must be signed in to change notification settings - Fork 626
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add CI for WASI threads #1819
Add CI for WASI threads #1819
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -210,7 +210,7 @@ jobs: | |
#$AOT_BUILD_OPTIONS, | ||
] | ||
os: [macos-latest] | ||
wasi_sdk_release: ["https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-12/wasi-sdk-12.0-macos.tar.gz"] | ||
wasi_sdk_release: ["https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-16/wasi-sdk-16.0-macos.tar.gz"] | ||
wabt_release: ["https://github.com/WebAssembly/wabt/releases/download/1.0.24/wabt-1.0.24-macos.tar.gz"] | ||
steps: | ||
- name: checkout | ||
|
@@ -246,7 +246,7 @@ jobs: | |
strategy: | ||
matrix: | ||
os: [macos-latest] | ||
wasi_sdk_release: ["https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-12/wasi-sdk-12.0-macos.tar.gz"] | ||
wasi_sdk_release: ["https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-16/wasi-sdk-16.0-macos.tar.gz"] | ||
wabt_release: ["https://github.com/WebAssembly/wabt/releases/download/1.0.24/wabt-1.0.24-macos.tar.gz"] | ||
steps: | ||
- name: checkout | ||
|
@@ -256,8 +256,8 @@ jobs: | |
run: | | ||
cd /opt | ||
sudo wget ${{ matrix.wasi_sdk_release }} | ||
sudo tar -xzf wasi-sdk-12.0-*.tar.gz | ||
sudo mv wasi-sdk-12.0 wasi-sdk | ||
sudo tar -xzf wasi-sdk-16.0-*.tar.gz | ||
sudo mv wasi-sdk-16.0 wasi-sdk | ||
|
||
- name: download and install wabt | ||
run: | | ||
|
@@ -266,6 +266,17 @@ jobs: | |
sudo tar -xzf wabt-1.0.24-*.tar.gz | ||
sudo mv wabt-1.0.24 wabt | ||
|
||
- name: build wasi-libc (needed for wasi-threads) | ||
run: | | ||
git clone --branch wasi-sdk-17 https://github.com/WebAssembly/wasi-libc | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above |
||
cd wasi-libc | ||
make \ | ||
AR=/opt/wasi-sdk/bin/llvm-ar \ | ||
NM=/opt/wasi-sdk/bin/llvm-nm \ | ||
CC=/opt/wasi-sdk/bin/clang \ | ||
THREAD_MODEL=posix | ||
working-directory: core/deps | ||
|
||
- name: Build Sample [basic] | ||
run: | | ||
cd samples/basic | ||
|
@@ -311,3 +322,11 @@ jobs: | |
cmake .. | ||
cmake --build . --config Release --parallel 4 | ||
./hello | ||
|
||
- name: Build Sample [wasi-threads] | ||
run: | | ||
cd samples/wasi-threads | ||
mkdir build && cd build | ||
cmake -DWASI_SYSROOT=`pwd`/../../../core/deps/wasi-libc/sysroot .. | ||
cmake --build . --config Release --parallel 4 | ||
./iwasm wasm-apps/no_pthread.wasm |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -244,7 +244,7 @@ jobs: | |
os: [ubuntu-20.04] | ||
wasi_sdk_release: | ||
[ | ||
"https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-12/wasi-sdk-12.0-linux.tar.gz", | ||
"https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-16/wasi-sdk-16.0-linux.tar.gz", | ||
] | ||
wabt_release: | ||
[ | ||
|
@@ -258,8 +258,8 @@ jobs: | |
run: | | ||
cd /opt | ||
sudo wget ${{ matrix.wasi_sdk_release }} | ||
sudo tar -xzf wasi-sdk-12.0-*.tar.gz | ||
sudo mv wasi-sdk-12.0 wasi-sdk | ||
sudo tar -xzf wasi-sdk-16.0-*.tar.gz | ||
sudo mv wasi-sdk-16.0 wasi-sdk | ||
|
||
- name: download and install wabt | ||
run: | | ||
|
@@ -268,6 +268,17 @@ jobs: | |
sudo tar -xzf wabt-1.0.24-*.tar.gz | ||
sudo mv wabt-1.0.24 wabt | ||
|
||
- name: build wasi-libc (needed for wasi-threads) | ||
run: | | ||
git clone --branch wasi-sdk-17 https://github.com/WebAssembly/wasi-libc | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above |
||
cd wasi-libc | ||
make \ | ||
AR=/opt/wasi-sdk/bin/llvm-ar \ | ||
NM=/opt/wasi-sdk/bin/llvm-nm \ | ||
CC=/opt/wasi-sdk/bin/clang \ | ||
THREAD_MODEL=posix | ||
working-directory: core/deps | ||
|
||
- name: install SGX SDK and necessary libraries | ||
run: | | ||
mkdir -p /opt/intel | ||
|
@@ -327,6 +338,14 @@ jobs: | |
cmake --build . --config Release --parallel 4 | ||
./hello | ||
|
||
- name: Build Sample [wasi-threads] | ||
run: | | ||
cd samples/wasi-threads | ||
mkdir build && cd build | ||
cmake -DWASI_SYSROOT=`pwd`/../../../core/deps/wasi-libc/sysroot .. | ||
cmake --build . --config Release --parallel 4 | ||
./iwasm wasm-apps/no_pthread.wasm | ||
|
||
spec_test_default: | ||
needs: [build_iwasm, build_llvm_libraries, build_wamrc] | ||
runs-on: ubuntu-20.04 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,6 +29,8 @@ function (compile_sample SOURCE_FILE) | |
LINKER:--export=__data_end | ||
LINKER:--shared-memory,--max-memory=1966080 | ||
LINKER:--export=wasi_thread_start | ||
LINKER:--export=malloc | ||
LINKER:--export=free | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because I was getting this error without the additional exports:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the aux stack allocation should be disabled for wasi-threads because it's libc's responsibility to allocate stack for new threads. no_pthread.c seems broken. its wasi_thread_start should either update the stack pointer global or avoid using C stack. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
How do I use the app heap? if I don't export the malloc and free functions I get There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. According to this,
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've read that one already, but if I don't export malloc and free I'm getting the corruption error There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
wamr doesn't need to (and shouldn't) use the heap (app heap or libc heap) at least for this purpose (stack allocation for wasi-threads) because the stack is managed inside the module itself. (usually by libc) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Threads implementation in WAMR is not fully completed yet. One of the things is to always (regardless of compilation flags) use on-heap aux stack allocation. I have change for that already but didn't test it yet; I'll make the change public beginning of next month when I'm back from holidays, until then I'd suggest waiting with merging this PR. |
||
) | ||
endfunction () | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Branch wasi-sdk-17 isn't found in the wasi-libc repo, seems that main branch is OK.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a tag https://github.com/WebAssembly/wasi-libc/tree/wasi-sdk-17.
I'd prefer to pin the version/tag rather than using main. Unless we want to use the current latest commit from main and we checkout that specific one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I remember that the combination
wasi-sdk-16
+main
fromwasi-libc
was failing on Ubuntu.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. So shall we merge the PR now? @loganek, are there any comments from you? Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think so, to recap:
wasi-sdk-16
becausewasi-sdk-17
would require a newer version of libc wrt the one on Ubuntu-20.04 used in the pipeline (the alternative would be to update the Ubuntu image)--export=malloc
and--export=free
are used here otherwise the pipeline would fail when executing thewasi-threads
samples (the alternative would be to comment the assert insamples/wasi-threads/wasm-apps/no_pthread.c
); the behavior will be fixed in a new PR