WebAssembly / wasi-libc

WASI libc implementation for WebAssembly
https://wasi.dev
Other
860 stars 203 forks source link

prepare libclang_rt.builtins-wasm32.a on wasm32-wasi-threads #543

Open oligamiq opened 1 month ago

oligamiq commented 1 month ago

Would you prepare libclang_rt.builtins-wasm32.a for wasm32-wasi-threads? In the wasi-sdk-24.0-x86_64-linux/lib/clang/18/lib, only wasi, wasip1, and wasip2 exist.

I manually linked libclang_rt.builtins-wasm32.a from wasip1, which resolved the issue, but I encountered:

(import "env" "__floatunditf" (func $fimport$2 (param i32 i64)))
(import "env" "__floatditf" (func $fimport$3 (param i32 i64)))

It seems that clang is unable to link libclang_rt.builtins-wasm32.a.

abrown commented 1 month ago

__floatunditf and __floatditf seem unrelated to threads and from the imports you mention it looks like they're using a module name I would expect Emscripten to satisfy. Maybe you can explain a bit more what you're trying to do? I'm trying to understand it but have to guess (e.g., are those imports unresolved? Where do you see that error?)

oligamiq commented 1 month ago

I apologize for my poor English. When I tried to build, the following imports remained and prevented execution:

(import "env" "__floatunditf" (func $fimport$2 (param i32 i64)))
(import "env" "__floatditf" (func $fimport$3 (param i32 i64)))

However, by linking libclang_rt.builtins-wasm32.a for wasip1, it was resolved and the program ran successfully. In other words, it seems that clang is not linking libclang_rt.builtins-wasm32.a when building for wasm32-wasip1-threads.

abrown commented 1 month ago

I think I resolved this in https://github.com/WebAssembly/wasi-sdk/pull/494, but to check the fix can you do the following:

Do you still see the issue?

oligamiq commented 1 week ago

I apologize for the delay, but it seems that the issue was on my end. However, when I configured it to use clang, the object being linked appears to be wasi-sdk-24.0-x86_64-linux/lib/clang/18/lib/wasi/libclang_rt.builtins-wasm32.a. I believe this is not an appropriate linking target when setting the target to wasip1-threads, so I suggest making adjustments.