This is the mail archive of the
mailing list for the GCC project.
Re: g++keeps unused objects with virtual functions
- From: Richard Biener <richard dot guenther at gmail dot com>
- To: Zan Lynx <zlynx at acm dot org>
- Cc: GCC Development <gcc at gcc dot gnu dot org>
- Date: Wed, 8 Apr 2015 10:00:43 +0200
- Subject: Re: g++keeps unused objects with virtual functions
- Authentication-results: sourceware.org; auth=none
- References: <55D79922DFF3F742B9F3F1A814CA6B7518FDEB at atvie01vm001 dot ehrlich dot lan> <5524643D dot 1090906 at acm dot org>
On Wed, Apr 8, 2015 at 1:11 AM, Zan Lynx <email@example.com> wrote:
> On 04/07/2015 09:00 AM, Stefan Ehrlich wrote:
>> compiler and linker options are:
>> avr-g++.exe -c -Os -Wall -fdata-sections -ffunction-sections -fvisibility=hidden -fvisibility-inlines-hidden -fno-rtti -flto -fuse-linker-plugin -mmcu=atmega8 ...
>> avr-gcc.exe -Wall -Os -Wl,-static -Wl,-flto -fuse-linker-plugin -Wl,--strip-all -Wl,-s -Wl,--gc-sections -mmcu=atmega8 ...
>> The more not used objects I use the worse the problem gets.
>> Is there any possibility to remove unused virtual functions or at least the objects, which are not used? I have not find any solution so far.
>> If not, is there a plan to add this feature to the linker?
> Try adding -fwhole-program to the options. I haven't tried it.
With using a linker plugin this shouldn't be required.
> I believe that GCC assumes that the executable can be dynamically opened
> and its functions used as if it were a shared library. Because of that
> GCC has to keep things available. Although I would have thought
> visibility=hidden would have taken care of that.
> But -fwhole-program promises that this is the whole program and there
> isn't anything else linking with it. I've noticed that when specified,
> the output is heavily inlined and missing most function definitions so
> it might be what you want.