Add CI for WASI threads#1819
Conversation
|
Not sure why the |
| ] | ||
| 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.
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.
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.
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 |
| LINKER:--shared-memory,--max-memory=1966080 | ||
| LINKER:--export=wasi_thread_start | ||
| LINKER:--export=malloc | ||
| LINKER:--export=free |
There was a problem hiding this comment.
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.
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.
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.
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.
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.
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.
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. |
|
|
||
| - 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.
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.
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.
I remember that the combination wasi-sdk-16 + main from wasi-libc was failing on Ubuntu.
There was a problem hiding this comment.
OK. So shall we merge the PR now? @loganek, are there any comments from you? Thanks.
There was a problem hiding this comment.
I think so, to recap:
- we're using
wasi-sdk-16becausewasi-sdk-17would 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=mallocand--export=freeare used here otherwise the pipeline would fail when executing thewasi-threadssamples (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
|
|
||
| - name: build wasi-libc (needed for wasi-threads) | ||
| run: | | ||
| git clone --branch wasi-sdk-17 https://github.com/WebAssembly/wasi-libc |
|
|
||
| - name: build wasi-libc (needed for wasi-threads) | ||
| run: | | ||
| git clone --branch wasi-sdk-17 https://github.com/WebAssembly/wasi-libc |
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.