WebAssembly/wasi-libc

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

Opened this issue · 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.

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

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.

I think I resolved this in WebAssembly/wasi-sdk#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?

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.