This is important for the cases where new symbols can be introduced
during LTO. Specifically this happens for during TLS-lowering where
references to __tls_base can be introduced.
Fixes: https://github.com/emscripten-core/emscripten/issues/12489
Differential D111171
[lld][WebAssembly] Create optional internal symbols only after LTO object as been added sbc100 on Oct 5 2021, 11:22 AM. Authored by
Details This is important for the cases where new symbols can be introduced Fixes: https://github.com/emscripten-core/emscripten/issues/12489
Diff Detail
Event TimelineComment Actions As I mentioned in https://github.com/emscripten-core/emscripten/issues/12489 I'm having trouble reproducing this and thus creating a test for it. The problem is that in all the tests I've managed to create all the TLS variables get lowered away by https://github.com/llvm/llvm-project/blob/f92961d238efdfeccce27f9bb7b0a6629c376d4a/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp#L295.. and therefore WebAssemblyTargetLowering::LowerGlobalTLSAddress is never called.. and AFAICT that is the only reasonable place that those references to __tls_base could be created during LTO. Comment Actions How about if you create two LTO object files, one with -mattr=+atomics,+bulk-memory and one without, then link them together? In the combined bitcode, the presence of +atomics and +bulk-memory on the functions from the first object file will prevent that stripping from running, and you should get references to __tls_base from code originating in both object files. Comment Actions Thanks for the tip. Yes I think I'm somehow not setting -mattr=+atomics,+bulk-memory in the LTO object file. In my test hand written .ll test case how do I enable those.. it seems not on the llvm-as command line? I guess they are embedded in the .ll itself... Comment Actions Finally got the test working. Fails without this change (undefined symbol __tls_base) .. passed after. |