Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 12866 - gdb-5.3 failed to compile on sparc64
Summary: gdb-5.3 failed to compile on sparc64
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Development (show other bugs)
Hardware: Sparc Linux
: High normal with 1 vote (vote)
Assignee: Sparc Porters
Depends on:
Reported: 2002-12-28 20:10 UTC by Jack Morgan (RETIRED)
Modified: 2003-08-17 07:28 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---

Patch /usr/include/sus/ucontext.h -> local copy of "ucontext.h" (ucontext.patch,2.83 KB, patch)
2003-01-16 08:22 UTC, Ferris McCormick (RETIRED)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jack Morgan (RETIRED) gentoo-dev 2002-12-28 20:10:25 UTC
gcc -c -O2  -pipe    -I. -I. -I./config -DLOCALEDIR="\"/usr/share/locale\"" -
DHAVE_CONFIG_H -I./../include/opcode -I./../readline/.. -I../bfd -I./../bfd  -
I./../include -I../intl -I./../intl -D_BSD_SOURCE -D_XOPEN_SOURCE=500 -
D_LARGEFILE64_SOURCE  -DMI_OUT=1 -DUI_OUT=1 -Wimplicit -Wreturn-type -Wcomment -
Wtrigraphs -Wformat -Wparentheses -Wpointer-arith -Wuninitialized  corelow.c
gcc -c -O2  -pipe    -I. -I. -I./config -DLOCALEDIR="\"/usr/share/locale\"" -
DHAVE_CONFIG_H -I./../include/opcode -I./../readline/.. -I../bfd -I./../bfd  -
I./../include -I../intl -I./../intl -D_BSD_SOURCE -D_XOPEN_SOURCE=500 -
D_LARGEFILE64_SOURCE  -DMI_OUT=1 -DUI_OUT=1 -Wimplicit -Wreturn-type -Wcomment -
Wtrigraphs -Wformat -Wparentheses -Wpointer-arith -Wuninitialized  sparc-nat.c
In file included from /usr/include/asm/reg.h:9,
                 from sparc-nat.c:36:
/usr/include/asm-sparc/reg.h:40: redefinition of `struct fpq'
/usr/include/asm-sparc/reg.h:45: redefinition of `struct fq'
/usr/include/asm-sparc/reg.h:75: redefinition of `struct fpu'
sparc-nat.c: In function `fetch_inferior_registers':
sparc-nat.c:103: warning: implicit declaration of function `memcpy'
make[1]: *** [sparc-nat.o] Error 1
make[1]: Leaving directory `/var/tmp/portage/gdb-5.3/work/gdb-5.3/gdb'
make: *** [all-gdb] Error 2

!!! ERROR: sys-devel/gdb-5.3 failed.
!!! Function src_compile, Line 30, Exitcode 2
!!! (no error message)
Comment 1 Ferris McCormick (RETIRED) gentoo-dev 2003-01-03 08:30:40 UTC
Yes.  Here is why it fails for me:

gdb/sparc-nat.c has both
#include <signal.h>
#include <asm/reg.h>

signal.h includes <ucontext.h>

You can't have both <ucontext.h> & <asm-sparc/reg.h> because:
This eventually gets you two conflicting definitions
for the structures (fpq, fpu, fq):  One set from <sys/ucontext.h>, and
one from <asm-sparc/reg.h>

You can make the compile go through if you make a local copy of
<ucontext.h> which includes <asm/reg.h> (and then fix up the definitions
in ucontext.h which reference the fpu structure).

The resulting gdb program seems to work, but I am far from a gdb expert, and
so I can't tell if it does anything correctly beyond basic functioning.
Comment 2 Ferris McCormick (RETIRED) gentoo-dev 2003-01-04 13:04:53 UTC
And, for what it's worth, this comes about because of the
"-D_XOPEN_SOURCE=500", which causes <features.h> (included by <signal.h>) to
#define __USE_XOPEN 1

which in turn gets <signal.h> to do
#include <ucontext.h>

But in fact, as previously mentioned, you can't have

#include <ucontext.h>
#include <asm-sparc/reg.h>

which is what you get.
Comment 3 Joshua Brindle (RETIRED) gentoo-dev 2003-01-08 10:28:16 UTC
can you include your local copy of ucontext.h so we can add this into the 
Comment 4 Ferris McCormick (RETIRED) gentoo-dev 2003-01-16 08:22:40 UTC
Created attachment 7368 [details, diff]
Patch /usr/include/sus/ucontext.h  -> local copy of "ucontext.h"
Comment 5 Ferris McCormick (RETIRED) gentoo-dev 2003-01-16 08:47:04 UTC
Yes, I can .  I hadn't noticed the comment, or I'd have responded sooner.
I think the patch is attached as patch#7368.  If not, please contact me
directly at "" for anything you need.

It will patch </usr/include/sys/ucontext.h> into a local copy which can live in
the gdb-5.3/gdb directory.

This is useful only for gdb, of course, because it does not define anything
defined in <usr/include/ucontext.h>, but it seems to be good enough for
<signal.h> in the gdb context.

I hesitate to recommend it for general consumption; it's just something I threw
together to get around the compilation problem.  I have checked again that it
does fix the reported problem, though (at least so far as the conflicting
declarations go.)  Very quick check:

define _XOPEN_SOURCE 500
#include <signal.h>
#include <asm/reg.h>
should fail without patch, succeed with.

There is a problem here that needs to be fixed in <usr/include/sys/ucontext.h>
but I don't know enough about what it has to define to suggest this as a general

Sorry for the delay in answering.
Comment 6 Joshua Brindle (RETIRED) gentoo-dev 2003-01-31 11:19:21 UTC
gdb-5.3 is now -sparc, 5.2.1 builds/runs fine on sparc, and should fulfill any gdb dependancies
Comment 7 Ferris McCormick (RETIRED) gentoo-dev 2003-02-04 08:17:59 UTC
Well, not quite.
1.  Maybe it's just me, but I found versions of gdb to be unusable for getting
    a quick snapshot of X-programs because of very long startup times after the
    'creating new thread' message, and this is not the case with gdb-5.3, last
    I checked.
2.  There's still a problem with the /usr/include files, because of the
    conflicting definitions demonstrated by the three line example in comment
On the other hand, once you get it built, gdb-5.3 seems to run OK on sparc... 
Comment 8 Jason Wever (RETIRED) gentoo-dev 2003-08-17 07:28:43 UTC