gdb: Fix compilation for arc-2018.09 in some cases
diff mbox series

Message ID 20181210093526.29619-1-abrodkin@synopsys.com
State Accepted
Headers show
Series
  • gdb: Fix compilation for arc-2018.09 in some cases
Related show

Commit Message

Alexey Brodkin Dec. 10, 2018, 9:35 a.m. UTC
In some cases which seem to depend on how toolchain headers
got installed or configured we may face well-known by now failure
fixed in upstream with [1]:
------------------------------>8----------------------------
In file included from nat/linux-ptrace.c:20:
nat/linux-ptrace.h:175:22: error: expected identifier before numeric constant
 # define TRAP_HWBKPT 4
                      ^
nat/linux-ptrace.h:175:22: error: expected '}' before numeric constant
In file included from .../output/host/arc-buildroot-linux-gnu/sysroot/usr/include/signal.h:58,
                 from build-gnulib/import/signal.h:52,
                 from .../output/host/arc-buildroot-linux-gnu/sysroot/usr/include/sys/wait.h:36,
                 from ./common/gdb_wait.h:23,
                 from nat/linux-ptrace.c:24:
.../output/host/arc-buildroot-linux-gnu/sysroot/usr/include/bits/siginfo-consts.h:156:1: note: to match this '{'
 {
 ^
In file included from nat/linux-ptrace.c:20:
nat/linux-ptrace.h:175:22: error: expected unqualified-id before numeric constant
 # define TRAP_HWBKPT 4
                      ^
In file included from .../output/host/arc-buildroot-linux-gnu/sysroot/usr/include/features.h:428,
                 from .../output/host/arc-buildroot-linux-gnu/sysroot/usr/include/bits/libc-header-start.h:33,
                 from .../output/host/arc-buildroot-linux-gnu/sysroot/usr/include/stdio.h:27,
                 from build-gnulib/import/stdio.h:43,
                 from ./common/common-defs.h:52,
                 from nat/linux-ptrace.c:19:
.../output/host/arc-buildroot-linux-gnu/sysroot/usr/include/sys/wait.h:158:1: error: expected declaration before '}' token
 __END_DECLS
 ^~~~~~~~~~~
------------------------------>8----------------------------

Back-porting the fix for ARC now to get predictably successful results.

[1] https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commit;h=5a6c3296a7a90694ad4042f6256f3da6d4fa4ee8

Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
---
 ...4-defining-TRAP_HWBKPT-before-including-g.patch | 49 ++++++++++++++++++++++
 1 file changed, 49 insertions(+)
 create mode 100644 package/gdb/arc-2018.09-gdb/0001-gdb-Fix-ia64-defining-TRAP_HWBKPT-before-including-g.patch

Comments

Thomas Petazzoni Dec. 10, 2018, 10:47 a.m. UTC | #1
Hello,

On Mon, 10 Dec 2018 12:35:26 +0300, Alexey Brodkin wrote:
> In some cases which seem to depend on how toolchain headers
> got installed or configured we may face well-known by now failure
> fixed in upstream with [1]:
> ------------------------------>8----------------------------  
> In file included from nat/linux-ptrace.c:20:
> nat/linux-ptrace.h:175:22: error: expected identifier before numeric constant
>  # define TRAP_HWBKPT 4
>                       ^
> nat/linux-ptrace.h:175:22: error: expected '}' before numeric constant
> In file included from .../output/host/arc-buildroot-linux-gnu/sysroot/usr/include/signal.h:58,
>                  from build-gnulib/import/signal.h:52,
>                  from .../output/host/arc-buildroot-linux-gnu/sysroot/usr/include/sys/wait.h:36,
>                  from ./common/gdb_wait.h:23,
>                  from nat/linux-ptrace.c:24:
> .../output/host/arc-buildroot-linux-gnu/sysroot/usr/include/bits/siginfo-consts.h:156:1: note: to match this '{'
>  {
>  ^
> In file included from nat/linux-ptrace.c:20:
> nat/linux-ptrace.h:175:22: error: expected unqualified-id before numeric constant
>  # define TRAP_HWBKPT 4
>                       ^
> In file included from .../output/host/arc-buildroot-linux-gnu/sysroot/usr/include/features.h:428,
>                  from .../output/host/arc-buildroot-linux-gnu/sysroot/usr/include/bits/libc-header-start.h:33,
>                  from .../output/host/arc-buildroot-linux-gnu/sysroot/usr/include/stdio.h:27,
>                  from build-gnulib/import/stdio.h:43,
>                  from ./common/common-defs.h:52,
>                  from nat/linux-ptrace.c:19:
> .../output/host/arc-buildroot-linux-gnu/sysroot/usr/include/sys/wait.h:158:1: error: expected declaration before '}' token
>  __END_DECLS
>  ^~~~~~~~~~~
> ------------------------------>8----------------------------  

Applied to master, thanks. I see this patch is in gdb 8.2, so surely
gdb 8.2 is not affected. What about previous gdb releases ?

Best regards,

Thomas
Alexey Brodkin Dec. 10, 2018, 10:52 a.m. UTC | #2
Hi Thomas,

On Mon, 2018-12-10 at 11:47 +0100, Thomas Petazzoni wrote:
> Hello,
> 
> On Mon, 10 Dec 2018 12:35:26 +0300, Alexey Brodkin wrote:
> > In some cases which seem to depend on how toolchain headers
> > got installed or configured we may face well-known by now failure
> > fixed in upstream with [1]:
> > ------------------------------>8----------------------------  
> > In file included from nat/linux-ptrace.c:20:
> > nat/linux-ptrace.h:175:22: error: expected identifier before numeric constant
> >  # define TRAP_HWBKPT 4
> >                       ^
> > nat/linux-ptrace.h:175:22: error: expected '}' before numeric constant
> > In file included from .../output/host/arc-buildroot-linux-gnu/sysroot/usr/include/signal.h:58,
> >                  from build-gnulib/import/signal.h:52,
> >                  from .../output/host/arc-buildroot-linux-gnu/sysroot/usr/include/sys/wait.h:36,
> >                  from ./common/gdb_wait.h:23,
> >                  from nat/linux-ptrace.c:24:
> > .../output/host/arc-buildroot-linux-gnu/sysroot/usr/include/bits/siginfo-consts.h:156:1: note: to match this '{'
> >  {
> >  ^
> > In file included from nat/linux-ptrace.c:20:
> > nat/linux-ptrace.h:175:22: error: expected unqualified-id before numeric constant
> >  # define TRAP_HWBKPT 4
> >                       ^
> > In file included from .../output/host/arc-buildroot-linux-gnu/sysroot/usr/include/features.h:428,
> >                  from .../output/host/arc-buildroot-linux-gnu/sysroot/usr/include/bits/libc-header-start.h:33,
> >                  from .../output/host/arc-buildroot-linux-gnu/sysroot/usr/include/stdio.h:27,
> >                  from build-gnulib/import/stdio.h:43,
> >                  from ./common/common-defs.h:52,
> >                  from nat/linux-ptrace.c:19:
> > .../output/host/arc-buildroot-linux-gnu/sysroot/usr/include/sys/wait.h:158:1: error: expected declaration before '}' token
> >  __END_DECLS
> >  ^~~~~~~~~~~
> > ------------------------------>8----------------------------  
> 
> Applied to master, thanks. I see this patch is in gdb 8.2, so surely
> gdb 8.2 is not affected. What about previous gdb releases ?

In OpenEmbedded they used to apply that patch for 8.1.x GDB unconditionally [1]
which means we may want to have it in "package/gdb/8.0.1" and "package/gdb/8.1.1"
but I didn't add it there since I had no way to reproduce this failure as
compared to ARC. If you want I may still apply it to mentioned GDB versions in
Buildroot.

[1] https://github.com/openembedded/openembedded-core/commit/1d9d117e8eee2d3b9802384cb93155aea487f002#diff-4a406ea95be89670d34dd1f5514a1212

-Alexey
Thomas Petazzoni Dec. 10, 2018, 11:03 a.m. UTC | #3
Hello,

On Mon, 10 Dec 2018 10:52:20 +0000, Alexey Brodkin wrote:

> > Applied to master, thanks. I see this patch is in gdb 8.2, so surely
> > gdb 8.2 is not affected. What about previous gdb releases ?  
> 
> In OpenEmbedded they used to apply that patch for 8.1.x GDB unconditionally [1]
> which means we may want to have it in "package/gdb/8.0.1" and "package/gdb/8.1.1"
> but I didn't add it there since I had no way to reproduce this failure as
> compared to ARC.

Under what exact situations is this build failure happening ?

Thanks,

Thomas
Alexey Brodkin Dec. 10, 2018, 11:09 a.m. UTC | #4
Hi Thomas,

On Mon, 2018-12-10 at 12:03 +0100, Thomas Petazzoni wrote:
> Hello,
> 
> On Mon, 10 Dec 2018 10:52:20 +0000, Alexey Brodkin wrote:
> 
> > > Applied to master, thanks. I see this patch is in gdb 8.2, so surely
> > > gdb 8.2 is not affected. What about previous gdb releases ?  
> > 
> > In OpenEmbedded they used to apply that patch for 8.1.x GDB unconditionally [1]
> > which means we may want to have it in "package/gdb/8.0.1" and "package/gdb/8.1.1"
> > but I didn't add it there since I had no way to reproduce this failure as
> > compared to ARC.
> 
> Under what exact situations is this build failure happening ?

That's a good question.
As I wrote in my commit message it has to do with some specifics of toolchain headers
configuration. But I'm not really sure what triggers this.

I mean I spent quite some time looking at differences between very similar build trees
in one of which this issue happens but not in another but didn't get to any
conclusion.

And given there's an upstream fix for that issue I didn't want to invest more time into
this investigation, sorry.

-Alexey
Thomas Petazzoni Dec. 10, 2018, 11:15 a.m. UTC | #5
Hello,

On Mon, 10 Dec 2018 11:09:19 +0000, Alexey Brodkin wrote:

> > Under what exact situations is this build failure happening ?  
> 
> That's a good question.
> As I wrote in my commit message it has to do with some specifics of toolchain headers
> configuration. But I'm not really sure what triggers this.
> 
> I mean I spent quite some time looking at differences between very similar build trees
> in one of which this issue happens but not in another but didn't get to any
> conclusion.
> 
> And given there's an upstream fix for that issue I didn't want to invest more time into
> this investigation, sorry.

Do you have a defconfig that fails to build ? Or is it related to the
build machine environment ?

Thomas
Alexey Brodkin Dec. 10, 2018, 1:09 p.m. UTC | #6
Hi Thomas,

On Mon, 2018-12-10 at 12:15 +0100, Thomas Petazzoni wrote:
> Hello,
> 
> On Mon, 10 Dec 2018 11:09:19 +0000, Alexey Brodkin wrote:
> 
> > > Under what exact situations is this build failure happening ?  
> > 
> > That's a good question.
> > As I wrote in my commit message it has to do with some specifics of toolchain headers
> > configuration. But I'm not really sure what triggers this.
> > 
> > I mean I spent quite some time looking at differences between very similar build trees
> > in one of which this issue happens but not in another but didn't get to any
> > conclusion.
> > 
> > And given there's an upstream fix for that issue I didn't want to invest more time into
> > this investigation, sorry.
> 
> Do you have a defconfig that fails to build ? Or is it related to the
> build machine environment ?

I have one setup where this problem happens.

If I rebuild everything from scratch with the same defconfig in the next folder
I cannot reproduce this issue - maybe because I made extra changes compared to
"problematic" defconfig.

-Alexey

Patch
diff mbox series

diff --git a/package/gdb/arc-2018.09-gdb/0001-gdb-Fix-ia64-defining-TRAP_HWBKPT-before-including-g.patch b/package/gdb/arc-2018.09-gdb/0001-gdb-Fix-ia64-defining-TRAP_HWBKPT-before-including-g.patch
new file mode 100644
index 0000000000..47992cba3d
--- /dev/null
+++ b/package/gdb/arc-2018.09-gdb/0001-gdb-Fix-ia64-defining-TRAP_HWBKPT-before-including-g.patch
@@ -0,0 +1,49 @@ 
+From e213d8e1b5317389c3beee648811bc649d62d743 Mon Sep 17 00:00:00 2001
+From: James Clarke <jrtc27@jrtc27.com>
+Date: Fri, 19 Jan 2018 17:22:49 +0000
+Subject: [PATCH] gdb: Fix ia64 defining TRAP_HWBKPT before including
+ gdb_wait.h
+
+On ia64, gdb_wait.h eventually includes siginfo-consts-arch.h, which
+contains an enum with TRAP_HWBKPT, along with a #define. Thus we cannot
+define TRAP_HWBKPT to 4 beforehand, and so gdb_wait.h must be included
+earlier; include it from linux-ptrace.h so it can never come afterwards.
+
+gdb/ChangeLog:
+
+	* nat/linux-ptrace.c: Remove unnecessary reinclusion of
+	gdb_ptrace.h, and move including gdb_wait.h ...
+	* nat/linux-ptrace.h: ... to here.
+---
+ gdb/nat/linux-ptrace.c | 2 --
+ gdb/nat/linux-ptrace.h | 1 +
+ 2 files changed, 1 insertion(+), 2 deletions(-)
+
+diff --git a/gdb/nat/linux-ptrace.c b/gdb/nat/linux-ptrace.c
+index 438177fa7622..1240eead0d50 100644
+--- a/gdb/nat/linux-ptrace.c
++++ b/gdb/nat/linux-ptrace.c
+@@ -21,8 +21,6 @@
+ #include "linux-procfs.h"
+ #include "linux-waitpid.h"
+ #include "buffer.h"
+-#include "gdb_wait.h"
+-#include "gdb_ptrace.h"
+ #ifdef HAVE_SYS_PROCFS_H
+ #include <sys/procfs.h>
+ #endif
+diff --git a/gdb/nat/linux-ptrace.h b/gdb/nat/linux-ptrace.h
+index 59549452c099..6faa89b22a0e 100644
+--- a/gdb/nat/linux-ptrace.h
++++ b/gdb/nat/linux-ptrace.h
+@@ -21,6 +21,7 @@
+ struct buffer;
+ 
+ #include "nat/gdb_ptrace.h"
++#include "gdb_wait.h"
+ 
+ #ifdef __UCLIBC__
+ #if !(defined(__UCLIBC_HAS_MMU__) || defined(__ARCH_HAS_MMU__))
+-- 
+2.19.2
+