gcc optimization options and lto (detailed info)

Jonathan Wakely jwakely.gcc@gmail.com
Tue May 17 08:30:56 GMT 2022


On Tue, 17 May 2022 at 07:57, muzungu--- via Gcc-help
<gcc-help@gcc.gnu.org> wrote:
> * does every -f<xyz> have a -fno-<xyz>?

Nearly all, yes:

"Many options have long names starting with -f or with -W --- for
example, -fmove-loop-invariants, -Wformat and so on.  Most of these
have both positive and negative forms; the negative form of -ffoo is
-fno-foo.  This manual documents only one of these two forms,
whichever one is not the default."


> * would I be able able to disable single optimizations activated via -O<x> using -fno-<xyz> after -O<x>?

Yes.

> * When LTO is enabled, are the optimizations only effective at link time and not during the compilation into IR (GIMPLE)?

Both.

> * Or are the optimizations effective in different stages of the build process? Are there information which options is applied when?

If a particular optimization is only effective before/during LTO I
think that will be mentioned in the manual. If it isn't mentioned,
assume it is effective at both times.

> Are there information available what the different optimizations do (which I know, is a long list) and how such unwanted optimization can be avoided respective the unwanted effects of the optimizations

No, it would be an entire book, and rapidly be outdated. All the
available documentation is already in the GCC manual. Of course the
source code is the ultimate guide, but it's not clear to follow unless
you already know how GCC works.

> * Since there is a rather long list of optimization options which would very likely exceed the command line length, what is the solution to activate a custom set of optimzations? I could not find a --configfile option or similar to replace the command line.

See the @file option.

But if you need so many options that you exceed the command-line
limits, maybe you're doing something wrong. That would be unusual.


More information about the Gcc-help mailing list