-
Notifications
You must be signed in to change notification settings - Fork 636
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
Conversation
Not sure why the |
@@ -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-17/wasi-sdk-17.0-macos.tar.gz"] |
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.
Wonder if we want to continue building for 12 to ensure backward compatibility? Or do we want to drop 12 and ask users to migrate to >= 17 now?
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 tried wasi-sdk
version 12 and wasi-libc
branch wasi-sdk-17
here but the build failed.
It was not immediate to find a compatible combination of wasi-sdk
and wasi-libc
for the different targets (on ubuntu I'm using wasi-sdk
version 16 in this PR since version 17 was not working).
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 am a little confused here. It seems the CI depends on the combination of wasi-sdk-X
+ a specific release of wasi-libc
now. Is there a plan that a future wasi-sdk release include everything and make the local combination not necessary?
2d39fc4
to
abe0053
Compare
It looks like all jobs are succeeding now, using |
Actually, looking at the output (and at some tests I was doing locally) I see a regression:
The new value and thread id are wrong. I'm adding
in |
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.
LGTM
@eloparco Shall I merge the PR?
@@ -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 comment
The 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 comment
The reason will be displayed to describe this comment to others. Learn more.
Because I was getting this error without the additional exports:
[09:52:39:510 - 101150580]: Memory instantiate success.
[09:52:39:614 - 101150580]: Error: app heap is corrupted, if the wasm file is compiled by wasi-sdk-12.0 or higher version, please add -Wl,--export=malloc -Wl,--export=free to export malloc and free functions. If it is compiled by asc, please add --exportRuntime to export the runtime helpers.
[09:52:39:618 - 101150580]: thread manager error: failed to allocate aux stack space for new thread
[09:52:39:620 - 101150580]: Failed to spawn a new thread
[09:52:39:623 - 101150580]: /Users/eloparco/dev/forks/wasm-micro-runtime/core/iwasm/interpreter/wasm_interp_fast.c, line 3959, meet an exception Exception: app heap corrupted
Exception: app heap corrupted
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.
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 comment
The 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.
https://github.com/bytecodealliance/wasm-micro-runtime/blob/dev/wasi_threads/core/config.h#L172
no_pthread.c seems broken. its wasi_thread_start should either update the stack pointer global or avoid using C stack.
How do I use the app heap? if I don't export the malloc and free functions I get Error: app heap is corrupted
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.
According to this,
app heap and libc heap: the heap to allocate memory for wasm app, note that app heap is created only when the malloc/free functions (or __new/__release functions for AssemblyScript) are not exported and runtime can not detect the libc heap.
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'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 comment
The 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.
https://github.com/bytecodealliance/wasm-micro-runtime/blob/dev/wasi_threads/core/config.h#L172
no_pthread.c seems broken. its wasi_thread_start should either update the stack pointer global or avoid using C stack.
How do I use the app heap? if I don't export the malloc and free functions I get
Error: app heap is corrupted
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 comment
The 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.
BTW, is there an issue to track the compilation error in https://github.com/eloparco/wasm-micro-runtime/actions/runs/3730554354/jobs/6327794669? |
@eloparco Wondering why you use wasi-sdk-16.0 for the CI and use wasi-sdk-17.0 for wasi-thread sample? Why not use wasi-sdk-17.0 for all? |
@wenyongh That's what I tried first, but it was failing on ubuntu/android: https://github.com/eloparco/wasm-micro-runtime/actions/runs/3703249930/jobs/6274621343
@lum1n0us Not yet, should I create one in this repo? |
@eloparco are you going to fix the issue? Or should we at least have an issue to upgrade to v17? |
Got it, I tested building wasi-libc and other wasm app with wasi-sdk-17 on Ubuntu-20.04, and got the same errors: /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)
/opt/wasi-sdk/bin/clang: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found (required by /opt/wasi-sdk/bin/clang)
/opt/wasi-sdk/bin/clang: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.33' not found (required by /opt/wasi-sdk/bin/clang) It seems that wasi-sdk-17 requires that libc-2.32 or newer version is installed, while by default in Ubuntu-20.04 libc-2.31 is installed. It may work in Ubuntu-22.04. But it seems that we had better just upgrade scripts to support wasi-sdk-16 now. |
@@ -323,6 +323,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 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
from wasi-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:
- we're using
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
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above
abe0053
to
1a74215
Compare
1a74215
to
de0fc1a
Compare
Update wasi-sdk from 12.0 to 16.0 in CI Build wasi-libc and build wai-threads sample in CI
No description provided.