ddio / gperftools

Automatically exported from code.google.com/p/gperftools
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

error: 'ucontext_t' was not declared in this scope #217

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
./comfigure && make

What is the expected output? What do you see instead?
 g++ -DHAVE_CONFIG_H -I. -I. -I./src -I./src -Wall -Wwrite-strings -
Woverloaded-virtual -Wno-sign-compare -g -O2 -MT stacktrace.lo -MD -MP -MF 
.deps/stacktrace.Tpo -c src/stacktrace.cc  -fPIC -DPIC -o 
.libs/stacktrace.o
/usr/include/ucontext.h:32: error: 'ucontext_t' was not declared in this 
scope
/usr/include/ucontext.h:32: error: '__ucp' was not declared in this scope
/usr/include/ucontext.h:32: error: expected ',' or ';' before 'throw'
/usr/include/ucontext.h:35: error: expected ',' or '...' before '*' token
/usr/include/ucontext.h:39: error: 'ucontext_t' was not declared in this 
scope
/usr/include/ucontext.h:39: error: expected primary-expression before 
'__restrict__'
/usr/include/ucontext.h:40: error: expected primary-expression before 
'const'
/usr/include/ucontext.h:40: error: initializer expression list treated as 
compound expression
/usr/include/ucontext.h:40: error: expected ',' or ';' before 'throw'
/usr/include/ucontext.h:48: error: variable or field 'makecontext' declared 
void
/usr/include/ucontext.h:48: error: 'ucontext_t' was not declared in this 
scope
/usr/include/ucontext.h:48: error: '__ucp' was not declared in this scope
/usr/include/ucontext.h:48: error: '__func' was not declared in this scope
/usr/include/ucontext.h:48: error: expected primary-expression before 
'void'
/usr/include/ucontext.h:49: error: expected primary-expression before 'int'
/usr/include/ucontext.h:49: error: expected primary-expression before '...' 
token
/usr/include/ucontext.h:49: error: initializer expression list treated as 
compound expression
/usr/include/ucontext.h:49: error: expected ',' or ';' before 'throw'
src/stacktrace_x86-inl.h: In function 'int GetStackTraceWithContext(void**, 
int, int, const void*)':
src/stacktrace_x86-inl.h:292: warning: dereferencing type-punned pointer 
will break strict-aliasing rules
src/stacktrace_x86-inl.h: In function 'int GetStackTrace(void**, int, 
int)':
src/stacktrace_x86-inl.h:343: warning: dereferencing type-punned pointer 
will break strict-aliasing rules
src/stacktrace_x86-inl.h: In function 'int GetStackFrames(void**, int*, 
int, int)':
src/stacktrace_x86-inl.h:420: warning: dereferencing type-punned pointer 
will break strict-aliasing rules
src/stacktrace_x86-inl.h: In function 'int 
GetStackFramesWithContext(void**, int*, int, int, const void*)':
src/stacktrace_x86-inl.h:489: warning: dereferencing type-punned pointer 
will break strict-aliasing rules
make: *** [stacktrace.lo] Error 1

What version of the product are you using? On what operating system?
1.5. I am trying to build it on Redhat 7.3:
Linux build-dev 2.4.20-28.7 #1 Thu Dec 18 11:31:59 EST 2003 i686 unknown
with gcc-4.1.2

Original issue reported on code.google.com by mailtome...@gmail.com on 23 Feb 2010 at 10:47

GoogleCodeExporter commented 9 years ago
Can you attach the output of your 'configure' run, and your config.log file?

Do you happen to know where ucontext_t is defined in redhat 7.3?

Original comment by csilv...@gmail.com on 23 Feb 2010 at 10:55

GoogleCodeExporter commented 9 years ago
I have attached output of configure(build.log), and config.log
$ grep -R ucontext_t /usr/include  
Binary file /usr/include/c++/4.1.2/i686-redhat-linux/bits/stdc++.h.gch/O0g.gch 
matches
Binary file /usr/include/c++/4.1.2/i686-redhat-linux/bits/stdc++.h.gch/O2g.gch 
matches
/usr/include/sys/ucontext.h:  } ucontext_t;
/usr/include/ucontext.h:extern int getcontext (ucontext_t *__ucp) __THROW;
/usr/include/ucontext.h:extern int setcontext (__const ucontext_t *__ucp) 
__THROW;
/usr/include/ucontext.h:extern int swapcontext (ucontext_t *__restrict __oucp,
/usr/include/ucontext.h:                        __const ucontext_t *__restrict 
__ucp) 
__THROW;
/usr/include/ucontext.h:extern void makecontext (ucontext_t *__ucp, void 
(*__func) 
(void),
grep: warning: /usr/include/gnome-xml/libxml: recursive directory loop

/usr/include/libguile/continuations.h:  ucontext_t ctx;

Original comment by mailtome...@gmail.com on 23 Feb 2010 at 11:04

Attachments:

GoogleCodeExporter commented 9 years ago
Ah, here is the key point, from config.log:
---
In file included from /usr/include/signal.h:324,
                 from /usr/include/sys/ucontext.h:23,
                 from conftest.c:59:
/usr/include/ucontext.h:32: error: expected ')' before '*' token
/usr/include/ucontext.h:35: error: expected ';', ',' or ')' before '*' token
/usr/include/ucontext.h:39: error: expected ')' before '*' token
/usr/include/ucontext.h:48: error: expected ')' before '*' token
---

What it looks like, is that this version of gcc required you to #include some 
other 
header file before #including <ucontext.h> (or <sys/ucontext.h>), or the latter 
wouldn't compile properly.

Does a quick look at ucontext.h show what this might be?  Or you could just 
attach 
the ucontext.h here.

Original comment by csilv...@gmail.com on 23 Feb 2010 at 11:09

GoogleCodeExporter commented 9 years ago
Thanks for the quick response. I have attached ucontext.h, sys/ucontext.h 
(sys.ucontext.h).

Original comment by mailtome...@gmail.com on 23 Feb 2010 at 11:15

Attachments:

GoogleCodeExporter commented 9 years ago
OK, I see the problem.  It's actually the reverse of what I said before: if you 
#include <sys/ucontext.h> instead of <ucontext.h>, redhat 7.3 barfs because 
sys/ucontext tries to #include ucontext before it has finished defining 
everything it 
needs.  This seems like a bug to me, and perhaps to others as well, since later 
gcc's 
don't have this issue.

Unfortunately, os x gets upset if ucontext.h is included instead of 
sys/ucontext.h, 
and now redhat 7.3 gets upset the other way around.  I'm not sure the best way 
to fix 
this.  In the short term, you can fix it by editing the 'configure' script, 
find the 
line that says
                         #include <sys/ucontext.h>
and change it to say
                         #include <ucontext.h>
instead.  Then do a './configure && make'.  It should work properly for you 
this 
time.

I'll try to figure out a better solution before the next release.  It will 
probably 
involve an ugly hack of some sort. :-(

Original comment by csilv...@gmail.com on 24 Feb 2010 at 12:24

GoogleCodeExporter commented 9 years ago
Thanks. 
I also modified src/stacktrace_x86-inl.h, src/getpc.h, src/profiler.cc to 
include 
ucontext.h instead of sys/ucontext.h. 

Original comment by mailtome...@gmail.com on 24 Feb 2010 at 1:51

GoogleCodeExporter commented 9 years ago
OK, I've decided to handle this by just putting in a special-case for redhat 7 
and 
below, in configure.ac.

Now I just need to know how to identify redhat 7.  Can you attach the contents 
of your 
/etc/issue file?  Or some other file I can look at that describes this as a 
redhat 7 
system?

Original comment by csilv...@gmail.com on 10 Mar 2010 at 7:08

GoogleCodeExporter commented 9 years ago
Actually, it looks like the best file to attach is /etc/redhat-release, if it 
exists 
on your system.

Original comment by csilv...@gmail.com on 10 Mar 2010 at 7:26

GoogleCodeExporter commented 9 years ago
Never mind, I found it:
   http://www.linuxquestions.org/questions/red-hat-31/looking-for-redhat-release-file-
for-rh45-538031/

I'll fix this up for the next release.

Original comment by csilv...@gmail.com on 10 Mar 2010 at 7:30

GoogleCodeExporter commented 9 years ago
This should be fixed in perftools 1.6, just released.

Original comment by csilv...@gmail.com on 5 Aug 2010 at 8:49

GoogleCodeExporter commented 9 years ago
Thanks a lot cslivers.

Original comment by mailtome...@gmail.com on 24 Aug 2010 at 7:14