https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58909
--- Comment #26 from Jonathan Wakely <redi at gcc dot gnu.org> --- If you create a new thread of execution then you'll get a non-weak reference to pthread_create, which should cause libpthread.so to be linked even with -Wl,--as-needed (and for static linking it will work if libpthread.a has a single .o with all symbols). If you don't actually have multiple threads in your program, then things like condition_variable and once_flag can end up using the stubs in libc.so.6 which are no-ops. But since you don't have multiple threads, it's probably not a major problem. Most uses of std::once_flag would be better done with a local static variable anyway (the exception being non-static data members of classes). With glibc 2.34 the problem goes away, so I'm not sure it's worth investing much effort in libstdc++ trying to work around the problems with weak symbols.