This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
simple pthread program and static link
- From: Atsushi Nemoto <anemo at mba dot ocn dot ne dot jp>
- To: libc-alpha at sources dot redhat dot com
- Date: Wed, 03 Oct 2007 11:10:30 +0900 (JST)
- Subject: simple pthread program and static link
When I compiled and linked this simple pthread program statically,
set_robust_list system call is never called. (on i386-linux or
mips-linux)
#define _GNU_SOURCE
#include <pthread.h>
int main(int argc, char **argv)
{
pthread_mutex_t mu;
pthread_mutexattr_t attr;
pthread_mutexattr_setrobust_np(&attr, PTHREAD_MUTEX_ROBUST_NP);
pthread_mutex_init(&mu, NULL);
pthread_mutex_lock(&mu);
pthread_mutex_unlock(&mu);
return 0;
}
This is because nptl/init.o was not linked to the exectable. No
problem if I linked it dynamically.
And this problem happens if I configured libc with
--enable-kernel=2.6.18 option. If libc was configured with
--enable-kernel=2.6.12, nptl/init.o is linked as expected.
I suppose this version-dependency is because __set_robust_list_avail
in init.c is required if __ASSUME_SET_ROBUST_LIST was not defined.
(__ASSUME_SET_ROBUST_LIST is enabled by --enable-kernel=2.6.18)
How can I make sure nptl/init.o always linked to pthread programs
(even if it was statically linked) ?
Usually __static_tls_size, etc. are required by pthread_create() or
something, so nptl/init.o is linked anyway. But if simple test
program like this did not work properly, it might surprise some
people.
---
Atsushi Nemoto