This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
RE: Correct use of "-flto"
- From: John Frankish <j-frankish at slb dot com>
- To: "gcc-help at gcc dot gnu dot org" <gcc-help at gcc dot gnu dot org>
- Cc: Ian Lance Taylor <iant at google dot com>
- Date: Wed, 27 Mar 2013 04:00:56 +0000
- Subject: RE: Correct use of "-flto"
- References: <E1B828866A01174CB7A0393CF2309BCC3E35BA71 at NL0230MBX12N1 dot DIR dot slb dot com> <CAKOQZ8wYbrMc7JpaMQqf614UeGmD_DD=33f6jxz__5FH3sV+Qg at mail dot gmail dot com>
> > On Tue, Mar 26, 2013 at 4:54 AM, John Frankish <j-frankish@slb.com> wrote:
> > I've been experimenting with "-flto" to compile various source packages.
> >
> > Using binutils-2.23.1 and gcc-4.7.2, both compiled with "--enable-lto"
> >
> > and
> >
> > CC="gcc -flto -fuse-linker-plugin -march=i486 -mtune=i686 -Os -pipe"
> > CXX="g++ -flto -fuse-linker-plugin -march=i486 -mtune=i686 -Os -pipe
> > -fno-exceptions -fno-rtti" ./configure --yada-yada
> >
> >
> > glibc-2.17 ./configure fails complaining that ld does not support array
> > something or other (removing "-flto -fuse-linker-plugin" fixes this).
Is there a patch or another way to be able to compile glibc with LTO?
> > 1. Am I using "-flto" correctly?
>
> Seems like it.
>
>
> > 2. I'm removing "-O2" from the Makefiles - do I need to remove "-g" as
> well?
>
> It depends on whether you want debug info or not. It doesn't really have
> anything to do with -flto.
I'd seen several posts stating that there were problems with -flto and debug symbols with gcc-4.6.x
> -O2 vs. -Os also doesn't really have anything to do with -flto. -flto will work
> with both.
>
> Your static libraries are larger because they now include LTO information
> used at link time. The increase in size is not relevant to the final linked
> program.
Is there a way to remove this LTO information (with strip)?
Otherwise I'm going to have to compile with LTO for apps/so libs and again without LTO for static libs...