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

Bug#819176: gcc-5: Please avoid storing -fdebug-prefix-map in DW_AT_producer (for better reproducibility)



Package: gcc-5
Version: 5.3.1-12
Severity: wishlist
Tags: patch
User: reproducible-builds@lists.alioth.debian.org
Usertags: buildpath

embedding the build path in binaries makes it harder to get
byte-for-byte reproducibility, because the build has to happen in the
same directory.

gcc by default embeds the build path in the debug info of C tools
(e.g. DW_AT_comp_dir and DW_AT_decl_file).  This isn't useful for
distributed binary packages, because the build environment isn't on
the same machine (or necessarily in the same place).

The build path can be mangled/stripped with gcc's -fdebug-prefix-map
argument.  For example:

   gcc -fdebug-prefix-map=$(pwd)=. -g -o foo foo.c

however, when supplying -fdebug-prefix-map, gcc puts that string
itself into DW_AT_producer.

The attached patch (pulled from upstream gcc master) avoids storing
-fdebug-prefix-map in DW_AT_producer.

I'd like this to be backported into debian's gcc so that we can make
and test a more reproducible toolchain.

(thinking about timing: we shouldn't need the patch once we move to
gcc 6, but we should be testing a buildpath-independent reproducible
toolchain now; i'll file a bug soon to add this pattern to either dh
or dpkg-buildflags)

Regards,

        --dkg

-- System Information:
Debian Release: stretch/sid
Architecture: amd64 (x86_64)

Kernel: Linux 4.4.0-1-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages gcc-5 depends on:
ii  binutils      2.26-5
ii  cpp-5         5.3.1-12
ii  gcc-5-base    5.3.1-12
ii  libc6         2.22-3
ii  libcc1-0      5.3.1-12
ii  libgcc-5-dev  5.3.1-12
ii  libgcc1       1:5.3.1-12
ii  libgmp10      2:6.1.0+dfsg-2
ii  libisl15      0.16.1-1
ii  libmpc3       1.0.3-1
ii  libmpfr4      3.1.4-1
ii  libstdc++6    5.3.1-12
ii  zlib1g        1:1.2.8.dfsg-2+b1

Versions of packages gcc-5 recommends:
ii  libc6-dev  2.22-3

Versions of packages gcc-5 suggests:
pn  gcc-5-doc         <none>
pn  gcc-5-locales     <none>
ii  gcc-5-multilib    5.3.1-12
pn  libasan2-dbg      <none>
pn  libatomic1-dbg    <none>
pn  libcilkrts5-dbg   <none>
pn  libgcc1-dbg       <none>
pn  libgomp1-dbg      <none>
pn  libitm1-dbg       <none>
pn  liblsan0-dbg      <none>
pn  libmpx0-dbg       <none>
pn  libquadmath0-dbg  <none>
pn  libtsan0-dbg      <none>
pn  libubsan0-dbg     <none>

-- debconf-show failed
>From 6ceddcd7b87911ddbb942923722af5a735dacedc Mon Sep 17 00:00:00 2001
From: bernds <bernds@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Fri, 18 Dec 2015 19:48:26 +0000
Subject: [PATCH] Ignore -fdebug-prefix-map in producer string (by Daniel Kahn
 Gillmor)

	* dwarf2out.c (gen_producer_string): Ignore -fdebug-prefix-map.

testsuite/
	* gcc.dg/debug/dwarf2/prod-options.c: New test.



git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@231835 138bc75d-0d04-0410-961f-82ee72b054a4
---
 gcc/ChangeLog                                    |  4 ++++
 gcc/dwarf2out.c                                  |  1 +
 gcc/testsuite/ChangeLog                          |  4 ++++
 gcc/testsuite/gcc.dg/debug/dwarf2/prod-options.c | 12 ++++++++++++
 4 files changed, 21 insertions(+)
 create mode 100644 gcc/testsuite/gcc.dg/debug/dwarf2/prod-options.c

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index fec7992..11ee620 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,7 @@
+2015-12-18  Daniel Kahn Gillmor  <dkg@fifthhorseman.net>
+
+	* dwarf2out.c (gen_producer_string): Ignore -fdebug-prefix-map.
+
 2015-12-18  Nathan Sidwell  <nathan@acm.org>
 
 	* config/nvptx/nvptx.c (nvptx_option_override): Emit sorry for
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index 067c4f2..320a077 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -21498,6 +21498,7 @@ gen_producer_string (void)
       case OPT_fpreprocessed:
       case OPT_fltrans_output_list_:
       case OPT_fresolution_:
+      case OPT_fdebug_prefix_map_:
 	/* Ignore these.  */
 	continue;
       default:
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 5da1ce4..b2d9d3b 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2015-12-18  Bernd Schmidt  <bschmidt@redhat.com>
+
+	* gcc.dg/debug/dwarf2/prod-options.c: New test.
+
 2015-12-18  Eric Botcazou  <ebotcazou@adacore.com>
 
 	* gnat.dg/specs/debug1.ads: Bump final count to 18.
diff --git a/gcc/testsuite/gcc.dg/debug/dwarf2/prod-options.c b/gcc/testsuite/gcc.dg/debug/dwarf2/prod-options.c
new file mode 100644
index 0000000..21449f9
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/dwarf2/prod-options.c
@@ -0,0 +1,12 @@
+/* Verify that the DW_AT_producer does not contain certain compiler options
+   such as -fdebug-prefix-map=; this is undesirable since path names make
+   the build not reproducible.  Other skipped options could be tested here
+   as well.  */
+/* { dg-do compile } */
+/* { dg-options "-O2 -gdwarf -dA -fdebug-prefix-map=a=b" } */
+/* { dg-final { scan-assembler "DW_AT_producer: \"GNU C" } } */
+/* { dg-final { scan-assembler-not "debug-prefix-map" } } */
+
+void func (void)
+{
+}
-- 
2.8.0.rc3


Reply to: