Bug 28302 - [11 Regression] gdb fails to build with glibc 2.34 (
Summary: [11 Regression] gdb fails to build with glibc 2.34 (
Status: RESOLVED FIXED
Alias: None
Product: gdb
Classification: Unclassified
Component: sim (show other bugs)
Version: 11.1
: P2 normal
Target Milestone: 11.2
Assignee: Mike Frysinger
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-09-03 07:18 UTC by Matthias Klose
Modified: 2022-01-16 10:08 UTC (History)
6 users (show)

See Also:
Host:
Target: arm-linux-gnueabihf, aarch64-linux-gnu
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Matthias Klose 2021-09-03 07:18:04 UTC
gdb fails to build on the gdb-11 branch with glibc-2.34, in the sim directory, at least on arm-linux-gnueabihf and aarch64-linux-gnu:

In file included from /usr/include/signal.h:328,
                 from ../../gnulib/import/signal.h:52,
                 from targ-map.c:7:
targ-map.c:412:17: error: initializer element is not constant
  412 |   { "SIGSTKSZ", SIGSTKSZ, TARGET_SIGSTKSZ },
      |                 ^~~~~~~~
targ-map.c:412:17: note: (near initialization for ‘cb_init_signal_map[18].host_val’)
make[5]: *** [Makefile:522: targ-map.o] Error 1
make[5]: Leaving directory '/<<PKGBUILDDIR>>/build/default/sim/aarch64'
make[4]: *** [Makefile:1271: all-recursive] Error 1
make[4]: Leaving directory '/<<PKGBUILDDIR>>/build/default/sim'
make[3]: *** [Makefile:898: all] Error 2
make[3]: Leaving directory '/<<PKGBUILDDIR>>/build/default/sim'
make[2]: *** [Makefile:8030: all-sim] Error 2

configured with

--build=aarch64-linux-gnu --host=aarch64-linux-gnu --prefix=/usr --libexecdir="\${prefix}/lib/gdb" --disable-werror --disable-maintainer-mode --disable-dependency-tracking --disable-silent-rules --disable-gdbtk --disable-shared --with-system-readline --with-expat --with-system-zlib --without-guile --with-debuginfod  --with-babeltrace --enable-tui --with-lzma --with-python=python3 --with-xxhash --with-mpfr
Comment 1 Luis Machado 2021-09-03 13:05:46 UTC
This might have something to do with glibc's commit 6c57d320484988e87e446e2e60ce42816bf51d53, or it may have to use a new reference for the constant.
Comment 2 Luis Machado 2021-09-03 13:13:07 UTC
glibc bug reopened here:

https://sourceware.org/bugzilla/show_bug.cgi?id=20305
Comment 3 Stafford Horne 2021-09-09 22:00:07 UTC
I ran into this failure today, there is a discussion about the reason
behind glibc making this change.

https://public-inbox.org/libc-alpha/87y2ew8i1w.fsf@igel.home/T/

It's kind of hacky but this patch worked as a fix for me.

diff --git a/sim/common/gentmap.c b/sim/common/gentmap.c
index 9f30e66e378..f690193f471 100644
--- a/sim/common/gentmap.c
+++ b/sim/common/gentmap.c
@@ -83,6 +83,14 @@ gen_targ_map_c (void)
   printf ("#include \"targ-vals.h\"\n");
   printf ("\n");

+  /* Make SIGSTKSZ a constant again.  */
+  printf ("#ifdef __USE_SC_SIGSTKSZ\n");
+  printf ("# undef SIGSTKSZ\n");
+  printf ("# define SIGSTKSZ 8192\n");
+  printf ("#endif\n");
+
+  printf ("\n");
+
   printf ("/* syscall mapping table */\n");
   printf ("CB_TARGET_DEFS_MAP cb_init_syscall_map[] = {\n");
   for (t = &sys_tdefs[0]; t->symbol; ++t)

On Fri, Sep 3, 2021 at 4:18 PM doko at debian dot org via Gdb-prs
<gdb-prs@sourceware.org> wrote:
>
> https://sourceware.org/bugzilla/show_bug.cgi?id=28302
>
>             Bug ID: 28302
>            Summary: [11 Regression] gdb fails to build with glibc 2.34 (
>            Product: gdb
>            Version: 11.1
>             Status: NEW
>           Severity: normal
>           Priority: P2
>          Component: sim
>           Assignee: unassigned at sourceware dot org
>           Reporter: doko at debian dot org
>                 CC: vapier at gentoo dot org
>   Target Milestone: ---
>
> gdb fails to build on the gdb-11 branch with glibc-2.34, in the sim directory,
> at least on arm-linux-gnueabihf and aarch64-linux-gnu:
>
> In file included from /usr/include/signal.h:328,
>                  from ../../gnulib/import/signal.h:52,
>                  from targ-map.c:7:
> targ-map.c:412:17: error: initializer element is not constant
>   412 |   { "SIGSTKSZ", SIGSTKSZ, TARGET_SIGSTKSZ },
>       |                 ^~~~~~~~
> targ-map.c:412:17: note: (near initialization for
> ‘cb_init_signal_map[18].host_val’)
> make[5]: *** [Makefile:522: targ-map.o] Error 1
> make[5]: Leaving directory '/<<PKGBUILDDIR>>/build/default/sim/aarch64'
> make[4]: *** [Makefile:1271: all-recursive] Error 1
> make[4]: Leaving directory '/<<PKGBUILDDIR>>/build/default/sim'
> make[3]: *** [Makefile:898: all] Error 2
> make[3]: Leaving directory '/<<PKGBUILDDIR>>/build/default/sim'
> make[2]: *** [Makefile:8030: all-sim] Error 2
>
> configured with
>
> --build=aarch64-linux-gnu --host=aarch64-linux-gnu --prefix=/usr
> --libexecdir="\${prefix}/lib/gdb" --disable-werror --disable-maintainer-mode
> --disable-dependency-tracking --disable-silent-rules --disable-gdbtk
> --disable-shared --with-system-readline --with-expat --with-system-zlib
> --without-guile --with-debuginfod  --with-babeltrace --enable-tui --with-lzma
> --with-python=python3 --with-xxhash --with-mpfr
>
> --
> You are receiving this mail because:
> You are on the CC list for the bug.
Comment 4 Adam Sampson 2021-09-14 15:15:55 UTC
While the glibc change caused the build failure here (I'm seeing it on rv64), I think the underlying problem is simpler. gentmap is trying to build a list of signal number definitions, so SIGSTKSZ shouldn't be in it in the first place - it just happens to match the regexp that sim/common/gennltvals.py is using.

I've worked around it with this patch:

--- gdb-11.1/sim/common/gennltvals.py	2021-09-13 02:32:09.000000000 +0100
+++ gdb-11.1/sim/common/gennltvals.py	2021-09-14 16:05:03.771667809 +0100
@@ -99,7 +99,7 @@
             data = fp.read()
         for line in data.splitlines():
             m = define_pattern.match(line)
-            if m:
+            if m and m.group(1) != 'SIGSTKSZ':
                 syms.add(m.group(1))
     for sym in sorted(syms):
         srcfile += f'#ifdef {sym}\nDEFVAL {{ "{sym}", {sym} }},\n#endif\n'
--- gdb-11.1/sim/common/nltvals.def	2021-07-03 18:41:11.000000000 +0100
+++ gdb-11.1/sim/common/nltvals.def	2021-09-14 16:05:02.789672121 +0100
@@ -116,7 +116,6 @@
  { "SIGPROF", 27 },
  { "SIGQUIT", 3 },
  { "SIGSEGV", 11 },
- { "SIGSTKSZ", 8192 },
  { "SIGSTOP", 17 },
  { "SIGSYS", 12 },
  { "SIGTERM", 15 },
Comment 5 Mike Frysinger 2021-10-03 16:09:49 UTC
(In reply to Adam Sampson from comment #4)
> While the glibc change caused the build failure here (I'm seeing it on
> rv64), I think the underlying problem is simpler. gentmap is trying to build
> a list of signal number definitions, so SIGSTKSZ shouldn't be in it in the
> first place - it just happens to match the regexp that
> sim/common/gennltvals.py is using.

this is a great idea, thanks.  i've implemented that now.
https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=39d53d04357606a15efd400147fa7369d71baf2c
Comment 6 Joel Brobecker 2022-01-12 05:04:24 UTC
re-opened to backport the fix in 11.2 as requested by user. Can be closed as soon as the fix is backported.
Comment 7 Joel Brobecker 2022-01-16 10:08:48 UTC
backported on Jan 12 by Mike, as:

commit 17d6f2152b583cdc7defafa7813b727a304bac5b
Author: Mike Frysinger <vapier@gentoo.org>
Date:   Sun Oct 3 12:02:53 2021 -0400
Subject: sim: filter out SIGSTKSZ [PR sim/28302]