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:
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?
Cheers!