This is the mail archive of the mailing list for the glibc project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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

#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);
	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

Atsushi Nemoto

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]