wasi-libc icon indicating copy to clipboard operation
wasi-libc copied to clipboard

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

Open oligamiq opened this issue 1 year ago • 4 comments

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.

oligamiq avatar Sep 29 '24 07:09 oligamiq

__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?)

abrown avatar Oct 03 '24 22:10 abrown

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.

oligamiq avatar Oct 04 '24 06:10 oligamiq

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

  • create the directory wasi-sdk-24.0-x86_64-linux/lib/clang/18/lib/wasip1-threads
  • copy libclang_rt.builtins-wasm32.a from one of the sibling directories (e.g., .../lib/wasip1) into wasip1-threads
  • compile as before without the manual linking

Do you still see the issue?

abrown avatar Oct 10 '24 19:10 abrown

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.

oligamiq avatar Nov 06 '24 05:11 oligamiq

I believe this has been closed by https://github.com/WebAssembly/wasi-sdk/pull/533; please re-open if for some reason there is more to do here.

abrown avatar Jun 30 '25 20:06 abrown