Bug 178354

Summary: Undefined pthread functions in gcc 4.0.2
Product: [Fedora] Fedora Reporter: Will Cladek <william.cladek>
Component: gccAssignee: Jakub Jelinek <jakub>
Status: CLOSED NOTABUG QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: 4   
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2006-01-20 17:31:29 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Will Cladek 2006-01-19 19:43:36 UTC
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; SunOS sun4u; en-US; rv:1.8) Gecko/20051130 Firefox/1.5

Description of problem:
I noticed this problem when attempting to compile nmap 3.95, but it may be more indicative of a general problem with the gcc 4.0.2-8 rpms.  When I compile nmap, and it gets to the linking stage, I receive these error messages:

nmap.o(.rodata+0x16c): undefined reference to `__gthrw_pthread_cancel(unsigned long)'
...
/usr/lib/gcc/i386-redhat-linux/4.0.2/../../../../include/c++/4.0.2/i386-redhat-linux/bits/gthr-default.h:488: undefined reference to `__gthrw_pthread_once(int*, void (*)())'

This problem was not there in gcc 4.0.0-8, and I've tracked it down to the referenced gthr-default.h file.  I'm not sure if those two referenced functions were defined in the older version, but in the older version's gthr-default.h, they were declared with
#pragma weak pthread_cancel
...
#pragma weak pthread_once

so that the linker would not complain if they weren't defined.  However in gcc 4.0.2-8, they are declared as follows:

# define __gthrw(name) \
  extern __typeof(name) __gthrw_ ## name __attribute__ ((__weakref__(#name)))
...
__gthrw(pthread_once);
...
__gthrw(pthread_cancel);

Compilation works fine when those declarations and the subsequent references are commented out of gthr-default.h.  Is this a bug that it is not finding the definitions of those functions?

Version-Release number of selected component (if applicable):
gcc-4.0.2-8.fc4

How reproducible:
Always

Steps to Reproduce:
1.
2.
3.
  

Additional info:

Comment 1 Jakub Jelinek 2006-01-20 15:08:40 UTC
By any chance, doesn't nmap do #define __attribute__(x) or something similarly
crappy?  Best to check by looking at -E -dD dump of nmap.C.
If so, the bug is on nmap side.

Comment 2 Will Cladek 2006-01-20 17:31:29 UTC
Bingo.  That was it.  There was a:
#define __attribute__(args)

in nbase.h, which is included.  Commenting that out got rid of the errors.