emulated-tls & lld lto


When targetting android (which doesn't support tls) I have to pass -mllvm -emulated-tls to get a working executable, however lld fails with:

lld.exe: error: TLS attribute mismatch: f_t31_RemObjects.Elements.System.SynchronizationContext.fCurrent
>>> defined in
>>> defined in lto.tmp

@f_t31_RemObjects.Elements.System.SynchronizationContext.fCurrent = hidden thread_local global %._RemObjects.Elements.System.SynchronizationContext* null

when linking two bitcode files. I'm currently having a bit of trouble reproducing this with a simple testcase so I wanted to ask if anyone knows what could cause this?

This happens in SymbolTable::insert, the first time it inserts a symbol when loading the Archive file, which sets it as TLS symbol. The second time when it actually did LTO and it's not TLS anymore.

Carlo Kok
RemObjects Software

I also cannot create a testcase that reproduces tihs.

What I find odd is that given

@a = hidden thread_local global i32 42, align 4

llc with -emulated-tl produces the symbols "__emutls_v.a" and
"__emutls_t.a", but not "a".

Any idea how
f_t31_RemObjects.Elements.System.SynchronizationContext.fCurrent is
showing up in lto.tmp?


Carlo Kok via llvm-dev <llvm-dev@lists.llvm.org> writes: