Index: include/__config =================================================================== --- include/__config +++ include/__config @@ -1120,6 +1120,12 @@ #endif #endif +#if __has_attribute(no_destroy) +# define _LIBCPP_NO_DESTROY __attribute__((__no_destroy__)) +#else +# define _LIBCPP_NO_DESTROY +#endif + #ifndef _LIBCPP_HAS_NO_ASAN _LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container( const void *, const void *, const void *, const void *); Index: src/debug.cpp =================================================================== --- src/debug.cpp +++ src/debug.cpp @@ -42,7 +42,7 @@ __libcpp_db* __get_db() { - static __libcpp_db db; + static _LIBCPP_NO_DESTROY __libcpp_db db; return &db; } @@ -64,7 +64,7 @@ mutex_type& mut() { - static mutex_type m; + static _LIBCPP_NO_DESTROY mutex_type m; return m; } #endif // !_LIBCPP_HAS_NO_THREADS