Ok, there are a few things happening here due to our incomplete implementation of pthreads+llvm backend in emscripten. Here's how you can hack around them.
wasm-ld: error: 'atomics' feature is used, so --shared-memory must be used
What's happening here is that Emscripten should be passing --shared-memory
to the linker because multithreaded applications require a wasm shared memory, but it's not. You can pass this flag manually to the linker with -Wl,--shared-memory
.
wasm-ld: error: Target feature 'atomics' is disallowed. Use --no-check-features to suppress.
You're getting this error because emscripten is trying to link your code against a libc (or other library) that contained atomic operations in its source but was compiled for MVP, which caused those atomic operations to be lowered to non-atomic operations. Linking your multithreaded code with these libraries is very dangerous because those libraries will not be thread safe, even if they were supposed to be.
The proper way to handle this is to recompile the libraries you are using with pthreads enabled, but unfortunately Emscripten does not know how to compile its libc with pthreads yet. As the error message says, you can pass --no-check-features to the linker to hack your way past this issue, but that would result in an unexpectedly thread-unsafe final binary.
tl;dr: Pass -Wl,--shared-memory,--no-check-features
to make these errors go away, but that's not exactly safe.
https://github.com/emscripten-core/emscripten/issues/8503