H.J. Lu 2012-09-06 23:25:45 UTC
https://sourceware.org/bugzilla/show_bug.cgi?id=5780#c2
~~~
The issue is GCC uses
1. Mark pthread_foo as weak.
2. Use a weak pthread_xxxx to check if thread is active.
3. It does
if (pthread_xxxx)
pthread_foo ();
With libpthread.a, there is no guarantee that linking in
archive member for pthread_xxxx will also include archive
member for pthread_foo. When it happens, static executable
crashes when calling pthread_foo. We can add
if (pthread_foo)
pthread_foo ();
But it may lead to bad static executable hehavior. The
list of pthread_foo is
pthread_attr_init
pthread_attr_setdetachstate
pthread_cond_broadcast
pthread_cond_destroy
pthread_cond_init
pthread_cond_signal
pthread_cond_wait
pthread_create
pthread_detach
pthread_exit
pthread_getschedparam
pthread_getspecific
pthread_join
pthread_key_create
pthread_key_delete
pthread_mutex_destroy
pthread_mutex_init
pthread_mutex_lock
pthread_mutex_trylock
pthread_mutex_unlock
pthread_once
pthread_self
pthread_setschedparam
pthread_setspecific
pthread_sigmask
__pthread_key_create
~~~