tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Moving pthread_(cond|mutex) to libc

Starting with NetBSD 6.0, libpthread is cursed with the NOLOAD flag,
which means it cannot be loaded by dlopen(). The problem is that we can
easily get to dlopen'able modules that do not use pthreads, but are
linked to libraries that are linked with -lpthread. Such module cannot
be loaded anymore in NetBSD 6.0.

It seems there is a conensus that pthread_(cond|mutex) should move to
libc so that libpthread could be freed from NOLOAD [1]. I started
looking at it and of course it raises a few problems.

1) src/lib/libpthread/pthread_(cond|mutex).c include "pthread_md.h"
which should be taken from src/lib/libpthread/arch/$arch/pthread_md.h.
Once moved to src/lib/libc they do not find it anymore. I worked around
this problem by adding in src/lib/libc/gen/ this, which
calls for comments:

PTHREAD_ARCHDIR=        ${NETBSDSRCDIR}/lib/libpthread/arch
CPPFLAGS.pthread_cond.c+=       -I${PTHREAD_ARCHSUBDIR}
CPPFLAGS.pthread_mutex.c+=      -I${PTHREAD_ARCHSUBDIR} 

2) libc then fails to link,which suggest more stuff should move from
libpthread to libc. Shall I carry on that way?

libc_pic.a(pthread_cond.pico):(.text+0x13d): undefined reference to
libc_pic.a(pthread_cond.pico):(.text+0x2a7): undefined reference to
libc_pic.a(pthread_cond.pico): In function `__libc_cond_init':
pthread_cond.c:(.text+0x337): undefined reference to
thread_cond.c:(.text+0x355): undefined reference to `pthread_lockinit'
pthread_cond.c:(.text+0x3a2): undefined reference to `pthread_lockinit'
libc_pic.a(pthread_cond.pico): In function `__libc_cond_destroy':
pthread_cond.c:(.text+0x43b): undefined reference to
pthread_cond.c:(.text+0x46c): undefined reference to
libc_pic.a(pthread_cond.pico): In function `__libc_cond_timedwait':
pthread_cond.c:(.text+0x514): undefined reference to
pthread_cond.c:(.text+0x67a): undefined reference to
pthread_cond.c:(.text+0x6a8): undefined reference to
pthread_cond.c:(.text+0x6e4): undefined reference to
pthread_cond.c:(.text+0x791): undefined reference to

[1] See that thread for background

Emmanuel Dreyfus

Home | Main Index | Thread Index | Old Index