PR98860 is a gcc-11 regression where bootstrap fails on Windows since
the switch to enable DWARF5 by default. The symptoms are that
executables generated by the stage1 compiler fail to run with "Exec
format error", which confuses subsequent configure steps and causes
hard errors. This happens even with the very latest binutils master.

Fixed by updating SUBTARGET_OVERRIDE_OPTIONS to set dwarf_version to 4
unless the user explicitly requested another version. I see some other
targets did the same.

Tested on Cygwin64 and mingw-w64.

Ok for master?

2021-02-08  Mikael Pettersson  <mikpeli...@gmail.com>

        PR bootstrap/98860
        * config/i386/cygming.h (SUBTARGET_OVERRIDE_OPTIONS): Override
        dwarf_version to 4.

--- a/gcc/config/i386/cygming.h
+++ b/gcc/config/i386/cygming.h
@@ -209,6 +209,9 @@ along with GCC; see the file COPYING3.  If not see
 #define SUBTARGET_OVERRIDE_OPTIONS                                     \
 do {                                                                   \
   flag_pic = TARGET_64BIT ? 1 : 0;                                      \
+  /* DWARF5 currently does not work on Windows. */                     \
+  if (!global_options_set.x_dwarf_version)                             \
+    dwarf_version = 4;                                                 \
 } while (0)

 /* Define this macro if references to a symbol must be treated
From 9d1b9e26cc77d325fd5574cb422771588d6aa71f Mon Sep 17 00:00:00 2001
From: Mikael Pettersson <mikpeli...@gmail.com>
Date: Sat, 6 Feb 2021 22:59:43 +0100
Subject: [PATCH] cygming: DWARF5 does not work on Windows

---
 gcc/config/i386/cygming.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/gcc/config/i386/cygming.h b/gcc/config/i386/cygming.h
index cfbca34f996..071f83cfd2d 100644
--- a/gcc/config/i386/cygming.h
+++ b/gcc/config/i386/cygming.h
@@ -209,6 +209,9 @@ along with GCC; see the file COPYING3.  If not see
 #define SUBTARGET_OVERRIDE_OPTIONS					\
 do {									\
   flag_pic = TARGET_64BIT ? 1 : 0;                                      \
+  /* DWARF5 currently does not work on Windows. */			\
+  if (!global_options_set.x_dwarf_version)				\
+    dwarf_version = 4;							\
 } while (0)
 
 /* Define this macro if references to a symbol must be treated
-- 
2.26.2

Reply via email to