This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [patch][rfc] Enabling more optimizations with -ON
- From: Cary Coutant <ccoutant at google dot com>
- To: Rafael EspÃndola <rafael dot espindola at gmail dot com>
- Cc: Binutils <binutils at sourceware dot org>
- Date: Wed, 19 Nov 2014 16:25:31 -0800
- Subject: Re: [patch][rfc] Enabling more optimizations with -ON
- Authentication-results: sourceware.org; auth=none
- References: <CAG3jRe+UXKKwUq==KLx9TQx2cSr2F-=fgz6cN41TndGoTwgaoQ at mail dot gmail dot com> <20141119230722 dot GA3225 at vapier dot wh0rd dot info> <CAG3jReL2HW7zp=Y9fLuYzcOg+_=6OyoTMgaUSZA7ebS6NzDSuQ at mail dot gmail dot com>
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.
-cary
On Wed, Nov 19, 2014 at 3:13 PM, Rafael EspÃndola
<rafael.espindola@gmail.com> wrote:
> On 19 November 2014 18:07, Mike Frysinger <vapier@gentoo.org> wrote:
>> On 03 Nov 2014 11:39, Rafael EspÃndola wrote:
>>> In compilers the -ON options enable various optimizations. Different
>>> compilers (and compiler versions) have different ones, but the option
>>> itself is commonly available and selects a somewhat corresponding
>>> level.
>>>
>>> In both bfd ld and gold very few optimizations are enabled with the
>>> -ON options. This means that users have to know which optimizations
>>> are available:
>>>
>>> ld ...-O3 --gc-sections --icf=safe....
>>>
>>> If an optimization is added to one of them, a configure check has to
>>> be used to find if the program is being linked with gold or bfd (and
>>> which version).
>>>
>>> As a starting point, the attached patch changes gold to gc sections by
>>> default if given -O3 or higher. It can still be disabled with an
>>> explicit --no-gc-sections.
>>
>> i don't think this is really useful. gc-sections requires code to be compiled
>> with -f{data,function}-sections in order to be effective. so at that point, the
>> user is opting in to the desired behavior ...
>
> This particular example is bit of a chicken and egg issue with the
> compiler. There was some discussion at least on the clang side to
> enable ffunction-sections and fdata-sections by default.
>
> The more general question is "should the liker do more optimizations
> at -Ox"? It is very convenient since then the user doesn't need to
> know the set of optimizations available for a given linker.
>
> For example, right now a project needs a configure/cmake check to find
> out if it is being linked with gold before using -icf=safe, but if it
> was enabled with some -O level, it could just pass that -O option to
> both gold and bfd.
>
>> -mike
>
> Cheers,
> Rafael