This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [Question] threads.h library
- From: Rich Felker <dalias at libc dot org>
- To: Juan Manuel Torres Palma <j dot m dot torrespalma at gmail dot com>
- Cc: libc-alpha <libc-alpha at sourceware dot org>
- Date: Sat, 28 Feb 2015 14:44:04 -0500
- Subject: Re: [Question] threads.h library
- Authentication-results: sourceware.org; auth=none
- References: <CAD82F-o5MxCVEreVRqZbKL6snfZmr0KFzuXyM+5+VM1iY=OO6g at mail dot gmail dot com>
On Sat, Feb 28, 2015 at 03:09:19PM +0100, Juan Manuel Torres Palma wrote:
> Hi glibc folks.
>
> As many of you may remember, I'm trying to add threads.h support for
> glibc. I have done a lot of improvements now that I have some free
> time. However, today was compiling and got a linker error, complaining
> about pthreads function definition and I realized that I need some
> guidance about where to add this library.
>
> Choices are 2:
>
> - libc. In this case, I would need to add -lpthread to the linker.
> - libpthread. In this case it's simpler, but I don't know if it's
> correct to put it here.
>
> I would like to know where to comile this module with, and why.
While I would very much like it, I think you'll find strong opposition
to adding libpthread to libc.so's DT_NEEDED.
I think the opposite would be much more agreeable to most people. If
it seems odd that you need a -l option (-lpthread) to access standard
ISO C functionality, consider that this is already the case for math
functions (-lm). Since ISO C does not specify how the compiler is
invoked, there's nothing wrong with telling users "you need -lpthread
to get this functionality".
Adding a third library may seem like an attractive option, but I think
it would be considerably worse. Since most of the C11 thread functions
need to access namespace-safe versions of the pthread functions, you'd
end up adding __-prefixed versions of most of the pthread symbols to
the public/inter-library API for libpthread (so libthrd could use
them) rather than having these be internal hidden symbols in
libpthread.so.
Rich