PGI User Forum
 SearchSearch   MemberlistMemberlist     RegisterRegister   ProfileProfile    Log inLog in 

Free OpenACC Course

Linking to pthreads: undefined reference to __builtin_expect

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



Joined: 10 Aug 2006
Posts: 11

PostPosted: Tue Jul 29, 2008 7:27 am    Post subject: Linking to pthreads: undefined reference to __builtin_expect Reply with quote

Hi,

The following C program compiles using PGI 7.1.4 on RHEL4u6, but doesn't on CentOS5.2 (in either 32- or 64-bit modes):

Code:

#include <pthread.h>
int main () {
    pthread_t th=pthread_self();

    pthread_join(th, 0);
    pthread_attr_init(0);

    pthread_cleanup_push(0, 0);
    pthread_create(0,0,0,0);
    pthread_cleanup_pop(0);

    return 0;
}


Instead, I get the following compilation error:

Code:

$ pgcc -o pthread_test pthread_test.c -lpthread
pthread_test.c:
pthread_test.o: In function `main':
pthread_test.c:(.text+0x52): undefined reference to `__builtin_expect'


Any ideas why?

OpenMPI 1.2.6's configure script uses this to determine whether a system has threading support or not.

Cheers,

Mark
Back to top
View user's profile
bbernieb



Joined: 21 Jul 2004
Posts: 11

PostPosted: Tue Jul 29, 2008 7:52 am    Post subject: Reply with quote

I don't know why it would work in RHEL and not a newer CENTOS, but the PGI release notes state that in 7.2-2, it is fixed.

14942 32/64-bit C/C++
C compiler gets unresolved reference to __builtin_expect
pgcc now recognizes the gcc extension, __builtin_expect()

Bernie Borenstein
The Boeing Company
Back to top
View user's profile
MarkDixon



Joined: 10 Aug 2006
Posts: 11

PostPosted: Tue Jul 29, 2008 7:58 am    Post subject: Reply with quote

bbernieb wrote:
I don't know why it would work in RHEL and not a newer CENTOS, but the PGI release notes state that in 7.2-2, it is fixed.


Doh. Thanks: I'll read later release notes in future ;)

Cheers,

Mark
Back to top
View user's profile
mkcolg



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

PostPosted: Tue Jul 29, 2008 8:18 am    Post subject: Reply with quote

Hi Mark,

Bernie is correct that we recently added support for the GCC C extension "__builtin_expect" to the 7.2-2 pgcc compiler. I believe GNU added this builtin to either their 4.0 or 4.1 compilers and explains why you did not get this error with RHEL4 which uses gcc version 3.4.

- Mat
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