On Sun, Jan 14, 2024 at 8:32 PM Roger Sayle <ro...@nextmovesoftware.com> wrote:
>
>
> This patch fixes three of the four unexpected failures that I'm seeing
> in the gcc testsuite on x86_64-pc-linux-gnu.  The three FAILs are:
> FAIL: gcc.c-torture/execute/fprintf-2.c   -O3 -g  (test for excess errors)
> FAIL: gcc.c-torture/execute/printf-2.c   -O3 -g  (test for excess errors)
> FAIL: gcc.c-torture/execute/user-printf.c   -O3 -g  (test for excess errors)
>
> and are caused by the linker/toolchain (GNU ld 2.27 on RedHat 7) issuing
> a link-time warning:
> /usr/bin/ld: Dwarf Error: found dwarf version '5', this reader only handles
> version 2, 3 and 4 information.

We're patching GCC on old systems to avoid this (and fallout from tools
not supporting DWARF5).

> This also explains why these c-torture tests only fail with -g.
>
> One solution might be to tweak/improve GCC's testsuite to ignore
> these warnings.  However, ideally it should also be possible to
> configure gcc not to generate dwarf5 debugging information on
> systems that don't/can't support it.  This patch supplements the
> current --with-dwarf2 configure option with the addition of a
> --with-dwarf4 option that adds a tm-dwarf4.h to $tm_file (using
> the same mechanism as --with-dwarf2) that changes/redefines
> DWARF_VERSION_DEFAULT to 4 (overriding the current default of 5),
>
> This patch has been tested on x86_64-pc-linux-gnu, with a full
> make bootstrap, both with and without --with-dwarf4.  This is
> fixes the three failures above, and causes no new failures outside
> of the gcc.dg/guality directory.  Unfortunately, the guality
> testsuite contains a large number of tests that assume support
> for dwarf5 and don't (yet) check check_effective_target_dwarf5.
> Hopefully, adding --with-dwarf4 will help improve/test the
> portability of the guality testsuite.
>
> Ok for mainline?  An alternative implementation might be to
> allow integer values for $with_dwarf such that --with-dwarf5,
> --with-dwarf3 etc. do the right thing.  In fact, I'd originally
> misread the documentation and assumed --with-dwarf4 was already
> supported.

The only thing to watch out for is ordering of tm_file since there's

./config/vxworks.h:#undef DWARF_VERSION_DEFAULT
./config/vxworks.h:#define DWARF_VERSION_DEFAULT (TARGET_VXWORKS7 ? 3 : 2)

it looks like the --with-dwarf4 adjustment is before the vxworks handling
so the vxworks handling will prevail even with --with-dwarf4.  Not sure
if that's intended?

I think this also needs documenting in install.texi (and mention whether
target specific defaults will prevail or not)

Richard.

>
> 2024-01-14  Roger Sayle  <ro...@nextmovesoftware.com>
>
> gcc/ChangeLog
>         * configure.ac: Add a with --with dwarf4 option.
>         * configure: Regenerate.
>         * config/tm-dwarf4.h: New target file to define
>         DWARF_VERSION_DEFAULT to 4.
>
>
> Thanks in advance,
> Roger
> --
>

Reply via email to