This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
cross compile & exceptions
- From: BELBACHIR Selim <selim dot belbachir at fr dot thalesgroup dot com>
- To: "gcc at gcc dot gnu dot org" <gcc at gcc dot gnu dot org>
- Date: Wed, 20 Nov 2013 17:23:21 +0100
- Subject: cross compile & exceptions
- Authentication-results: sourceware.org; auth=none
Hi,
I'm trying to migrate from gcc4.5.2 to gcc4.7.3.
Here are a part of my makefile to build gcc (same config used with gcc4.5.2 and gcc4.7.3) :
cd $(GCC_OBJDIR); CFLAGS="-g -O0" $(GCC_SRCDIR)/configure
-quiet
--prefix=$(INSTALLDIR)
--target=$(TARGET)
--enable-languages=c,c++,ada
--disable-nls
--disable-decimal-float
--disable-fixed-point
--disable-libmudflap
--disable-libffi
--disable-libssp
--disable-shared
--disable-threads
--without-headers
--disable-libada
--enable-version-specific-runtime-lib
--enable-checking=release
make -C $(GCC_OBJDIR) all-gcc
make -C $(GCC_OBJDIR) install-gcc
The c++ (and not c) compiler produced segmentation fault on very small source only when I use default option -O0
cmd : pgcc test.cpp -S
src :
extern void bar(int *);
void toto () {
int tmp;
bar (&tmp);
}
Looking at the dumps I noticed in test.cpp.152r.rtl_eh that a bad RTL SET is generated inside a bunch of rtl dealing with exception.
(insn 19 20 12 5 (set (reg:SI 131)
(reg:SI -1)) -1 <<<--- REG -1 is invalid
(nil))
(insn 12 19 13 5 (set (reg/f:SI 130 [ D.1841 ])
(reg:SI 131)) -1
(nil))
(insn 13 12 14 5 (set (reg:SI 4 $C4)
(reg/f:SI 130 [ D.1841 ])) -1
(nil))
(call_insn 14 13 15 5 (parallel [
(call (mem:SI (symbol_ref:SI ("_Unwind_Resume") [flags 0x41] <function_decl 0x2b1caf9cfd00 __builtin_unwind_resume>) [0 __builtin_unwind_resume S4 A32])
(const_int 0 [0]))
(clobber (reg:SI 1 $C1))
]) -1
I don't want need/want exceptions on my port and it seems that -00 always produce some extra code to handle exception in c++. That was not the normal behaviour of gcc4.5.2.
I don't see any good configure option but I tried --enable-sjlj-exceptions to see the result. The segmentation fault disappears but extra code to call _Unwind_SjLj_Register is produced (with a save of all registers in function prologue ...), that's not what I wanted. Configure using --disable-sjlj-exceptions produce the same segmentation described above.
I also tried to compile my test with -fno-exceptions. It produces the result I expected with no error and no extra code equivalent to the gcc4.5.2 without options.
Something new in gcc4.7.3 has to be configured to disable exceptions by default ?
I noticed a change of behaviour on -fomit-frame-pointer between 4.5.2 & 4.7.3 (described in my previous post). gcc4.5.2 behaviour was exactly what I wanted (fomit-frame-pointer & fno-exceptions by default) how to obtain that with 4.7.3 ?
Regards,
Selim