Opened 9 years ago
Closed 8 years ago
#3042 closed defect (fixed)
Patches to make the build reproducible (fileordering, randomness)
Reported by: | Bas Couwenberg | Owned by: | |
---|---|---|---|
Priority: | critical | Milestone: | 7.0.5 |
Component: | Compiling | Version: | 7.0.4 |
Keywords: | Cc: | ||
CPU: | Unspecified | Platform: | Linux |
Description
As reported by Alexis Bienvenüe in Debian Bug #825092:
While working on the “reproducible builds” effort, we have noticed that 'grass' could not be built reproducibly.
There are several reproducibility issues:
1) File ordering issues - the build result depends on the order of the files listed with
readdir
or equivalent.
- in
tools/build_modules_xml.py
- see patch01-sort-build-modules-list.patch
- in
lib/db/dbmi_base/dbmscap.c
(this affects options order in thehtml/db.*.html
files) - see patch02-sort-dbmscap.patch
that builds an ordered list.
- in
include/Make/Vars.make
(this affects the order in which object files are merged) - see patch03-sort-obj-files.patch
2) Randomness issue: html/colortables/random.png is built using a pseudo-random generator seeded with build-time value. See patch
04-srand48_auto-from-SOURCE_DATE_EPOCH.patch
that uses the SOURCE_DATE_EPOCH environment variable (when set) to set a seed from lastdebian/changelog
entry date.3) Makefile mistake: from https://buildd.debian.org/status/fetch.php?pkg=grass&arch=i386&ver=7.0.4-1&stamp=1462121195, it seems to me that the binary NAD files are not installed properly:
/usr/bin/install -c -m 644 OBJ.i686-pc-linux-gnu/prvi /«PKGBUILDDIR»/dist.i686-pc-linux-gnu/etc/proj/nad/prvi /usr/bin/install -c -m 644 OBJ.i686-pc-linux-gnu/prvi /«PKGBUILDDIR»/dist.i686-pc-linux-gnu/etc/proj/nad/hawaii /usr/bin/install -c -m 644 OBJ.i686-pc-linux-gnu/prvi /«PKGBUILDDIR»/dist.i686-pc-linux-gnu/etc/proj/nad/alaska /usr/bin/install -c -m 644 OBJ.i686-pc-linux-gnu/prvi /«PKGBUILDDIR»/dist.i686-pc-linux-gnu/etc/proj/nad/stgeorge /usr/bin/install -c -m 644 OBJ.i686-pc-linux-gnu/prvi /«PKGBUILDDIR»/dist.i686-pc-linux-gnu/etc/proj/nad/FL /usr/bin/install -c -m 644 OBJ.i686-pc-linux-gnu/prvi /«PKGBUILDDIR»/dist.i686-pc-linux-gnu/etc/proj/nad/WO /usr/bin/install -c -m 644 OBJ.i686-pc-linux-gnu/prvi /«PKGBUILDDIR»/dist.i686-pc-linux-gnu/etc/proj/nad/TN /usr/bin/install -c -m 644 OBJ.i686-pc-linux-gnu/prvi /«PKGBUILDDIR»/dist.i686-pc-linux-gnu/etc/proj/nad/stlrnc /usr/bin/install -c -m 644 OBJ.i686-pc-linux-gnu/prvi /«PKGBUILDDIR»/dist.i686-pc-linux-gnu/etc/proj/nad/stpaul /usr/bin/install -c -m 644 OBJ.i686-pc-linux-gnu/prvi /«PKGBUILDDIR»/dist.i686-pc-linux-gnu/etc/proj/nad/conus /usr/bin/install -c -m 644 OBJ.i686-pc-linux-gnu/prvi /«PKGBUILDDIR»/dist.i686-pc-linux-gnu/etc/proj/nad/MD /usr/bin/install -c -m 644 OBJ.i686-pc-linux-gnu/prvi /«PKGBUILDDIR»/dist.i686-pc-linux-gnu/etc/proj/nad/WIThe single
OBJ.i686-pc-linux-gnu/prvi
file is here installed to *all*/etc/proj/nad
files. See the patch05-binary-nad-install.patch
for a fix.4) nad2bin issue: nad2bin has unreproducible output (see Debian Bug #825088)
Once these proposed patches are applied (and Debian Bug #825088 fixed), grass can be built reproducibly in our current experimental framework.
Attachments (6)
Change History (20)
by , 9 years ago
Attachment: | 01-sort-build-modules-list.patch added |
---|
by , 9 years ago
Attachment: | 02-sort-dbmscap.patch added |
---|
by , 9 years ago
Attachment: | 03-sort-obj-files.patch added |
---|
by , 9 years ago
Attachment: | 04-srand48_auto-from-SOURCE_DATE_EPOCH.patch added |
---|
by , 9 years ago
Attachment: | 05-binary-nad-install.patch added |
---|
comment:1 by , 9 years ago
comment:2 by , 9 years ago
Component: | Default → Compiling |
---|---|
Priority: | normal → critical |
follow-up: 8 comment:3 by , 9 years ago
Replying to sebastic:
2) Randomness issue: html/colortables/random.png is built using a pseudo-random generator seeded with build-time value. See patch
04-srand48_auto-from-SOURCE_DATE_EPOCH.patch
that uses the SOURCE_DATE_EPOCH environment variable (when set) to set a seed from lastdebian/changelog
entry date.
While I agree with the idea, G_srand48_auto() shouldn't be using this variable directly, but something more appropriate, e.g. GRASS_RANDOM_SEED (or GRASS_RND_SEED, which is what r.mapcalc used prior to the RNG changes).
Debian can then set that variable from $SOURCE_DATE_EPOCH as part of their build process.
In theory, modules which use randomness should be providing a command-line option to get the seed, with G_srand48_auto() only being used if the user specifically wants a non-deterministic seed. But that probably isn't going to happen in the foreseeable future.
comment:4 by , 8 years ago
follow-up: 9 comment:8 by , 8 years ago
Replying to glynn:
While I agree with the idea, G_srand48_auto() shouldn't be using this variable directly, but something more appropriate, e.g. GRASS_RANDOM_SEED (or GRASS_RND_SEED, which is what r.mapcalc used prior to the RNG changes).
Updated patch attached - attachment:04-srand48_auto-from-GRASS_RANDOM_SEED.patch. Can be applied in this way?
by , 8 years ago
Attachment: | 04-srand48_auto-from-GRASS_RANDOM_SEED.patch added |
---|
follow-up: 11 comment:9 by , 8 years ago
Replying to martinl:
Replying to glynn:
While I agree with the idea, G_srand48_auto() shouldn't be using this variable directly, but something more appropriate, e.g. GRASS_RANDOM_SEED (or GRASS_RND_SEED, which is what r.mapcalc used prior to the RNG changes).
Updated patch attached - attachment:04-srand48_auto-from-GRASS_RANDOM_SEED.patch. Can be applied in this way?
The variable should be renamed, because it now uses GRASS_RANDOM_SEED
instead of SOURCE_DATE_EPOCH
, i.e. s/source_date_epoch/grass_random_seed/g
.
comment:11 by , 8 years ago
comment:12 by , 8 years ago
No objection from me, I'm happy to drop these patches from the Debian package.
All patches target the 7.0 branch, but apply to trunk too. Except
01-sort-build-modules-list.patch
,build_modules_xml.py
is no longer used there.