Skip to contentSkip to conversation

gdb: Fix compilation for arc-2018.09 in some cases

PATCH New Alexey Brodkin 2 participants 7 messages Dec 10, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gdb: Fix compilation for arc-2018.09 in some cases

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

---
 ...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
package/gdb/arc-2018.09-gdb/0001-gdb-Fix-ia64-defining-TRAP_HWBKPT-before-including-g.patch new file +49 -0
new file mode 100644
index 0000000000..47992cba3d
@@ -0,0 +1,49 @@
+From e213d8e1b5317389c3beee648811bc649d62d743 Mon Sep 17 00:00:00 2001
+From: James Clarke <[email protected]>
+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
+
Signature · 1 line
2.16.2
#1 lore raw

PATCH 1/1 gdb: Fix compilation for arc-2018.09 in some cases

Hello,

Quoted 23 lines · Alexey Brodkin

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,
Quoted 8 lines
                 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

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#2 lore raw

PATCH 1/1 gdb: Fix compilation for arc-2018.09 in some cases

Hi Thomas,

Quoted 35 lines · Thomas Petazzoni

Hello,

Quoted 23 lines · Alexey Brodkin

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,
Quoted 8 lines
                 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----------------------------  
Quoted 2 lines

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

#3 lore raw

PATCH 1/1 gdb: Fix compilation for arc-2018.09 in some cases

Hello,

Quoted 7 lines · Alexey Brodkin
Quoted 2 lines

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

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#4 lore raw

PATCH 1/1 gdb: Fix compilation for arc-2018.09 in some cases

Hi Thomas,

Quoted 7 lines · Thomas Petazzoni

Hello,

Quoted 3 lines · Alexey Brodkin
Quoted 2 lines

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 ?

Quoted 6 lines
Quoted 4 lines

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

#5 lore raw

PATCH 1/1 gdb: Fix compilation for arc-2018.09 in some cases

Hello,

Quoted 6 lines · Alexey Brodkin
Quoted 1 line

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.

Quoted 6 lines

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

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#6 lore raw

PATCH 1/1 gdb: Fix compilation for arc-2018.09 in some cases

Hi Thomas,

Quoted 14 lines · Thomas Petazzoni

Hello,

Quoted 10 lines · Alexey Brodkin
Quoted 1 line

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.

Quoted 5 lines
Quoted 2 lines

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