https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55394
--- Comment #10 from Sergei Trofimovich <slyfox at gcc dot gnu.org> ---
How about something as simple as:
--- a/libgcc/gthr-posix.h
+++ b/libgcc/gthr-posix.h
@@ -697,7 +697,12 @@ static inline int
__gthread_once (__gthread_once_t *__once, void (*__func) (void))
{
if (__gthread_active_p ())
- return __gthrw_(pthread_once) (__once, __func);
+ /*
+ * Call non-weak form of a symbol to force linker
+ * resolve real implementation of pthread_once even
+ * for as-needed case: https://gcc.gnu.org/PR55394.
+ */
+ return pthread_once (__once, __func);
else
return -1;
}
Superficial test fixes "-flto -Wl,--as-needed" case above for me.
The fix leaves '__gthread_active_p ()' to probe weak symbols but calls non-weak
form of pthread_once().
If it's a plausible path I can have a pass through all static inline functions,
and convert weak calls to non-weak calls where glibc-2.32 does not define a
symbol in libc.so.6.