[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#777753: gcc: LTO produces unreproducible debug information



Source: gcc-4.9
Version: 4.9.2-10
Severity: normal
Tags: patch
User: reproducible-builds@lists.alioth.debian.org
Usertags: randomness toolchain
X-Debbugs-Cc: reproducible-builds@lists.alioth.debian.org
Forwarded: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65015

The GCC produced binaries seem to be only reproducible when not using
link time optimization. This was discussed on the mailing list [1]. Both
Jérémy Bobbio and Richard Biener pointed me in the direction of debug
information which contained artifacts from the randomly generated
temporary files of the LTO builds.

The last test [2] showed that these really seemed to be the culprit of
the problem. In the meantime, Richard Biener proposed patches which can
solve this problem. I've compiled my own version  of gcc-4.9 using the
attached patch and can confirm that the LTO builds are now working
perfectly fine and no changes to the affected packages are necessary
anymore.

Other versions of gcc might also have this problem but this is right now
only for the default gcc version used by the build infrastructure.

A small testcase is attached to the upstream bug.


[1] http://lists.alioth.debian.org/pipermail/reproducible-builds/Week-of-Mon-20150209/000933.html
[2] http://lists.alioth.debian.org/pipermail/reproducible-builds/Week-of-Mon-20150209/000942.html
diff -u gcc-4.9-4.9.2/debian/rules.patch gcc-4.9-4.9.2/debian/rules.patch
--- gcc-4.9-4.9.2/debian/rules.patch
+++ gcc-4.9-4.9.2/debian/rules.patch
@@ -232,6 +232,7 @@
 	sys-auxv-header \
 	libcilkrts-targets \
 	go-use-gold \
+	drop_opt \
 
 ifeq ($(with_softfloat),yes)
   debian_patches += arm-multilib-soft-float
only in patch2:
unchanged:
--- gcc-4.9-4.9.2.orig/debian/patches/drop_opt.diff
+++ gcc-4.9-4.9.2/debian/patches/drop_opt.diff
@@ -0,0 +1,28 @@
+Bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65015
+
+--- a/src/gcc/dwarf2out.c
++++ b/src/gcc/dwarf2out.c
+@@ -19196,6 +19196,9 @@ gen_producer_string (void)
+       case OPT__sysroot_:
+       case OPT_nostdinc:
+       case OPT_nostdinc__:
++      case OPT_fpreprocessed:
++      case OPT_fltrans_output_list_:
++      case OPT_fresolution_:
+ 	/* Ignore these.  */
+ 	continue;
+       default:
+@@ -23984,8 +23987,11 @@ dwarf2out_finish (const char *filename)
+   gen_remaining_tmpl_value_param_die_attribute ();
+ 
+   /* Add the name for the main input file now.  We delayed this from
+-     dwarf2out_init to avoid complications with PCH.  */
+-  add_name_attribute (comp_unit_die (), remap_debug_filename (filename));
++     dwarf2out_init to avoid complications with PCH.
++     Avoid doing this for LTO produced units as it adds random
++     tempfile names.  */
++  if (!in_lto_p)
++    add_name_attribute (comp_unit_die (), remap_debug_filename (filename));
+   if (!IS_ABSOLUTE_PATH (filename) || targetm.force_at_comp_dir)
+     add_comp_dir_attribute (comp_unit_die ());
+   else if (get_AT (comp_unit_die (), DW_AT_comp_dir) == NULL)

Reply to: