[Xcb] new library for pthread stub functions

Josh Triplett josh at freedesktop.org
Wed Nov 22 14:06:37 PST 2006


Barton C Massey wrote:
> In message <20061122105339.GA12023 at id.minilop.net> you wrote:
>> Bart points out that I could just have suppressed gcc's warning about
>> unused static functions.
> 
> To be clear: I think we should suppress GCC's warnings about
> unused static functions regardless of what we do about this
> particular problem.  In my experience, such warnings are
> almost always false positives for harmless situations,
> rather than indicators of an actual bug.

I tend to agree.  GCC should just silently drop any static function which
doesn't get referenced.  From the GCC manual:

`-Wunused-function'
     Warn whenever a static function is declared but not defined or a
     non-inline static function is unused.  This warning is enabled by
     `-Wall'.

So we could just use -Wno-unused-function.  However, I think we actually want
the first half of that warning, just not the second half.

>> Josh and I came up with a different, and I think dramatically better,
>> solution. Take a look at:
>> 	git://anongit.freedesktop.org/git/xcb/pthread-stubs
> 
> I think this is a very nice solution, and support it.  I'm
> probably being stupid, but I'm missing why the static
> linking case is hard; why not just provide static
> implementations of all the stubbed functions and flat-out
> link against them?

Assume that you have a system where pthread-stubs has content, because libc
lacks some stubs.  Consider the case of libxcb.  For the dynamic case, we can
just express a dependency on pthread-stubs, and link against the shared
library.  At runtime, libxcb.so will pull in libpthread-stubs.so, and
something which depends on libxcb.so may or may not pull in libpthread.so, so
the weak symbols will do the right thing.  However, what about the static
library libxcb.a?  We can't pull in libpthread-stubs.a, because that prevents
people from using threads, since they can't pull in libpthread.a and override
our functions; weak symbols don't work for static libraries.  We need to not
link against any thread .a, and instead we need the program using libxcb.a to
pull in either libpthread-stubs.a or libpthread.a.  On the other hand, in the
dynamic case, we don't want the program to have to pull in
libpthread-stubs.so, since we can do that; we just want them to pull in
libpthread.so if they need it.  Thus, we force every program to do something
slightly different for the static and non-static case, and we don't have any
way of expressing that in pkg-config.

- Josh Triplett

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 252 bytes
Desc: OpenPGP digital signature
Url : http://lists.freedesktop.org/archives/xcb/attachments/20061122/b01ca9d6/signature.pgp


More information about the Xcb mailing list