On Tue, Oct 01, 2024 at 11:10:03AM +0100, Jonathan Wakely wrote: > Let's use an inline variable. A function-local static requires > __cxa_guard_acquire, which (for some targets, including the ones > affected by this change) uses __gthread_active_p which will > recursively re-enter the variable's initialization. > > So something like: > > #pragma GCC diagnostic push > #pragma GCC diagnostic ignored "-Wc++17-extensions" > inline volatile int __gthread_active = -1; > #pragma GCC diagnostic pop
Note, only for #ifdef __cplusplus, for C there is no such thing as inline variables and in that case it should use static volatile int __ghtread_active = -1; instead. Jakub