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: RFA: Enhance information recorded by -frecord-gcc-switches

On Thu, Jun 08, 2017 at 03:30:07PM +0100, Nick Clifton wrote:
> Hi Richard,
> >>    The -frecord-gcc-switches option records the gcc command line.  It
> >>    does not however expand options like -O2 into the optimizations that
> >>    this enables.
> > 
> > I think individually enabled passes by -On are not really useful information
> > as you generally cannot replace -On by a set of other switches on the
> > command-line.
> Is that true ?  I always thought that -O2 could be duplicated by using a (very
> long) set of individual command line options.

It can't.  Various decisions in the compiler are based on the optimize
argument itself, the most important is of course that for optimize == 0 or
optimize_debug the pass queue is significantly different, with hundreds of
optimization passes not being run even if they are enabled, but there are
also optimize >= 2 or optimize >= 3 or optimize_size etc. guarded decisions
in many places.  So, with -O0 + all options that appear to be enabled by -O1
you still get something that is significantly closer to -O0 than -O1.
And even with -O1 + all options that appear to be enabled by -O2 but not
-O1, you still get something very different from -O2, etc.

> Regardless, the point of this patch is to record which options were enabled, via
> whatever route, in the binaries.  This can be useful to users, or distributors,
> who want to check that, for example, a specific security option was enabled, or
> that a particular a particular optimization was run.

And that again doesn't tell you whether the particular optimization pass was
run, just that some flag variable was zero or non-zero or had some other
value.  The decisions in the compiler are more complex and keep changing
between compiler versions.  For one particular compiler version, -O2 vs. -O1
if that is what was originally used to compile something is all you need,
that implies a particular behavior, set of options and their interactions.
For comparisons between different compiler versions, some of the options
are ignored, others are added, others change meaning, and expanding the list
of guarded options isn't really useful.


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