This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Call GNU ld with -O*
- From: Ian Lance Taylor <iant at google dot com>
- To: Jakub Jelinek <jakub at redhat dot com>
- Cc: Marc Glisse <marc dot glisse at inria dot fr>, gcc-patches at gcc dot gnu dot org
- Date: Fri, 12 Jul 2013 12:41:12 -0700
- Subject: Re: Call GNU ld with -O*
- References: <alpine dot DEB dot 2 dot 02 dot 1307121633360 dot 28978 at stedding dot saclay dot inria dot fr> <CAKOQZ8z0Nj2pjOiHQujr1XRw1e=9ynrMagyBayg_=Z3iO0VQUg at mail dot gmail dot com> <alpine dot DEB dot 2 dot 10 dot 1307122018190 dot 7127 at stedding dot saclay dot inria dot fr> <CAKOQZ8yQBzDFU0wqu+NpdV-hGtTaUix2JCon0f+ynUTxdmwZvw at mail dot gmail dot com> <20130712193050 dot GB2475 at laptop dot redhat dot com>
On Fri, Jul 12, 2013 at 12:30 PM, Jakub Jelinek <jakub@redhat.com> wrote:
> On Fri, Jul 12, 2013 at 12:25:16PM -0700, Ian Lance Taylor wrote:
>> For gold I think it has two effects. If you use compressed debug
>> sections, it will compress them with zlib level 9 rather than 1. If
>
> Marc's patch enabled it only for -O3/-Ofast (which are already compile time
> expensive options, thus it perhaps it doesn't hurt that much to spend extra
> time in the linker too) and -Os (then you are really looking for small,
> and if ld -O2 provides that, then perhaps it is desirable too).
OK, let me put it this way: perhaps there is some set of linker
options that we should enable by default when linking with -O. But I
don't see any particular reason that they are specifically the linker
options that are selected by -O.
>> you use -O2 or greater it will optimize string tables (e.g., the table
>> holding the names of symbols) such that if the table stores two
>> strings S1 and S2, and S2 is a suffix of S1, it will store only S1,
>> and change pointers to S2 to point to the suffix of S1. So you are
>> correct that the result will be smaller, but not faster to link.
>
> Oh, gold doesn't do this by default? ld.bfd does (unless it changed since
> I've implemented many years ago).
Correct: gold does not do it by default. For us link time matters
most for large C++ programs. For those programs, the optimization
only fired a tiny percentage of the time, but it took something like
4% of total link time. It wasn't worth it by default.
Ian