unofficial mirror of guix-patches@gnu.org 
 help / color / Atom feed
* [bug#42014] [PATCH] WIP: gnu: Re-bootstrap Haskell with GHC 8.2.2 binaries.
@ 2020-06-23  1:48 Alex Griffin via Guix-patches via
  2020-06-27 21:16 ` [bug#42014] [PATCH] WIP: gnu: ghc@8.4: Support 32- and 64-bit ARM systems Alex Griffin via Guix-patches via
  2020-06-27 21:21 ` [bug#42014] [PATCH] WIP: gnu: Re-bootstrap Haskell with GHC 8.2.2 binaries Ricardo Wurmus
  0 siblings, 2 replies; 4+ messages in thread
From: Alex Griffin via Guix-patches via @ 2020-06-23  1:48 UTC (permalink / raw)
  To: 42014

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

This patch replaces the GHC 7.8.4 bootstrap binaries with binaries of GHC 8.2.2, with an eye towards supporting ARM systems. I have not yet succeeded in bootstrapping GHC on ARM, but 8.2.2 is the first release with official binary distributions for both armv7 and aarch64.
--
Alex Griffin


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-gnu-Re-bootstrap-Haskell-with-GHC-8.2.2-binaries.patch --]
[-- Type: text/x-patch; name=0001-gnu-Re-bootstrap-Haskell-with-GHC-8.2.2-binaries.patch, Size: 24131 bytes --]

From 6998f89c2d29278363e509603ad89067133a2ae1 Mon Sep 17 00:00:00 2001
From: Alex Griffin <a@ajgrf.com>
Date: Mon, 22 Jun 2020 11:45:54 -0500
Subject: [PATCH] gnu: Re-bootstrap Haskell with GHC 8.2.2 binaries.

* gnu/packages/haskell.scm (ghc-8.4): Move inherited fields to package
definition.
[native-inputs]: Add patchelf and ghc-binary.
[arguments]: Add new phases unpack-bin, configure-bin, and install-bin.
(ghc-bootstrap-x86_64-7.8.4, ghc-bootstrap-i686-7.8.4, ghc-7,
ghc-8.0): Delete variables.
(ghc-bootstrap-x86_64-8.2.2, ghc-bootstrap-i686-8.2.2): New variables.
(ghc-8.6)[arguments]: Delete new phases added to ghc-8.4.
---
 gnu/packages/haskell.scm | 415 ++++++++++-----------------------------
 1 file changed, 106 insertions(+), 309 deletions(-)

diff --git a/gnu/packages/haskell.scm b/gnu/packages/haskell.scm
index 1533302dcc..ac5ad14320 100644
--- a/gnu/packages/haskell.scm
+++ b/gnu/packages/haskell.scm
@@ -20,6 +20,7 @@
 ;;; Copyright © 2019 Robert Vollmert <rob@vllmrt.net>
 ;;; Copyright © 2019 Jacob MacDonald <jaccarmac@gmail.com>
 ;;; Copyright © 2020 Marius Bakke <mbakke@fastmail.com>
+;;; Copyright © 2020 Alex Griffin <a@ajgrf.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -96,323 +97,26 @@
 top of CLISP.")
       (license license:bsd-4))))
 
-(define ghc-bootstrap-x86_64-7.8.4
+(define ghc-bootstrap-x86_64-8.2.2
   (origin
     (method url-fetch)
     (uri
-     "https://www.haskell.org/ghc/dist/7.8.4/ghc-7.8.4-x86_64-unknown-linux-deb7.tar.xz")
+     "https://www.haskell.org/ghc/dist/8.2.2/ghc-8.2.2-x86_64-deb8-linux.tar.xz")
     (sha256
      (base32
-      "13azsl53xgj20mi1hj9x0xb32vvcvs6cpmvwx6znxhas7blh0bpn"))))
+      "0ahv26304pqi3dm7i78si4pxwvg5f5dc2jwsfgvcrhcx5g30bqj8"))))
 
-(define ghc-bootstrap-i686-7.8.4
+(define ghc-bootstrap-i686-8.2.2
   (origin
     (method url-fetch)
     (uri
-     "https://www.haskell.org/ghc/dist/7.8.4/ghc-7.8.4-i386-unknown-linux-deb7.tar.xz")
+     "https://www.haskell.org/ghc/dist/8.2.2/ghc-8.2.2-i386-deb8-linux.tar.xz")
     (sha256
      (base32
-      "0wj5s435j0zgww70bj1d3f6wvnnpzlxwvwcyh2qv4qjq5z8j64kg"))))
-
-;; 43 tests out of 3965 fail.
-;;
-;; Most of them do not appear to be serious:
-;;
-;; - some tests generate files referring to "/bin/sh" and "/bin/ls". I've not
-;;   figured out how these references are generated.
-;;
-;; - Some tests allocate more memory than expected (ca. 3% above upper limit)
-;;
-;; - Some tests try to load unavailable libriries: Control.Concurrent.STM,
-;;   Data.Vector, Control.Monad.State.
-;;
-;; - Test posix010 tries to check the existence of a user on the system:
-;;   getUserEntryForName: does not exist (no such user)
-(define-public ghc-7
-  (package
-    (name "ghc")
-    (version "7.10.2")
-    (source
-     (origin
-      (method url-fetch)
-      (uri (string-append "https://www.haskell.org/ghc/dist/"
-                          version "/" name "-" version "-src.tar.xz"))
-      (sha256
-       (base32
-        "1x8m4rp2v7ydnrz6z9g8x7z3x3d3pxhv2pixy7i7hkbqbdsp7kal"))))
-    (build-system gnu-build-system)
-    (supported-systems '("i686-linux" "x86_64-linux"))
-    (outputs '("out" "doc"))
-    (inputs
-     `(("gmp" ,gmp)
-       ("ncurses" ,ncurses)
-       ("libffi" ,libffi)
-       ("ghc-testsuite"
-        ,(origin
-           (method url-fetch)
-           (uri (string-append
-                 "https://www.haskell.org/ghc/dist/"
-                 version "/" name "-" version "-testsuite.tar.xz"))
-           (sha256
-            (base32
-             "0qp9da9ar87zbyn6wjgacd2ic1vgzbi3cklxnhsmjqyafv9qaj4b"))))))
-    (native-inputs
-     `(("perl" ,perl)
-       ("python" ,python-2)                ; for tests (fails with python-3)
-       ("ghostscript" ,ghostscript)        ; for tests
-       ("patchelf" ,patchelf)
-       ;; GHC is built with GHC. Therefore we need bootstrap binaries.
-       ("ghc-binary"
-        ,(if (string-match "x86_64" (or (%current-target-system) (%current-system)))
-             ghc-bootstrap-x86_64-7.8.4
-             ghc-bootstrap-i686-7.8.4))))
-    (arguments
-     `(#:test-target "test"
-       ;; We get a smaller number of test failures by disabling parallel test
-       ;; execution.
-       #:parallel-tests? #f
-
-       ;; Don't pass --build=<triplet>, because the configure script
-       ;; auto-detects slightly different triplets for --host and --target and
-       ;; then complains that they don't match.
-       #:build #f
-
-       #:modules ((guix build gnu-build-system)
-                  (guix build utils)
-                  (guix build rpath)
-                  (srfi srfi-26)
-                  (srfi srfi-1))
-       #:imported-modules (,@%gnu-build-system-modules
-                           (guix build rpath))
-       #:configure-flags
-       (list
-        (string-append "--with-gmp-libraries="
-                       (assoc-ref %build-inputs "gmp") "/lib")
-        (string-append "--with-gmp-includes="
-                       (assoc-ref %build-inputs "gmp") "/include")
-        "--with-system-libffi"
-        (string-append "--with-ffi-libraries="
-                       (assoc-ref %build-inputs "libffi") "/lib")
-        (string-append "--with-ffi-includes="
-                       (assoc-ref %build-inputs "libffi") "/include"))
-       ;; FIXME: The user-guide needs dblatex, docbook-xsl and docbook-utils.
-       ;; Currently we do not have the last one.
-       ;; #:make-flags
-       ;; (list "BUILD_DOCBOOK_HTML = YES")
-       #:phases
-       (let* ((ghc-bootstrap-path
-               (string-append (getcwd) "/" ,name "-" ,version "/ghc-bin"))
-              (ghc-bootstrap-prefix
-               (string-append ghc-bootstrap-path "/usr" )))
-         (alist-cons-after
-          'unpack-bin 'unpack-testsuite-and-fix-bins
-          (lambda* (#:key inputs outputs #:allow-other-keys)
-            (with-directory-excursion ".."
-              (copy-file (assoc-ref inputs "ghc-testsuite")
-                         "ghc-testsuite.tar.xz")
-              (system* "tar" "xvf" "ghc-testsuite.tar.xz"))
-            (substitute*
-                (list "testsuite/timeout/Makefile"
-                      "testsuite/timeout/timeout.py"
-                      "testsuite/timeout/timeout.hs"
-                      "testsuite/tests/rename/prog006/Setup.lhs"
-                      "testsuite/tests/programs/life_space_leak/life.test"
-                      "libraries/process/System/Process/Internals.hs"
-                      "libraries/unix/cbits/execvpe.c")
-              (("/bin/sh") (which "sh"))
-              (("/bin/rm") "rm"))
-            #t)
-          (alist-cons-after
-           'unpack 'unpack-bin
-           (lambda* (#:key inputs outputs #:allow-other-keys)
-             (mkdir-p ghc-bootstrap-prefix)
-             (with-directory-excursion ghc-bootstrap-path
-               (copy-file (assoc-ref inputs "ghc-binary")
-                          "ghc-bin.tar.xz")
-               (zero? (system* "tar" "xvf" "ghc-bin.tar.xz"))))
-           (alist-cons-before
-            'install-bin 'configure-bin
-            (lambda* (#:key inputs outputs #:allow-other-keys)
-              (let* ((binaries
-                      (list
-                       "./utils/ghc-pwd/dist-install/build/tmp/ghc-pwd"
-                       "./utils/hpc/dist-install/build/tmp/hpc"
-                       "./utils/haddock/dist/build/tmp/haddock"
-                       "./utils/hsc2hs/dist-install/build/tmp/hsc2hs"
-                       "./utils/runghc/dist-install/build/tmp/runghc"
-                       "./utils/ghc-cabal/dist-install/build/tmp/ghc-cabal"
-                       "./utils/hp2ps/dist/build/tmp/hp2ps"
-                       "./utils/ghc-pkg/dist-install/build/tmp/ghc-pkg"
-                       "./utils/unlit/dist/build/tmp/unlit"
-                       "./ghc/stage2/build/tmp/ghc-stage2"))
-                     (gmp (assoc-ref inputs "gmp"))
-                     (gmp-lib (string-append gmp "/lib"))
-                     (gmp-include (string-append gmp "/include"))
-                     (ncurses-lib
-                      (string-append (assoc-ref inputs "ncurses") "/lib"))
-                     (ld-so (string-append (assoc-ref inputs "libc")
-                                           ,(glibc-dynamic-linker)))
-                     (libtinfo-dir
-                      (string-append ghc-bootstrap-prefix
-                                     "/lib/ghc-7.8.4/terminfo-0.4.0.0")))
-                (with-directory-excursion
-                    (string-append ghc-bootstrap-path "/ghc-7.8.4")
-                  (setenv "CONFIG_SHELL" (which "bash"))
-                  (setenv "LD_LIBRARY_PATH" gmp-lib)
-                  ;; The binaries have "/lib64/ld-linux-x86-64.so.2" hardcoded.
-                  (for-each
-                   (cut system* "patchelf" "--set-interpreter" ld-so <>)
-                   binaries)
-                  ;; The binaries include a reference to libtinfo.so.5 which
-                  ;; is a subset of libncurses.so.5.  We create a symlink in a
-                  ;; directory included in the bootstrap binaries rpath.
-                  (mkdir-p libtinfo-dir)
-                  (symlink
-                   (string-append ncurses-lib "/libncursesw.so."
-                                  ;; Extract "6.0" from "6.0-20170930" if a
-                                  ;; dash-separated version tag exists.
-                                  ,(let* ((v (package-version ncurses))
-                                          (d (or (string-index v #\-)
-                                                 (string-length v))))
-                                     (version-major+minor (string-take v d))))
-                   (string-append libtinfo-dir "/libtinfo.so.5"))
-
-                  (setenv "PATH"
-                          (string-append (getenv "PATH") ":"
-                                         ghc-bootstrap-prefix "/bin"))
-                  (system*
-                   (string-append (getcwd) "/configure")
-                   (string-append "--prefix=" ghc-bootstrap-prefix)
-                   (string-append "--with-gmp-libraries=" gmp-lib)
-                   (string-append "--with-gmp-includes=" gmp-include)))))
-            (alist-cons-before
-             'configure 'install-bin
-             (lambda* (#:key inputs outputs #:allow-other-keys)
-               (with-directory-excursion
-                   (string-append ghc-bootstrap-path "/ghc-7.8.4")
-                 (zero? (system* "make" "install"))))
-             %standard-phases)))))))
-    (native-search-paths (list (search-path-specification
-                                (variable "GHC_PACKAGE_PATH")
-                                (files (list
-                                        (string-append "lib/ghc-" version)))
-                                (file-pattern ".*\\.conf\\.d$")
-                                (file-type 'directory))))
-    (home-page "https://www.haskell.org/ghc")
-    (synopsis "The Glasgow Haskell Compiler")
-    (description
-     "The Glasgow Haskell Compiler (GHC) is a state-of-the-art compiler and
-interactive environment for the functional language Haskell.")
-    (license license:bsd-3)))
-
-(define-public ghc-8.0
-  (package
-    (name "ghc")
-    (version "8.0.2")
-    (source
-     (origin
-      (method url-fetch)
-      (uri (string-append "https://www.haskell.org/ghc/dist/"
-                          version "/" name "-" version "-src.tar.xz"))
-      (sha256
-       (base32 "1c8qc4fhkycynk4g1f9hvk53dj6a1vvqi6bklqznns6hw59m8qhi"))
-      (patches
-       (search-patches "ghc-8.0-fall-back-to-madv_dontneed.patch"))))
-    (build-system gnu-build-system)
-    (supported-systems '("i686-linux" "x86_64-linux"))
-    (outputs '("out" "doc"))
-    (inputs
-     `(("gmp" ,gmp)
-       ("ncurses" ,ncurses)
-       ("libffi" ,libffi)
-       ("ghc-testsuite"
-        ,(origin
-           (method url-fetch)
-           (uri (string-append
-                 "https://www.haskell.org/ghc/dist/"
-                 version "/" name "-" version "-testsuite.tar.xz"))
-           (sha256
-            (base32 "1wjc3x68l305bl1h1ijd3yhqp2vqj83lkp3kqbr94qmmkqlms8sj"))))))
-    (native-inputs
-     `(("perl" ,perl)
-       ("python" ,python-2)                ; for tests
-       ("ghostscript" ,ghostscript)        ; for tests
-       ;; GHC is built with GHC.
-       ("ghc-bootstrap" ,ghc-7)))
-    (arguments
-     `(#:test-target "test"
-       ;; We get a smaller number of test failures by disabling parallel test
-       ;; execution.
-       #:parallel-tests? #f
-
-       ;; Don't pass --build=<triplet>, because the configure script
-       ;; auto-detects slightly different triplets for --host and --target and
-       ;; then complains that they don't match.
-       #:build #f
-
-       #:configure-flags
-       (list
-        (string-append "--with-gmp-libraries="
-                       (assoc-ref %build-inputs "gmp") "/lib")
-        (string-append "--with-gmp-includes="
-                       (assoc-ref %build-inputs "gmp") "/include")
-        "--with-system-libffi"
-        (string-append "--with-ffi-libraries="
-                       (assoc-ref %build-inputs "libffi") "/lib")
-        (string-append "--with-ffi-includes="
-                       (assoc-ref %build-inputs "libffi") "/include")
-        (string-append "--with-curses-libraries="
-                       (assoc-ref %build-inputs "ncurses") "/lib")
-        (string-append "--with-curses-includes="
-                       (assoc-ref %build-inputs "ncurses") "/include"))
-       #:phases
-       (modify-phases %standard-phases
-         (add-after 'unpack 'unpack-testsuite
-           (lambda* (#:key inputs #:allow-other-keys)
-             (with-directory-excursion ".."
-               (copy-file (assoc-ref inputs "ghc-testsuite")
-                          "ghc-testsuite.tar.xz")
-               (zero? (system* "tar" "xvf" "ghc-testsuite.tar.xz")))))
-         (add-before 'build 'fix-lib-paths
-           (lambda _
-             (substitute*
-                 (list "libraries/process/System/Process/Posix.hs"
-                       "libraries/process/tests/process001.hs"
-                       "libraries/process/tests/process002.hs"
-                       "libraries/unix/cbits/execvpe.c")
-               (("/bin/sh") (which "sh"))
-               (("/bin/ls") (which "ls")))
-             #t))
-         (add-before 'build 'fix-environment
-           (lambda _
-             (unsetenv "GHC_PACKAGE_PATH")
-             (setenv "CONFIG_SHELL" (which "bash"))
-             #t))
-         (add-before 'check 'fix-testsuite
-           (lambda _
-             (substitute*
-                 (list "testsuite/timeout/Makefile"
-                       "testsuite/timeout/timeout.py"
-                       "testsuite/timeout/timeout.hs"
-                       "testsuite/tests/programs/life_space_leak/life.test")
-               (("/bin/sh") (which "sh"))
-               (("/bin/rm") "rm"))
-             #t)))))
-    (native-search-paths (list (search-path-specification
-                                (variable "GHC_PACKAGE_PATH")
-                                (files (list
-                                        (string-append "lib/ghc-" version)))
-                                (file-pattern ".*\\.conf\\.d$")
-                                (file-type 'directory))))
-    (home-page "https://www.haskell.org/ghc")
-    (synopsis "The Glasgow Haskell Compiler")
-    (description
-     "The Glasgow Haskell Compiler (GHC) is a state-of-the-art compiler and
-interactive environment for the functional language Haskell.")
-    (license license:bsd-3)))
+      "08w2ik55dp3n95qikmrflc91lsiq01xp53ki3jlhnbj8fqnxfrwy"))))
 
 (define-public ghc-8.4
-  (package (inherit ghc-8.0)
+  (package
     (name "ghc")
     (version "8.4.4")
     (source
@@ -422,6 +126,9 @@ interactive environment for the functional language Haskell.")
                            version "/" name "-" version "-src.tar.xz"))
        (sha256
         (base32 "1ch4j2asg7pr52ai1hwzykxyj553wndg7wq93i47ql4fllspf48i"))))
+    (build-system gnu-build-system)
+    (supported-systems '("i686-linux" "x86_64-linux"))
+    (outputs '("out" "doc"))
     (inputs
      `(("gmp" ,gmp)
        ("ncurses" ,ncurses)
@@ -430,8 +137,12 @@ interactive environment for the functional language Haskell.")
      `(("perl" ,perl)
        ("python" ,python)               ; for tests
        ("ghostscript" ,ghostscript)     ; for tests
-       ;; GHC 8.4.3 is built with GHC 8.
-       ("ghc-bootstrap" ,ghc-8.0)
+       ("patchelf" ,patchelf)
+       ;; GHC is built with GHC. Therefore we need bootstrap binaries.
+       ("ghc-binary"
+        ,(match (or (%current-target-system) (%current-system))
+           ("x86_64-linux" ghc-bootstrap-x86_64-8.2.2)
+           ("i686-linux" ghc-bootstrap-i686-8.2.2)))
        ("ghc-testsuite"
         ,(origin
            (method url-fetch)
@@ -452,6 +163,13 @@ interactive environment for the functional language Haskell.")
        ;; then complains that they don't match.
        #:build #f
 
+       #:modules ((guix build gnu-build-system)
+                  (guix build utils)
+                  (guix build rpath)
+                  (srfi srfi-26)
+                  (srfi srfi-1))
+       #:imported-modules (,@%gnu-build-system-modules
+                           (guix build rpath))
        #:configure-flags
        (list
         (string-append "--with-gmp-libraries="
@@ -467,6 +185,10 @@ interactive environment for the functional language Haskell.")
                        (assoc-ref %build-inputs "ncurses") "/lib")
         (string-append "--with-curses-includes="
                        (assoc-ref %build-inputs "ncurses") "/include"))
+       ;; FIXME: The user-guide needs dblatex, docbook-xsl and docbook-utils.
+       ;; Currently we do not have the last one.
+       ;; #:make-flags
+       ;; (list "BUILD_DOCBOOK_HTML = YES")
        #:phases
        (modify-phases %standard-phases
          (add-after 'unpack 'unpack-testsuite
@@ -475,6 +197,12 @@ interactive environment for the functional language Haskell.")
                      (assoc-ref inputs "ghc-testsuite")
                      "--strip-components=1")
              #t))
+         (add-after 'unpack-testsuite 'unpack-bin
+           (lambda* (#:key inputs #:allow-other-keys)
+             (mkdir-p "./ghc-bin/usr")
+             (with-directory-excursion "./ghc-bin"
+               (invoke "tar" "xvf" (assoc-ref inputs "ghc-binary")))
+             #t))
          ;; This phase patches the 'ghc-pkg' command so that it sorts the list
          ;; of packages in the binary cache it generates.
          (add-before 'build 'fix-ghc-pkg-nondeterminism
@@ -523,17 +251,83 @@ interactive environment for the functional language Haskell.")
                (("/bin/ls") (which "ls"))
                (("/bin/rm") "rm"))
              #t))
-         (add-before 'build 'fix-environment
+         (add-before 'configure 'fix-environment
            (lambda _
              (unsetenv "GHC_PACKAGE_PATH")
              (setenv "CONFIG_SHELL" (which "bash"))
+             #t))
+         (add-after 'fix-environment 'configure-bin
+           (lambda* (#:key inputs outputs #:allow-other-keys)
+             (let* ((ghc-bootstrap-path (string-append (getcwd) "/ghc-bin"))
+                    (ghc-bootstrap-prefix
+                     (string-append ghc-bootstrap-path "/usr" ))
+                    (binaries
+                     '("./utils/hpc/dist-install/build/tmp/hpc"
+                       "./utils/haddock/dist/build/tmp/haddock"
+                       "./utils/hsc2hs/dist-install/build/tmp/hsc2hs"
+                       "./utils/runghc/dist-install/build/tmp/runghc"
+                       "./utils/ghc-cabal/dist-install/build/tmp/ghc-cabal"
+                       "./utils/hp2ps/dist/build/tmp/hp2ps"
+                       "./utils/ghc-pkg/dist-install/build/tmp/ghc-pkg"
+                       "./utils/unlit/dist/build/tmp/unlit"
+                       "./ghc/stage2/build/tmp/ghc-stage2"))
+                    (gmp (assoc-ref inputs "gmp"))
+                    (gmp-lib (string-append gmp "/lib"))
+                    (gmp-include (string-append gmp "/include"))
+                    (ncurses-lib
+                     (string-append (assoc-ref inputs "ncurses") "/lib"))
+                    (ld-so (string-append (assoc-ref inputs "libc")
+                                          ,(glibc-dynamic-linker)))
+                    (libtinfo-dir
+                     (string-append ghc-bootstrap-prefix
+                                    "/lib/ghc-8.2.2/terminfo-0.4.1.0")))
+               (with-directory-excursion
+                   (string-append ghc-bootstrap-path "/ghc-8.2.2")
+                 (setenv "LD_LIBRARY_PATH" gmp-lib)
+                 ;; The binaries have "/lib64/ld-linux-x86-64.so.2" hardcoded.
+                 (for-each
+                  (cut invoke "patchelf" "--set-interpreter" ld-so <>)
+                  binaries)
+                 ;; The binaries include a reference to libtinfo.so.5 which
+                 ;; is a subset of libncurses.so.5.  We create a symlink in a
+                 ;; directory included in the bootstrap binaries rpath.
+                 (mkdir-p libtinfo-dir)
+                 (symlink
+                  (string-append ncurses-lib "/libncursesw.so."
+                                 ;; Extract "6.0" from "6.0-20170930" if a
+                                 ;; dash-separated version tag exists.
+                                 ,(let* ((v (package-version ncurses))
+                                         (d (or (string-index v #\-)
+                                                (string-length v))))
+                                    (version-major+minor (string-take v d))))
+                  (string-append libtinfo-dir "/libtinfo.so.5"))
+
+                 (setenv "PATH"
+                         (string-append (getenv "PATH") ":"
+                                        ghc-bootstrap-prefix "/bin"))
+                 (invoke
+                  (string-append (getcwd) "/configure")
+                  (string-append "--prefix=" ghc-bootstrap-prefix)
+                  (string-append "--with-gmp-libraries=" gmp-lib)
+                  (string-append "--with-gmp-includes=" gmp-include))))
+             #t))
+         (add-after 'configure-bin 'install-bin
+           (lambda _
+             (with-directory-excursion "./ghc-bin/ghc-8.2.2"
+               (invoke "make" "install"))
              #t)))))
     (native-search-paths (list (search-path-specification
                                 (variable "GHC_PACKAGE_PATH")
                                 (files (list
                                         (string-append "lib/ghc-" version)))
                                 (file-pattern ".*\\.conf\\.d$")
-                                (file-type 'directory))))))
+                                (file-type 'directory))))
+    (home-page "https://www.haskell.org/ghc")
+    (synopsis "The Glasgow Haskell Compiler")
+    (description
+     "The Glasgow Haskell Compiler (GHC) is a state-of-the-art compiler and
+interactive environment for the functional language Haskell.")
+    (license license:bsd-3)))
 
 (define-public ghc-8.6
   (package (inherit ghc-8.4)
@@ -579,7 +373,10 @@ interactive environment for the functional language Haskell.")
                  (("^test\\('T8108'") "# guix skipped: test('T8108'"))
                (substitute* "libraries/unix/tests/libposix/all.T"
                  (("^test\\('posix010'") "# guix skipped: test('posix010'"))
-               #t))))))
+               #t))
+           (delete 'unpack-bin)
+           (delete 'configure-bin)
+           (delete 'install-bin)))))
     (native-search-paths (list (search-path-specification
                                 (variable "GHC_PACKAGE_PATH")
                                 (files (list
-- 
2.26.2


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

* [bug#42014] [PATCH] WIP: gnu: ghc@8.4: Support 32- and 64-bit ARM systems.
  2020-06-23  1:48 [bug#42014] [PATCH] WIP: gnu: Re-bootstrap Haskell with GHC 8.2.2 binaries Alex Griffin via Guix-patches via
@ 2020-06-27 21:16 ` Alex Griffin via Guix-patches via
  2020-06-27 21:21 ` [bug#42014] [PATCH] WIP: gnu: Re-bootstrap Haskell with GHC 8.2.2 binaries Ricardo Wurmus
  1 sibling, 0 replies; 4+ messages in thread
From: Alex Griffin via Guix-patches via @ 2020-06-27 21:16 UTC (permalink / raw)
  To: 42014

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

Here's the second patch. I'm making some progress on bootstrapping Haskell on ARM. Currently it builds the stage1 compiler just fine, then panics while building the stage2 compiler.

Progress is super slow, mainly because long compilation times mean I can only try 1 change per day.
--
Alex Griffin


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0002-gnu-ghc-8.4-Support-32-and-64-bit-ARM-systems.patch --]
[-- Type: text/x-patch; name=0002-gnu-ghc-8.4-Support-32-and-64-bit-ARM-systems.patch, Size: 5919 bytes --]

From 405cf569abeaa583ddf6ea3639d9f74853fee36a Mon Sep 17 00:00:00 2001
From: Alex Griffin <a@ajgrf.com>
Date: Sat, 27 Jun 2020 16:01:14 -0500
Subject: [PATCH 2/2] gnu: ghc@8.4: Support 32- and 64-bit ARM systems.

* gnu/packages/haskell.scm (ghc-bootstrap-aarch64-8.2.2,
ghc-bootstrap-armhf-8.2.2): New variables.
(ghc-8.4)[supported-systems]: Add armhf-linux and aarch64-linux.
[inputs, native-inputs]: Add extra dependencies for ARM builds.
[arguments]: Use gold linker, add libgcc_s to LD_LIBRARY_PATH, and
don't call patchelf on non-existent files.
---
 gnu/packages/haskell.scm | 52 +++++++++++++++++++++++++++++++++++-----
 1 file changed, 46 insertions(+), 6 deletions(-)

diff --git a/gnu/packages/haskell.scm b/gnu/packages/haskell.scm
index ac5ad14320..533d82ae44 100644
--- a/gnu/packages/haskell.scm
+++ b/gnu/packages/haskell.scm
@@ -39,11 +39,14 @@
 
 (define-module (gnu packages haskell)
   #:use-module (gnu packages)
+  #:use-module (gnu packages base)
   #:use-module (gnu packages bootstrap)
   #:use-module (gnu packages elf)
+  #:use-module (gnu packages gcc)
   #:use-module (gnu packages ghostscript)
   #:use-module (gnu packages libffi)
   #:use-module (gnu packages lisp)
+  #:use-module (gnu packages llvm)
   #:use-module (gnu packages multiprecision)
   #:use-module (gnu packages ncurses)
   #:use-module (gnu packages perl)
@@ -115,6 +118,24 @@ top of CLISP.")
      (base32
       "08w2ik55dp3n95qikmrflc91lsiq01xp53ki3jlhnbj8fqnxfrwy"))))
 
+(define ghc-bootstrap-aarch64-8.2.2
+  (origin
+    (method url-fetch)
+    (uri
+     "https://www.haskell.org/ghc/dist/8.2.2/ghc-8.2.2-aarch64-deb8-linux.tar.xz")
+    (sha256
+     (base32
+      "1k2amylcp1ad67c75h1pqf7czf9m0zj1i7hdc45ghjklnfq9hrk7"))))
+
+(define ghc-bootstrap-armhf-8.2.2
+  (origin
+    (method url-fetch)
+    (uri
+     "https://www.haskell.org/ghc/dist/8.2.2/ghc-8.2.2-armv7-deb8-linux.tar.xz")
+    (sha256
+     (base32
+      "1jmv8qmnh5bn324fivbwdcaj55kvw7cb2zq9pafmlmv3qwwx7s46"))))
+
 (define-public ghc-8.4
   (package
     (name "ghc")
@@ -127,12 +148,21 @@ top of CLISP.")
        (sha256
         (base32 "1ch4j2asg7pr52ai1hwzykxyj553wndg7wq93i47ql4fllspf48i"))))
     (build-system gnu-build-system)
-    (supported-systems '("i686-linux" "x86_64-linux"))
+    (supported-systems '("i686-linux" "x86_64-linux"
+                         "armhf-linux" "aarch64-linux"))
     (outputs '("out" "doc"))
     (inputs
      `(("gmp" ,gmp)
        ("ncurses" ,ncurses)
-       ("libffi" ,libffi)))
+       ("libffi" ,libffi)
+       ,@(match (or (%current-target-system) (%current-system))
+           ((or "aarch64-linux" "armhf-linux")
+            `(("gcc:lib" ,gcc "lib")
+              ("gold-wrapper"
+               ,(make-ld-wrapper "gold-wrapper"
+                                 #:binutils binutils-gold))
+              ("llvm" ,llvm)))
+           (_ '()))))
     (native-inputs
      `(("perl" ,perl)
        ("python" ,python)               ; for tests
@@ -142,7 +172,9 @@ top of CLISP.")
        ("ghc-binary"
         ,(match (or (%current-target-system) (%current-system))
            ("x86_64-linux" ghc-bootstrap-x86_64-8.2.2)
-           ("i686-linux" ghc-bootstrap-i686-8.2.2)))
+           ("i686-linux" ghc-bootstrap-i686-8.2.2)
+           ("aarch64-linux" ghc-bootstrap-aarch64-8.2.2)
+           ("armhf-linux" ghc-bootstrap-armhf-8.2.2)))
        ("ghc-testsuite"
         ,(origin
            (method url-fetch)
@@ -226,7 +258,8 @@ top of CLISP.")
            (lambda* (#:key inputs #:allow-other-keys)
              (let ((binutils (assoc-ref inputs "binutils"))
                    (gcc (assoc-ref inputs "gcc"))
-                   (ld-wrapper (assoc-ref inputs "ld-wrapper")))
+                   (ld-wrapper (or (assoc-ref inputs "gold-wrapper")
+                                   (assoc-ref inputs "ld-wrapper"))))
                (setenv "CC" (string-append gcc "/bin/gcc"))
                (setenv "CXX" (string-append gcc "/bin/g++"))
                (setenv "LD" (string-append ld-wrapper "/bin/ld"))
@@ -271,11 +304,16 @@ top of CLISP.")
                        "./utils/ghc-pkg/dist-install/build/tmp/ghc-pkg"
                        "./utils/unlit/dist/build/tmp/unlit"
                        "./ghc/stage2/build/tmp/ghc-stage2"))
+                    (gcclib (assoc-ref inputs "gcc:lib"))
                     (gmp (assoc-ref inputs "gmp"))
                     (gmp-lib (string-append gmp "/lib"))
                     (gmp-include (string-append gmp "/include"))
                     (ncurses-lib
                      (string-append (assoc-ref inputs "ncurses") "/lib"))
+                    (ld-lib-path (cons gmp-lib
+                                       (if gcclib
+                                           (list (string-append gcclib "/lib"))
+                                           '())))
                     (ld-so (string-append (assoc-ref inputs "libc")
                                           ,(glibc-dynamic-linker)))
                     (libtinfo-dir
@@ -283,10 +321,12 @@ top of CLISP.")
                                     "/lib/ghc-8.2.2/terminfo-0.4.1.0")))
                (with-directory-excursion
                    (string-append ghc-bootstrap-path "/ghc-8.2.2")
-                 (setenv "LD_LIBRARY_PATH" gmp-lib)
+                 (setenv "LD_LIBRARY_PATH" (string-join ld-lib-path ":"))
                  ;; The binaries have "/lib64/ld-linux-x86-64.so.2" hardcoded.
                  (for-each
-                  (cut invoke "patchelf" "--set-interpreter" ld-so <>)
+                  (lambda (binary)
+                    (when (file-exists? binary)
+                      (invoke "patchelf" "--set-interpreter" ld-so binary)))
                   binaries)
                  ;; The binaries include a reference to libtinfo.so.5 which
                  ;; is a subset of libncurses.so.5.  We create a symlink in a
-- 
2.26.2


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

* [bug#42014] [PATCH] WIP: gnu: Re-bootstrap Haskell with GHC 8.2.2 binaries.
  2020-06-23  1:48 [bug#42014] [PATCH] WIP: gnu: Re-bootstrap Haskell with GHC 8.2.2 binaries Alex Griffin via Guix-patches via
  2020-06-27 21:16 ` [bug#42014] [PATCH] WIP: gnu: ghc@8.4: Support 32- and 64-bit ARM systems Alex Griffin via Guix-patches via
@ 2020-06-27 21:21 ` Ricardo Wurmus
  2020-06-27 22:09   ` Alex Griffin via Guix-patches via
  1 sibling, 1 reply; 4+ messages in thread
From: Ricardo Wurmus @ 2020-06-27 21:21 UTC (permalink / raw)
  To: Alex Griffin; +Cc: 42014


Alex Griffin via Guix-patches via <guix-patches@gnu.org> writes:

> This patch replaces the GHC 7.8.4 bootstrap binaries with binaries of
> GHC 8.2.2, with an eye towards supporting ARM systems. I have not yet
> succeeded in bootstrapping GHC on ARM, but 8.2.2 is the first release
> with official binary distributions for both armv7 and aarch64.

Can we do this only for armhf and aarch64?  I wouldn’t like to replace
the bootstrap binary for the other architectures with a newer version
without a good reason.  (We should aim to remove the binary completely,
not replace it with newer and newer versions.)

-- 
Ricardo




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

* [bug#42014] [PATCH] WIP: gnu: Re-bootstrap Haskell with GHC 8.2.2 binaries.
  2020-06-27 21:21 ` [bug#42014] [PATCH] WIP: gnu: Re-bootstrap Haskell with GHC 8.2.2 binaries Ricardo Wurmus
@ 2020-06-27 22:09   ` Alex Griffin via Guix-patches via
  0 siblings, 0 replies; 4+ messages in thread
From: Alex Griffin via Guix-patches via @ 2020-06-27 22:09 UTC (permalink / raw)
  To: 42014

Hi Ricardo,

I actually had the same thought, and asked about it on IRC with no response. So I just did the simplest thing I could to get started. Once we have a working compiler on ARM, it should be pretty easy to restore the old x86 bootstrap path.

In particular, the complexities of having the GHC 8.4 package bootstrapped from upstream binaries on some architectures vs a previous package on others, just seemed like an unnecessary distraction until we can work through the build problems on ARM.

--
Alex Griffin

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Saturday, June 27, 2020 9:21 PM, Ricardo Wurmus <rekado@elephly.net> wrote:

>
>
> Alex Griffin via Guix-patches viaguix-patches@gnu.org writes:
>
> > This patch replaces the GHC 7.8.4 bootstrap binaries with binaries of
> > GHC 8.2.2, with an eye towards supporting ARM systems. I have not yet
> > succeeded in bootstrapping GHC on ARM, but 8.2.2 is the first release
> > with official binary distributions for both armv7 and aarch64.
>
> Can we do this only for armhf and aarch64? I wouldn’t like to replace
> the bootstrap binary for the other architectures with a newer version
> without a good reason. (We should aim to remove the binary completely,
> not replace it with newer and newer versions.)
>
> --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
> Ricardo






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

end of thread, back to index

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-23  1:48 [bug#42014] [PATCH] WIP: gnu: Re-bootstrap Haskell with GHC 8.2.2 binaries Alex Griffin via Guix-patches via
2020-06-27 21:16 ` [bug#42014] [PATCH] WIP: gnu: ghc@8.4: Support 32- and 64-bit ARM systems Alex Griffin via Guix-patches via
2020-06-27 21:21 ` [bug#42014] [PATCH] WIP: gnu: Re-bootstrap Haskell with GHC 8.2.2 binaries Ricardo Wurmus
2020-06-27 22:09   ` Alex Griffin via Guix-patches via

unofficial mirror of guix-patches@gnu.org 

Archives are clonable:
	git clone --mirror https://yhetil.org/guix-patches/1 guix-patches/git/1.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 guix-patches guix-patches/ https://yhetil.org/guix-patches \
		guix-patches@gnu.org
	public-inbox-index guix-patches

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://news.yhetil.org/yhetil.gnu.guix.patches


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git