jwt27 / build-gcc

Shell scripts to build various gcc cross-compilers (primarily djgpp)
https://jw.h4ck.me/debian/
GNU General Public License v3.0
44 stars 9 forks source link

building GDB 8.2.1 fails with GCC 14 #43

Closed manxorist closed 3 months ago

manxorist commented 3 months ago

GDB 8.2.1 fails to build with GCC 14 (this is on a current Debian testing), it looks like while building libreadline:

gcc -c -DHAVE_CONFIG_H    -I. -I../../readline -DRL_LIBRARY_VERSION='"6.2"'  ../../readline/complete.c
../../readline/complete.c: In function ‘fnwidth’:
../../readline/complete.c:701:19: error: implicit declaration of function ‘wcwidth’; did you mean ‘fnwidth’? [-Wimplicit-function-declaration]
  701 |               w = wcwidth (wc);
      |                   ^~~~~~~
      |                   fnwidth

Is there any particular reason why GDB is fixed to version 8.2.1 for DJGPP?

jwt27 commented 3 months ago

Thanks, I noticed the same issue, which is why the Debian/Ubuntu packages haven't yet been upgraded. Presumably it's fixed by: https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=16bfc2f9705b40a11052f465b83fea2ec0904ce5

We're stuck with 8.2.1 on djgpp since later versions will crash as soon it connects to the remote. I think I reported this on the bugzilla once but no one ever bothered to look further into it (including myself :) ). This will need to be fixed at some point since gdb 8 also depends on python2, which I see has already been removed from Debian.

manxorist commented 3 months ago

I tried passing CFLAGS="-g -O2 -Wno-implicit-function-declaration" in GDB_CONFIGURE_OPTIONS, but I failed to figure out the correct quoting/escaping to make it work. I am just patching script/build-gdb.sh for now.

manxorist commented 3 months ago

commit 8e5069d566efa230cea1bb9f701c309f471e02a0 works for me, thanks

jwt27 commented 3 months ago

I tried gdb 15.1 with djgpp, it segfaults while loading symbols:

Thread 1 "i386-pc-msdosdj" received signal SIGSEGV, Segmentation fault.
0x0000555555755fec in dwarf2_per_bfd::locate_sections (this=this@entry=0x555556194170, abfd=abfd@entry=0x555556053f80,
    sectp=sectp@entry=0x55555604c328, names=...) at ../../gdb/dwarf2/read.c:1428
1428      else if (elf_section_data (sectp)->this_hdr.sh_size
(gdb) list
1423      flagword aflag = bfd_section_flags (sectp);
1424
1425      if ((aflag & SEC_HAS_CONTENTS) == 0)
1426        {
1427        }
1428      else if (elf_section_data (sectp)->this_hdr.sh_size
1429               > bfd_get_file_size (abfd))
1430        {
1431          bfd_size_type size = elf_section_data (sectp)->this_hdr.sh_size;
1432          warning (_("Discarding section %s which has a section size (%s"
(gdb) p sectp
$1 = (asection *) 0x55555604c328
(gdb) p elf_section_data(sectp)
$2 = (bfd_elf_section_data *) 0x0
(gdb) q

This code was introduced here

It assumes the input file is ELF, which is of course not the case for us. Reverting this commit appears to make it work, but my stub has some bugs so that will need fixing before I can be sure. Maybe more such assumptions have crept in over the years.

Also note that this patch was introduced in 9.x, so not sure then what the issue with 8.3 was.

jwt27 commented 3 months ago

After reporting the above on gdb's bugzilla, it got fixed right away. I applied the patch here to gdb 15.1. If you have a gdbstub (with fewer bugs than mine :) ) and want to help try the new version, you can build this with ./build-djgpp.sh gdb-15.1.

manxorist commented 3 months ago

If you have a gdbstub (with fewer bugs than mine :) ) and want to help try the new version, you can build this with ./build-djgpp.sh gdb-15.1.

Builds fine for me, but I have not yet tried/needed to debug anything on DOS :)