Removing -fexceptions from $RPM_OPT_FLAGS

Frank Ch. Eigler fche at redhat.com
Tue Jan 18 23:08:37 UTC 2011


Pierre-Yves <pingou at pingoured.fr> writes:

> [...]
> I have been looking into the review #668863 in which the packager for
> this library (who also happens to be upstream) is actually removing the
> flag "-fexceptions" from $RPM_OPT_FLAGS in the %build.
> [...]

> - Upstream does not want to have this flag on, saying that if an
> exception occurs the program should crash anyway (that is its expected
> behavior)*.

-fexception allows a C library to participate in C++ exception
handling.  It does not cost anything except extra data tables in the
ELF file.  Its presence matters in cases where a C library is used by
a C++ program, for example where the library may make a callback into
the C++ program, and that callback might throw an exception.  With
-fexception, that exception will be propagated properly through the C
library, to the outermost application.  Without it, exceptions thrown
from a callback may abort the program, even if the overall application
wanted to catch it.

If the C library does not have callbacks, then this particular reason
may not apply, but others might.  -fexception should be kept.

- FChE


`-fexceptions'
     Enable exception handling.  Generates extra code needed to
     propagate exceptions.  For some targets, this implies GCC will
     generate frame unwind information for all functions, which can
     produce significant data size overhead, although it does not
     affect execution.  If you do not specify this option, GCC will
     enable it by default for languages like C++ which normally require
     exception handling, and disable it for languages like C that do
     not normally require it.  However, you may need to enable this
     option when compiling C code that needs to interoperate properly
     with exception handlers written in C++.  You may also wish to
     disable this option if you are compiling older C++ programs that
     don't use exception handling.


More information about the devel mailing list