how to overcome missing stubs in FreeBSD 6

Alex Dupre ale at
Tue Sep 22 16:16:20 UTC 2009

I have a scenario with a thread-safe library that uses pthread_equal()
function. In FreeBSD 7+ there is the appropriate libc stub, but in
FreeBSD 6 it's missing, so a single-threaded binary linked to this
library should be linked also to a threading library to resolve the
missing symbol.

This is not good for two reasons:
- additional overhead for useless threading lib
- different linking between FreeBSD versions

I thought that declaring pthread_equal() as weak symbol with a stub
function in the library would globally solve the problem in FreeBSD 6,
but actually it doesn't work as expected: a binary linked to the library
with -pthread continues to use the stub function instead of the one
defined in libpthread. The only way I found to make it working was to
link directly to -lpthread *before* the incriminated lib, but this is
not acceptable.

Is there a clean solution?

Alex Dupre

More information about the freebsd-threads mailing list