This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: duplicate -lgcc --as-needed -lgcc_s --no-as-needed
On Fri, Jun 03, 2005 at 10:56:37AM +0100, Nix wrote:
> The point of that trickery is to avoid introducing a dependency on the
> shared libgcc for programs that don't use exception handling. If they
> do, it'll come from the shared libgcc: otherwise, the shared libgcc gets
> entirely dropped thanks to --as-needed. (This is *not* quite the same as
> dropping it for C programs and keeping it for C++ programs: C programs
> can be linked with -fexceptions for the same of exception propagation
> from C++, and then they'd pull in symbols from libgcc_s, even if they
> are themselves not using the symbol anywhere else: perhaps they're a
> shared library, or will dlopen() something written in C++ which may
> throw.)
Right, just a minor nit. -fexceptions alone in C code does not
cause libgcc_s to be brought in, you need to do something in C that
requires the EH stuff from libgcc_s. So, either explicitely call
one of the _Unwind_* routines, or use __attribute__((cleanup (fn))).
Jakub