[clang] [lld] [llvm] Conditionalize use of POSIX features missing on WASI/WebAssembly (PR #92677)

James Y Knight via llvm-commits llvm-commits at lists.llvm.org
Sun Jul 14 18:23:25 PDT 2024


jyknight wrote:

> It wasn't clear to me initially what the way forward is, but it seems like it's not really feasible to conditionalize each use of `std::mutex` and instead WASI sysroots should provide a single-threaded implementation of synchronization primitives for embeddings which do not spawn threads, rather than placing this burden on code targeting Wasm.

Absolutely. This is, perhaps, a "bug" (enhancement request) for libc++: its `_LIBCPP_HAS_NO_THREADS` mode currently deletes the mutex and related types, but it should instead make them stubs. (it should continue to delete the thread types like it does today.) Alternatively, perhaps it would be good to stub it out at the pthread API level, so that C code is also handled.

So, I think it'd be good to get this PR in with only supporting WASI-with-threads for now, then return to wasi-without-threads after addressing the above.

https://github.com/llvm/llvm-project/pull/92677


More information about the llvm-commits mailing list