[lxc-devel] [PATCH] Link against pthread when not on bionic.

Daniel Lezcano daniel.lezcano at free.fr
Mon Feb 18 21:10:07 UTC 2013


On 02/18/2013 09:46 PM, Stéphane Graber wrote:
> On 02/18/2013 03:40 PM, Daniel Lezcano wrote:
>> On 02/18/2013 06:23 PM, Stéphane Graber wrote:
>>> dpkg spotted that we're not explicitly linking against pthread even though
>>> we use some of its symbols (sem_*).
>> uh ? wait.
>>
>> We shouldn't link against the lib pthread.
>>
>> I don't think sem_* is a symbol coming from the pthread library.
>>
>> Could you give the output of dpkg ?
> From "man sem_open":
>        Link with -pthread.

-pthread, not -lpthread

or -librt

As lxc is not thread safe, you should prevent to link against the
libpthread because the user will think it is thread safe and that could
lead to some unexpected behavior.

Linking against librt should be ok. I don't understand the warning of dpkg.

Could you check by commenting the lines below if the warning still appear ?

#if !IS_BIONIC
liblxc_so_LDADD += -lutil -lrt
#endif



> dpkg-shlibdeps output:
> dpkg-shlibdeps: warning: symbol sem_post used by
> debian/liblxc0/usr/lib/x86_64-linux-gnu/liblxc.so.0.9.0.alpha3 found in
> none of the libraries
> dpkg-shlibdeps: warning: symbol sem_open used by
> debian/liblxc0/usr/lib/x86_64-linux-gnu/liblxc.so.0.9.0.alpha3 found in
> none of the libraries
> dpkg-shlibdeps: warning: symbol sem_close used by
> debian/liblxc0/usr/lib/x86_64-linux-gnu/liblxc.so.0.9.0.alpha3 found in
> none of the libraries
> dpkg-shlibdeps: warning: symbol sem_init used by
> debian/liblxc0/usr/lib/x86_64-linux-gnu/liblxc.so.0.9.0.alpha3 found in
> none of the libraries
> dpkg-shlibdeps: warning: symbol sem_timedwait used by
> debian/liblxc0/usr/lib/x86_64-linux-gnu/liblxc.so.0.9.0.alpha3 found in
> none of the libraries
> dpkg-shlibdeps: warning: symbol sem_destroy used by
> debian/liblxc0/usr/lib/x86_64-linux-gnu/liblxc.so.0.9.0.alpha3 found in
> none of the libraries
> dpkg-shlibdeps: warning: symbol sem_wait used by
> debian/liblxc0/usr/lib/x86_64-linux-gnu/liblxc.so.0.9.0.alpha3 found in
> none of the libraries
>
>
> Looking at pthread.so it appears to provide:
> sem_init
> sem_destroy
> sem_open
> sem_close
> sem_unlink
> sem_getvalue
> sem_wait
> sem_trywait
> sem_timedwait
> sem_post
>
>>> Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
>>> ---
>>>  src/lxc/Makefile.am | 2 +-
>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/src/lxc/Makefile.am b/src/lxc/Makefile.am
>>> index 8974ca9..a0077aa 100644
>>> --- a/src/lxc/Makefile.am
>>> +++ b/src/lxc/Makefile.am
>>> @@ -115,7 +115,7 @@ liblxc_so_LDFLAGS = \
>>>  liblxc_so_LDADD = $(CAP_LIBS) $(APPARMOR_LIBS) $(SECCOMP_LIBS)
>>>  
>>>  if !IS_BIONIC
>>> -liblxc_so_LDADD += -lutil -lrt
>>> +liblxc_so_LDADD += -lutil -lrt -lpthread
>>>  endif
>>>  
>>>  bin_SCRIPTS = \
>





More information about the lxc-devel mailing list