Red Hat Bugzilla – Bug 178354
Undefined pthread functions in gcc 4.0.2
Last modified: 2007-11-30 17:11:21 EST
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)))
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):
Steps to Reproduce:
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.
Bingo. That was it. There was a:
in nbase.h, which is included. Commenting that out got rid of the errors.