This is needed to get DWARF version 5 .debug_line tables.
It is also obviously wrong. It needs a check for whether as supports
--gdwarf-<version> for all versions we support and it should only
be added when generating DWARF debug information for the specific
DWARF version we are generating.

It also needs some fixes to binutils, to make sure the line table is
generated correctly:
https://sourceware.org/pipermail/binutils/2020-August/112685.html
And to make sure it can read the generated line table itself:
https://sourceware.org/pipermail/binutils/2020-August/112966.html
---
 gcc/gcc.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/gcc/gcc.c b/gcc/gcc.c
index 10bc9881aed3..98b10e7cd154 100644
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -1882,6 +1882,11 @@ init_spec (void)
   }
 #endif
 
+  static const char dv[] = "--gdwarf-5 ";
+  obstack_grow (&obstack, dv, sizeof (dv) - 1);
+  obstack_grow0 (&obstack, asm_spec, strlen (asm_spec));
+  asm_spec = XOBFINISH (&obstack, const char *);
+
 #if defined LINK_EH_SPEC || defined LINK_BUILDID_SPEC || \
     defined LINKER_HASH_STYLE
 # ifdef LINK_BUILDID_SPEC
-- 
2.18.4

Reply via email to