Compile to WASM without threads?
Is it possible to compile to wasm through emscripten without using pthreads? I have code which uses tbb. With older versions, I was able to compile but just not set the -pthread compile/link flag, and it would run single threaded (I'm assuming tbb has an internal single threaded scheduler if it doesn't find pthreads?). This is useful for running on sites that are not yet setting cross origin headers correctly. Newer versions of tbb force the use of the -pthread flag: https://github.com/oneapi-src/oneTBB/blob/58653a3729f343c48fecb4809a894cd4ba0b8574/CMakeLists.txt#L195C1-L202C31
Yes, oneTBB can compile without pthreads. You can try removing the line that you mentioned and this. Since, without this flag a few of our tests starts failing, it is difficult for us to comment on the APIs being tested.
Thanks, it does seem to work if I make those two changes. Is it possible to make this a cmake option? tbb is included using FetchContent. It would be a few more steps if we need to modify the package directly, instead of just setting a cmake option.
Yes, we can create a cmake option. I will update this issue with the PR when we are ready with it.
Awesome, this will be a big help!
'EMSCRIPTEN_WITHOUT_PTHREAD=true' should should compile without pthreads.
Thank you!