Unfortunately thread local storage has not been implemented in the WebAssembly LLVM backend yet, although we’re just starting to work on it now. I saw the LLVM bug you filed, and we will definitely take a look at how we can avoid the crash you’re seeing or at least give a more helpful error message until TLS support is complete.
For now you can try using the pthreads library TLS rather than language-level TLS. I believe that should work. > On Jul 4, 2019, at 12:43, Mehdi Sabwat <[email protected]> wrote: > > Hi, > > Putting this here because I think it could lead to an interesting discussion. > (and because by writing things down, I can understand them better. This is > (very) new to me) > > cross compiling this > [thread_local]$ cat main.c > #include <threads.h> > #include <stdio.h> > > thread_local int a; > > int main() > { > printf("%d\n", a); > } > > with: > > emcc -pthread main.c > > or: > emcc -s USE_PTHREADS=1 > > or: > clang-9 --target=wasm32-unknown-emscripten > -I../../emsdk/upstream/emscripten/system/include/libc/ -pthread main.c) > > leads to a SIGABORT because this assertion fails: > virtual uint64_t (anonymous > namespace)::WasmObjectWriter::writeObject(llvm::MCAssembler &, const > llvm::MCAsmLayout &): Assertion `Sec.getKind().isMetadata()' failed > > WasmObjectWriter fails to write object code because of the IR, which has > weird or unrecognized sections. Question is, if we change the code to > initialise the sections, would it be recognised by WASM if so, how ? :) > there doesn't seem to be any reference of thread_local in WebAssembly. > > Since pthread support is experimental in WASM (although we can already do a > lot of things), I wanted to know if there was something we could do to work > around it? > > Complete logs are here. > > Cheers! > -- > You received this message because you are subscribed to the Google Groups > "emscripten-discuss" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/emscripten-discuss/78f61504-4e78-4afb-a4be-3e0314f5e29f%40googlegroups.com. > For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "emscripten-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/emscripten-discuss/2DE1A1C5-73E6-42E5-BAA8-ED54CB8D0F66%40google.com. For more options, visit https://groups.google.com/d/optout.
