From patchwork Tue Jun 23 01:48:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "vasilii.smirnov--- via Guix-patches\" via" X-Patchwork-Id: 22830 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id DA2C227BBE1; Tue, 23 Jun 2020 02:57:11 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,T_DKIM_INVALID, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTP id E0E7C27BBE3 for ; Tue, 23 Jun 2020 02:57:09 +0100 (BST) Received: from localhost ([::1]:49270 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jnYBR-0004ap-De for patchwork@mira.cbaines.net; Mon, 22 Jun 2020 21:57:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41554) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jnYBK-0004ab-Mf for guix-patches@gnu.org; Mon, 22 Jun 2020 21:57:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:51785) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jnYBK-0006Sc-9X for guix-patches@gnu.org; Mon, 22 Jun 2020 21:57:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jnYBK-000103-7c for guix-patches@gnu.org; Mon, 22 Jun 2020 21:57:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#42014] [PATCH] WIP: gnu: Re-bootstrap Haskell with GHC 8.2.2 binaries. Resent-From: Alex Griffin Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 23 Jun 2020 01:57:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 42014 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 42014@debbugs.gnu.org X-Debbugs-Original-To: "guix-patches@gnu.org" Received: via spool by submit@debbugs.gnu.org id=B.15928774143826 (code B ref -1); Tue, 23 Jun 2020 01:57:02 +0000 Received: (at submit) by debbugs.gnu.org; 23 Jun 2020 01:56:54 +0000 Received: from localhost ([127.0.0.1]:35098 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jnYB6-0000zX-3G for submit@debbugs.gnu.org; Mon, 22 Jun 2020 21:56:53 -0400 Received: from lists.gnu.org ([209.51.188.17]:47962) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jnYB2-0000zO-E0 for submit@debbugs.gnu.org; Mon, 22 Jun 2020 21:56:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41258) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jnYB2-0004Zz-1k for guix-patches@gnu.org; Mon, 22 Jun 2020 21:56:44 -0400 Received: from mail-40131.protonmail.ch ([185.70.40.131]:57006) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jnYAy-00067e-0K for guix-patches@gnu.org; Mon, 22 Jun 2020 21:56:43 -0400 Date: Tue, 23 Jun 2020 01:48:58 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ajgrf.com; s=protonmail; t=1592876944; bh=J4L9+WN9EcMgmHWnLDflzUxbxB8IMAXFibI8K1nwobw=; h=Date:To:From:Reply-To:Subject:From; b=SwQ0AUTQe/Fpp9BtrMnccgmG3/QXO7clWHJWWpNa+nGtvcwL0dvuKsptoco5ixi6l y5FWIvA5P44lXQiBO+6rRAt4SQHr5YAZPymFhGHP/UyRQfJ8X2SkcVCJHSoFxOM8S2 +/zwxu6l80qDSs7F8m9T4uEw0UWp+fPChYblRfTN93+BEgGZolOlTB52oWA3mBaYlz aDzyemwYj84x1XGNZmGkw+bvP7CHHrfWx4dtU1j+scQsFoHtJCum+2hForVJEE+C1a BxGra2cUo22n/7JLlJwRg4PRnlidKUci0jui+p0vOjPwHLppBM/+tZ799w5DAaRZXi G8t4iJ8IpN5Hg== Message-ID: MIME-Version: 1.0 Received-SPF: pass client-ip=185.70.40.131; envelope-from=a@ajgrf.com; helo=mail-40131.protonmail.ch X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/22 21:56:36 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" Reply-to: Alex Griffin , Alex Griffin via Guix-patches X-Patchwork-Original-From: Alex Griffin via Guix-patches via From: "vasilii.smirnov--- via Guix-patches\" via" X-getmail-retrieved-from-mailbox: Patches 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 From 6998f89c2d29278363e509603ad89067133a2ae1 Mon Sep 17 00:00:00 2001 From: Alex Griffin 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 ;;; Copyright © 2019 Jacob MacDonald ;;; Copyright © 2020 Marius Bakke +;;; Copyright © 2020 Alex Griffin ;;; ;;; 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=, 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=, 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