C++ static destructors can be problematic in multi-threaded environment. Some of the issues users often complain about include:
- Teardown ordering: crashes when one thread is exiting the process and calling destructors while another thread is still running and accessing the destructing variables
- Shared code that is compiled both as an application and as a library. When library mode is chosen, goto (1).
- Some projects currently override __cxa_atexit to avoid the behavior in question.
To get around that, I propose we add the compiler flag -fno-cxx-static-destructors, which allows clang to suppress static destructor registration (suppress emitting __cxa_atexit, atexit, etc).