[patch][rfc] Enabling more optimizations with -ON

Rafael Espíndola rafael.espindola@gmail.com
Thu Nov 20 15:02:00 GMT 2014


On 19 November 2014 19:25, Cary Coutant <ccoutant@google.com> wrote:
> Sorry, Rafael, I'm not ignoring your proposal -- I'm just pondering
> it. I'm not wild about the -O option in the first place, since it
> implies that we can nicely arrange the various optimizations into some
> order. Right now, we use it in exactly two places: -O1 with
> --compress-debug-sections uses ZIP compression level 9 instead of 1,
> and -O2 does tail optimization of the string tables. Both of those
> probably would have been cleaner with distinct options, but it was
> convenient and both simply trade a little link time for a smaller
> executable without any risk. It's not clear to me that --gc-sections
> or --icf are universally applicable, which is what bundling them with
> some optimization level would imply.

The issue then is that every software package has to test what liker
is being used to link it.

I got here by first modifying the clang build to pass --gc-sections
when linking clang. That found that older versions of bfd ld could not
handle --export-dynamic+gc-sections. I could (and if needed will)
write a check for "is this gold or a fixed bfd ld", but that need is
common to every project that wants gc-sections, so I tried to make
something more generic.

In the compiler land a project can just use -ON (module bugs) instead
of "-fopt1 -fopt2
-fopt-something-introduced-in-gcc-4.9-but-an-error-in-4.8".

Cheers,
Rafael



More information about the Binutils mailing list