From: Yoann Congal <[email protected]> On Ubuntu 26.04, gcc 15.2 defaults to --std=gnu23 in which static_assert is a keyword, and not a macro to define like with older GCC. This make MIPS64 code in gdb fail to compile with: | In file included from ../../gdb-14.2/opcodes/mips16-opc.c:25: | ../../gdb-14.2/opcodes/mips16-opc.c: In function ‘decode_mips16_operand’: | ../../gdb-14.2/opcodes/mips-formats.h:86:7: error: expected identifier or ‘(’ before ‘static_assert’ | 86 | static_assert[(1 << (SIZE)) == ARRAY_SIZE (MAP)]; \ | | ^~~~~~~~~~~~~ | ../../gdb-14.2/opcodes/mips16-opc.c:52:15: note: in expansion of macro ‘MAPPED_REG’ | 52 | case '.': MAPPED_REG (0, 0, GP, reg_0_map); | | ^~~~~~~~~~
Signed-off-by: Yoann Congal <[email protected]> --- meta/recipes-devtools/gdb/gdb.inc | 1 + ...gnu23-compatibility-wrt-static_asser.patch | 75 +++++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 meta/recipes-devtools/gdb/gdb/0001-opcodes-fix-std-gnu23-compatibility-wrt-static_asser.patch diff --git a/meta/recipes-devtools/gdb/gdb.inc b/meta/recipes-devtools/gdb/gdb.inc index 81ac441462a..d806a66ac43 100644 --- a/meta/recipes-devtools/gdb/gdb.inc +++ b/meta/recipes-devtools/gdb/gdb.inc @@ -13,5 +13,6 @@ SRC_URI = "${GNU_MIRROR}/gdb/gdb-${PV}.tar.xz \ file://0006-resolve-restrict-keyword-conflict.patch \ file://0007-Fix-invalid-sigprocmask-call.patch \ file://0008-Define-alignof-using-_Alignof-when-using-C11-or-newe.patch \ + file://0001-opcodes-fix-std-gnu23-compatibility-wrt-static_asser.patch \ " SRC_URI[sha256sum] = "2d4dd8061d8ded12b6c63f55e45344881e8226105f4d2a9b234040efa5ce7772" diff --git a/meta/recipes-devtools/gdb/gdb/0001-opcodes-fix-std-gnu23-compatibility-wrt-static_asser.patch b/meta/recipes-devtools/gdb/gdb/0001-opcodes-fix-std-gnu23-compatibility-wrt-static_asser.patch new file mode 100644 index 00000000000..d0d4aa5bd20 --- /dev/null +++ b/meta/recipes-devtools/gdb/gdb/0001-opcodes-fix-std-gnu23-compatibility-wrt-static_asser.patch @@ -0,0 +1,75 @@ +From 2b8d72efbe1af100ea4dad4c976b2d3a1fbad676 Mon Sep 17 00:00:00 2001 +From: Sam James <[email protected]> +Date: Sat, 16 Nov 2024 05:03:52 +0000 +Subject: [PATCH] opcodes: fix -std=gnu23 compatibility wrt static_assert + + +static_assert is declared in C23 so we can't reuse that identifier: +* Define our own static_assert conditionally; + +* Rename "static assert" hacks to _N as we do already in some places + to avoid a conflict. + +ChangeLog: + PR ld/32372 + + * i386-gen.c (static_assert): Define conditionally. + * mips-formats.h (MAPPED_INT): Rename identifier. + (MAPPED_REG): Rename identifier. + (OPTIONAL_MAPPED_REG): Rename identifier. + * s390-opc.c (static_assert): Define conditionally. + +Upstream-Status: Backport [https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=8ebe62f3f0d27806b1bf69f301f5e188b4acd2b4] +Backport: +* No static_assert to patch in this version of s390-opc.c. +Signed-off-by: Yoann Congal <[email protected]> +--- + opcodes/i386-gen.c | 2 ++ + opcodes/mips-formats.h | 6 +++--- + 2 files changed, 5 insertions(+), 3 deletions(-) + +diff --git a/opcodes/i386-gen.c b/opcodes/i386-gen.c +index cfc5a7a6172..d5901b9667d 100644 +--- a/opcodes/i386-gen.c ++++ b/opcodes/i386-gen.c +@@ -30,7 +30,9 @@ + + /* Build-time checks are preferrable over runtime ones. Use this construct + in preference where possible. */ ++#ifndef static_assert + #define static_assert(e) ((void)sizeof (struct { int _:1 - 2 * !(e); })) ++#endif + + static const char *program_name = NULL; + static int debug = 0; +diff --git a/opcodes/mips-formats.h b/opcodes/mips-formats.h +index ac73f060a3e..790e23f1783 100644 +--- a/opcodes/mips-formats.h ++++ b/opcodes/mips-formats.h +@@ -49,7 +49,7 @@ + #define MAPPED_INT(SIZE, LSB, MAP, PRINT_HEX) \ + { \ + typedef char ATTRIBUTE_UNUSED \ +- static_assert[(1 << (SIZE)) == ARRAY_SIZE (MAP)]; \ ++ static_assert_3[(1 << (SIZE)) == ARRAY_SIZE (MAP)]; \ + static const struct mips_mapped_int_operand op = { \ + { OP_MAPPED_INT, SIZE, LSB }, MAP, PRINT_HEX \ + }; \ +@@ -83,7 +83,7 @@ + #define MAPPED_REG(SIZE, LSB, BANK, MAP) \ + { \ + typedef char ATTRIBUTE_UNUSED \ +- static_assert[(1 << (SIZE)) == ARRAY_SIZE (MAP)]; \ ++ static_assert_4[(1 << (SIZE)) == ARRAY_SIZE (MAP)]; \ + static const struct mips_reg_operand op = { \ + { OP_REG, SIZE, LSB }, OP_REG_##BANK, MAP \ + }; \ +@@ -93,7 +93,7 @@ + #define OPTIONAL_MAPPED_REG(SIZE, LSB, BANK, MAP) \ + { \ + typedef char ATTRIBUTE_UNUSED \ +- static_assert[(1 << (SIZE)) == ARRAY_SIZE (MAP)]; \ ++ static_assert_5[(1 << (SIZE)) == ARRAY_SIZE (MAP)]; \ + static const struct mips_reg_operand op = { \ + { OP_OPTIONAL_REG, SIZE, LSB }, OP_REG_##BANK, MAP \ + }; \
-=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#239439): https://lists.openembedded.org/g/openembedded-core/message/239439 Mute This Topic: https://lists.openembedded.org/mt/119949392/21656 Group Owner: [email protected] Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]] -=-=-=-=-=-=-=-=-=-=-=-
