https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115686
Bug ID: 115686 Summary: gcc cannot generate weak link function for thread_local variable `TLS init function` Product: gcc Version: 15.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: MacroModel at trajectronix dot onmicrosoft.com Target Milestone: --- gcc cannot generate weak link function for thread_local variable `TLS init function` ```cpp // h1.h #include <vector> inline thread_local ::std::vector<int> v{}; // c1.cpp #include "h1.h" int main() { v.push_back(1); } // c2.cpp #include "h1.h" void foo() { v.push_back(2); } ``` compile: ```bash g++ -o test c1.cpp c2.cpp -std=c++2c G:/x86_64-w64-mingw32/bin/../lib/gcc/x86_64-w64-mingw32/15.0.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\User\AppData\Local\Temp\ccQoDAAa.o:c2.cpp:(.text+0x2a): multiple definition of `TLS init function for v'; C:\Users\User\AppData\Local\Temp\ccjOPJhU.o:c1.cpp:(.text+0x33): first defined here ``` gcc version: ```bash Using built-in specs. COLLECT_GCC=G:\x86_64-w64-mingw32\bin\g++.exe COLLECT_LTO_WRAPPER=G:/x86_64-w64-mingw32/bin/../libexec/gcc/x86_64-w64-mingw32/15.0.0/lto-wrapper.exe Target: x86_64-w64-mingw32 Configured with: /home/cqwrteur/toolchains_build/gcc/configure --with-gxx-libcxx-include-dir=/home/cqwrteur/toolchains/x86_64-w64-mingw32/x86_64-w64-mingw32/include/c++/v1 --prefix=/home/cqwrteur/toolchains/x86_64-w64-mingw32/x86_64-w64-mingw32 --build=x86_64-pc-linux-gnu --host=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --disable-nls --disable-werror --enable-languages=c,c++ --enable-multilib --disable-bootstrap --disable-libstdcxx-verbose --enable-libstdcxx-static-eh-pool --with-libstdcxx-eh-pool-obj-count=0 --disable-sjlj-exceptions --enable-libstdcxx-threads --enable-libstdcxx-backtrace Thread model: win32 Supported LTO compression algorithms: zlib gcc version 15.0.0 20240622 (experimental) (GCC) ```