This is the mail archive of the
mailing list for the GCC project.
Re: RFA: Enhance information recorded by -frecord-gcc-switches
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Nick Clifton <nickc at redhat dot com>
- Cc: Richard Biener <richard dot guenther at gmail dot com>, GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 8 Jun 2017 17:19:43 +0200
- Subject: Re: RFA: Enhance information recorded by -frecord-gcc-switches
- Authentication-results: sourceware.org; auth=none
- Authentication-results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com
- Authentication-results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=jakub at redhat dot com
- Dkim-filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 47188C05FFE5
- Dmarc-filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 47188C05FFE5
- References: <email@example.com> <CAFiYyc0ay79w9dbxJAhLaai3XRC8-wvjj7UcZrYmpV2SraWvNw@mail.gmail.com> <firstname.lastname@example.org>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
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.