Bug#722079: hello: Please provide a deterministic Build ID

2013-09-07 Thread Jérémy Bobbio
Package: hello
Version: 2.8-4
Severity: wishlist
Tags: patch

Hi!

In the quest to get deterministic/reproducible builds [1], I have
noticed that the result of building hello currently varies according to
its build path.

The attached patch use the debugedit tool to prevent such variation by
relocating the source associated with the debug data to a deterministic
path.

It also adds `-fno-merge-debug-strings` to the CFLAGS, because the
resulting .debug_str section will be different depending on the initial
input strings. This behaviour should eventually be fixed at the compiler
level.

[1] http://wiki.debian.org/ReproducibleBuilds

Thanks,
-- 
Lunar.''`. 
lu...@debian.org: :Ⓐ  :  # apt-get install anarchism
`. `'` 
  `-   
diff -Naur a/debian/control b/debian/control
--- a/debian/control	2011-08-04 13:07:58.0 +0200
+++ b/debian/control	2013-09-07 15:18:45.29439 +0200
@@ -2,6 +2,7 @@
 Section: devel
 Priority: optional
 Maintainer: Santiago Vila sanv...@debian.org
+Build-Depends: debugedit | rpm (= 4.7.0-3)
 Standards-Version: 3.9.2
 Homepage: http://www.gnu.org/software/hello/
 
diff -Naur a/debian/rules b/debian/rules
--- a/debian/rules	2013-08-16 09:36:35.0 +0200
+++ b/debian/rules	2013-09-07 15:09:36.755619230 +0200
@@ -10,7 +10,7 @@
 package = hello
 docdir = debian/tmp/usr/share/doc/$(package)
 
-CFLAGS := `dpkg-buildflags --get CFLAGS` -Wall
+CFLAGS := `dpkg-buildflags --get CFLAGS` -Wall -fno-merge-debug-strings
 LDFLAGS := `dpkg-buildflags --get LDFLAGS`
 CPPFLAGS := `dpkg-buildflags --get CPPFLAGS`
 
@@ -34,6 +34,8 @@
   STRIP = $(stripcmd) --remove-section=.comment --remove-section=.note
 endif
 
+DEBUGEDIT = /usr/lib/rpm/debugedit
+
 build:
 	./configure CFLAGS=$(CFLAGS) CPPFLAGS=$(CPPFLAGS) \
 		LDFLAGS=$(LDFLAGS) $(confflags) --prefix=/usr
@@ -54,6 +56,7 @@
 	rm -rf debian/tmp
 	install -d debian/tmp/DEBIAN $(docdir)
 	$(MAKE) prefix=$$(pwd)/debian/tmp/usr install
+	$(DEBUGEDIT) -b $(dir $(realpath $(CURDIR))) -d /usr/src/debug -i debian/tmp/usr/bin/hello
 	$(STRIP) debian/tmp/usr/bin/hello
 	cp -a NEWS debian/copyright $(docdir)
 	cp -a debian/changelog $(docdir)/changelog.Debian


signature.asc
Description: Digital signature


Bug#722079: hello: Please provide a deterministic Build ID

2013-09-07 Thread Santiago Vila

El 07/09/13 17:04, Jérémy Bobbio escribió:

Package: hello
Version: 2.8-4
Severity: wishlist
Tags: patch

Hi!

In the quest to get deterministic/reproducible builds [1], I have
noticed that the result of building hello currently varies according to
its build path.

The attached patch use the debugedit tool to prevent such variation by
relocating the source associated with the debug data to a deterministic
path.

It also adds `-fno-merge-debug-strings` to the CFLAGS, because the
resulting .debug_str section will be different depending on the initial
input strings.


While I can agree that reproducible builds is a good thing (I added gzip 
-n recently), the proposed patch makes debugedit to be build-essential 
and it looks like an awfully horrible hack.



This behaviour should eventually be fixed at the compiler
level.


Or maybe just

s/eventually//


--
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Bug#722079: hello: Please provide a deterministic Build ID

2013-09-07 Thread Jérémy Bobbio
Hi!

Santiago Vila:
 In the quest to get deterministic/reproducible builds [1], I have
 noticed that the result of building hello currently varies according to
 its build path.
 […]
 While I can agree that reproducible builds is a good thing (I added
 gzip -n recently), the proposed patch makes debugedit to be
 build-essential and it looks like an awfully horrible hack.
 
 This behaviour should eventually be fixed at the compiler
 level.
 
 Or maybe just
 
 s/eventually//

Thanks for pushing me to look at other solutions.

After poking some more at GCC and its documentation, I came up with the
attached patch. It only adds two new switches to the CFLAGS:
`-fdebug-prefix-map=` to adjust the source path and
`-gno-record-gcc-switches` to prevent the difference in
`-fdebug-prefix-map=` values from affecting the output.

Does that sound more acceptable to you?

-- 
Lunar.''`. 
lu...@debian.org: :Ⓐ  :  # apt-get install anarchism
`. `'` 
  `-   
diff -Naur a/debian/rules b/debian/rules
--- a/debian/rules	2013-08-16 09:36:35.0 +0200
+++ b/debian/rules	2013-09-07 15:09:36.755619230 +0200
@@ -10,7 +10,7 @@
 package = hello
 docdir = debian/tmp/usr/share/doc/$(package)
 
-CFLAGS := `dpkg-buildflags --get CFLAGS` -Wall
+CFLAGS := `dpkg-buildflags --get CFLAGS` -Wall -fdebug-prefix-map=$(dir $(realpath $(CURDIR)))=/usr/src/debug/ -gno-record-gcc-switches
 LDFLAGS := `dpkg-buildflags --get LDFLAGS`
 CPPFLAGS := `dpkg-buildflags --get CPPFLAGS`
 


signature.asc
Description: Digital signature


Bug#722079: hello: Please provide a deterministic Build ID

2013-09-07 Thread Santiago Vila

El 07/09/13 18:27, Jérémy Bobbio escribió:

After poking some more at GCC and its documentation, I came up with the
attached patch. It only adds two new switches to the CFLAGS:
`-fdebug-prefix-map=` to adjust the source path and
`-gno-record-gcc-switches` to prevent the difference in
`-fdebug-prefix-map=` values from affecting the output.

Does that sound more acceptable to you?


It would be more acceptable, yes, but IMHO your target example package 
should be hello-debhelper, which uses dh, not hello.
[ In fact, I'm actually planning to rename hello as hello-traditional 
and hello-debhelper as just hello at the next upstream release ].


If you have to change *anything* in hello-debhelper to achieve your 
goal, you can reasonably assume that you will potentially have to change 
each and every package, which would be insane.


Depending on the changes you make to things like gcc and dpkg-dev first, 
the amount of changes in other packages could be a lot smaller.


In other words, I see a great difference between A and B, being:

A) You have to change each and every package.
B) Ypu only have to change each and every package which does *not* use 
dh/cdbs/etc.


I wish you luck in both cases but I think your goal will be a lot easier 
to achieve if you avoid A and try B first.



--
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org