Issue |
145195
|
Summary |
[LTO][MinGW] Cannot build a DLL containing auto-exported emulated-TLS variable for MinGW target if LTO enabled
|
Labels |
new issue
|
Assignees |
|
Reporter |
kikairoya
|
When building a DLL with LTO, the linker cannot resolve auto-exported emulated-TLS `thread_local` variables.
```
// pass
// RUN: clang++ -fuse-ld=lld %s -shared -o %t.dll -target x86_64-windows-gnu -femulated-tls -flto -Wl,--exclude-all-symbols
// RUN: clang++ -fuse-ld=lld %s -shared -o %t.dll -target x86_64-windows-gnu -fno-emulated-tls -flto
// RUN: clang++ -fuse-ld=lld %s -shared -o %t.dll -target x86_64-windows-gnu -femulated-tls -flto -DUSE_DLLEXPORT
// RUN: clang++ -fuse-ld=lld %s -shared -o %t.dll -target x86_64-windows-gnu -femulated-tls -fno-lto
// RUN: llvm-readobj --coff-exports %t.dll | FileCheck %s
// CHECK: Name: __emutls_v.tls_var
// fail
// RUN: clang++ -fuse-ld=lld %s -shared -o %t.dll -target x86_64-windows-gnu -femulated-tls -flto
int thread_local tls_var;
#ifdef USE_DLLEXPORT
__declspec(dllexport) int other_var;
#endif
int main() {}
```
result:
```
ld.lld: error: <root>: undefined symbol: tls_var
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
```
The linker reports `tls_var` as undefined, although `__emutls_v.tls_var` should be referenced instead in emulated-TLS mode.
Maybe related to: https://github.com/llvm/llvm-project/issues/134725 https://github.com/llvm/llvm-project/issues/79715
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs