From: Paul H. Hargrove (PHHargrove_at_lbl_dot_gov)
Date: Fri Feb 09 2007 - 11:24:06 PST
Chao, I am sorry it has taken so long for me to be able to do anything with your BLCR link problem. I now have a better understating for where the problem is coming from and why my glibc doesn't have the same problem. While I cannot reproduce your problem myself, I think I understand enough to try to fix it. Could you please download the BLCR 0.5.0_b1 (or b2 if it is out by the time you see this) and apply the attached path. I suspect that it will fix your problem - please let me know of your success or failure. -Paul wchao_at_ncsu_dot_edu wrote: > Hi Paul, > > We still failed with the new snapshot on x86_64 fc5/2.6.16: > > gcc -shared .libs/libcr_la-cr_async.o .libs/libcr_la-cr_core.o > .libs/libcr_la-cr_cs.o .libs/libcr_la-cr_pthread.o > .libs/libcr_la-cr_sig_sync.o .libs/libcr_la-cr_syscall.o > .libs/libcr_la-cr_trace.o .libs/libcr_la-cr_strerror.o -ldl -lpthread > -nostdlib -Wl,-soname -Wl,libcr.so.0 -o .libs/libcr.so.0.1.3 > /usr/bin/ld: /usr/lib64/libpthread_nonshared.a(pthread_atfork.oS): > relocation R_X86_64_PC32 against `__dso_handle' can not be used when > making a shared object; recompile with -fPIC > /usr/bin/ld: final link failed: Bad value > > and -fPIC doesn't fix the error: > > gcc -fPIC -shared .libs/libcr_la-cr_async.o .libs/libcr_la-cr_core.o > .libs/libcr_la-cr_cs.o .libs/libcr_la-cr_pthread.o > .libs/libcr_la-cr_sig_sync.o .libs/libcr_la-cr_syscall.o > .libs/libcr_la-cr_trace.o .libs/libcr_la-cr_strerror.o -ldl -lpthread > -nostdlib -Wl,-soname -Wl,libcr.so.0 -o .libs/libcr.so.0.1.3 > /usr/bin/ld: /usr/lib64/libpthread_nonshared.a(pthread_atfork.oS): > relocation R_X86_64_PC32 against `__dso_handle' can not be used when > making a shared object; recompile with -fPIC > /usr/bin/ld: final link failed: Bad value > > Our gcc and binutils are: > gcc-4.1.0-3 > binutils-2.16.91.0.6-5 > > Which gcc do you use for your compilation on x86-64? > > Any suggestions are welcome! > Thanks! > Chao > > >> I've posted BLCR_0_4_pre3_snapshot_2006_09_06 to >> http://mantis.lbl.gov/blcr-dist >> If anybody still sees compilation or runtime failures on kernels >> 2.6.14-2.6.17, please let me know. >> >> -Paul >> >> -- Paul H. Hargrove PHHargrove_at_lbl_dot_gov Future Technologies Group HPC Research Department Tel: +1-510-495-2352 Lawrence Berkeley National Laboratory Fax: +1-510-486-6900 Index: libcr/cr_async.c =================================================================== RCS file: /var/local/cvs/lbnl_cr/libcr/cr_async.c,v retrieving revision 1.51 diff -u -r1.51 cr_async.c --- libcr/cr_async.c 1 Sep 2005 03:16:04 -0000 1.51 +++ libcr/cr_async.c 9 Feb 2007 19:17:31 -0000 @@ -179,7 +179,7 @@ if (thread_state == CRI_THREAD_STOPPED) { int rc; - rc = pthread_atfork(NULL, NULL, &thread_reset); + rc = cri_pthread_atfork(NULL, NULL, &thread_reset); if (rc != 0) { CRI_ABORT("pthread_atfork() returned %d", rc); } Index: libcr/cr_private.h =================================================================== RCS file: /var/local/cvs/lbnl_cr/libcr/cr_private.h,v retrieving revision 1.84 diff -u -r1.84 cr_private.h --- libcr/cr_private.h 5 Jan 2007 23:47:38 -0000 1.84 +++ libcr/cr_private.h 9 Feb 2007 19:17:31 -0000 @@ -99,6 +99,7 @@ // Perform pthreads-related initialization if needed. extern void cri_pthread_init(void); +extern int cri_pthread_atfork(void (*prepare)(void), void (*parent)(void), void (*child)(void)); // Register a callback extern cr_callback_id_t cri_do_register(cri_info_t*, cr_callback_t, void*, int); Index: libcr/cr_pthread.c =================================================================== RCS file: /var/local/cvs/lbnl_cr/libcr/cr_pthread.c,v retrieving revision 1.28 diff -u -r1.28 cr_pthread.c --- libcr/cr_pthread.c 24 Oct 2006 00:58:40 -0000 1.28 +++ libcr/cr_pthread.c 9 Feb 2007 19:17:31 -0000 @@ -30,6 +30,17 @@ #include <errno.h> #include "cr_private.h" +// pthread_atfork handling for shared objects */ +extern void *__dso_handle __attribute__((__weak__)); +extern int __register_atfork(void (*prepare)(void), void (*parent)(void), void (*child)(void), void *dso_handle); + +extern int +cri_pthread_atfork(void (*prepare)(void), void (*parent)(void), void (*child)(void)) +{ + void *my_handle = &__dso_handle ? __dso_handle : NULL; + return __register_atfork(prepare, parent, child, my_handle); +} + // Holds thread-specific data key for cri_info pthread_key_t cri_info_key; @@ -75,7 +86,7 @@ } // Install a pthread_atfork callback to cleanup state in children - rc = pthread_atfork(NULL, NULL, &child_reset); + rc = cri_pthread_atfork(NULL, NULL, &child_reset); if (rc != 0) { CRI_ABORT("pthread_atfork() returned %d", rc); }