diff mbox

Build gcc/ with -fno-exceptions -fno-rtti

Message ID Pine.LNX.4.64.1111031509150.30317@wotan.suse.de
State New
Headers show

Commit Message

Michael Matz Nov. 3, 2011, 2:16 p.m. UTC
Hi,


On Thu, 3 Nov 2011, Eric Botcazou wrote:

> > There is a bug about not using -fexceptions (50857).
> 
> Then let's fix it, as you said there "We fail to pass -fno-exceptions 
> -fno-rtti to g++ for stage2 and stage3 building the host binaries.  
> That leads to increased compile-time and possibly runtime."

This follows Ians suggestion from PR50857, testing in libcpp/ and gcc/ if 
-fno-exceptions and -fno-rtti work with the compiler, and add them to 
ALL_CXXFLAGS.  It does fix bootstrap with c,c++,ada and my patch.  No yet 
put through an all-language bootstrap of testsuite.  What do you think?
(I also looked at doing this from top-level configure/Makefile/whatever, 
but that's too complicated for me it seems).


Ciao,
Michael.

libcpp/
	* configure.ac: Check for -fno-exceptions -fno-rtti.
	* configure: Regenerate.
	* Makefile.in (NOEXCEPTION_FLAGS): New flag.
	(ALL_CXXFLAGS): Use it.

gcc/
	* configure.ac: Check for -fno-exceptions -fno-rtti.
	* configure: Regenerate.
	* Makefile.in (NOEXCEPTION_FLAGS): New flag.
	(ALL_CXXFLAGS): Use it.

Comments

Paolo Bonzini Nov. 3, 2011, 2:19 p.m. UTC | #1
On 11/03/2011 03:16 PM, Michael Matz wrote:
>
>>> >  >  There is a bug about not using -fexceptions (50857).
>> >
>> >  Then let's fix it, as you said there "We fail to pass -fno-exceptions
>> >  -fno-rtti to g++ for stage2 and stage3 building the host binaries.
>> >  That leads to increased compile-time and possibly runtime."
> This follows Ians suggestion from PR50857, testing in libcpp/ and gcc/ if
> -fno-exceptions and -fno-rtti work with the compiler, and add them to
> ALL_CXXFLAGS.  It does fix bootstrap with c,c++,ada and my patch.  No yet
> put through an all-language bootstrap of testsuite.  What do you think?
> (I also looked at doing this from top-level configure/Makefile/whatever,
> but that's too complicated for me it seems).

I think it's good this way.  We know the subset of C++ we use (aka C) 
doesn't have either exceptions or RTTI.

Paolo
Richard Biener Nov. 3, 2011, 2:21 p.m. UTC | #2
On Thu, Nov 3, 2011 at 3:19 PM, Paolo Bonzini <bonzini@gnu.org> wrote:
> On 11/03/2011 03:16 PM, Michael Matz wrote:
>>
>>>> >  >  There is a bug about not using -fexceptions (50857).
>>>
>>> >
>>> >  Then let's fix it, as you said there "We fail to pass -fno-exceptions
>>> >  -fno-rtti to g++ for stage2 and stage3 building the host binaries.
>>> >  That leads to increased compile-time and possibly runtime."
>>
>> This follows Ians suggestion from PR50857, testing in libcpp/ and gcc/ if
>> -fno-exceptions and -fno-rtti work with the compiler, and add them to
>> ALL_CXXFLAGS.  It does fix bootstrap with c,c++,ada and my patch.  No yet
>> put through an all-language bootstrap of testsuite.  What do you think?
>> (I also looked at doing this from top-level configure/Makefile/whatever,
>> but that's too complicated for me it seems).
>
> I think it's good this way.  We know the subset of C++ we use (aka C)
> doesn't have either exceptions or RTTI.

Yes.  It's also one of the premises of switching to C++, not use that
features (intially at least).

Thus, ok if it passes some testing.

Richard.

> Paolo
>
Eric Botcazou Nov. 3, 2011, 2:50 p.m. UTC | #3
> Thus, ok if it passes some testing.

And with PR bootstrap/50857 in the ChangeLog for extra brownie points.
Michael Matz Nov. 3, 2011, 5:28 p.m. UTC | #4
Hi,

On Thu, 3 Nov 2011, Eric Botcazou wrote:

> > Thus, ok if it passes some testing.
> 
> And with PR bootstrap/50857 in the ChangeLog for extra brownie points.

r180833.


Ciao,
Michael.
diff mbox

Patch

Index: libcpp/configure.ac
===================================================================
--- libcpp/configure.ac	(revision 180700)
+++ libcpp/configure.ac	(working copy)
@@ -39,6 +39,10 @@  ACX_PROG_CC_WARNING_OPTS([-Wstrict-proto
 			  -Wold-style-definition -Wc++-compat], [c_warn])
 ACX_PROG_CC_WARNING_ALMOST_PEDANTIC([-Wno-long-long])
 
+# Disable exceptions and RTTI if building with g++
+ACX_PROG_CC_WARNING_OPTS(
+       m4_quote(m4_do([-fno-exceptions -fno-rtti])), [noexception_flags])
+
 # Only enable with --enable-werror-always until existing warnings are
 # corrected.
 ACX_PROG_CC_WARNINGS_ARE_ERRORS([manual])
Index: libcpp/Makefile.in
===================================================================
--- libcpp/Makefile.in	(revision 180700)
+++ libcpp/Makefile.in	(working copy)
@@ -56,6 +56,7 @@  XGETTEXT = @XGETTEXT@
 CCDEPMODE = @CCDEPMODE@
 CXXDEPMODE = @CXXDEPMODE@
 DEPDIR = @DEPDIR@
+NOEXCEPTION_FLAGS = @noexception_flags@
 
 datarootdir = @datarootdir@
 datadir = @datadir@
@@ -72,7 +73,8 @@  INCLUDES = -I$(srcdir) -I. -I$(srcdir)/.
 	-I$(srcdir)/include
 
 ALL_CFLAGS = $(CFLAGS) $(WARN_CFLAGS) $(INCLUDES) $(CPPFLAGS)
-ALL_CXXFLAGS = $(CXXFLAGS) $(WARN_CXXFLAGS) $(INCLUDES) $(CPPFLAGS)
+ALL_CXXFLAGS = $(CXXFLAGS) $(WARN_CXXFLAGS) $(NOEXCEPTION_FLAGS) $(INCLUDES) \
+	$(CPPFLAGS)
 
 # The name of the compiler to use.
 ENABLE_BUILD_WITH_CXX = @ENABLE_BUILD_WITH_CXX@
Index: gcc/configure.ac
===================================================================
--- gcc/configure.ac	(revision 180700)
+++ gcc/configure.ac	(working copy)
@@ -357,6 +357,10 @@  fi
 AC_SUBST(warn_cflags)
 AC_SUBST(warn_cxxflags)
 
+# Disable exceptions and RTTI if building with g++
+ACX_PROG_CC_WARNING_OPTS(
+	m4_quote(m4_do([-fno-exceptions -fno-rtti])), [noexception_flags])
+	
 # Enable expensive internal checks
 is_release=
 if test x"`cat $srcdir/DEV-PHASE`" != xexperimental; then
Index: gcc/Makefile.in
===================================================================
--- gcc/Makefile.in	(revision 180700)
+++ gcc/Makefile.in	(working copy)
@@ -164,6 +164,8 @@  C_STRICT_WARN = @c_strict_warn@
 # "extern" tags in header files.
 NOCOMMON_FLAG = @nocommon_flag@
 
+NOEXCEPTION_FLAGS = @noexception_flags@
+
 # This is set by --disable-maintainer-mode (default) to "#"
 # FIXME: 'MAINT' will always be set to an empty string, no matter if
 # --disable-maintainer-mode is used or not.  This is because the
@@ -1033,7 +1035,7 @@  ALL_CFLAGS = $(T_CFLAGS) $(CFLAGS-$@) \
 
 # The C++ version.
 ALL_CXXFLAGS = $(T_CFLAGS) $(CFLAGS-$@) $(CXXFLAGS) $(INTERNAL_CFLAGS) \
-  $(COVERAGE_FLAGS) $(WARN_CXXFLAGS) @DEFS@
+  $(COVERAGE_FLAGS) $(NOEXCEPTION_FLAGS) $(WARN_CXXFLAGS) @DEFS@
 
 # Likewise.  Put INCLUDES at the beginning: this way, if some autoconf macro
 # puts -I options in CPPFLAGS, our include files in the srcdir will always