Hi,

this is the bootstrap failure on MinGW configured w/ --disable-sjlj-exceptions 
--with-dwarf2, a regression present on the mainline and 5 branch.  The problem 
is the undefined symbol __EH_FRAME_BEGIN__ coming from libgcc2.c, which 
prevents libgcc_s.dll from being linked.

The audit trail of the PR is quite confused: __LIBGCC_EH_FRAME_SECTION_NAME__ 
needs to be (and is correctly) defined during the libgcc build because DWARF2 
exceptions are used.  The problem is that libgcc2.c expects the usual non-ELF 
setup, with __EH_FRAME_BEGIN__ defined in crtstuff.c.  Now t-cygwin has:

CUSTOM_CRTSTUFF = yes

crtbegin.o: $(srcdir)/config/i386/cygming-crtbegin.c
        $(crt_compile) -fno-omit-frame-pointer  -c $<

crtbeginS.o: $(srcdir)/config/i386/cygming-crtbegin.c
        $(crt_compile) -fno-omit-frame-pointer  -c $< -DCRTSTUFFS_O

# We intentionally use a implementation-reserved init priority of 0,
# so allow the warning.
crtend.o: $(srcdir)/config/i386/cygming-crtend.c
        $(crt_compile) -fno-omit-frame-pointer -Wno-error -c $<

That is to say, crtstuff.c is not compiled and instead __EH_FRAME_BEGIN__ is 
private to cygming-crtbegin.c:

/* Stick a label at the beginning of the frame unwind info so we can
   register/deregister it with the exception handling library code.  */
#if DWARF2_UNWIND_INFO
static EH_FRAME_SECTION_CONST char __EH_FRAME_BEGIN__[]
  __attribute__((used, section(__LIBGCC_EH_FRAME_SECTION_NAME__), aligned(4)))
  = { };

with the registration/deregistration machinery in the same file.  Therefore 
the equivalent code in libgcc2.c simply needs to be skipped.

This code is already entirely skipped for Cygwin because of:

#ifndef __CYGWIN__

so the attached patch adds a similar test on MinGW for the problematic code.

Tested on x86/Windows configured with --disable-sjlj-exceptions --with-dwarf2, 
OK for the mainline and 5 branch?


2016-04-04  Eric Botcazou  <ebotca...@adacore.com>

        PR target/67172
        * libgcc2.c (L__main): Undefine __LIBGCC_EH_FRAME_SECTION_NAME__ if
        __MINGW32__ is defined.

-- 
Eric Botcazou
Index: libgcc2.c
===================================================================
--- libgcc2.c	(revision 234695)
+++ libgcc2.c	(working copy)
@@ -2209,7 +2209,12 @@ TRANSFER_FROM_TRAMPOLINE
 #if !defined (HAS_INIT_SECTION) || !defined (OBJECT_FORMAT_ELF)
 
 /* Some ELF crosses use crtstuff.c to provide __CTOR_LIST__, but use this
-   code to run constructors.  In that case, we need to handle EH here, too.  */
+   code to run constructors.  In that case, we need to handle EH here, too.
+   But MINGW32 is special because it handles CRTSTUFF and EH on its own.  */
+
+#ifdef __MINGW32__
+#undef __LIBGCC_EH_FRAME_SECTION_NAME__
+#endif
 
 #ifdef __LIBGCC_EH_FRAME_SECTION_NAME__
 #include "unwind-dw2-fde.h"

Reply via email to