From mboxrd@z Thu Jan 1 00:00:00 1970 From: Timothy Sample Subject: bug#33922: failing git-annex build Date: Wed, 02 Jan 2019 17:14:38 -0500 Message-ID: <87ftuazoz5.fsf@ngyro.com> References: <87h8evvjr2.fsf@kyleam.com> <87bm53gs9w.fsf@elephly.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([208.118.235.92]:50385) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1geon3-0005ED-V1 for bug-guix@gnu.org; Wed, 02 Jan 2019 17:15:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1geon0-0000Qq-LH for bug-guix@gnu.org; Wed, 02 Jan 2019 17:15:05 -0500 Received: from debbugs.gnu.org ([208.118.235.43]:47318) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1geon0-0000QD-9C for bug-guix@gnu.org; Wed, 02 Jan 2019 17:15:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1geomz-0006sL-U4 for bug-guix@gnu.org; Wed, 02 Jan 2019 17:15:01 -0500 In-Reply-To: <87bm53gs9w.fsf@elephly.net> Sender: "Debbugs-submit" Resent-Message-ID: List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guix-bounces+gcggb-bug-guix=m.gmane.org@gnu.org Sender: "bug-Guix" To: Ricardo Wurmus Cc: 33922@debbugs.gnu.org --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi, Ricardo Wurmus writes: > [...] > > It seems to me that this is a more general problem affecting all of our > Haskell packages. The configure phase that you didn=E2=80=99t paste shou= ld show > that modules are provided by slightly different packages. > > The haskell-build-system suffers from non-determinism. It might just be > limited to the package database files that are generated by ghc-pkg > (where readdir is used and the result isn=E2=80=99t sorted). This is exactly the problem. I=E2=80=99ve attached a patch that should fix this. Unfortunately, I kind of rediscovered this from scratch, so for the sake of completeness, here=E2=80=99s all the details of what I found. I don=E2=80=99t recall the exact chain of dependencies that led me from git-annex to ghc-exceptions, but the latter is a nice and small example of the general problem. The ghc-exceptions package depends on ghc-stm. Even though Hydra and Berlin built the exact same ghc-stm (save for the =E2=80=9Cpackage.cache=E2=80=9D file), the way that ghc-exceptions depends = on it differs between build servers. Hydra uses =E2=80=9Cstm-[version]=E2=80=9D in the g= hc-exceptions package database, and Berlin uses =E2=80=9Cstm-[version]-[hash]=E2=80=9D. = For more complicated packages, these differences get sufficiently jumbled up and GHC gets grumpy because we are trying to use two =E2=80=9Cdifferent=E2=80= =9D versions of ghc-stm. In this case, they both have the same name, ID, ABI, and are even bit-for-bit identical (again, except for =E2=80=9Cpackage.cache=E2=80= =9D), but GHC doesn=E2=80=99t care because it is worried about the different reference (w= ith the hash and without it). Another concrete example is ghc-aeson. It needs (among other things) ghc-uuid-types and ghc-hashable. These both need ghc-text. Right now, I cannot build ghc-aeson because it has conflicting requirements for ghc-text. It looks like I got a ghc-uuid-types substitute from Hydra that doesn=E2=80=99t include the hash, and a ghc-hashable substitute from B= erlin that does. Again, ghc-text is bit-for-bit identical between the two up to =E2=80=9Cpackage.cache=E2=80=9D. What=E2=80=99s great is that both build servers are internally consistent, = so they never run into trouble. It=E2=80=99s just us poor users that suffer. = :p Obviously the =E2=80=9Cpackage.cache=E2=80=9D file looks pretty guilty, but= it is also pretty inscrutable. I pulled code out of GHC to dump a textual representation of it, and found out that the only differences are in the order of packages. Everything else is the same. I modified 'ghc-pkg' to write a sorted binary cache, and it seems to solve all the issues mentioned above. That is, I built ghc-text, ghc-hashable, and ghc-uuid-types on two different computers, and got bit-for-bit identical results for all of them. (I also built ghc-text on both computers without the patch, and saw the same differing =E2=80=9Cpackage.cache=E2=80=9D problem that I observed between Hydra and B= erlin.) I think this patch will solve the git-annex problem, as well improve Haskell reproducibility. Thoughts? -- Tim --=-=-= Content-Type: text/x-patch; charset=utf-8 Content-Disposition: attachment; filename=0001-gnu-ghc-Sort-packages-before-writing-binary-cache.patch Content-Transfer-Encoding: quoted-printable >From bb29ee8ccc656b86039127b31fd8b79533927053 Mon Sep 17 00:00:00 2001 From: Timothy Sample Date: Wed, 2 Jan 2019 16:40:48 -0500 Subject: [PATCH] gnu: ghc: Sort packages before writing binary cache. This improves the reproducibility of packages built with the Haskell build system. * gnu/packages/haskell.scm (ghc)[arguments]: Add a phase that patches 'ghc-pkg' so that it sorts packages before generating a binary cache. --- gnu/packages/haskell.scm | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/gnu/packages/haskell.scm b/gnu/packages/haskell.scm index 8d0e2aef6..1a751a5b4 100644 --- a/gnu/packages/haskell.scm +++ b/gnu/packages/haskell.scm @@ -14,7 +14,7 @@ ;;; Copyright =C2=A9 2017 rsiddharth ;;; Copyright =C2=A9 2017, 2018 Tobias Geerinckx-Rice ;;; Copyright =C2=A9 2018 Tonton -;;; Copyright =C2=A9 2018 Timothy Sample +;;; Copyright =C2=A9 2018, 2019 Timothy Sample ;;; Copyright =C2=A9 2018 Arun Isaac ;;; ;;; This file is part of GNU Guix. @@ -508,6 +508,18 @@ interactive environment for the functional language Ha= skell.") (assoc-ref inputs "ghc-testsuite") "--strip-components=3D1") #t)) + ;; This phase patches the 'ghc-pkg' command so that it sorts + ;; the list of packages in the binary cache it generates. + (add-after 'unpack 'patch-ghc-pkg + (lambda _ + (substitute* "utils/ghc-pkg/Main.hs" + (("import Data.List") + (string-append "import Data.List\n" + "import Data.Ord (comparing)")) + (("pkgsCabalFormat =3D packages db") + (string-append "pkgsCabalFormat =3D sortBy" + " (comparing (display . installedUnitId))" + " (packages db)"))))) (add-after 'unpack-testsuite 'fix-shell-wrappers (lambda _ (substitute* '("driver/ghci/ghc.mk" --=20 2.20.1 --=-=-=--