llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

"cannot compile this non-trivial TLS destruction yet", when compiling with -fno-use-cxa-atexit

Open llvmbot opened this issue 7 years ago • 3 comments

Bugzilla Link 42182
Resolution FIXED
Resolved on Aug 09, 2019 08:21
Version unspecified
OS Linux
Reporter LLVM Bugzilla Contributor
CC @DougGregor,@erichkeane,@jyu2-git,@zygoloid
Fixed by commit(s) 363288

Extended Description

Compiler reports being unable to compile the following code "yet"...

class foo { public: foo(); ~foo(); };

void some_func (void) { foo thread_local my_var; }

The error only happens when compiling with the “-fno-use-cxa-atexit” flag:

$ clang++ -fno-use-cxa-atexit -o foo.o -c foo.cxx

foo.cxx:9:20: error: cannot compile this non-trivial TLS destruction yet foo thread_local my_var; ^

Issue exists with clang 7.1.0, 8, and trunk (as of May 18th content)

llvmbot avatar Jun 07 '19 16:06 llvmbot

I think I did the right thing here: https://reviews.llvm.org/D63283

I'm still not sure I get what GCC is doing, but it seems we should be allowed to use __cxa_thread_atexit for thread-local-storage.

erichkeane avatar Jun 13 '19 17:06 erichkeane

It seems that this happens in the ItaniumCXXABI implementation of registerGlobalDtor(~line 2365). The reason -fno-use-cxx-atexit causes this is that we use __cxa_atexit if possible, otherwise we mark it as unsupported.

I don't really understand what GCC is doing, but the differences are here: https://godbolt.org/z/11nn0F

The flag suppresses using __dso_handle when calling, but Jennifer is right that GCC seems to use __cxa_thread_atexit.

erichkeane avatar Jun 13 '19 15:06 erichkeane

-fno-use-cxa-atexit should not effect __cxa_thread_atexit. I checked g++ with -fno-use-cxa-atexit the __cxa_thread_atexit is used.

jyu2-git avatar Jun 08 '19 00:06 jyu2-git