Support single-threaded WASI: guard std::mutex behind __wasi__ - #5
Conversation
libc++ in the wasm32-wasip1 SDK is built without threads, so std::mutex is unavailable. Gate the no-thread-branch StrictKey mutex (tvgLock.h) and the SwRenderer global mutex behind __wasi__ so the SW engine compiles for wasm.
|
Approach looks right and the premise holds: Two things I'd change: 1. So: #ifdef __STDCPP_THREADS__
std::mutex mtx;
#endifNot wasm-specific, so it also covers any other freestanding/no-thread target, and it self-corrects if we ever move to the threads triple. (libc++'s 2. Two different mechanisms for the same problem. Minor: the 3-line comment in For the record on which target this affects: we build plain single-threaded wasip1 in both places — |
libc++ in the wasm32-wasip1 SDK is built without threads, so std::mutex is unavailable. Gate
the no-thread-branch StrictKey mutex (tvgLock.h) and the SwRenderer global mutex behind wasi so the SW engine compiles for wasm.