-pthread and shared libraries

Previous thread: Re: Mini-documentation project - Exports section to the web site by Matthew Dillon on Monday, July 21, 2008 - 8:53 pm. (1 message)

Next thread: Wikipedia and versioning by Sdävtaker on Wednesday, July 23, 2008 - 10:12 am. (1 message)
To: <kernel@...>
Date: Tuesday, July 22, 2008 - 5:25 pm

While trying to find out why multimedia/gnash doesn't build in DragonFly I
discovered the point why there is probably no problem in NetBSD. Note,
that I don't say that this is the problem which must be fixed to get
gnash to build etc, the problem itself is probably elsewhere.

The point is that using -pthread to link a shared library doesn't link it
against libpthread.so, it just resolves symbols AFAICS. So far I thought
that -pthread and -lpthread are equal in linking phase.

hasso@pos:~$ gcc -shared -o test.so test.c -pthread
hasso@pos:~$ ldd ./test.so
./test.so:
libc.so.6 => /usr/lib/libc.so.6 (0x28070000)
hasso@pos:~$ gcc -shared -o test.so test.c -lpthread
hasso@pos:~$ ldd ./test.so
./test.so:
libpthread.so.0 => /usr/lib/libpthread.so.0 (0x2812b000)
libc.so.6 => /usr/lib/libc.so.6 (0x28070000)
hasso@pos:~$

What's the reason for that? Is it a historic and could be removed now to
avoid confusion?

--
Hasso Tepper

To: <kernel@...>
Date: Wednesday, July 23, 2008 - 6:05 am

Thread-aware libraries should not be linked against libpthread as it
forces the full pthread overhead everywhere.

Joerg

To: <kernel@...>
Date: Wednesday, July 23, 2008 - 6:23 am

But they are linked against libpthread in NetBSD? I don't have NetBSD
system to play with at the moment, I just looked at boost-libs binary
package.

--
Hasso Tepper

To: <kernel@...>
Date: Wednesday, July 23, 2008 - 6:34 am

Yes and this is not something I am happy with. This mostly happens in
NetBSD because the autoconf test for mutex etc normally doesn't include
pthread.h and therefore doesn't get the libc stubs. It creates more
problems than it is worth though.

Joerg

Previous thread: Re: Mini-documentation project - Exports section to the web site by Matthew Dillon on Monday, July 21, 2008 - 8:53 pm. (1 message)

Next thread: Wikipedia and versioning by Sdävtaker on Wednesday, July 23, 2008 - 10:12 am. (1 message)