public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r11-7923] i386, debug: Default to -gdwarf-4 on Windows targets with broken ld.bfd [PR98860]
@ 2021-03-31  7:12 Jakub Jelinek
  0 siblings, 0 replies; only message in thread
From: Jakub Jelinek @ 2021-03-31  7:12 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:a49a96f681bf13c6e77644d4507e867f00f93fe6

commit r11-7923-ga49a96f681bf13c6e77644d4507e867f00f93fe6
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Wed Mar 31 09:11:29 2021 +0200

    i386, debug: Default to -gdwarf-4 on Windows targets with broken ld.bfd [PR98860]
    
    As mentioned in the PR, before the
    https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=ba6eb62ff0ea9843a018cfd7cd06777bd66ae0a0
    fix from March 1st, PECOFF ld.bfd didn't know about .debug_loclists,
    .debug_rnglists and other debug sections new in DWARF 5.  Unfortunately,
    unlike for ELF linkers, that means the sections were placed in wrong
    ordering with wrong VMA/LMA, so the resulting executables are apparently
    unusable.
    
    As that is pretty new change, newer than 2.35.2 or 2.36 binutils releases,
    the following patch adds a workaround that turns -gdwarf-4 by default
    instead of -gdwarf-5 if a broken linker is found at configure time.
    Users can still explicitly play with -gdwarf-5 and either use a non-broken
    linker or use custom linker scripts for the broken one, but at least
    by default it should work.
    
    2021-03-31  Jakub Jelinek  <jakub@redhat.com>
    
            PR bootstrap/98860
            * configure.ac (HAVE_LD_BROKEN_PE_DWARF5): New AC_DEFINE if PECOFF
            linker doesn't support DWARF sections new in DWARF5.
            * config/i386/i386-options.c (ix86_option_override_internal): Default
            to dwarf_version 4 if HAVE_LD_BROKEN_PE_DWARF5 for TARGET_PECOFF
            targets.
            * config.in: Regenerated.
            * configure: Regenerated.

Diff:
---
 gcc/config.in                  |  6 ++++++
 gcc/config/i386/i386-options.c |  7 +++++++
 gcc/configure                  | 44 +++++++++++++++++++++++++++++-------------
 gcc/configure.ac               | 25 ++++++++++++++++++++++++
 4 files changed, 69 insertions(+), 13 deletions(-)

diff --git a/gcc/config.in b/gcc/config.in
index 10a13cde586..313c13c8e49 100644
--- a/gcc/config.in
+++ b/gcc/config.in
@@ -1580,6 +1580,12 @@
 #endif
 
 
+/* Define if the PE linker has broken DWARF 5 support. */
+#ifndef USED_FOR_TARGET
+#undef HAVE_LD_BROKEN_PE_DWARF5
+#endif
+
+
 /* Define if your linker supports --build-id. */
 #ifndef USED_FOR_TARGET
 #undef HAVE_LD_BUILDID
diff --git a/gcc/config/i386/i386-options.c b/gcc/config/i386/i386-options.c
index 88d5e717f26..93cd6e8ed27 100644
--- a/gcc/config/i386/i386-options.c
+++ b/gcc/config/i386/i386-options.c
@@ -1861,6 +1861,13 @@ ix86_option_override_internal (bool main_args_p,
   SUBSUBTARGET_OVERRIDE_OPTIONS;
 #endif
 
+#ifdef HAVE_LD_BROKEN_PE_DWARF5
+  /* If the PE linker has broken DWARF 5 support, make
+     DWARF 4 the default.  */
+  if (TARGET_PECOFF)
+    SET_OPTION_IF_UNSET (opts, opts_set, dwarf_version, 4);
+#endif
+
   /* -fPIC is the default for x86_64.  */
   if (TARGET_MACHO && TARGET_64BIT_P (opts->x_ix86_isa_flags))
     opts->x_flag_pic = 2;
diff --git a/gcc/configure b/gcc/configure
index 9bb436ce7bd..e8ecb3b0297 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -19392,7 +19392,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 19405 "configure"
+#line 19395 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -19498,7 +19498,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 19511 "configure"
+#line 19501 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -22237,16 +22237,6 @@ freebsd* | dragonfly*)
   esac
   ;;
 
-gnu*)
-  version_type=linux
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  hardcode_into_libs=yes
-  ;;
-
 haiku*)
   version_type=linux
   need_lib_prefix=no
@@ -22368,7 +22358,7 @@ linux*oldld* | linux*aout* | linux*coff*)
 # project, but have not yet been accepted: they are GCC-local changes
 # for the time being.  (See
 # https://lists.gnu.org/archive/html/libtool-patches/2018-05/msg00000.html)
-linux* | k*bsd*-gnu | kopensolaris*-gnu | uclinuxfdpiceabi)
+linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu* | uclinuxfdpiceabi)
   version_type=linux
   need_lib_prefix=no
   need_version=no
@@ -30223,6 +30213,34 @@ _ACEOF
 
 fi
 
+case $target_os in
+  win32 | pe | cygwin* | mingw32*)
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking broken PE linker dwarf5 support" >&5
+$as_echo_n "checking broken PE linker dwarf5 support... " >&6; }
+    gcc_cv_ld_broken_pe_dwarf5=yes
+    if test $in_tree_ld = yes ; then
+      if grep -q '\.debug_loclists.*BLOCK.*__section_alignment__.*NOLOAD.*:' \
+	   $gcc_cv_ld_gld_srcdir/scripttempl/pe*.sc \
+	 && grep -q '\.debug_rnglists.*BLOCK.*__section_alignment__.*NOLOAD.*:' \
+	      $gcc_cv_ld_gld_srcdir/scripttempl/pe*.sc; then
+	gcc_cv_ld_broken_pe_dwarf5=no
+      fi
+    else
+      if $gcc_cv_ld --verbose 2>&1 | grep -q '\.debug_loclists.*BLOCK.*__section_alignment__.*NOLOAD.*:' \
+	 && $gcc_cv_ld --verbose 2>&1 | grep -q '\.debug_rnglists.*BLOCK.*__section_alignment__.*NOLOAD.*:'; then
+	gcc_cv_ld_broken_pe_dwarf5=no
+      fi
+    fi
+    if test x$gcc_cv_ld_broken_pe_dwarf5 = xyes; then
+
+$as_echo "#define HAVE_LD_BROKEN_PE_DWARF5 1" >>confdefs.h
+
+    fi
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_ld_broken_pe_dwarf5" >&5
+$as_echo "$gcc_cv_ld_broken_pe_dwarf5" >&6; }
+    ;;
+esac
+
 # --------
 # UNSORTED
 # --------
diff --git a/gcc/configure.ac b/gcc/configure.ac
index caa611933df..96a6f62b0d3 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -6190,6 +6190,31 @@ if test x"$ld64_flag" = x"yes"; then
   [Define to 1 if ld64 supports '-export_dynamic'.])
 fi
 
+case $target_os in
+  win32 | pe | cygwin* | mingw32*)
+    AC_MSG_CHECKING(broken PE linker dwarf5 support)
+    gcc_cv_ld_broken_pe_dwarf5=yes
+    if test $in_tree_ld = yes ; then
+      if grep -q '\.debug_loclists.*BLOCK.*__section_alignment__.*NOLOAD.*:' \
+	   $gcc_cv_ld_gld_srcdir/scripttempl/pe*.sc \
+	 && grep -q '\.debug_rnglists.*BLOCK.*__section_alignment__.*NOLOAD.*:' \
+	      $gcc_cv_ld_gld_srcdir/scripttempl/pe*.sc; then
+	gcc_cv_ld_broken_pe_dwarf5=no
+      fi
+    else
+      if $gcc_cv_ld --verbose 2>&1 | grep -q '\.debug_loclists.*BLOCK.*__section_alignment__.*NOLOAD.*:' \
+	 && $gcc_cv_ld --verbose 2>&1 | grep -q '\.debug_rnglists.*BLOCK.*__section_alignment__.*NOLOAD.*:'; then
+	gcc_cv_ld_broken_pe_dwarf5=no
+      fi
+    fi
+    if test x$gcc_cv_ld_broken_pe_dwarf5 = xyes; then
+      AC_DEFINE(HAVE_LD_BROKEN_PE_DWARF5, 1,
+	        [Define if the PE linker has broken DWARF 5 support.])
+    fi
+    AC_MSG_RESULT($gcc_cv_ld_broken_pe_dwarf5)
+    ;;
+esac
+
 # --------
 # UNSORTED
 # --------


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-03-31  7:12 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-31  7:12 [gcc r11-7923] i386, debug: Default to -gdwarf-4 on Windows targets with broken ld.bfd [PR98860] Jakub Jelinek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).