PGI User Forum
 SearchSearch   MemberlistMemberlist     RegisterRegister   ProfileProfile    Log inLog in 

Free OpenACC Webinar

pthreads & SLES9

 
Post new topic   Reply to topic    PGI User Forum Forum Index -> Programming and Compiling
View previous topic :: View next topic  
Author Message
troyt



Joined: 26 Apr 2005
Posts: 4

PostPosted: Tue Apr 26, 2005 11:38 am    Post subject: pthreads & SLES9 Reply with quote

System is a dual-opteron system running SuSE Linux Enterprise (SLES) 9 (x86_64)

I'm going to attempt to make this as simple as possible: When I try to compile against pthreads, it compiles fine -- but when I try to execute the binary, I receive the following error:

Quote:
relocation error: /opt/pgi/linux86-64/6.0/lib/libpthread.so.0: symbol _h_errno, version GLIBC_2.2.5 not defined in file libc.so.6 with link time reference


It doesn't really matter what I am compiling, but here's a test case:
Code:
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <pthread.h>

void *print_message_function( void *ptr );

main()
{
     pthread_t thread1, thread2;
     char *message1 = "Thread 1";
     char *message2 = "Thread 2";
     int  iret1, iret2;

    /* Create independant threads each of which will execute function */

     iret1 = pthread_create( &thread1, NULL, print_message_function, (void*) message1);
     iret2 = pthread_create( &thread2, NULL, print_message_function, (void*) message2);

     /* Wait till threads are complete before main continues. Unless we  */
     /* wait we run the risk of executing an exit which will terminate   */
     /* the process and all threads before the threads have completed.   */

     pthread_join( thread1, NULL);
     pthread_join( thread2, NULL);

     printf("Thread 1 returns: %d\n",iret1);
     printf("Thread 2 returns: %d\n",iret2);
     exit(0);
}

void *print_message_function( void *ptr )
{
     char *message;
     message = (char *) ptr;
     printf("%s \n", message);
}


and is compiled using the command:
Code:
pgcc test.c -lpthread -o test.pgi


The code otherwise compiles & executes fine with gcc (3.3.3), Intel 8.1, and Pathscale 2.0.

libpthread.so.0 symlinks to libpgthread.so, which links to /lib64/libpthread.so.0

Ideas?
Back to top
View user's profile
mkcolg



Joined: 30 Jun 2004
Posts: 6213
Location: The Portland Group Inc.

PostPosted: Tue Apr 26, 2005 2:13 pm    Post subject: Reply with quote

Hi troyt,

Here's the output from my run on one of our Dual Opteron SLES9 systems:
Code:
emblem:/tmp% pgcc test.c -lpthread -o test.pgi
PGC-W-0118-Function print_message_function does not contain a return statement (test.c: 37)
PGC/x86-64 Linux/x86-64 6.0-2: compilation completed with warnings
emblem:/tmp% ldd test.pgi
        libpthread.so.0 => /lib64/tls/libpthread.so.0 (0x00002aaaaabc2000)
        libc.so.6 => /lib64/tls/libc.so.6 (0x00002aaaaacd6000)
        libm.so.6 => /lib64/tls/libm.so.6 (0x00002aaaaaef7000)
        /lib64/ld-linux-x86-64.so.2 => /lib64/ld-linux-x86-64.so.2 (0x00002aaaaaaab000)
emblem:/tmp% test.pgi
Thread 1
Thread 2
Thread 1 returns: 0
Thread 2 returns: 0


As you can see, it works on my system. I suspect that the linker is not using the thread local storage (tls) version of the libraries, but why I'm not sure. What I'd like to see is the output of the following commands:

Code:
ls -l /lib64/libpthread.so.0
ls -l /lib64/tls/libpthread.so.0
pgcc test.c -v -lpthread -o test.pgi
echo $LD_LIBRARY_PATH
ldd test.pgi
test.pgi


Also, have you made any changes to your system that might have changed these libraries?

Thanks,
Mat
Back to top
View user's profile
troyt



Joined: 26 Apr 2005
Posts: 4

PostPosted: Fri Apr 29, 2005 10:30 am    Post subject: Sry reply took so long... Reply with quote

Quote:
What I'd like to see is the output of the following commands:
ls -l /lib64/libpthread.so.0
ls -l /lib64/tls/libpthread.so.0

Code:
-rwxr-xr-x  1 root root 95509 2004-11-05 11:05 /lib64/libpthread.so.0
-rwxr-xr-x  1 root root 99188 2004-11-05 11:17 /lib64/tls/libpthread.so.0

Quote:
pgcc test.c -v -lpthread -o test.pgi

Code:

/opt/pgi/linux86-64/6.0/bin/pgc test.c -opt 1 -x 119 0xa10000 -x 122 0x40 -x 123 0x1000 -x 127 4 -x 19 0x400000 -quad -x 120 0x80000000 -x 59 4 -y 80 0x1000 -x 80 0x10800000 -astype 0 -stdinc /opt/pgi/linux86-64/6.0/include:/usr/local/include:/usr/lib64/gcc-lib/x86_64-suse-linux/3.3.3/include:/usr/lib64/gcc-lib/x86_64-suse-linux/3.3.3/include:/usr/include -def unix -def __unix -def __unix__ -def linux -def __linux -def __linux__ -def __inline__= -def __NO_INLINE__ -def __NO_MATH_INLINES -def __x86_64__ -def __LONG_MAX__=9223372036854775807L -def '__SIZE_TYPE__=unsigned long int' -def '__PTRDIFF_TYPE__=long int' -def __THROW= -def __amd64__ -predicate '#machine(x86_64) #lint(off) #system(posix) #cpu(x86_64)' -cmdline '+pgcc test.c -v -lpthread -o test.pgi' -asm /tmp/pgccaaaaawsbat.s
PGC-I-0222-Redundant definition for symbol __THROW (/usr/include/sys/cdefs.h: 57)
PGC-W-0118-Function print_message_function does not contain a return statement (test.c: 37)
PGC/x86-64 Linux/x86-64 6.0-2: compilation completed with warnings

/usr/bin/as /tmp/pgccaaaaawsbat.s -o /tmp/pgccbaaaawsbau.o

/usr/bin/ld /usr/lib64/crt1.o /usr/lib64/crti.o /usr/lib64/gcc-lib/x86_64-suse-linux/3.3.3/crtbegin.o -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 /tmp/pgccbaaaawsbau.o -o test.pgi -L/opt/pgi/linux86-64/6.0/lib -L/usr/lib64 -L/usr/lib64/gcc-lib/x86_64-suse-linux/3.3.3 -rpath /opt/pgi/linux86-64/6.0/lib -lpthread -lc -lnspgc -lpgc -lm -lgcc -lc -lgcc /usr/lib64/gcc-lib/x86_64-suse-linux/3.3.3/crtend.o /usr/lib64/crtn.o
Unlinking /tmp/pgccaaaaawsbat.s
Unlinking /tmp/pgccbaaaawsbau.o

Quote:
echo $LD_LIBRARY_PATH

This is actually null; however, I have the following in my ld.so.conf:

Code:
/opt/pgi/linux86-64/6.0/lib
/opt/pgi/linux86-64/6.0/libso

Quote:
ldd test.pgi

Code:
libpthread.so.0 => /opt/pgi/linux86-64/6.0/lib/libpthread.so.0 (0x0000002a9566d000)
libc.so.6 => /lib64/tls/libc.so.6 (0x0000002a9581f000)
libm.so.6 => /lib64/tls/libm.so.6 (0x0000002a95a41000)
/lib64/ld-linux-x86-64.so.2 => /lib64/ld-linux-x86-64.so.2 (0x0000002a95556000)

Quote:
test.pgi

Code:
./test.pgi: relocation error: /opt/pgi/linux86-64/6.0/lib/libpthread.so.0: symbol _h_errno, version GLIBC_2.2.5 not defined in file libc.so.6 with link time reference

Quote:
Also, have you made any changes to your system that might have changed these libraries?


Only if using the YAST updater counts as changes to the system. I actually do all of my development from within a chrooted environment. In this way, I can ensure that I'm not actually making any changes to the 'real' system's software/libraries. (And I frequently just rsync the 'real' system -> the 'chroot' to back out any changes made to the chroot). It's a fairly nice setup that lets me have the 'real' system completely clean -- nothing that is not installed from SLES9 RPM's (ie. using its updater/installer) is on the 'real' system. I go to great lenghts to make sure the 'real' system is clean.

I've actually ran the test.c compile from the 'real' system just to ensure that everything listed above are identical to the results from within the 'chroot' -- they are.

I've also done a query of the RPM database to see if anything touches the libc libraries. I've even re-installed them, overwriting what was there. No difference.

I've removed entries from ld.so.conf that relate to other non-gcc non-pgi compilers, just in case there may be some sort of conflict. Again, it makes no difference in PGI's behavior.
Back to top
View user's profile
mkcolg



Joined: 30 Jun 2004
Posts: 6213
Location: The Portland Group Inc.

PostPosted: Fri Apr 29, 2005 11:25 am    Post subject: Reply with quote

Hi troyt,

Thanks for the information. I believe the problem is that "libpthread.so" has been copied to your PGI lib directory. We provide a library called "libpgthread.so" which on all but a Red Hat 7.3 system is a link to "/lib[64]/libpthread.so", but there should not be a "libpthread.so" in the PGI lib directory.

Most likely, you've copied the PGI directory tree and the "libpgthread.so" symlink got resolved. Instead of preserving the symlink, "libpthread.so" got copied into the lib directory. The the error your seeing is because the linker is using the TLS version of libc but the non-TLS version of pthread. To fix, remove "libpthread.so" from the PGI lib directory and recreate the "libpgthread.so" symlink.

- Mat
Back to top
View user's profile
troyt



Joined: 26 Apr 2005
Posts: 4

PostPosted: Tue May 03, 2005 12:20 pm    Post subject: Close enough to help Reply with quote

Not dead on, but close enough to be useful!

Now here's the details (FYI, and anybody reading this in the future)
I used the 'install' script to install everything...

Quote:
there should not be a "libpthread.so" in the PGI lib directory.


And, in my case, there sorta wasn't. (ls -l /opt/pgi/.../lib/)
Code:
lrwxrwxrwx  1 root root 23 2005-04-12 12:43 libpgthread.a -> /usr/lib64/libpthread.a
lrwxrwxrwx  1 root root 26 2005-05-03 13:09 libpgthread.so -> /lib64/libpthread.so.0
lrwxrwxrwx  1 root root 14 2005-04-13 11:10 libpthread.so.0 -> libpgthread.so


There was a symlink from libpthread.so to libpgthread.so. And libpgthread pointed to /lib64/libpthread.so.0.

Quote:
The the error your seeing is because the linker is using the TLS version of libc but the non-TLS version of pthread. To fix, remove "libpthread.so" from the PGI lib directory and recreate the "libpgthread.so" symlink.


This was most helpful. I'm not sure if you meant this, so I'll state what I did explicitly. I saw no need to remove the libpthread.so, since it just pointed to libpgthread.so (although I tried it both ways with no difference). But what I did do was change the libpgthread.so library to point to /usr/tls/libpthread.so, rather than /usr/libpthread.so, making the 'ls -l' of /opt/pgi/.../lib/ look like this:
Code:
lrwxrwxrwx  1 root root 23 2005-04-12 12:43 libpgthread.a -> /usr/lib64/libpthread.a
lrwxrwxrwx  1 root root 26 2005-05-03 13:09 libpgthread.so -> /lib64/tls/libpthread.so.0
lrwxrwxrwx  1 root root 14 2005-04-13 11:10 libpthread.so.0 -> libpgthread.so


And now everything's happy. Thanks!
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    PGI User Forum Forum Index -> Programming and Compiling All times are GMT - 7 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © phpBB Group