This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Call GNU ld with -O*


On Fri, 12 Jul 2013 18:53:58 +0200, Jakub Jelinek <> wrote:
> On Fri, Jul 12, 2013 at 09:49:28AM -0700, Thomas Schwinge wrote:
> > On Fri, 12 Jul 2013 16:54:21 +0200 (CEST), Marc Glisse <> wrote:
> > > this patch makes the driver pass -O2 to GNU ld if gcc was called with -O3 
> > > (or more), -Ofast or -Os.
> > 
> > I wondered about this before: why are no -O flags are passed to the (GNU)
> > linker.
> > 
> > What's the rationale for the mapping you propose of GCC and linker
> > optimization flags?  Why not a one-to-one mapping?
> Because there is no 1:1 mapping.  I bet ld doesn't grok -Os or -Ofast or
> -Og, and what -O* does in the linker doesn't have direct correspondence to
> what -O* does in the compiler.  Last time I've looked, -O* in the linker
> just enabled some link time expensive computation of the hash table,
> so enabling -O in the linker for -O1 in the compiler is definitely not a
> good idea, similarly for -Og, those definitely want speed rather than better
> hash table.

OK, there currently is no one-to-one mapping -- but why not establish
one?  Then the linker would enable the expensive optimizations only for
-O2 and higher -- which would break backwards compatibility, bummer...
(Though, I could see potential uses in the linker for -Ofast and -Og,


Attachment: pgpBChvGQrmIc.pgp
Description: PGP signature

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]