gnu: icecat: Apply fixes for CVE-2015-{0817,0818} and other selected bugs.
[jackhill/guix/guix.git] / gnu / packages / haskell.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2015 Federico Beffa <beffa@fbengineering.ch>
3 ;;;
4 ;;; This file is part of GNU Guix.
5 ;;;
6 ;;; GNU Guix is free software; you can redistribute it and/or modify it
7 ;;; under the terms of the GNU General Public License as published by
8 ;;; the Free Software Foundation; either version 3 of the License, or (at
9 ;;; your option) any later version.
10 ;;;
11 ;;; GNU Guix is distributed in the hope that it will be useful, but
12 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ;;; GNU General Public License for more details.
15 ;;;
16 ;;; You should have received a copy of the GNU General Public License
17 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
18
19 (define-module (gnu packages haskell)
20 #:use-module (ice-9 regex)
21 #:use-module (guix licenses)
22 #:use-module (guix packages)
23 #:use-module (guix download)
24 #:use-module (guix utils)
25 #:use-module (guix build-system gnu)
26 #:use-module (gnu packages perl)
27 #:use-module (gnu packages elf)
28 #:use-module (gnu packages bootstrap)
29 #:use-module (gnu packages ghostscript)
30 #:use-module (gnu packages libffi)
31 #:use-module (gnu packages libedit)
32 #:use-module (gnu packages multiprecision)
33 #:use-module (gnu packages ncurses)
34 #:use-module (gnu packages python))
35
36 ;; We use bootstrap binaries with a fix version which can be used to build
37 ;; more versions of the GHC compiler.
38 (define ghc-bootstrap-7.8.4
39 (origin
40 (method url-fetch)
41 (uri (string-append "https://www.haskell.org/ghc/dist/"
42 "7.8.4/ghc-7.8.4-"
43 (if (string-match "x86_64" (%current-system))
44 "x86_64"
45 "i386")
46 "-unknown-linux-deb7.tar.xz"))
47 (sha256
48 (base32
49 (if (string-match "x86_64" (%current-system))
50 "13azsl53xgj20mi1hj9x0xb32vvcvs6cpmvwx6znxhas7blh0bpn"
51 "0wj5s435j0zgww70bj1d3f6wvnnpzlxwvwcyh2qv4qjq5z8j64kg")))))
52
53 ;; 43 tests out of 3965 fail.
54 ;;
55 ;; Most of them do not appear to be serious:
56 ;;
57 ;; - some tests generate files referring to "/bin/sh" and "/bin/ls". I've not
58 ;; figured out how these references are generated.
59 ;;
60 ;; - Some tests allocate more memory than expected (ca. 3% above upper limit)
61 ;;
62 ;; - Some tests try to load unavailable libriries: Control.Concurrent.STM,
63 ;; Data.Vector, Control.Monad.State.
64 ;;
65 ;; - Test posix010 tries to check the existence of a user on the system:
66 ;; getUserEntryForName: does not exist (no such user)
67 (define-public ghc
68 (package
69 (name "ghc")
70 (version "7.8.4")
71 (source
72 (origin
73 (method url-fetch)
74 (uri (string-append "https://www.haskell.org/ghc/dist/"
75 version "/" name "-" version "-src.tar.xz"))
76 (sha256
77 (base32
78 "1i4254akbb4ym437rf469gc0m40bxm31blp6s1z1g15jmnacs6f3"))))
79 (build-system gnu-build-system)
80 (supported-systems '("i686-linux" "x86_64-linux"))
81 (outputs '("out" "doc"))
82 (inputs
83 `(("gmp" ,gmp)
84 ("ncurses" ,ncurses)
85 ("libffi" ,libffi)
86 ("libedit" ,libedit)
87 ("ghc-testsuite"
88 ,(origin
89 (method url-fetch)
90 (uri (string-append
91 "https://www.haskell.org/ghc/dist/"
92 version "/" name "-" version "-testsuite.tar.xz"))
93 (sha256
94 (base32
95 "0q95whf87y4mxjzwzy899g7z7l9pazq4si6iciyhxkcdhqq2ycyh"))))))
96 (native-inputs
97 `(("perl" ,perl)
98 ("python" ,python-2) ; for tests (fails with python-3)
99 ("ghostscript" ,ghostscript) ; for tests
100 ("patchelf" ,patchelf)
101 ;; GHC is built with GHC. Therefore we need bootstrap binaries.
102 ("ghc-binary" ,ghc-bootstrap-7.8.4)))
103 (arguments
104 `(#:test-target "test"
105 ;; We get a smaller number of test failures by disabling parallel test
106 ;; execution.
107 #:parallel-tests? #f
108 #:modules ((guix build gnu-build-system)
109 (guix build utils)
110 (guix build rpath)
111 (srfi srfi-26)
112 (srfi srfi-1))
113 #:imported-modules ((guix build gnu-build-system)
114 (guix build utils)
115 (guix build rpath))
116 #:configure-flags
117 (list
118 (string-append "--with-gmp-libraries="
119 (assoc-ref %build-inputs "gmp") "/lib")
120 (string-append "--with-gmp-includes="
121 (assoc-ref %build-inputs "gmp") "/include")
122 "--with-system-libffi"
123 (string-append "--with-ffi-libraries="
124 (assoc-ref %build-inputs "libffi") "/lib")
125 (string-append "--with-ffi-includes="
126 (assoc-ref %build-inputs "libffi") "/include"))
127 ;; FIXME: The user-guide needs dblatex, docbook-xsl and docbook-utils.
128 ;; Currently we do not have the last one.
129 ;; #:make-flags
130 ;; (list "BUILD_DOCBOOK_HTML = YES")
131 #:phases
132 (let* ((ghc-bootstrap-path
133 (string-append (getcwd) "/" ,name "-" ,version "/ghc-bin"))
134 (ghc-bootstrap-prefix
135 (string-append ghc-bootstrap-path "/usr" )))
136 (alist-cons-after
137 'unpack-bin 'unpack-and-fix-testsuite
138 (lambda* (#:key inputs outputs #:allow-other-keys)
139 (with-directory-excursion ".."
140 (copy-file (assoc-ref inputs "ghc-testsuite")
141 "ghc-testsuite.tar.xz")
142 (system* "tar" "xvf" "ghc-testsuite.tar.xz"))
143 (substitute*
144 (list "testsuite/timeout/Makefile"
145 "testsuite/timeout/timeout.py"
146 "testsuite/timeout/timeout.hs"
147 "testsuite/tests/rename/prog006/Setup.lhs"
148 "testsuite/tests/programs/life_space_leak/life.test")
149 (("/bin/sh") (which "sh"))
150 (("/bin/rm") "rm"))
151 #t)
152 (alist-cons-after
153 'unpack 'unpack-bin
154 (lambda* (#:key inputs outputs #:allow-other-keys)
155 (mkdir-p ghc-bootstrap-prefix)
156 (with-directory-excursion ghc-bootstrap-path
157 (copy-file (assoc-ref inputs "ghc-binary")
158 "ghc-bin.tar.xz")
159 (zero? (system* "tar" "xvf" "ghc-bin.tar.xz"))))
160 (alist-cons-before
161 'install-bin 'configure-bin
162 (lambda* (#:key inputs outputs #:allow-other-keys)
163 (let* ((binaries
164 (list
165 "./utils/ghc-pwd/dist-install/build/tmp/ghc-pwd"
166 "./utils/hpc/dist-install/build/tmp/hpc"
167 "./utils/haddock/dist/build/tmp/haddock"
168 "./utils/hsc2hs/dist-install/build/tmp/hsc2hs"
169 "./utils/runghc/dist-install/build/tmp/runghc"
170 "./utils/ghc-cabal/dist-install/build/tmp/ghc-cabal"
171 "./utils/hp2ps/dist/build/tmp/hp2ps"
172 "./utils/ghc-pkg/dist-install/build/tmp/ghc-pkg"
173 "./utils/unlit/dist/build/tmp/unlit"
174 "./ghc/stage2/build/tmp/ghc-stage2"))
175 (gmp (assoc-ref inputs "gmp"))
176 (gmp-lib (string-append gmp "/lib"))
177 (gmp-include (string-append gmp "/include"))
178 (ncurses-lib
179 (string-append (assoc-ref inputs "ncurses") "/lib"))
180 (ld-so (string-append (assoc-ref inputs "libc")
181 ,(glibc-dynamic-linker)))
182 (libtinfo-dir
183 (string-append ghc-bootstrap-prefix
184 "/lib/ghc-7.8.4/terminfo-0.4.0.0")))
185 (with-directory-excursion
186 (string-append ghc-bootstrap-path "/" ,name "-" ,version)
187 (setenv "CONFIG_SHELL" (which "bash"))
188 (setenv "LD_LIBRARY_PATH" gmp-lib)
189 ;; The binaries have "/lib64/ld-linux-x86-64.so.2" hardcoded.
190 (for-each
191 (cut system* "patchelf" "--set-interpreter" ld-so <>)
192 binaries)
193 ;; The binaries include a reference to libtinfo.so.5 which
194 ;; is a subset of libncurses.so.5. We create a symlink in a
195 ;; directory included in the bootstrap binaries rpath.
196 (mkdir-p libtinfo-dir)
197 (symlink
198 (string-append ncurses-lib "/libncursesw.so."
199 ,(version-major+minor
200 (package-version ncurses)))
201 (string-append libtinfo-dir "/libtinfo.so.5"))
202 (setenv "PATH"
203 (string-append (getenv "PATH") ":"
204 ghc-bootstrap-prefix "/bin"))
205 (system*
206 (string-append (getcwd) "/configure")
207 (string-append "--prefix=" ghc-bootstrap-prefix)
208 (string-append "--with-gmp-libraries=" gmp-lib)
209 (string-append "--with-gmp-includes=" gmp-include)))))
210 (alist-cons-before
211 'configure 'install-bin
212 (lambda* (#:key inputs outputs #:allow-other-keys)
213 (with-directory-excursion
214 (string-append ghc-bootstrap-path "/" ,name "-" ,version)
215 (zero? (system* "make" "install"))))
216 %standard-phases)))))))
217 (home-page "https://www.haskell.org/ghc")
218 (synopsis "The Glasgow Haskell Compiler")
219 (description
220 "The Glasgow Haskell Compiler (GHC) is a state-of-the-art compiler and
221 interactive environment for the functional language Haskell.")
222 (license bsd-3)))
223
224 ;;; haskell.scm ends here