https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77285
--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> --- Reduced: cat >a.cpp <<EOF struct __attribute__((abi_tag("tag"))) X { ~X() { }int i = 0; }; thread_local X gFeelingLucky; EOF cat >main.cpp <<EOF struct __attribute__((abi_tag("tag"))) X { ~X() { }int i = 0; }; extern thread_local X gFeelingLucky; int main() { return gFeelingLucky.i; } EOF g++ main.cpp a.cpp /tmp/ccTyHWNr.o: In function `TLS wrapper function for gFeelingLucky': main.cpp:(.text._ZTW13gFeelingLucky[_ZTW13gFeelingLucky]+0x5): undefined reference to `TLS init function for gFeelingLucky' collect2: error: ld returned 1 exit status nm a.o U _GLOBAL_OFFSET_TABLE_ 0000000000000000 B _Z13gFeelingLuckyB5cxx11 U _ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC1Ev U _ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED1Ev 0000000000000000 r _ZStL19piecewise_construct 0000000000000000 T _ZTH13gFeelingLuckyB5cxx11 U __cxa_thread_atexit U __dso_handle 0000000000000020 b __tls_guard 0000000000000000 t __tls_init nm main.o U _GLOBAL_OFFSET_TABLE_ U _Z13gFeelingLuckyB5cxx11 U _ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE6lengthEv 0000000000000000 r _ZStL19piecewise_construct U _ZTH13gFeelingLucky 0000000000000000 W _ZTW13gFeelingLucky 0000000000000000 T main