unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
* [bug#54729] [PATCH] build: haskell-build-system: Support packages w. multiple libraries
@ 2022-04-05 15:15 Philip Munksgaard
  2022-04-06 19:19 ` [bug#54729] [PATCH core-updates v2 1/2] build: haskell-build-system: Remove trailing #t zimoun
                   ` (2 more replies)
  0 siblings, 3 replies; 16+ messages in thread
From: Philip Munksgaard @ 2022-04-05 15:15 UTC (permalink / raw)
  To: 54729; +Cc: Philip Munksgaard

As discussed in #53655 [0], haskell-build-system.scm does not currently
support packages which contain multiple libraries, such as attoparsec
[1]. Such libraries are often used for internal or convenience libraries, as
detailed in the documentation [2].

The current state of affairs means that attoparsec and any other libraries
with similar structure cannot be built on guix, nor can any library or
executable that depends on such a library.

Instead of assuming that `runhaskell Setup.hs --gen-pkg-config=...` always
outputs a single file, we detect whether the result was a directory. If so, we
need to handle each file independently in lexicographic order by calling the
new private function `install-from-config-file`.

Because `install-transitive-deps` can now be called multiple times for each
call to `register`, it has also been amended to support the files already
installed.

0: https://issues.guix.gnu.org/53655
1: https://hackage.haskell.org/package/attoparsec-0.14.4/attoparsec.cabal
2: https://downloads.haskell.org/cabal/Cabal-3.0.0.0/doc/users-guide/installing-packages.html#cmdoption-setup-register-gen-pkg-config
---
 guix/build/haskell-build-system.scm | 34 ++++++++++++++++++-----------
 1 file changed, 21 insertions(+), 13 deletions(-)

diff --git a/guix/build/haskell-build-system.scm b/guix/build/haskell-build-system.scm
index ef6cb316ee..e827e23aba 100644
--- a/guix/build/haskell-build-system.scm
+++ b/guix/build/haskell-build-system.scm
@@ -217,11 +217,13 @@ (define* (register #:key name system inputs outputs #:allow-other-keys)
          (if (not (vhash-assoc id seen))
              (let ((dep-conf  (string-append src  "/" id ".conf"))
                    (dep-conf* (string-append dest "/" id ".conf")))
-               (when (not (file-exists? dep-conf))
+               (unless (file-exists? dep-conf*)
+                 (when (not (file-exists? dep-conf))
                    (error (format #f "File ~a does not exist. This usually means the dependency ~a is missing. Was checking conf-file ~a." dep-conf id conf-file)))
-               (copy-file dep-conf dep-conf*) ;XXX: maybe symlink instead?
-               (loop (vhash-cons id #t seen)
-                     (append lst (conf-depends dep-conf))))
+                 (copy-file dep-conf dep-conf*) ;XXX: maybe symlink instead?
+
+                 (loop (vhash-cons id #t seen)
+                       (append lst (conf-depends dep-conf*)))))
              (loop seen tail))))))
 
   (let* ((out (assoc-ref outputs "out"))
@@ -234,13 +236,12 @@ (define* (register #:key name system inputs outputs #:allow-other-keys)
                                     "/ghc-" version
                                     "/" name ".conf.d"))
          (id-rx (make-regexp "^id:[ \n\t]+([^ \t\n]+)$" regexp/newline))
-         (config-file (string-append out "/" name ".conf"))
+         (config-output (string-append out "/" name ".conf"))
          (params
-          (list (string-append "--gen-pkg-config=" config-file))))
+          (list (string-append "--gen-pkg-config=" config-output))))
     (run-setuphs "register" params)
-    ;; The conf file is created only when there is a library to register.
-    (when (file-exists? config-file)
-      (mkdir-p config-dir)
+
+    (define (install-from-config-file config-file)
       (let* ((contents (call-with-input-file config-file read-string))
              (config-file-name+id (match:substring (first (list-matches id-rx contents)) 1)))
 
@@ -270,10 +271,17 @@ (define* (register #:key name system inputs outputs #:allow-other-keys)
         (install-transitive-deps config-file %tmp-db-dir config-dir)
         (rename-file config-file
                      (string-append config-dir "/"
-                                    config-file-name+id ".conf"))
-        (invoke "ghc-pkg"
-                (string-append "--package-db=" config-dir)
-                "recache")))
+                                    config-file-name+id ".conf"))))
+
+    ;; The conf file is created only when there is a library to register.
+    (when (file-exists? config-output)
+      (mkdir-p config-dir)
+      (if (file-is-directory? config-output)
+          (for-each install-from-config-file (find-files config-output))
+          (install-from-config-file config-output))
+      (invoke "ghc-pkg"
+              (string-append "--package-db=" config-dir)
+              "recache"))
     #t))
 
 (define* (check #:key tests? test-target #:allow-other-keys)
-- 
2.35.1





^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [bug#54729] [PATCH core-updates v2 1/2] build: haskell-build-system: Remove trailing #t.
  2022-04-05 15:15 [bug#54729] [PATCH] build: haskell-build-system: Support packages w. multiple libraries Philip Munksgaard
@ 2022-04-06 19:19 ` zimoun
  2022-04-06 19:19   ` [bug#54729] [PATCH core-updates v2 2/2] build: haskell-build-system: Support multiple libraries zimoun
  2022-04-06 19:23 ` [bug#54729] [PATCH] build: haskell-build-system: Support packages w. " zimoun
  2022-09-23  9:42 ` itd
  2 siblings, 1 reply; 16+ messages in thread
From: zimoun @ 2022-04-06 19:19 UTC (permalink / raw)
  To: 54729; +Cc: zimoun

* guix/build/haskell-build-system.scm (configure, install, setup-compiler,
make-ghc-package-database, install-transitive-deps, check, haddock,
patch-cabal-file, generate-setuphs): Delete trailing #t.
---
 guix/build/haskell-build-system.scm | 25 +++++++++----------------
 1 file changed, 9 insertions(+), 16 deletions(-)

diff --git a/guix/build/haskell-build-system.scm b/guix/build/haskell-build-system.scm
index ef6cb316ee..e2e5904dce 100644
--- a/guix/build/haskell-build-system.scm
+++ b/guix/build/haskell-build-system.scm
@@ -5,6 +5,7 @@
 ;;; Copyright © 2018, 2020 Ricardo Wurmus <rekado@elephly.net>
 ;;; Copyright © 2018 Alex Vong <alexvong1995@gmail.com>
 ;;; Copyright © 2021 John Kehayias <john.kehayias@protonmail.com>
+;;; Copyright © 2022 Simon Tournier <zimon.toutoune@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -118,8 +119,7 @@ (define* (configure #:key outputs inputs tests? (configure-flags '())
       (setenv "CONFIG_SHELL" "sh"))
     (run-setuphs "configure" params)
 
-    (setenv "GHC_PACKAGE_PATH" ghc-path)
-    #t))
+    (setenv "GHC_PACKAGE_PATH" ghc-path)))
 
 (define* (build #:key parallel-build? #:allow-other-keys)
   "Build a given Haskell package."
@@ -140,8 +140,7 @@ (define* (install #:key outputs #:allow-other-keys)
                          (new    (string-append static subdir)))
                     (mkdir-p (dirname new))
                     (rename-file static-lib new)))
-                (find-files lib "\\.a$"))))
-  #t)
+                (find-files lib "\\.a$")))))
 
 (define* (setup-compiler #:key system inputs outputs #:allow-other-keys)
   "Setup the compiler environment."
@@ -175,8 +174,7 @@ (define (make-ghc-package-database system inputs outputs)
               conf-files)
     (invoke "ghc-pkg"
             (string-append "--package-db=" %tmp-db-dir)
-            "recache")
-    #t))
+            "recache")))
 
 (define* (register #:key name system inputs outputs #:allow-other-keys)
   "Generate the compiler registration and binary package database files for a
@@ -273,21 +271,18 @@ (define (install-transitive-deps conf-file src dest)
                                     config-file-name+id ".conf"))
         (invoke "ghc-pkg"
                 (string-append "--package-db=" config-dir)
-                "recache")))
-    #t))
+                "recache")))))
 
 (define* (check #:key tests? test-target #:allow-other-keys)
   "Run the test suite of a given Haskell package."
   (if tests?
       (run-setuphs test-target '())
-      (format #t "test suite not run~%"))
-  #t)
+      (format #t "test suite not run~%")))
 
 (define* (haddock #:key outputs haddock? haddock-flags #:allow-other-keys)
   "Generate the Haddock documentation of a given Haskell package."
   (when haddock?
-    (run-setuphs "haddock" haddock-flags))
-  #t)
+    (run-setuphs "haddock" haddock-flags)))
 
 (define* (patch-cabal-file #:key cabal-revision #:allow-other-keys)
   (when cabal-revision
@@ -296,8 +291,7 @@ (define* (patch-cabal-file #:key cabal-revision #:allow-other-keys)
       ((original)
        (format #t "replacing ~s with ~s~%" original cabal-revision)
        (copy-file cabal-revision original))
-      (_ (error "Could not find a Cabal file to patch."))))
-  #t)
+      (_ (error "Could not find a Cabal file to patch.")))))
 
 (define* (generate-setuphs #:rest empty)
   "Generate a default Setup.hs if needed."
@@ -307,8 +301,7 @@ (define* (generate-setuphs #:rest empty)
     (with-output-to-file "Setup.hs"
       (lambda ()
         (format #t "import Distribution.Simple~%")
-        (format #t "main = defaultMain~%"))))
-  #t)
+        (format #t "main = defaultMain~%")))))
 
 (define %standard-phases
   (modify-phases gnu:%standard-phases

base-commit: e3e3381fdbc56f351063d9b4a49e99645b20d7d3
-- 
2.34.0





^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [bug#54729] [PATCH core-updates v2 2/2] build: haskell-build-system: Support multiple libraries.
  2022-04-06 19:19 ` [bug#54729] [PATCH core-updates v2 1/2] build: haskell-build-system: Remove trailing #t zimoun
@ 2022-04-06 19:19   ` zimoun
  0 siblings, 0 replies; 16+ messages in thread
From: zimoun @ 2022-04-06 19:19 UTC (permalink / raw)
  To: 54729; +Cc: Philip Munksgaard, zimoun

From: Philip Munksgaard <philip@munksgaard.me>

Fixes <https://bugs.gnu.org/53655>.

The patch handles correctly the multiple registration of some package using
their own internal sub-libraries.  It allows to call 'install-transitive-deps'
multiple times and deals with packages requiring a multiple registration.

* guix/build/haskell-build-system.scm (register)[install-transitive-deps]:
Guard also the destination direction.
[install-config-file]: New procedure.

Co-Authored-by: zimoun <zimon.toutoune@gmail.com>.
---
 guix/build/haskell-build-system.scm | 87 ++++++++++++++++-------------
 1 file changed, 49 insertions(+), 38 deletions(-)

diff --git a/guix/build/haskell-build-system.scm b/guix/build/haskell-build-system.scm
index e2e5904dce..fb4aba28ea 100644
--- a/guix/build/haskell-build-system.scm
+++ b/guix/build/haskell-build-system.scm
@@ -6,6 +6,7 @@
 ;;; Copyright © 2018 Alex Vong <alexvong1995@gmail.com>
 ;;; Copyright © 2021 John Kehayias <john.kehayias@protonmail.com>
 ;;; Copyright © 2022 Simon Tournier <zimon.toutoune@gmail.com>
+;;; Copyright © 2022 Philip Munksgaard <philip@munksgaard.me>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -215,13 +216,50 @@ (define (install-transitive-deps conf-file src dest)
          (if (not (vhash-assoc id seen))
              (let ((dep-conf  (string-append src  "/" id ".conf"))
                    (dep-conf* (string-append dest "/" id ".conf")))
-               (when (not (file-exists? dep-conf))
+               (unless (file-exists? dep-conf*)
+                 (unless (file-exists? dep-conf)
                    (error (format #f "File ~a does not exist. This usually means the dependency ~a is missing. Was checking conf-file ~a." dep-conf id conf-file)))
-               (copy-file dep-conf dep-conf*) ;XXX: maybe symlink instead?
-               (loop (vhash-cons id #t seen)
-                     (append lst (conf-depends dep-conf))))
+                 (copy-file dep-conf dep-conf*) ;XXX: maybe symlink instead?
+                 (loop (vhash-cons id #t seen)
+                       (append lst (conf-depends dep-conf)))))
              (loop seen tail))))))
 
+  (define (install-config-file conf-file dest output:doc output:lib)
+      ;; Copy CONF-FILE to DEST removing reference to OUTPUT:DOC from
+      ;; OUTPUT:LIB and using install-transitive-deps.
+      (let* ((contents (call-with-input-file conf-file read-string))
+             (id-rx (make-regexp "^id:[ \n\t]+([^ \t\n]+)$" regexp/newline))
+             (config-file-name+id
+              (match:substring (first (list-matches id-rx contents)) 1)))
+
+        (when (or
+               (and
+                (string? config-file-name+id)
+                (string-null? config-file-name+id))
+               (not config-file-name+id))
+          (error (format #f "The package id for ~a is empty. This is a bug." conf-file)))
+
+        ;; Remove reference to "doc" output from "lib" (or "out") by rewriting the
+        ;; "haddock-interfaces" field and removing the optional "haddock-html"
+        ;; field in the generated .conf file.
+        (when output:doc
+          (substitute* conf-file
+            (("^haddock-html: .*") "\n")
+            (((format #f "^haddock-interfaces: ~a" output:doc))
+             (string-append "haddock-interfaces: " output:lib)))
+          ;; Move the referenced file to the "lib" (or "out") output.
+          (match (find-files output:doc "\\.haddock$")
+            ((haddock-file . rest)
+             (let* ((subdir (string-drop haddock-file (string-length output:doc)))
+                    (new    (string-append output:lib subdir)))
+               (mkdir-p (dirname new))
+               (rename-file haddock-file new)))
+            (_ #f)))
+        (install-transitive-deps conf-file %tmp-db-dir dest)
+        (rename-file conf-file
+                     (string-append dest "/"
+                                    config-file-name+id ".conf"))))
+
   (let* ((out (assoc-ref outputs "out"))
          (doc (assoc-ref outputs "doc"))
          (haskell  (assoc-ref inputs "haskell"))
@@ -231,7 +269,6 @@ (define (install-transitive-deps conf-file src dest)
          (config-dir (string-append lib
                                     "/ghc-" version
                                     "/" name ".conf.d"))
-         (id-rx (make-regexp "^id:[ \n\t]+([^ \t\n]+)$" regexp/newline))
          (config-file (string-append out "/" name ".conf"))
          (params
           (list (string-append "--gen-pkg-config=" config-file))))
@@ -239,39 +276,13 @@ (define (install-transitive-deps conf-file src dest)
     ;; The conf file is created only when there is a library to register.
     (when (file-exists? config-file)
       (mkdir-p config-dir)
-      (let* ((contents (call-with-input-file config-file read-string))
-             (config-file-name+id (match:substring (first (list-matches id-rx contents)) 1)))
-
-        (when (or
-                (and
-                  (string? config-file-name+id)
-                  (string-null? config-file-name+id))
-                (not config-file-name+id))
-          (error (format #f "The package id for ~a is empty. This is a bug." config-file)))
-
-        ;; Remove reference to "doc" output from "lib" (or "out") by rewriting the
-        ;; "haddock-interfaces" field and removing the optional "haddock-html"
-        ;; field in the generated .conf file.
-        (when doc
-          (substitute* config-file
-            (("^haddock-html: .*") "\n")
-            (((format #f "^haddock-interfaces: ~a" doc))
-             (string-append "haddock-interfaces: " lib)))
-          ;; Move the referenced file to the "lib" (or "out") output.
-          (match (find-files doc "\\.haddock$")
-            ((haddock-file . rest)
-             (let* ((subdir (string-drop haddock-file (string-length doc)))
-                    (new    (string-append lib subdir)))
-               (mkdir-p (dirname new))
-               (rename-file haddock-file new)))
-            (_ #f)))
-        (install-transitive-deps config-file %tmp-db-dir config-dir)
-        (rename-file config-file
-                     (string-append config-dir "/"
-                                    config-file-name+id ".conf"))
-        (invoke "ghc-pkg"
-                (string-append "--package-db=" config-dir)
-                "recache")))))
+      (if (file-is-directory? config-file)
+          (for-each (cut install-config-file <> config-dir doc lib)
+           (find-files config-file))
+          (install-config-file config-file config-dir doc lib))
+      (invoke "ghc-pkg"
+              (string-append "--package-db=" config-dir)
+              "recache"))))
 
 (define* (check #:key tests? test-target #:allow-other-keys)
   "Run the test suite of a given Haskell package."
-- 
2.34.0





^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [bug#54729] [PATCH] build: haskell-build-system: Support packages w. multiple libraries
  2022-04-05 15:15 [bug#54729] [PATCH] build: haskell-build-system: Support packages w. multiple libraries Philip Munksgaard
  2022-04-06 19:19 ` [bug#54729] [PATCH core-updates v2 1/2] build: haskell-build-system: Remove trailing #t zimoun
@ 2022-04-06 19:23 ` zimoun
  2022-04-07  6:08   ` Lars-Dominik Braun
  2022-09-23  9:42 ` itd
  2 siblings, 1 reply; 16+ messages in thread
From: zimoun @ 2022-04-06 19:23 UTC (permalink / raw)
  To: Philip Munksgaard, rekado, lars; +Cc: 54729

Hi,

Thanks for your patch.  I have send a v2 ready for core-updates.

Ricardo or Lars, can you push this v2 to core-updates?

The simple test is to use attoparsec@0.14 from bug#53655 [1].  The
rebuild of this package takes less than half hour.

I have checked and rebuilt all the ghc- packages; nothing broken.


1: <https://issues.guix.gnu.org/53655>


Cheers,
simon




^ permalink raw reply	[flat|nested] 16+ messages in thread

* [bug#54729] [PATCH] build: haskell-build-system: Support packages w. multiple libraries
  2022-04-06 19:23 ` [bug#54729] [PATCH] build: haskell-build-system: Support packages w. " zimoun
@ 2022-04-07  6:08   ` Lars-Dominik Braun
  2022-04-07  6:49     ` Philip Munksgaard
                       ` (2 more replies)
  0 siblings, 3 replies; 16+ messages in thread
From: Lars-Dominik Braun @ 2022-04-07  6:08 UTC (permalink / raw)
  To: zimoun; +Cc: rekado, Philip Munksgaard, 54729

Hi simon,

> Ricardo or Lars, can you push this v2 to core-updates?
I’d rather have this in a separate wip-haskell branch than let it sit
on core-updates indefinitely. Stackage also has a new release[1] using
GHC 9.0, which we could update to at the same time.

Any other Haskell changes we can batch into that branch?

Cheers,
Lars

[1] https://www.stackage.org/lts-19.2





^ permalink raw reply	[flat|nested] 16+ messages in thread

* [bug#54729] [PATCH] build: haskell-build-system: Support packages w. multiple libraries
  2022-04-07  6:08   ` Lars-Dominik Braun
@ 2022-04-07  6:49     ` Philip Munksgaard
  2022-04-07  8:25       ` Philip Munksgaard
  2022-04-07  7:35     ` zimoun
  2022-04-13 18:59     ` Philip Munksgaard
  2 siblings, 1 reply; 16+ messages in thread
From: Philip Munksgaard @ 2022-04-07  6:49 UTC (permalink / raw)
  To: Lars-Dominik Braun, zimoun; +Cc: Ricardo Wurmus, 54729

Hi Lars

On Thu, 7 Apr 2022, at 08:08, Lars-Dominik Braun wrote:
> Any other Haskell changes we can batch into that branch?

I don't know of any finished patches, but there are some issues that would be nice to have fixed, like https://issues.guix.gnu.org/52152 (which also applies to attoparsec) and https://issues.guix.gnu.org/54752. However, I think it's more important to get this current patch merged.

Best,
Philip




^ permalink raw reply	[flat|nested] 16+ messages in thread

* [bug#54729] [PATCH] build: haskell-build-system: Support packages w. multiple libraries
  2022-04-07  6:08   ` Lars-Dominik Braun
  2022-04-07  6:49     ` Philip Munksgaard
@ 2022-04-07  7:35     ` zimoun
  2022-04-13 18:59     ` Philip Munksgaard
  2 siblings, 0 replies; 16+ messages in thread
From: zimoun @ 2022-04-07  7:35 UTC (permalink / raw)
  To: Lars-Dominik Braun; +Cc: rekado, Philip Munksgaard, 54729

Hi Lars,

On Thu, 07 Apr 2022 at 08:08, Lars-Dominik Braun <lars@6xq.net> wrote:

> I’d rather have this in a separate wip-haskell branch than let it sit
> on core-updates indefinitely. Stackage also has a new release[1] using
> GHC 9.0, which we could update to at the same time.
>
> Any other Haskell changes we can batch into that branch?

Ok, let’s do use this wip-haskell branch: fix the build system as this
v2 is doing and update LTS.  Currently, the wip-haskell is at:
c1522b280137df2f670f47fa1e682e610406bb39 (Thu Sep 30 09:29:51 2021
+0200), so let me know once you have rebase it to the current master.


Cheers,
simon




^ permalink raw reply	[flat|nested] 16+ messages in thread

* [bug#54729] [PATCH] build: haskell-build-system: Support packages w. multiple libraries
  2022-04-07  6:49     ` Philip Munksgaard
@ 2022-04-07  8:25       ` Philip Munksgaard
  0 siblings, 0 replies; 16+ messages in thread
From: Philip Munksgaard @ 2022-04-07  8:25 UTC (permalink / raw)
  To: Lars-Dominik Braun, zimoun; +Cc: Ricardo Wurmus, 54729

Hi again

On Thu, 7 Apr 2022, at 08:49, Philip Munksgaard wrote:
> Hi Lars
>
> On Thu, 7 Apr 2022, at 08:08, Lars-Dominik Braun wrote:
>> Any other Haskell changes we can batch into that branch?
>
> I don't know of any finished patches, but there are some issues that 
> would be nice to have fixed, like https://issues.guix.gnu.org/52152 
> (which also applies to attoparsec) and 
> https://issues.guix.gnu.org/54752. However, I think it's more important 
> to get this current patch merged.

I've also created a new issue for invalid dependencies generated by multiple libraries in one package:

https://issues.guix.gnu.org/54760




^ permalink raw reply	[flat|nested] 16+ messages in thread

* [bug#54729] [PATCH] build: haskell-build-system: Support packages w. multiple libraries
  2022-04-07  6:08   ` Lars-Dominik Braun
  2022-04-07  6:49     ` Philip Munksgaard
  2022-04-07  7:35     ` zimoun
@ 2022-04-13 18:59     ` Philip Munksgaard
  2022-04-14 18:21       ` Lars-Dominik Braun
  2 siblings, 1 reply; 16+ messages in thread
From: Philip Munksgaard @ 2022-04-13 18:59 UTC (permalink / raw)
  To: Lars-Dominik Braun, zimoun; +Cc: Ricardo Wurmus, 54729

Hi again

On Thu, 7 Apr 2022, at 08:08, Lars-Dominik Braun wrote:
> I’d rather have this in a separate wip-haskell branch than let it sit
> on core-updates indefinitely. Stackage also has a new release[1] using
> GHC 9.0, which we could update to at the same time.

Any news on this? Was the branch created? I can't seem to find it on https://git.savannah.gnu.org, and the changes haven't made it into master, as far as I can tell.

Best,
Philip




^ permalink raw reply	[flat|nested] 16+ messages in thread

* [bug#54729] [PATCH] build: haskell-build-system: Support packages w. multiple libraries
  2022-04-13 18:59     ` Philip Munksgaard
@ 2022-04-14 18:21       ` Lars-Dominik Braun
  2022-04-15  8:19         ` Philip Munksgaard
  0 siblings, 1 reply; 16+ messages in thread
From: Lars-Dominik Braun @ 2022-04-14 18:21 UTC (permalink / raw)
  To: Philip Munksgaard; +Cc: Ricardo Wurmus, 54729, zimoun

Hi Philip,

> Any news on this? Was the branch created? I can't seem to find it on https://git.savannah.gnu.org, and the changes haven't made it into master, as far as I can tell.

sorry, I’ve been busy rebasing my new python-build-system (PEP 517) on
top of master.

I created the branch wip-haskell and pushed zimoun’s v2 – I
hope that’s alright with you Philip? (I didn’t check the patches
thoroughly, just tried to build attoparsec.)

Cheers,
Lars





^ permalink raw reply	[flat|nested] 16+ messages in thread

* [bug#54729] [PATCH] build: haskell-build-system: Support packages w. multiple libraries
  2022-04-14 18:21       ` Lars-Dominik Braun
@ 2022-04-15  8:19         ` Philip Munksgaard
  0 siblings, 0 replies; 16+ messages in thread
From: Philip Munksgaard @ 2022-04-15  8:19 UTC (permalink / raw)
  To: Lars-Dominik Braun; +Cc: Ricardo Wurmus, 54729, zimoun

Hi Lars

On Thu, 14 Apr 2022, at 20:21, Lars-Dominik Braun wrote:
> sorry, I’ve been busy rebasing my new python-build-system (PEP 517) on
> top of master.

No worries, I just wanted to make sure it wasn't forgotten :-)

> I created the branch wip-haskell and pushed zimoun’s v2 – I
> hope that’s alright with you Philip? (I didn’t check the patches
> thoroughly, just tried to build attoparsec.)

Yeah that sounds perfect.

Best,
Philip




^ permalink raw reply	[flat|nested] 16+ messages in thread

* [bug#54729] [PATCH] build: haskell-build-system: Support packages w. multiple libraries
  2022-04-05 15:15 [bug#54729] [PATCH] build: haskell-build-system: Support packages w. multiple libraries Philip Munksgaard
  2022-04-06 19:19 ` [bug#54729] [PATCH core-updates v2 1/2] build: haskell-build-system: Remove trailing #t zimoun
  2022-04-06 19:23 ` [bug#54729] [PATCH] build: haskell-build-system: Support packages w. " zimoun
@ 2022-09-23  9:42 ` itd
  2022-12-21 12:48   ` itd
  2023-01-06 11:51   ` Lars-Dominik Braun
  2 siblings, 2 replies; 16+ messages in thread
From: itd @ 2022-09-23  9:42 UTC (permalink / raw)
  To: 54729

[-- Attachment #1: Type: text/plain, Size: 2943 bytes --]

Hi,

thanks for the patch!  I applied it, tried it, and ran into some build
issues.  Maybe I missed something; here is (roughly) what I tried:

$ # apply diff to current master
$ git checkout a57c4eff6bbdcff79294fa15ecb95ab2b3c55bb4
$ git checkout origin/wip-haskell -- guix/build/haskell-build-system.scm
$ # bump ghc-attoparsec version
$ git diff gnu/packages/haskell-xyz.scm
diff --git a/gnu/packages/haskell-xyz.scm b/gnu/packages/haskell-xyz.scm
index db653f8c93..c4da66aa4a 100644
--- a/gnu/packages/haskell-xyz.scm
+++ b/gnu/packages/haskell-xyz.scm
@@ -589,7 +589,7 @@ (define-public ghc-atomic-write-0.2.0.7
 (define-public ghc-attoparsec
   (package
     (name "ghc-attoparsec")
-    (version "0.13.2.5")
+    (version "0.14.4")
     (source
      (origin
        (method url-fetch)
@@ -599,10 +599,12 @@ (define-public ghc-attoparsec
              ".tar.gz"))
        (sha256
         (base32
-         "0vv88m5m7ynjrg114psp4j4s69f1a5va3bvn293vymqrma7g7q11"))))
+         "0v4yjz4qi8bwhbyavqxlhsfb1iv07v10gxi64khmsmi4hvjpycrz"))))
     (build-system haskell-build-system)
     (arguments
-     `(#:phases
+     `(#:cabal-revision
+       ("2" "00jyrn2asz1kp698l3fyh19xxxz4npf1993y041x9b9cq239smn0")
+       #:phases
        (modify-phases %standard-phases
          (add-after 'unpack 'patch-for-newer-quickcheck
            (lambda _
$ # build ghc-attoparsec-iso8601 which depends on ghc-attoparsec
$ guix shell -D guix help2man git strace --pure # & bootstrap & ...
$ ./pre-inst-env guix build ghc-attoparsec-iso8601

After some time, this build failed with:

> phase `setup-compiler' succeeded after 0.1 seconds
> starting phase `configure'
> running "runhaskell Setup.hs" with command "configure" and parameters ("--prefix=/gnu/store/70ddgy9ayd4239dp37b7kvcsdxkg5nrj-ghc-attoparsec-iso8601-1.0.2.0" "--libdir=/gnu/store/70ddgy9ayd4239dp37b7kvcsdxkg5nrj-ghc-attoparsec-iso8601-1.0.2.0/lib" "--docdir=/gnu/store/70ddgy9ayd4239dp37b7kvcsdxkg5nrj-ghc-attoparsec-iso8601-1.0.2.0/share/doc/ghc-attoparsec-iso8601-1.0.2.0" "--libsubdir=$compiler/$pkg-$version" "--package-db=/tmp/guix-build-ghc-attoparsec-iso8601-1.0.2.0.drv-0/package.conf.d" "--global" "--enable-tests" "--enable-shared" "--enable-executable-dynamic" "--ghc-option=-fPIC" "--ghc-option=-optl=-Wl,-rpath=/gnu/store/70ddgy9ayd4239dp37b7kvcsdxkg5nrj-ghc-attoparsec-iso8601-1.0.2.0/lib/$compiler/$pkg-$version")
> Configuring attoparsec-iso8601-1.0.2.0...
> Error:
>     The following packages are broken because other packages they depend on are missing. These broken packages must be rebuilt before they can be used.
> installed package attoparsec-0.14.4 is broken due to missing package scientific-0.3.7.0-9XG3zUjXOw970JFcruv0cZ


Ignorant of the patch provided here, I tried to build newer versions of
ghc-attoparsec / its dependants and ended up with the attached patch.
Using this patch, the build succeeds (but I am not sure if the patch's
approach is sensible).

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-WIP-update-haskell-build-system-for-newer-attoparsec.patch --]
[-- Type: text/x-diff, Size: 6392 bytes --]

From 959dc9de2d4aa39b7490b4c90e28820edf0d00f9 Mon Sep 17 00:00:00 2001
From: itd <itd@net.in.tum.de>
Date: Fri, 23 Sep 2022 10:58:09 +0200
Subject: [PATCH] WIP update haskell-build-system for newer attoparsec

---
 guix/build/haskell-build-system.scm | 86 +++++++++++++++++------------
 1 file changed, 51 insertions(+), 35 deletions(-)

diff --git a/guix/build/haskell-build-system.scm b/guix/build/haskell-build-system.scm
index ef6cb316ee..d4c4ed4c8c 100644
--- a/guix/build/haskell-build-system.scm
+++ b/guix/build/haskell-build-system.scm
@@ -219,7 +219,10 @@ (define* (register #:key name system inputs outputs #:allow-other-keys)
                    (dep-conf* (string-append dest "/" id ".conf")))
                (when (not (file-exists? dep-conf))
                    (error (format #f "File ~a does not exist. This usually means the dependency ~a is missing. Was checking conf-file ~a." dep-conf id conf-file)))
-               (copy-file dep-conf dep-conf*) ;XXX: maybe symlink instead?
+               ;; Different libraries of same package may share
+               ;; dependencies. Hence, file may exist already.
+               (when (not (file-exists? dep-conf*))
+                   (copy-file dep-conf dep-conf*)) ;XXX: maybe symlink instead?
                (loop (vhash-cons id #t seen)
                      (append lst (conf-depends dep-conf))))
              (loop seen tail))))))
@@ -234,46 +237,59 @@ (define* (register #:key name system inputs outputs #:allow-other-keys)
                                     "/ghc-" version
                                     "/" name ".conf.d"))
          (id-rx (make-regexp "^id:[ \n\t]+([^ \t\n]+)$" regexp/newline))
-         (config-file (string-append out "/" name ".conf"))
+         (maybe-config-file (string-append out "/" name ".conf"))
          (params
-          (list (string-append "--gen-pkg-config=" config-file))))
+          (list (string-append "--gen-pkg-config=" maybe-config-file))))
     (run-setuphs "register" params)
     ;; The conf file is created only when there is a library to register.
-    (when (file-exists? config-file)
+    (when (file-exists? maybe-config-file)
       (mkdir-p config-dir)
-      (let* ((contents (call-with-input-file config-file read-string))
-             (config-file-name+id (match:substring (first (list-matches id-rx contents)) 1)))
+      ;; If more that one library is defined, they share conf file as
+      ;; parent directory.
+      (let* ((config-files (if (file-is-directory? maybe-config-file)
+                             (find-files maybe-config-file)
+                             (list maybe-config-file))))
+        (map
+          (lambda (config-file)
+            (let* ((contents (call-with-input-file config-file read-string))
+                   (config-file-name+id (match:substring (first (list-matches id-rx contents)) 1)))
 
-        (when (or
-                (and
-                  (string? config-file-name+id)
-                  (string-null? config-file-name+id))
-                (not config-file-name+id))
-          (error (format #f "The package id for ~a is empty. This is a bug." config-file)))
+              (when (or
+                      (and
+                        (string? config-file-name+id)
+                        (string-null? config-file-name+id))
+                      (not config-file-name+id))
+                (error (format #f "The package id for ~a is empty. This is a bug." config-file)))
 
-        ;; Remove reference to "doc" output from "lib" (or "out") by rewriting the
-        ;; "haddock-interfaces" field and removing the optional "haddock-html"
-        ;; field in the generated .conf file.
-        (when doc
-          (substitute* config-file
-            (("^haddock-html: .*") "\n")
-            (((format #f "^haddock-interfaces: ~a" doc))
-             (string-append "haddock-interfaces: " lib)))
-          ;; Move the referenced file to the "lib" (or "out") output.
-          (match (find-files doc "\\.haddock$")
-            ((haddock-file . rest)
-             (let* ((subdir (string-drop haddock-file (string-length doc)))
-                    (new    (string-append lib subdir)))
-               (mkdir-p (dirname new))
-               (rename-file haddock-file new)))
-            (_ #f)))
-        (install-transitive-deps config-file %tmp-db-dir config-dir)
-        (rename-file config-file
-                     (string-append config-dir "/"
-                                    config-file-name+id ".conf"))
-        (invoke "ghc-pkg"
-                (string-append "--package-db=" config-dir)
-                "recache")))
+              ;; Remove reference to "doc" output from "lib" (or "out") by rewriting the
+              ;; "haddock-interfaces" field and removing the optional "haddock-html"
+              ;; field in the generated .conf file.
+              (when doc
+                (substitute* config-file
+                  (("^haddock-html: .*") "\n")
+                  (((format #f "^haddock-interfaces: ~a" doc))
+                   (string-append "haddock-interfaces: " lib)))
+                ;; Move the referenced file to the "lib" (or "out") output.
+                (match (find-files doc "\\.haddock$")
+                  ((haddock-file . rest)
+                   (let* ((subdir (string-drop haddock-file (string-length doc)))
+                          (new    (string-append lib subdir)))
+                     (mkdir-p (dirname new))
+                     (rename-file haddock-file new)))
+                  (_ #f)))
+              (install-transitive-deps config-file %tmp-db-dir config-dir)
+              ;; Make current conf file available for possible
+              ;; subsequent conf files.
+              (copy-file config-file
+                         (string-append %tmp-db-dir "/"
+                                        config-file-name+id ".conf"))
+              (rename-file config-file
+                           (string-append config-dir "/"
+                                          config-file-name+id ".conf"))
+              (invoke "ghc-pkg"
+                      (string-append "--package-db=" config-dir)
+                      "recache")))
+          config-files)))
     #t))
 
 (define* (check #:key tests? test-target #:allow-other-keys)

base-commit: a57c4eff6bbdcff79294fa15ecb95ab2b3c55bb4
-- 
2.37.3


[-- Attachment #3: Type: text/plain, Size: 13 bytes --]


Regards
itd

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [bug#54729] [PATCH] build: haskell-build-system: Support packages w. multiple libraries
  2022-09-23  9:42 ` itd
@ 2022-12-21 12:48   ` itd
  2022-12-23 14:03     ` Philip Munksgaard
  2023-01-06 11:51   ` Lars-Dominik Braun
  1 sibling, 1 reply; 16+ messages in thread
From: itd @ 2022-12-21 12:48 UTC (permalink / raw)
  To: Lars-Dominik Braun; +Cc: Philip Munksgaard, 54729, zimoun

Dear Haskell team,
dear all,

itd <itd@net.in.tum.de> writes:

> thanks for the patch!  I applied it, tried it, and ran into some build
> issues. [...]
> Ignorant of the patch provided here, I tried to build newer versions of
> ghc-attoparsec / its dependants and ended up with the attached patch.
> Using this patch, the build succeeds (but I am not sure if the patch's
> approach is sensible). [...]

if possible, I'd appreciate feedback on my previous mail.  E.g., does my
attempt in using the originally proposed patch make sense?  Any opinions
on my patch?

Thank you.

Regards
itd




^ permalink raw reply	[flat|nested] 16+ messages in thread

* [bug#54729] [PATCH] build: haskell-build-system: Support packages w. multiple libraries
  2022-12-21 12:48   ` itd
@ 2022-12-23 14:03     ` Philip Munksgaard
  0 siblings, 0 replies; 16+ messages in thread
From: Philip Munksgaard @ 2022-12-23 14:03 UTC (permalink / raw)
  To: itd, Lars-Dominik Braun; +Cc: 54729, zimoun

Dear itd,

On Wed, 21 Dec 2022, at 13:48, itd wrote:
> if possible, I'd appreciate feedback on my previous mail.  E.g., does my
> attempt in using the originally proposed patch make sense?  Any opinions
> on my patch?

Yes, I've been meaning to try out your patch, but I haven't had time yet. I will try to get to it over the holidays. Sorry for my tardiness.

Best holiday wishes,
Philip 




^ permalink raw reply	[flat|nested] 16+ messages in thread

* [bug#54729] [PATCH] build: haskell-build-system: Support packages w. multiple libraries
  2022-09-23  9:42 ` itd
  2022-12-21 12:48   ` itd
@ 2023-01-06 11:51   ` Lars-Dominik Braun
  2023-01-12 17:30     ` itd
  1 sibling, 1 reply; 16+ messages in thread
From: Lars-Dominik Braun @ 2023-01-06 11:51 UTC (permalink / raw)
  To: itd; +Cc: Philip Munksgaard, 54729

[-- Attachment #1: Type: text/plain, Size: 580 bytes --]

Hi,

> >     The following packages are broken because other packages they depend on are missing. These broken packages must be rebuilt before they can be used.
> > installed package attoparsec-0.14.4 is broken due to missing package scientific-0.3.7.0-9XG3zUjXOw970JFcruv0cZ
I can reproduce the problem on wip-haskell, which also uses
attoparsec-0.14.4 and GHC 9.2.5.

Further analysis suggests that this is a different issue, which is simply
exposed by attoparsec’s multiple libraries. I applied the attached
patch to wip-haskell, which fixes the issue for me.

Cheers,
Lars


[-- Attachment #2: 0001-build-haskell-build-system-Process-all-transitive-de.patch --]
[-- Type: text/plain, Size: 2697 bytes --]

From 272dc241677872a235e19135885599a18ef5f102 Mon Sep 17 00:00:00 2001
From: Lars-Dominik Braun <lars@6xq.net>
Date: Fri, 6 Jan 2023 12:46:26 +0100
Subject: [PATCH] build: haskell-build-system: Process all transitive
 dependencies.

A bug caused install-transitive-deps to stop looping if a dependency
file already existed in the target directory. For Haskell packages
with multiple libraries (like attoparsec) this resulted in missing
dependencies and error messages like this:

    The following packages are broken because other packages they depend
    on are missing. These broken packages must be rebuilt before they
    can be used.
    installed package attoparsec-0.14.4 is broken due to missing package
    scientific-0.3.7.0-9XG3zUjXOw970JFcruv0cZ

See <https://issues.guix.gnu.org/54729#11>.

* guix/build/haskell-build-system.scm (register): Unconditionally loop
over all tails.
---
 guix/build/haskell-build-system.scm | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/guix/build/haskell-build-system.scm b/guix/build/haskell-build-system.scm
index fb4aba28ea..72e12ba746 100644
--- a/guix/build/haskell-build-system.scm
+++ b/guix/build/haskell-build-system.scm
@@ -214,14 +214,16 @@ (define (install-transitive-deps conf-file src dest)
         (() #t)                         ;done
         ((id . tail)
          (if (not (vhash-assoc id seen))
-             (let ((dep-conf  (string-append src  "/" id ".conf"))
-                   (dep-conf* (string-append dest "/" id ".conf")))
-               (unless (file-exists? dep-conf*)
-                 (unless (file-exists? dep-conf)
+             (let* ((dep-conf  (string-append src  "/" id ".conf"))
+                    (dep-conf* (string-append dest "/" id ".conf"))
+                    (dep-conf-exists? (file-exists? dep-conf))
+                    (dep-conf*-exists? (file-exists? dep-conf*))
+                    (next-tail (append lst (if dep-conf-exists? (conf-depends dep-conf) '()))))
+               (unless dep-conf*-exists?
+                 (unless dep-conf-exists?
                    (error (format #f "File ~a does not exist. This usually means the dependency ~a is missing. Was checking conf-file ~a." dep-conf id conf-file)))
-                 (copy-file dep-conf dep-conf*) ;XXX: maybe symlink instead?
-                 (loop (vhash-cons id #t seen)
-                       (append lst (conf-depends dep-conf)))))
+                 (copy-file dep-conf dep-conf*)) ;XXX: maybe symlink instead?
+                (loop (vhash-cons id #t seen) next-tail))
              (loop seen tail))))))
 
   (define (install-config-file conf-file dest output:doc output:lib)
-- 
2.38.2


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [bug#54729] [PATCH] build: haskell-build-system: Support packages w. multiple libraries
  2023-01-06 11:51   ` Lars-Dominik Braun
@ 2023-01-12 17:30     ` itd
  0 siblings, 0 replies; 16+ messages in thread
From: itd @ 2023-01-12 17:30 UTC (permalink / raw)
  To: Lars-Dominik Braun; +Cc: Philip Munksgaard, 54729

Hi,

Lars-Dominik Braun <lars@6xq.net> writes:

> I can reproduce the problem on wip-haskell, which also uses
> attoparsec-0.14.4 and GHC 9.2.5.

thanks for checking!

> Further analysis suggests that this is a different issue, which is simply
> exposed by attoparsec’s multiple libraries. I applied the attached
> patch to wip-haskell, which fixes the issue for me.

Thanks for looking into it.  I can confirm that the wip-haskell changes
combined with this patch fix the issue for me as well.

Best regards
itd




^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2023-01-12 18:15 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-05 15:15 [bug#54729] [PATCH] build: haskell-build-system: Support packages w. multiple libraries Philip Munksgaard
2022-04-06 19:19 ` [bug#54729] [PATCH core-updates v2 1/2] build: haskell-build-system: Remove trailing #t zimoun
2022-04-06 19:19   ` [bug#54729] [PATCH core-updates v2 2/2] build: haskell-build-system: Support multiple libraries zimoun
2022-04-06 19:23 ` [bug#54729] [PATCH] build: haskell-build-system: Support packages w. " zimoun
2022-04-07  6:08   ` Lars-Dominik Braun
2022-04-07  6:49     ` Philip Munksgaard
2022-04-07  8:25       ` Philip Munksgaard
2022-04-07  7:35     ` zimoun
2022-04-13 18:59     ` Philip Munksgaard
2022-04-14 18:21       ` Lars-Dominik Braun
2022-04-15  8:19         ` Philip Munksgaard
2022-09-23  9:42 ` itd
2022-12-21 12:48   ` itd
2022-12-23 14:03     ` Philip Munksgaard
2023-01-06 11:51   ` Lars-Dominik Braun
2023-01-12 17:30     ` itd

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).