-
Notifications
You must be signed in to change notification settings - Fork 214
Closed
Description
When attempting to use wasi-sdk
to compile a program that might use threads (or shared memories, etc.), the program will fail to link because the libc used has not been compiled with all of the right features (i.e., --shared-memory
which relies on --features='atomics,bulk-memory'
):
$ cat << EOF > test.c
#include <stdio.h>
int main() {
printf("...");
return 0;
}
EOF
$ /opt/wasi-sdk/wasi-sdk-16.0/bin/clang -O3 --target=wasm32-wasi \
--sysroot=/opt/wasi-sdk/wasi-sdk-16.0/share/wasi-sysroot \
-mthread-model posix -Xlinker --features='atomics,bulk-memory' -Xlinker --shared-memory \
test.c -o test.wasm -v
...
"/opt/wasi-sdk/wasi-sdk-16.0/bin/wasm-ld" -m wasm32 -L/opt/wasi-sdk/wasi-sdk-16.0/share/wasi-sysroot/lib/wasm32-wasi /opt/wasi-sdk/wasi-sdk-16.0/share/wasi-sysroot/lib/wasm32-wasi/crt1-command.o --features=atomics,bulk-memory --shared-memory /tmp/test-86de01.o -lc /opt/wasi-sdk/wasi-sdk-16.0/lib/clang/14.0.4/lib/wasi/libclang_rt.builtins-wasm32.a -o test.wasm
/opt/wasi-sdk/wasi-sdk-16.0/bin/wasm-ld: /lib64/libtinfo.so.6: no version information available (required by /opt/wasi-sdk/wasi-sdk-16.0/bin/wasm-ld)
wasm-ld: error: --shared-memory is disallowed by errno.o because it was not compiled with 'atomics' or 'bulk-memory' features.
clang-14: error: linker command failed with exit code 1 (use -v to see invocation)
There should be some way to package up the output of a make THREAD_MODEL=posix
build in the released binaries and helpfully link in the right things when, e.g., -pthreads
or -mthread-model=posix
are used. Any thoughts on how to move forward on this?
Metadata
Metadata
Assignees
Labels
No labels