[uclibc-ng-devel] pthread_mutex_*() functions, dynamic vs. static linking

Waldemar Brodkorb wbx at uclibc-ng.org
Fri Aug 19 19:34:43 CEST 2016


Hi Thomas,
Thomas Petazzoni wrote,

> Hello,
> 
> On Thu, 18 Aug 2016 22:33:35 +0200, Waldemar Brodkorb wrote:
> 
> > What about following patch, which creates dummies for
> > pthread_mutex_* functions in the !SHARED case:
> > 
> > From 8d11aa1b9a983e0422dffa84eb1a7b71c616a096 Mon Sep 17 00:00:00 2001
> > From: Waldemar Brodkorb <wbx at uclibc-ng.org>
> > Date: Thu, 18 Aug 2016 08:17:36 +0200
> > Subject: [PATCH] add dummies
> > 
> > 
> > Signed-off-by: Waldemar Brodkorb <wbx at uclibc-ng.org>
> > ---
> >  libc/misc/internals/__uClibc_main.c |    3 +++
> >  1 file changed, 3 insertions(+)
> > 
> > diff --git a/libc/misc/internals/__uClibc_main.c b/libc/misc/internals/__uClibc_main.c
> > index 9bb81fc..9320039 100644
> > --- a/libc/misc/internals/__uClibc_main.c
> > +++ b/libc/misc/internals/__uClibc_main.c
> > @@ -81,6 +81,9 @@ static int __pthread_return_0 (pthread_mutex_t *unused) { return 0; }
> >  weak_alias (__pthread_return_0, __pthread_mutex_lock)
> >  weak_alias (__pthread_return_0, __pthread_mutex_trylock)
> >  weak_alias (__pthread_return_0, __pthread_mutex_unlock)
> > +weak_alias (__pthread_return_0, pthread_mutex_lock)
> > +weak_alias (__pthread_return_0, pthread_mutex_trylock)
> > +weak_alias (__pthread_return_0, pthread_mutex_unlock)
> 
> Hum, why not, but this raises a few questions:
> 
>  - Why does it work in the shared case and not in the static case?
> 
>  - What are those __pthread_mutex_* variants?
> 
> Do we have a list of the pthread functions that libc.so/libc.a is
> supposed to provide? See the mail I just send about the axel/libintl
> issue where libintl also uses pthread_rwlock_*() without being linked
> with libpthread.so.

I discussed the issues with Rich Felker and he is suggesting _not_
to do some wacky weak/strong handling of these symbols to provide
some hackish way for applications to save some space.
We should just link with -lpthread if any pthread_* function is in
use to avoid any surprises when actually running the application.

So please add explicit -lpthread for these static linking failures
and add in libpthread.a functions. It might be just by accident that
libc.so provides these function dummies for external uses and may be 
we should fix this instead.

Thanks
 Waldemar


More information about the devel mailing list