This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Does `-fwhole-program' make sense when compiling shared libraries?
- From: Joe Buck <Joe dot Buck at synopsys dot COM>
- To: Toon Moene <toon at moene dot org>
- Cc: Dave Korn <dave dot korn dot cygwin at gmail dot com>, "gcc at gcc dot gnu dot org" <gcc at gcc dot gnu dot org>
- Date: Mon, 17 May 2010 11:23:41 -0700
- Subject: Re: Does `-fwhole-program' make sense when compiling shared libraries?
- References: <4BF1861F.5020406@gmail.com> <4BF1838B.2090603@moene.org>
On Mon, May 17, 2010 at 10:57:31AM -0700, Toon Moene wrote:
> On 05/17/2010 08:08 PM, Dave Korn wrote:
> >
> > Hi!
> >
> > PR42904 is a bug where, when compiling a windows DLL using -fwhole-program,
> > the compiler optimises away the entire library body, because there's no
> > dependency chain related to 'main' to anchor it.
Not a bug, but perhaps the beginning of a reasonable enhancement project.
> Aren't "shared library" and "whole program" mutually exclusive concepts ?
>
> The mere fact that you are building a library means that it cannot be
> the whole program, and because a shared library cannot be determined to
> have being used by any fixed program, by definition cannot be "the whole
> program".
>
> Or so I'd think.
The concept would need to be extended so that the compiler would be told
exactly what interfaces of the shared library are considered free, and
which are considered internal calls. Then a -fwhole-library could make
sense.