This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[MinGW] Allow Building GCC with --disable-sjlj-exceptions


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

  Right now if I try to build the GCC trunk with
- --disable-sjlj-exceptions for the i686-pc-mingw32 target, I'm
greeted with an ICE while compiling
"libstdc++-v3/libsupc++/eh_alloc.cc":
- ----------------------------- 8< -----------------------------
(gdb) r
Starting program: /extra/src/gcc/build/gcc/cc1plus -quiet -nostdinc++
- -I/extra/src/gcc/gcc/libstdc++-v3/../gcc
- -I/extra/src/gcc/build/i686-pc-mingw32/libstdc++-v3/include/i686-pc-mingw32
- -I/extra/src/gcc/build/i686-pc-mingw32/libstdc++-v3/include
- -I/extra/src/gcc/gcc/libstdc++-v3/libsupc++ -iprefix
/extra/src/gcc/build/gcc/../lib/gcc/i686-pc-mingw32/4.2.0/ -isysroot
/extra/xgcc/sys-root -isystem /extra/src/gcc/build/./gcc/include
- -isystem /extra/xgcc/i686-pc-mingw32/include -isystem
/extra/xgcc/i686-pc-mingw32/sys-include
/extra/src/gcc/gcc/libstdc++-v3/libsupc++/eh_alloc.cc -quiet -dumpbase
eh_alloc.cc -mtune=generic -auxbase-strip eh_alloc.o -g -O2 -Wall
- -Wextra -Wwrite-strings -Wcast-qual -fno-implicit-templates
- -fdiagnostics-show-location=once -o /tmp/ccXRFUFB.s

Program received signal SIGSEGV, Segmentation fault.
0x08401031 in i386_pe_strip_name_encoding (str=0x0)
   at /extra/src/gcc/gcc/gcc/config/i386/winnt.c:393
393       if (strncmp (str, DLL_IMPORT_PREFIX, strlen (DLL_IMPORT_PREFIX))
- ----------------------------- 8< -----------------------------

The attached patch allows the GCC build to complete successfully.

It was tested with clean cross-GCC builds for i686-pc-mingw32 on
i686-pc-linux-gnu (C,C++), once using --enable-sjlj-exceptions and
then using --disable-sjlj-exceptions. The built C++ compilers
were tested with this simple C++ programme:
- ----------------------------- 8< -----------------------------
#include <iostream>
using namespace std;
class snafu {
public:
  snafu( ) { cout << "Constructed..." << endl; }
  ~snafu( ) { cout << "Destructed..." << endl; }
};

void bar( void){
  cout << "Hello World!" << endl;
  throw 23;
}

void foo (void){
  snafu x;
  bar( );
}

int main (void){
  try {
    foo( );
  } catch (...) {
    cout << "Hello Exceptional World!" << endl;
  }
  return 0;
}
- ----------------------------- 8< -----------------------------

The output from the SJLJ EH version was (as expected):
- ----------------------------- 8< -----------------------------
D:\TEMP>a.exe
Constructed...
Hello World!
Destructed...
Hello Exceptional World!
- ----------------------------- 8< -----------------------------

and that from the DWARF-2 EH version was:
- ----------------------------- 8< -----------------------------
D:\TEMP>a
Constructed...
Hello World!
terminate called after throwing an instance of 'int'
terminate called recursively

abnormal program termination
- ----------------------------- 8< -----------------------------

Yes, DW2 EH for MinGW in FSF GCC still doesn't work but there
are other patches to make it work and this tiny patch at least
lets it build.

OK for mainline?

Thanks,
Ranjit.

- --
Ranjit Mathew      Email: rmathew AT gmail DOT com

Bangalore, INDIA.    Web: http://rmathew.com/


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFEkSmKYb1hx2wRS48RAgf9AJkBQjk/KRBhL/lisL0M0OPDk5dfoQCfeeqQ
/ku3lv3U+tGOfP6JcaaxRjE=
=6bnL
-----END PGP SIGNATURE-----
Index: ChangeLog
from  Ranjit Mathew  <rmathew@gcc.gnu.org>

	* config/i386/cygming.h: Define DWARF2_UNWIND_INFO as 1.

Index: config/i386/cygming.h
===================================================================
--- config/i386/cygming.h	(revision 114669)
+++ config/i386/cygming.h	(working copy)
@@ -265,7 +265,7 @@ extern void i386_pe_unique_section (TREE
 /* DWARF2 Unwinding doesn't work with exception handling yet.  To make
    it work, we need to build a libgcc_s.dll, and dcrt0.o should be
    changed to call __register_frame_info/__deregister_frame_info.  */
-#define DWARF2_UNWIND_INFO 0
+#define DWARF2_UNWIND_INFO 1
 
 /* Don't assume anything about the header files.  */
 #define NO_IMPLICIT_EXTERN_C

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]