public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: Reproducible gcc builds, gfortran, and -grecord-gcc-switches
       [not found]     ` <alpine.LNX.2.00.1208161634250.2706@wotan.suse.de>
@ 2012-08-16 16:59       ` Simon Baldwin
  2012-08-16 19:34         ` Jakub Jelinek
  0 siblings, 1 reply; 10+ messages in thread
From: Simon Baldwin @ 2012-08-16 16:59 UTC (permalink / raw)
  To: Michael Matz, gcc-patches; +Cc: Gerald Pfeifer

On 16 August 2012 16:40, Michael Matz <matz@suse.de> wrote:
>
> ,,,
>
> Do you have considered to use a new option flag (usable in the .opt files)
> instead of a langhook?  I.e. add a flag cl_dont_record to cl_option, a
> string Norecord for the .opt files, some handling for it in
> opt-functions.awk and the like?
>
> Adding lang-hooks used by debug producers make me twitch :)

Okay.  Below is an alternative approach.

I've moved discussion to gcc-patches, since it's now more concrete
than abstract.

----------

Omit OPT_cpp_ from the DWARF producer string in gfortran.

Gfortran uses -cpp=<temporary file> internally, and with -grecord_gcc_switches
this command line switch is stored by default in object files.  This causes
problems with build and packaging systems that care about gcc binary
reproducibility and file checksums; the temporary file is different on each
compiler invocation.

Fixed by adding a new opt marker NoDwarfRecord and associated flag, filtering
options for this this setting when writing the producer string, and setting
this flag for fortran -cpp=<temporary file>

Tested for fortran (suppresses -cpp=...) and c (no effect).

gcc/ChangeLog
2012-08-16  Simon Baldwin  <simonb@google.com>

	* dwarf2out.c (gen_producer_string): Omit command line switch if
	CL_NO_DWARF_RECORD flag set.
	* opts.c (print_specific_help): Add CL_NO_DWARF_RECORD handling.
	* opts.h (CL_NO_DWARF_RECORD): New.
	* opt-functions.awk (switch_flags): Add NoDwarfRecord.

gcc/fortran/ChangeLog
2012-08-16  Simon Baldwin  <simonb@google.com>

	* lang.opt (-cpp=): Mark flag NoDwarfRecord.


Index: gcc/dwarf2out.c
===================================================================
--- gcc/dwarf2out.c	(revision 190442)
+++ gcc/dwarf2out.c	(working copy)
@@ -18101,6 +18101,9 @@ gen_producer_string (void)
 	/* Ignore these.  */
 	continue;
       default:
+        if (cl_options[save_decoded_options[j].opt_index].flags
+	    & CL_NO_DWARF_RECORD)
+	  continue;
         gcc_checking_assert (save_decoded_options[j].canonical_option[0][0]
 			     == '-');
         switch (save_decoded_options[j].canonical_option[0][1])
Index: gcc/opts.c
===================================================================
--- gcc/opts.c	(revision 190442)
+++ gcc/opts.c	(working copy)
@@ -1186,7 +1186,9 @@ print_specific_help (unsigned int includ
     {
       if (any_flags == 0)
 	{
-	  if (include_flags & CL_UNDOCUMENTED)
+	  if (include_flags & CL_NO_DWARF_RECORD)
+	    description = _("The following options are not recorded by DWARF");
+          else if (include_flags & CL_UNDOCUMENTED)
 	    description = _("The following options are not documented");
 	  else if (include_flags & CL_SEPARATE)
 	    description = _("The following options take separate arguments");
@@ -1292,7 +1294,7 @@ common_handle_option (struct gcc_options
 	/* Walk along the argument string, parsing each word in turn.
 	   The format is:
 	   arg = [^]{word}[,{arg}]
-	   word = {optimizers|target|warnings|undocumented|
+	   word = {optimizers|target|warnings|undocumented|nodwarfrecord|
 		   params|common|<language>}  */
 	while (* a != 0)
 	  {
@@ -1307,6 +1309,7 @@ common_handle_option (struct gcc_options
 	      { "target", CL_TARGET },
 	      { "warnings", CL_WARNING },
 	      { "undocumented", CL_UNDOCUMENTED },
+	      { "nodwarfrecord", CL_NO_DWARF_RECORD },
 	      { "params", CL_PARAMS },
 	      { "joined", CL_JOINED },
 	      { "separate", CL_SEPARATE },
Index: gcc/opts.h
===================================================================
--- gcc/opts.h	(revision 190442)
+++ gcc/opts.h	(working copy)
@@ -145,6 +145,7 @@ extern const unsigned int cl_lang_count;
 #define CL_JOINED		(1U << 22) /* If takes joined argument.  */
 #define CL_SEPARATE		(1U << 23) /* If takes a separate argument.  */
 #define CL_UNDOCUMENTED		(1U << 24) /* Do not output with --help.  */
+#define CL_NO_DWARF_RECORD	(1U << 25) /* Do not add to producer string.  */

 /* Flags for an enumerated option argument.  */
 #define CL_ENUM_CANONICAL	(1 << 0) /* Canonical for this value.  */
Index: gcc/fortran/lang.opt
===================================================================
--- gcc/fortran/lang.opt	(revision 190442)
+++ gcc/fortran/lang.opt	(working copy)
@@ -287,7 +287,7 @@ Fortran Negative(nocpp)
 Enable preprocessing

 cpp=
-Fortran Joined Negative(nocpp) Undocumented
+Fortran Joined Negative(nocpp) Undocumented NoDwarfRecord
 ; Internal option generated by specs from -cpp.

 nocpp
Index: gcc/opt-functions.awk
===================================================================
--- gcc/opt-functions.awk	(revision 190442)
+++ gcc/opt-functions.awk	(working copy)
@@ -103,6 +103,7 @@ function switch_flags (flags)
 	  test_flag("JoinedOrMissing", flags, " | CL_JOINED") \
 	  test_flag("Separate", flags, " | CL_SEPARATE") \
 	  test_flag("Undocumented", flags,  " | CL_UNDOCUMENTED") \
+	  test_flag("NoDwarfRecord", flags,  " | CL_NO_DWARF_RECORD") \
 	  test_flag("Warning", flags,  " | CL_WARNING") \
 	  test_flag("Optimization", flags,  " | CL_OPTIMIZATION")
 	sub( "^0 \\| ", "", result )

--
Google UK Limited | Registered Office: Belgrave House, 76 Buckingham
Palace Road, London SW1W 9TQ | Registered in England Number: 3977902

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Reproducible gcc builds, gfortran, and -grecord-gcc-switches
  2012-08-16 16:59       ` Reproducible gcc builds, gfortran, and -grecord-gcc-switches Simon Baldwin
@ 2012-08-16 19:34         ` Jakub Jelinek
  2012-08-17  9:46           ` Simon Baldwin
  0 siblings, 1 reply; 10+ messages in thread
From: Jakub Jelinek @ 2012-08-16 19:34 UTC (permalink / raw)
  To: Simon Baldwin; +Cc: Michael Matz, gcc-patches, Gerald Pfeifer

On Thu, Aug 16, 2012 at 06:59:09PM +0200, Simon Baldwin wrote:
> On 16 August 2012 16:40, Michael Matz <matz@suse.de> wrote:
> >
> > ,,,
> >
> > Do you have considered to use a new option flag (usable in the .opt files)
> > instead of a langhook?  I.e. add a flag cl_dont_record to cl_option, a
> > string Norecord for the .opt files, some handling for it in
> > opt-functions.awk and the like?
> >
> > Adding lang-hooks used by debug producers make me twitch :)
> 
> Okay.  Below is an alternative approach.
> 
> I've moved discussion to gcc-patches, since it's now more concrete
> than abstract.

You could have just added
  case OPT_cpp_:
to the switch in gen_producer_string, instead of all this.

> --- gcc/dwarf2out.c	(revision 190442)
> +++ gcc/dwarf2out.c	(working copy)
> @@ -18101,6 +18101,9 @@ gen_producer_string (void)
>  	/* Ignore these.  */
>  	continue;
>        default:
> +        if (cl_options[save_decoded_options[j].opt_index].flags
> +	    & CL_NO_DWARF_RECORD)
> +	  continue;
>          gcc_checking_assert (save_decoded_options[j].canonical_option[0][0]
>  			     == '-');
>          switch (save_decoded_options[j].canonical_option[0][1])

	Jakub

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Reproducible gcc builds, gfortran, and -grecord-gcc-switches
  2012-08-16 19:34         ` Jakub Jelinek
@ 2012-08-17  9:46           ` Simon Baldwin
  2012-08-17 14:56             ` Joseph S. Myers
  0 siblings, 1 reply; 10+ messages in thread
From: Simon Baldwin @ 2012-08-17  9:46 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: Michael Matz, gcc-patches, Gerald Pfeifer

On 16 August 2012 21:28, Jakub Jelinek <jakub@redhat.com> wrote:
>
> On Thu, Aug 16, 2012 at 06:59:09PM +0200, Simon Baldwin wrote:
> > On 16 August 2012 16:40, Michael Matz <matz@suse.de> wrote:
> > >
> > > ,,,
> > >
> > > Do you have considered to use a new option flag (usable in the .opt files)
> > > instead of a langhook?  I.e. add a flag cl_dont_record to cl_option, a
> > > string Norecord for the .opt files, some handling for it in
> > > opt-functions.awk and the like?
> > >
> > > Adding lang-hooks used by debug producers make me twitch :)
> >
> > Okay.  Below is an alternative approach.
> >
> > I've moved discussion to gcc-patches, since it's now more concrete
> > than abstract.
>
> You could have just added
>   case OPT_cpp_:
> to the switch in gen_producer_string, instead of all this.

Thanks.  I was under the impression, apparently mistaken, that
OPT_cpp_ exists only if fortran is enabled.

--
Google UK Limited | Registered Office: Belgrave House, 76 Buckingham
Palace Road, London SW1W 9TQ | Registered in England Number: 3977902

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Reproducible gcc builds, gfortran, and -grecord-gcc-switches
  2012-08-17  9:46           ` Simon Baldwin
@ 2012-08-17 14:56             ` Joseph S. Myers
  2012-08-20 14:30               ` Simon Baldwin
  0 siblings, 1 reply; 10+ messages in thread
From: Joseph S. Myers @ 2012-08-17 14:56 UTC (permalink / raw)
  To: Simon Baldwin; +Cc: Jakub Jelinek, Michael Matz, gcc-patches, Gerald Pfeifer

On Fri, 17 Aug 2012, Simon Baldwin wrote:

> > You could have just added
> >   case OPT_cpp_:
> > to the switch in gen_producer_string, instead of all this.
> 
> Thanks.  I was under the impression, apparently mistaken, that
> OPT_cpp_ exists only if fortran is enabled.

OPT_* for Fortran options only exist when the Fortran front-end is in the 
source tree (whether or not enabled).  I think we try to avoid knowingly 
breaking use cases where people remove some front ends from the source 
tree, although we don't actively test them and no longer provide split-up 
source tarballs.

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Reproducible gcc builds, gfortran, and -grecord-gcc-switches
  2012-08-17 14:56             ` Joseph S. Myers
@ 2012-08-20 14:30               ` Simon Baldwin
  2012-08-20 14:45                 ` Joseph S. Myers
  0 siblings, 1 reply; 10+ messages in thread
From: Simon Baldwin @ 2012-08-20 14:30 UTC (permalink / raw)
  To: Joseph S. Myers; +Cc: Jakub Jelinek, Michael Matz, gcc-patches, Gerald Pfeifer

On 17 August 2012 16:55, Joseph S. Myers <joseph@codesourcery.com> wrote:
>
> On Fri, 17 Aug 2012, Simon Baldwin wrote:
>
> > > You could have just added
> > >   case OPT_cpp_:
> > > to the switch in gen_producer_string, instead of all this.
> >
> > Thanks.  I was under the impression, apparently mistaken, that
> > OPT_cpp_ exists only if fortran is enabled.
>
> OPT_* for Fortran options only exist when the Fortran front-end is in the
> source tree (whether or not enabled).  I think we try to avoid knowingly
> breaking use cases where people remove some front ends from the source
> tree, although we don't actively test them and no longer provide split-up
> source tarballs.

Thanks for the update.  Which fix should move forwards?

--
Google UK Limited | Registered Office: Belgrave House, 76 Buckingham
Palace Road, London SW1W 9TQ | Registered in England Number: 3977902

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Reproducible gcc builds, gfortran, and -grecord-gcc-switches
  2012-08-20 14:30               ` Simon Baldwin
@ 2012-08-20 14:45                 ` Joseph S. Myers
  2012-08-21 12:20                   ` Simon Baldwin
  0 siblings, 1 reply; 10+ messages in thread
From: Joseph S. Myers @ 2012-08-20 14:45 UTC (permalink / raw)
  To: Simon Baldwin; +Cc: Jakub Jelinek, Michael Matz, gcc-patches, Gerald Pfeifer

On Mon, 20 Aug 2012, Simon Baldwin wrote:

> > OPT_* for Fortran options only exist when the Fortran front-end is in the
> > source tree (whether or not enabled).  I think we try to avoid knowingly
> > breaking use cases where people remove some front ends from the source
> > tree, although we don't actively test them and no longer provide split-up
> > source tarballs.
> 
> Thanks for the update.  Which fix should move forwards?

I think the approach using a new option flag is the way to go, though the 
patch needs (at least) documentation for the new flag in options.texi.

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Reproducible gcc builds, gfortran, and -grecord-gcc-switches
  2012-08-20 14:45                 ` Joseph S. Myers
@ 2012-08-21 12:20                   ` Simon Baldwin
  2012-08-21 15:18                     ` Joseph S. Myers
  0 siblings, 1 reply; 10+ messages in thread
From: Simon Baldwin @ 2012-08-21 12:20 UTC (permalink / raw)
  To: Joseph S. Myers, gcc-patches; +Cc: Jakub Jelinek, Michael Matz, Gerald Pfeifer

On 20 August 2012 16:45, Joseph S. Myers <joseph@codesourcery.com> wrote:
>
> On Mon, 20 Aug 2012, Simon Baldwin wrote:
>
> > > OPT_* for Fortran options only exist when the Fortran front-end is in the
> > > source tree (whether or not enabled).  I think we try to avoid knowingly
> > > breaking use cases where people remove some front ends from the source
> > > tree, although we don't actively test them and no longer provide split-up
> > > source tarballs.
> >
> > Thanks for the update.  Which fix should move forwards?
>
> I think the approach using a new option flag is the way to go, though the
> patch needs (at least) documentation for the new flag in options.texi.
>

Updated version appended below.  Okay for 4.8 trunk?

----------

Omit OPT_cpp_ from the DWARF producer string in gfortran.

Gfortran uses -cpp=<temporary file> internally, and with -grecord_gcc_switches
this command line switch is stored by default in object files.  This causes
problems with build and packaging systems that care about gcc binary
reproducibility and file checksums; the temporary file is different on each
compiler invocation.

Fixed by adding a new opt marker NoDWARFRecord and associated flag, filtering
options for this this setting when writing the producer string, and setting
this flag for fortran -cpp=<temporary file>

Tested for fortran (suppresses -cpp=...) and c (no effect).

gcc/ChangeLog
2012-08-21  Simon Baldwin  <simonb@google.com>

	* dwarf2out.c (gen_producer_string): Omit command line switch if
	CL_NO_DWARF_RECORD flag set.
	* opts.c (print_specific_help): Add CL_NO_DWARF_RECORD handling.
	* opts.h (CL_NO_DWARF_RECORD): New.
	* opt-functions.awk (switch_flags): Add NoDWARFRecord.
	* doc/options.texi: Document NoDWARFRecord option flag.
	* doc/invoke.texi: Document --help=nodwarfrecord.

gcc/fortran/ChangeLog
2012-08-21  Simon Baldwin  <simonb@google.com>

	* lang.opt (-cpp=): Mark flag NoDWARFRecord.


Index: gcc/doc/options.texi
===================================================================
--- gcc/doc/options.texi	(revision 190535)
+++ gcc/doc/options.texi	(working copy)
@@ -468,4 +468,8 @@ of @option{-@var{opt}}, if not explicitl
 specify several different languages.  Each @var{language} must have
 been declared by an earlier @code{Language} record.  @xref{Option file
 format}.
+
+@item NoDWARFRecord
+The option is added to the list of those omitted from the producer string
+written by @option{-grecord-gcc-switches}.
 @end table
Index: gcc/doc/invoke.texi
===================================================================
--- gcc/doc/invoke.texi	(revision 190535)
+++ gcc/doc/invoke.texi	(working copy)
@@ -1330,6 +1330,10 @@ sign in the same continuous piece of tex
 @item @samp{separate}
 Display options taking an argument that appears as a separate word
 following the original option, such as: @samp{-o output-file}.
+
+@item @samp{nodwarfrecord}
+Display only those options that are marked for addition to the list of
+options omitted from @option{-grecord-gcc-switches}.
 @end table

 Thus for example to display all the undocumented target-specific
Index: gcc/dwarf2out.c
===================================================================
--- gcc/dwarf2out.c	(revision 190535)
+++ gcc/dwarf2out.c	(working copy)
@@ -18101,6 +18101,9 @@ gen_producer_string (void)
 	/* Ignore these.  */
 	continue;
       default:
+        if (cl_options[save_decoded_options[j].opt_index].flags
+	    & CL_NO_DWARF_RECORD)
+	  continue;
         gcc_checking_assert (save_decoded_options[j].canonical_option[0][0]
 			     == '-');
         switch (save_decoded_options[j].canonical_option[0][1])
Index: gcc/opts.c
===================================================================
--- gcc/opts.c	(revision 190535)
+++ gcc/opts.c	(working copy)
@@ -1186,7 +1186,9 @@ print_specific_help (unsigned int includ
     {
       if (any_flags == 0)
 	{
-	  if (include_flags & CL_UNDOCUMENTED)
+	  if (include_flags & CL_NO_DWARF_RECORD)
+	    description = _("The following options are not recorded by DWARF");
+          else if (include_flags & CL_UNDOCUMENTED)
 	    description = _("The following options are not documented");
 	  else if (include_flags & CL_SEPARATE)
 	    description = _("The following options take separate arguments");
@@ -1292,7 +1294,7 @@ common_handle_option (struct gcc_options
 	/* Walk along the argument string, parsing each word in turn.
 	   The format is:
 	   arg = [^]{word}[,{arg}]
-	   word = {optimizers|target|warnings|undocumented|
+	   word = {optimizers|target|warnings|undocumented|nodwarfrecord|
 		   params|common|<language>}  */
 	while (* a != 0)
 	  {
@@ -1307,6 +1309,7 @@ common_handle_option (struct gcc_options
 	      { "target", CL_TARGET },
 	      { "warnings", CL_WARNING },
 	      { "undocumented", CL_UNDOCUMENTED },
+	      { "nodwarfrecord", CL_NO_DWARF_RECORD },
 	      { "params", CL_PARAMS },
 	      { "joined", CL_JOINED },
 	      { "separate", CL_SEPARATE },
Index: gcc/opts.h
===================================================================
--- gcc/opts.h	(revision 190535)
+++ gcc/opts.h	(working copy)
@@ -145,6 +145,7 @@ extern const unsigned int cl_lang_count;
 #define CL_JOINED		(1U << 22) /* If takes joined argument.  */
 #define CL_SEPARATE		(1U << 23) /* If takes a separate argument.  */
 #define CL_UNDOCUMENTED		(1U << 24) /* Do not output with --help.  */
+#define CL_NO_DWARF_RECORD	(1U << 25) /* Do not add to producer string.  */

 /* Flags for an enumerated option argument.  */
 #define CL_ENUM_CANONICAL	(1 << 0) /* Canonical for this value.  */
Index: gcc/fortran/lang.opt
===================================================================
--- gcc/fortran/lang.opt	(revision 190535)
+++ gcc/fortran/lang.opt	(working copy)
@@ -295,7 +295,7 @@ Fortran Negative(nocpp)
 Enable preprocessing

 cpp=
-Fortran Joined Negative(nocpp) Undocumented
+Fortran Joined Negative(nocpp) Undocumented NoDWARFRecord
 ; Internal option generated by specs from -cpp.

 nocpp
Index: gcc/opt-functions.awk
===================================================================
--- gcc/opt-functions.awk	(revision 190535)
+++ gcc/opt-functions.awk	(working copy)
@@ -103,6 +103,7 @@ function switch_flags (flags)
 	  test_flag("JoinedOrMissing", flags, " | CL_JOINED") \
 	  test_flag("Separate", flags, " | CL_SEPARATE") \
 	  test_flag("Undocumented", flags,  " | CL_UNDOCUMENTED") \
+	  test_flag("NoDWARFRecord", flags,  " | CL_NO_DWARF_RECORD") \
 	  test_flag("Warning", flags,  " | CL_WARNING") \
 	  test_flag("Optimization", flags,  " | CL_OPTIMIZATION")
 	sub( "^0 \\| ", "", result )

--
Google UK Limited | Registered Office: Belgrave House, 76 Buckingham
Palace Road, London SW1W 9TQ | Registered in England Number: 3977902

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Reproducible gcc builds, gfortran, and -grecord-gcc-switches
  2012-08-21 12:20                   ` Simon Baldwin
@ 2012-08-21 15:18                     ` Joseph S. Myers
  2012-08-24 11:09                       ` Simon Baldwin
  0 siblings, 1 reply; 10+ messages in thread
From: Joseph S. Myers @ 2012-08-21 15:18 UTC (permalink / raw)
  To: Simon Baldwin; +Cc: gcc-patches, Jakub Jelinek, Michael Matz, Gerald Pfeifer

On Tue, 21 Aug 2012, Simon Baldwin wrote:

> Index: gcc/doc/options.texi
> ===================================================================
> --- gcc/doc/options.texi	(revision 190535)
> +++ gcc/doc/options.texi	(working copy)
> @@ -468,4 +468,8 @@ of @option{-@var{opt}}, if not explicitl
>  specify several different languages.  Each @var{language} must have
>  been declared by an earlier @code{Language} record.  @xref{Option file
>  format}.
> +
> +@item NoDWARFRecord
> +The option is added to the list of those omitted from the producer string
> +written by @option{-grecord-gcc-switches}.

Remove "added to the list of those" (which seems unnecessarily verbose).

> +@item @samp{nodwarfrecord}
> +Display only those options that are marked for addition to the list of
> +options omitted from @option{-grecord-gcc-switches}.

I don't think there's any need for special --help support for options with 
this flag; this flag is really an implementation detail.  (Thus, I think 
all the opts.c changes are unnecessary.)

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Reproducible gcc builds, gfortran, and -grecord-gcc-switches
  2012-08-21 15:18                     ` Joseph S. Myers
@ 2012-08-24 11:09                       ` Simon Baldwin
  2012-08-24 14:48                         ` Joseph S. Myers
  0 siblings, 1 reply; 10+ messages in thread
From: Simon Baldwin @ 2012-08-24 11:09 UTC (permalink / raw)
  To: Joseph S. Myers; +Cc: gcc-patches, Jakub Jelinek, Michael Matz, Gerald Pfeifer

On 21 August 2012 17:18, Joseph S. Myers <joseph@codesourcery.com> wrote:
>
> On Tue, 21 Aug 2012, Simon Baldwin wrote:
>
> > Index: gcc/doc/options.texi
> > ===================================================================
> > --- gcc/doc/options.texi      (revision 190535)
> > +++ gcc/doc/options.texi      (working copy)
> > @@ -468,4 +468,8 @@ of @option{-@var{opt}}, if not explicitl
> >  specify several different languages.  Each @var{language} must have
> >  been declared by an earlier @code{Language} record.  @xref{Option file
> >  format}.
> > +
> > +@item NoDWARFRecord
> > +The option is added to the list of those omitted from the producer
> > string
> > +written by @option{-grecord-gcc-switches}.
>
> Remove "added to the list of those" (which seems unnecessarily verbose).
>
> > +@item @samp{nodwarfrecord}
> > +Display only those options that are marked for addition to the list of
> > +options omitted from @option{-grecord-gcc-switches}.
>
> I don't think there's any need for special --help support for options with
> this flag; this flag is really an implementation detail.  (Thus, I think
> all the opts.c changes are unnecessary.)

Thanks, revised and shorter version below.  Please take another look when ready.

----------
Omit OPT_cpp_ from the DWARF producer string in gfortran.

Gfortran uses -cpp=<temporary file> internally, and with -grecord_gcc_switches
this command line switch is stored by default in object files.  This causes
problems with build and packaging systems that care about gcc binary
reproducibility and file checksums; the temporary file is different on each
compiler invocation.

Fixed by adding a new opt marker NoDWARFRecord and associated flag, filtering
options for this this setting when writing the producer string, and setting
this flag for fortran -cpp=<temporary file>

Tested for fortran (suppresses -cpp=...) and c (no effect).

gcc/ChangeLog
2012-08-24  Simon Baldwin  <simonb@google.com>

	* dwarf2out.c (gen_producer_string): Omit command line switch if
	CL_NO_DWARF_RECORD flag set.
	* opts.h (CL_NO_DWARF_RECORD): New.
	* opt-functions.awk (switch_flags): Add NoDWARFRecord.
	* doc/options.texi: Document NoDWARFRecord option flag.

gcc/fortran/ChangeLog
2012-08-24  Simon Baldwin  <simonb@google.com>

	* lang.opt (-cpp=): Mark flag NoDWARFRecord.


Index: gcc/doc/options.texi
===================================================================
--- gcc/doc/options.texi	(revision 190642)
+++ gcc/doc/options.texi	(working copy)
@@ -468,4 +468,8 @@ of @option{-@var{opt}}, if not explicitl
 specify several different languages.  Each @var{language} must have
 been declared by an earlier @code{Language} record.  @xref{Option file
 format}.
+
+@item NoDWARFRecord
+The option is omitted from the producer string written by
+@option{-grecord-gcc-switches}.
 @end table
Index: gcc/dwarf2out.c
===================================================================
--- gcc/dwarf2out.c	(revision 190642)
+++ gcc/dwarf2out.c	(working copy)
@@ -18138,6 +18138,9 @@ gen_producer_string (void)
 	/* Ignore these.  */
 	continue;
       default:
+        if (cl_options[save_decoded_options[j].opt_index].flags
+	    & CL_NO_DWARF_RECORD)
+	  continue;
         gcc_checking_assert (save_decoded_options[j].canonical_option[0][0]
 			     == '-');
         switch (save_decoded_options[j].canonical_option[0][1])
Index: gcc/opts.h
===================================================================
--- gcc/opts.h	(revision 190642)
+++ gcc/opts.h	(working copy)
@@ -145,6 +145,7 @@ extern const unsigned int cl_lang_count;
 #define CL_JOINED		(1U << 22) /* If takes joined argument.  */
 #define CL_SEPARATE		(1U << 23) /* If takes a separate argument.  */
 #define CL_UNDOCUMENTED		(1U << 24) /* Do not output with --help.  */
+#define CL_NO_DWARF_RECORD	(1U << 25) /* Do not add to producer string.  */

 /* Flags for an enumerated option argument.  */
 #define CL_ENUM_CANONICAL	(1 << 0) /* Canonical for this value.  */
Index: gcc/fortran/lang.opt
===================================================================
--- gcc/fortran/lang.opt	(revision 190642)
+++ gcc/fortran/lang.opt	(working copy)
@@ -295,7 +295,7 @@ Fortran Negative(nocpp)
 Enable preprocessing

 cpp=
-Fortran Joined Negative(nocpp) Undocumented
+Fortran Joined Negative(nocpp) Undocumented NoDWARFRecord
 ; Internal option generated by specs from -cpp.

 nocpp
Index: gcc/opt-functions.awk
===================================================================
--- gcc/opt-functions.awk	(revision 190642)
+++ gcc/opt-functions.awk	(working copy)
@@ -103,6 +103,7 @@ function switch_flags (flags)
 	  test_flag("JoinedOrMissing", flags, " | CL_JOINED") \
 	  test_flag("Separate", flags, " | CL_SEPARATE") \
 	  test_flag("Undocumented", flags,  " | CL_UNDOCUMENTED") \
+	  test_flag("NoDWARFRecord", flags,  " | CL_NO_DWARF_RECORD") \
 	  test_flag("Warning", flags,  " | CL_WARNING") \
 	  test_flag("Optimization", flags,  " | CL_OPTIMIZATION")
 	sub( "^0 \\| ", "", result )

--
Google UK Limited | Registered Office: Belgrave House, 76 Buckingham
Palace Road, London SW1W 9TQ | Registered in England Number: 3977902

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Reproducible gcc builds, gfortran, and -grecord-gcc-switches
  2012-08-24 11:09                       ` Simon Baldwin
@ 2012-08-24 14:48                         ` Joseph S. Myers
  0 siblings, 0 replies; 10+ messages in thread
From: Joseph S. Myers @ 2012-08-24 14:48 UTC (permalink / raw)
  To: Simon Baldwin; +Cc: gcc-patches, Jakub Jelinek, Michael Matz, Gerald Pfeifer

On Fri, 24 Aug 2012, Simon Baldwin wrote:

> gcc/ChangeLog
> 2012-08-24  Simon Baldwin  <simonb@google.com>
> 
> 	* dwarf2out.c (gen_producer_string): Omit command line switch if
> 	CL_NO_DWARF_RECORD flag set.
> 	* opts.h (CL_NO_DWARF_RECORD): New.
> 	* opt-functions.awk (switch_flags): Add NoDWARFRecord.
> 	* doc/options.texi: Document NoDWARFRecord option flag.
> 
> gcc/fortran/ChangeLog
> 2012-08-24  Simon Baldwin  <simonb@google.com>
> 
> 	* lang.opt (-cpp=): Mark flag NoDWARFRecord.

OK.

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2012-08-24 14:48 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CAPTY64p0=m3O6TOfPf1w1rtF944gHe_ODOsH+Ryx-tdTupVzUA@mail.gmail.com>
     [not found] ` <alpine.LNX.2.00.1208160912270.2871@gerinyyl.fvgr>
     [not found]   ` <CAPTY64ofrdhFVrYNJcHhyrA3J7vpZ=Y6EPrdoWJEwsv3tm3xyw@mail.gmail.com>
     [not found]     ` <alpine.LNX.2.00.1208161634250.2706@wotan.suse.de>
2012-08-16 16:59       ` Reproducible gcc builds, gfortran, and -grecord-gcc-switches Simon Baldwin
2012-08-16 19:34         ` Jakub Jelinek
2012-08-17  9:46           ` Simon Baldwin
2012-08-17 14:56             ` Joseph S. Myers
2012-08-20 14:30               ` Simon Baldwin
2012-08-20 14:45                 ` Joseph S. Myers
2012-08-21 12:20                   ` Simon Baldwin
2012-08-21 15:18                     ` Joseph S. Myers
2012-08-24 11:09                       ` Simon Baldwin
2012-08-24 14:48                         ` Joseph S. Myers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).