This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Disable all optimization options in GCC
- From: Mikhail Maltsev <maltsevm at gmail dot com>
- To: Jonathan Wakely <jwakely dot gcc at gmail dot com>, Mohamed Boussaa <mohamedboussaa3 at gmail dot com>
- Cc: gcc-help <gcc-help at gcc dot gnu dot org>
- Date: Thu, 22 Oct 2015 22:25:13 +0300
- Subject: Re: Disable all optimization options in GCC
- Authentication-results: sourceware.org; auth=none
- References: <CADEOxiNzOK65QoDvq+xrBDCDf1MTc2XHWUo4khCsu_PTwyj4Zw at mail dot gmail dot com> <CADEOxiNjVvDN2ais42Q7rwkmy4MH5zmE8gp+Ok7OPefng0d8Zg at mail dot gmail dot com> <CAH6eHdR=51WPO+Db-TxjSnPSrU03KJRGrS=UeL5zBOpkxEDoeA at mail dot gmail dot com>
On 10/22/2015 09:30 PM, Jonathan Wakely wrote:
>> Options that reduce compilation time
>> and make debugging better will be turned on.
>
> Wrong. At -O0 options that would _increase_ compilation time are _not_
> turned on.
>
>
>> In other words, O0 is optimizing in the level of compilation. Produced
>> binaries are not optimized in order to ease debugging process.
>
> I don't know what this means.
I think OP meant that -O0 reduces compile time at the cost of increasing
run time. In general that is not always true. -O0 indeed turns off
optimizations, but in some cases this leads to increased compile time.
A simple (and thus not very precise) explanation: compilation is
organized into passes. If some optimization removes lots of code at some
early stage, all later passes will no longer need to process this code.
Because the compiler not only optimizes the code, but also does other
work (selects instructions, allocates registers, generates debugging
information, etc.), at -O0 this work will be done on more code. That's
why, say '-Og -ggdb3' can result in faster compilation than '-O0 -ggdb3'.
--
Regards,
Mikhail Maltsev