gnu: emacs-helm: Update to 3.8.7.
[jackhill/guix/guix.git] / gnu / packages / haskell.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2015, 2016 Federico Beffa <beffa@fbengineering.ch>
3 ;;; Copyright © 2015 Siniša Biđin <sinisa@bidin.eu>
4 ;;; Copyright © 2015 Paul van der Walt <paul@denknerd.org>
5 ;;; Copyright © 2015, 2019 Eric Bavier <bavier@member.fsf.org>
6 ;;; Copyright © 2016, 2018, 2019, 2021 Ludovic Courtès <ludo@gnu.org>
7 ;;; Copyright © 2016, 2017 Nikita <nikita@n0.is>
8 ;;; Copyright © 2016, 2022 Efraim Flashner <efraim@flashner.co.il>
9 ;;; Copyright © 2015, 2016, 2017, 2018, 2019, 2020, 2022 Ricardo Wurmus <rekado@elephly.net>
10 ;;; Copyright © 2016, 2017 David Craven <david@craven.ch>
11 ;;; Copyright © 2017 Danny Milosavljevic <dannym@scratchpost.org>
12 ;;; Copyright © 2017 Peter Mikkelsen <petermikkelsen10@gmail.com>
13 ;;; Copyright © 2017, 2018 Alex Vong <alexvong1995@gmail.com>
14 ;;; Copyright © 2017 rsiddharth <s@ricketyspace.net>
15 ;;; Copyright © 2017, 2018, 2019 Tobias Geerinckx-Rice <me@tobias.gr>
16 ;;; Copyright © 2018 Tonton <tonton@riseup.net>
17 ;;; Copyright © 2018, 2019, 2020 Timothy Sample <samplet@ngyro.com>
18 ;;; Copyright © 2018 Arun Isaac <arunisaac@systemreboot.net>
19 ;;; Copyright © 2018, 2019 Gabriel Hondet <gabrielhondet@gmail.com>
20 ;;; Copyright © 2019 Robert Vollmert <rob@vllmrt.net>
21 ;;; Copyright © 2019 Jacob MacDonald <jaccarmac@gmail.com>
22 ;;; Copyright © 2020 Marius Bakke <mbakke@fastmail.com>
23 ;;; Copyright © 2021 Matthew James Kraai <kraai@ftbfs.org>
24 ;;; Copyright © 2021 Xinglu Chen <public@yoctocell.xyz>
25 ;;; Copyright © 2021 Simon Tournier <zimon.toutoune@gmail.com>
26 ;;;
27 ;;; This file is part of GNU Guix.
28 ;;;
29 ;;; GNU Guix is free software; you can redistribute it and/or modify it
30 ;;; under the terms of the GNU General Public License as published by
31 ;;; the Free Software Foundation; either version 3 of the License, or (at
32 ;;; your option) any later version.
33 ;;;
34 ;;; GNU Guix is distributed in the hope that it will be useful, but
35 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
36 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
37 ;;; GNU General Public License for more details.
38 ;;;
39 ;;; You should have received a copy of the GNU General Public License
40 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
41
42 (define-module (gnu packages haskell)
43 #:use-module (gnu packages)
44 #:use-module (gnu packages autotools)
45 #:use-module (gnu packages base)
46 #:use-module (gnu packages bash)
47 #:use-module (gnu packages bison)
48 #:use-module (gnu packages bootstrap)
49 #:use-module (gnu packages compression)
50 #:use-module (gnu packages elf)
51 #:use-module (gnu packages file)
52 #:use-module (gnu packages gawk)
53 #:use-module (gnu packages gcc)
54 #:use-module (gnu packages ghostscript)
55 #:use-module (gnu packages libffi)
56 #:use-module (gnu packages linux)
57 #:use-module (gnu packages lisp)
58 #:use-module (gnu packages multiprecision)
59 #:use-module (gnu packages ncurses)
60 #:use-module (gnu packages perl)
61 #:use-module (gnu packages python)
62 #:use-module (gnu packages version-control)
63 #:use-module (guix build-system gnu)
64 #:use-module (guix download)
65 #:use-module (guix git-download)
66 #:use-module (guix gexp)
67 #:use-module ((guix licenses) #:prefix license:)
68 #:use-module (guix packages)
69 #:use-module (guix utils)
70 #:use-module (ice-9 match)
71 #:use-module (ice-9 regex))
72
73 (define-public cl-yale-haskell
74 (let ((commit "85f94c72a16c5f70301dd8db04cde9de2d7dd270")
75 (revision "1"))
76 (package
77 (name "cl-yale-haskell")
78 (version (string-append "2.0.5-" revision "." (string-take commit 9)))
79 (source (origin
80 (method git-fetch)
81 (uri (git-reference
82 (url "https://git.elephly.net/software/yale-haskell.git")
83 (commit commit)))
84 (file-name (string-append "yale-haskell-" commit "-checkout"))
85 (sha256
86 (base32
87 "0bal3m6ryrjamz5p93bhs9rp5msk8k7lpcqr44wd7xs9b9k8w74g"))))
88 (build-system gnu-build-system)
89 (arguments
90 `(#:tests? #f ; no tests
91 ;; Stripping binaries leads to a broken executable lisp system image.
92 #:strip-binaries? #f
93 #:make-flags
94 (list (string-append "PREFIX=" (assoc-ref %outputs "out")))
95 #:phases
96 (modify-phases %standard-phases
97 (replace 'configure
98 (lambda _
99 (setenv "PRELUDE" "./progs/prelude")
100 (setenv "HASKELL_LIBRARY" "./progs/lib")
101 (setenv "PRELUDEBIN" "./progs/prelude/clisp")
102 (setenv "HASKELLPROG" "./bin/clisp-haskell")
103 #t)))))
104 (inputs
105 (list clisp))
106 (home-page "https://git.elephly.net/software/yale-haskell.git")
107 (synopsis "Port of the Yale Haskell system to CLISP")
108 (description "This package provides the Yale Haskell system running on
109 top of CLISP.")
110 (license license:bsd-4))))
111
112 ;; This package contains lots of generated .hc files containing C code to
113 ;; bootstrap the compiler without a Haskell compiler. The included .hc files
114 ;; cover not just the compiler sources but also all Haskell libraries.
115 (define-public nhc98
116 (package
117 (name "nhc98")
118 (version "1.22")
119 (source
120 (origin
121 (method url-fetch)
122 (uri (string-append "https://www.haskell.org/nhc98/nhc98src-"
123 version ".tar.gz"))
124 (sha256
125 (base32
126 "0fkgxgsd2iqxvwcgnad1702kradwlbcal6rxdrgb22vd6dnc3i8l"))
127 (patches (search-patches "nhc98-c-update.patch"))))
128 (build-system gnu-build-system)
129 (supported-systems '("i686-linux" "x86_64-linux"))
130 (arguments
131 (list
132 #:tests? #false ;there is no test target
133 #:system "i686-linux"
134 #:parallel-build? #false ;not supported
135 #:strip-binaries? #false ;doesn't work
136 #:make-flags '(list "all-gcc")
137 #:phases
138 #~(modify-phases %standard-phases
139 (replace 'configure
140 (lambda _
141 (setenv "SHELL" (which "sh"))
142 (setenv "CPATH" (string-append
143 (getcwd) "/src/runtime/Kernel:"
144 (or (getenv "C_INCLUDE_PATH") "")))
145 (substitute* "configure"
146 (("echo '#!/bin/sh'")
147 (string-append "echo '#!" (which "sh") "'")))
148 (with-fluids ((%default-port-encoding #f))
149 (substitute* '("script/greencard.inst"
150 "script/harch.inst"
151 "script/hi.inst"
152 "script/hmake-config.inst"
153 ;; TODO: can't fix this with substitute*
154 ;"script/hmake.inst"
155 "script/hood.inst"
156 "script/hsc2hs.inst"
157 "script/nhc98-pkg.inst"
158 "script/nhc98.inst")
159 (("^MACHINE=.*") "MACHINE=ix86-Linux\n")))
160 (invoke "sh" "configure"
161 (string-append "--prefix=" #$output)
162 ;; Remove -m32 from compiler/linker invocation
163 "--ccoption="
164 "--ldoption=")))
165 (replace 'install
166 (lambda _
167 (invoke "sh" "configure"
168 (string-append "--prefix=" #$output)
169 ;; Remove -m32 from compiler/linker invocation
170 "--ccoption="
171 "--ldoption="
172 "--install"))))))
173 (home-page "https://www.haskell.org/nhc98")
174 (synopsis "Nearly a Haskell Compiler")
175 (description
176 "nhc98 is a small, standards-compliant compiler for Haskell 98, the lazy
177 functional programming language. It aims to produce small executables that
178 run in small amounts of memory. It produces medium-fast code, and compilation
179 is itself quite fast.")
180 (license
181 (license:non-copyleft
182 "https://www.haskell.org/nhc98/copyright.html"))))
183
184 (define-public ghc-4
185 (package
186 (name "ghc")
187 (version "4.08.2")
188 (source
189 (origin
190 (method url-fetch)
191 (uri (string-append "https://www.haskell.org/ghc/dist/"
192 version "/" name "-" version "-src.tar.bz2"))
193 (sha256
194 (base32
195 "0ar4nxy4cr5vwvfj71gmc174vx0n3lg9ka05sa1k60c8z0g3xp1q"))
196 (patches (search-patches "ghc-4.patch"))))
197 (build-system gnu-build-system)
198 (supported-systems '("i686-linux" "x86_64-linux"))
199 (arguments
200 `(#:system "i686-linux"
201 #:strip-binaries? #f
202 #:phases
203 (modify-phases %standard-phases
204 (replace 'bootstrap
205 (lambda* (#:key inputs #:allow-other-keys)
206 (delete-file "configure")
207 (delete-file "config.sub")
208 (install-file (search-input-file inputs
209 "/bin/config.sub")
210 ".")
211
212 ;; Avoid dependency on "happy"
213 (substitute* "configure.in"
214 (("FPTOOLS_HAPPY") "echo sure\n"))
215
216 ;; Set options suggested in ghc/interpreter/README.BUILDING.HUGS.
217 (with-output-to-file "mk/build.mk"
218 (lambda ()
219 (display "
220 WithGhcHc=ghc-4.06
221 GhcLibWays=u
222 #HsLibsFor=hugs
223 # Setting this leads to building the interpreter.
224 GhcHcOpts=-DDEBUG
225 GhcRtsHcOpts=-optc-DDEBUG -optc-D__HUGS__ -unreg -optc-g -optc-D_GNU_SOURCE=1
226 GhcRtsCcOpts=-optc-DDEBUG -optc-g -optc-D__HUGS__ -optc-D_GNU_SOURCE=1
227 SplitObjs=NO
228 ")))
229
230 (substitute* "ghc/interpreter/interface.c"
231 ;; interface.c:2702: `stackOverflow' redeclared as different kind of symbol
232 ;; ../includes/Stg.h:188: previous declaration of `stackOverflow'
233 ((".*Sym\\(stackOverflow\\).*") "")
234 ;; interface.c:2713: `stg_error_entry' undeclared here (not in a function)
235 ;; interface.c:2713: initializer element is not constant
236 ;; interface.c:2713: (near initialization for `rtsTab[11].ad')
237 ((".*SymX\\(stg_error_entry\\).*") "")
238 ;; interface.c:2713: `Upd_frame_info' undeclared here (not in a function)
239 ;; interface.c:2713: initializer element is not constant
240 ;; interface.c:2713: (near initialization for `rtsTab[32].ad')
241 ((".*SymX\\(Upd_frame_info\\).*") ""))
242
243 ;; We need to use the absolute file names here or else the linker
244 ;; will complain about missing symbols. Perhaps this could be
245 ;; avoided by modifying the library search path in a way that
246 ;; this old linker understands.
247 (substitute* "ghc/interpreter/Makefile"
248 (("-lbfd -liberty")
249 (string-append (search-input-file inputs "/lib/libbfd.a") " "
250 (search-input-file inputs "/lib/libiberty.a"))))
251
252 (let ((bash (which "bash")))
253 (substitute* '("configure.in"
254 "ghc/configure.in"
255 "ghc/rts/gmp/mpn/configure.in"
256 "ghc/rts/gmp/mpz/configure.in"
257 "ghc/rts/gmp/configure.in"
258 "distrib/configure-bin.in")
259 (("`/bin/sh") (string-append "`" bash))
260 (("SHELL=/bin/sh") (string-append "SHELL=" bash))
261 (("^#! /bin/sh") (string-append "#! " bash)))
262
263 (substitute* '("mk/config.mk.in"
264 "ghc/rts/gmp/mpz/Makefile.in"
265 "ghc/rts/gmp/Makefile.in")
266 (("^SHELL.*=.*/bin/sh") (string-append "SHELL = " bash)))
267 (substitute* "aclocal.m4"
268 (("SHELL=/bin/sh") (string-append "SHELL=" bash)))
269
270 (setenv "CONFIG_SHELL" bash)
271 (setenv "SHELL" bash))
272
273 ;; The 'hscpp' script invokes GCC 2.95's 'cpp' (RAWCPP), which
274 ;; segfaults unless passed '-x c'.
275 (substitute* "mk/config.mk.in"
276 (("-traditional")
277 "-traditional -x c"))
278
279 (setenv "CPP" (which "cpp"))
280 (invoke "autoreconf" "--verbose" "--force")))
281 (add-before 'configure 'configure-gmp
282 (lambda* (#:key build inputs outputs #:allow-other-keys)
283 (with-directory-excursion "ghc/rts/gmp"
284 (let ((bash (which "bash"))
285 (out (assoc-ref outputs "out")))
286 (invoke bash "./configure")))))
287 (replace 'configure
288 (lambda* (#:key build inputs outputs #:allow-other-keys)
289 (let ((bash (which "bash"))
290 (out (assoc-ref outputs "out")))
291 (call-with-output-file "config.cache"
292 (lambda (port)
293 ;; GCC 2.95 fails to deal with anonymous unions in glibc's
294 ;; 'struct_rusage.h', so skip that.
295 (display "ac_cv_func_getrusage=no\n" port)))
296
297 (invoke bash "./configure"
298 "--enable-hc-boot"
299 (string-append "--prefix=" out)
300 (string-append "--build=" build)
301 (string-append "--host=" build)))))
302 (add-before 'build 'make-boot
303 (lambda _
304 ;; CLK_TCK has been removed from recent libc.
305 (substitute* "ghc/interpreter/nHandle.c"
306 (("CLK_TCK") "sysconf (_SC_CLK_TCK)"))
307
308 ;; Only when building with more recent GCC
309 (when #false
310 ;; GCC 2.95 is fine with these comments, but GCC 4.6 is not.
311 (substitute* "ghc/rts/universal_call_c.S"
312 (("^# .*") "")))
313
314 ;; Only when using more recent Perl
315 (when #false
316 (substitute* "ghc/driver/ghc-asm.prl"
317 (("local\\(\\$\\*\\) = 1;") "")
318 (("endef\\$/") "endef$/s")))
319
320 (setenv "CPATH"
321 (string-append (getcwd) "/ghc/includes:"
322 (getcwd) "/mk:"
323 (or (getenv "CPATH") "")))
324 (invoke "make" "boot")))
325 (replace 'build
326 (lambda _
327 ;; TODO: since we don't have a Haskell compiler we cannot build
328 ;; the standard library. And without the standard library we
329 ;; cannot build a Haskell compiler.
330 ;; make[3]: *** No rule to make target 'Array.o', needed by 'libHSstd.a'. Stop.
331 ;; make[2]: *** No rule to make target 'utils/Argv.o', needed by 'hsc'. Stop.
332 (invoke "make" "all")))
333 (add-after 'build 'build-hugs
334 (lambda _
335 (invoke "make" "-C" "ghc/interpreter")
336 (invoke "make" "-C" "ghc/interpreter" "install")))
337 (add-after 'install 'install-sources
338 (lambda* (#:key outputs #:allow-other-keys)
339 (let ((lib (string-append (assoc-ref outputs "out") "/lib")))
340 (copy-recursively "hslibs"
341 (string-append lib "/hslibs"))
342 (copy-recursively "ghc/lib"
343 (string-append lib "/ghc/lib"))
344 (copy-recursively "ghc/compiler"
345 (string-append lib "/ghc/compiler"))
346 (copy-recursively "ghc/interpreter/lib" lib)
347 (install-file "ghc/interpreter/nHandle.so" lib)))))))
348 (native-inputs
349 (list autoconf-2.13
350 bison ;for parser.y
351 config
352
353 ;; Needed to support lvalue casts.
354 gcc-2.95
355
356 ;; Use an older assembler to work around this error in GMP:
357 ;; Error: `%edx' not allowed with `testb'
358 binutils-2.33
359
360 ;; TODO: Perl used to allow setting $* to enable multi-line
361 ;; matching. If we want to use a more recent Perl we need to patch
362 ;; all expressions that require multi-line matching. Hard to tell.
363 perl-5.14))
364 (home-page "https://www.haskell.org/ghc")
365 (synopsis "The Glasgow Haskell Compiler")
366 (description
367 "The Glasgow Haskell Compiler (GHC) is a state-of-the-art compiler and
368 interactive environment for the functional language Haskell. The value of
369 this package lies in the modified build of Hugs that is linked with GHC's STG
370 runtime system, the RTS. \"STG\" stands for \"spineless, tagless,
371 G-machine\"; it is the abstract machine designed to support nonstrict
372 higher-order functional languages. Neither the compiler nor the Haskell
373 libraries are included in this package.")
374 (license license:bsd-3)))
375
376 (define ghc-bootstrap-x86_64-7.8.4
377 (origin
378 (method url-fetch)
379 (uri
380 "https://www.haskell.org/ghc/dist/7.8.4/ghc-7.8.4-x86_64-unknown-linux-deb7.tar.xz")
381 (sha256
382 (base32
383 "13azsl53xgj20mi1hj9x0xb32vvcvs6cpmvwx6znxhas7blh0bpn"))))
384
385 (define ghc-bootstrap-i686-7.8.4
386 (origin
387 (method url-fetch)
388 (uri
389 "https://www.haskell.org/ghc/dist/7.8.4/ghc-7.8.4-i386-unknown-linux-deb7.tar.xz")
390 (sha256
391 (base32
392 "0wj5s435j0zgww70bj1d3f6wvnnpzlxwvwcyh2qv4qjq5z8j64kg"))))
393
394 ;; 43 tests out of 3965 fail.
395 ;;
396 ;; Most of them do not appear to be serious:
397 ;;
398 ;; - some tests generate files referring to "/bin/sh" and "/bin/ls". I've not
399 ;; figured out how these references are generated.
400 ;;
401 ;; - Some tests allocate more memory than expected (ca. 3% above upper limit)
402 ;;
403 ;; - Some tests try to load unavailable libriries: Control.Concurrent.STM,
404 ;; Data.Vector, Control.Monad.State.
405 ;;
406 ;; - Test posix010 tries to check the existence of a user on the system:
407 ;; getUserEntryForName: does not exist (no such user)
408 (define-public ghc-7
409 (package
410 (name "ghc")
411 (version "7.10.2")
412 (source
413 (origin
414 (method url-fetch)
415 (uri (string-append "https://www.haskell.org/ghc/dist/"
416 version "/" name "-" version "-src.tar.xz"))
417 (sha256
418 (base32
419 "1x8m4rp2v7ydnrz6z9g8x7z3x3d3pxhv2pixy7i7hkbqbdsp7kal"))))
420 (build-system gnu-build-system)
421 (supported-systems '("i686-linux" "x86_64-linux"))
422 (outputs '("out" "doc"))
423 (inputs
424 `(("gmp" ,gmp)
425 ("ncurses" ,ncurses)
426 ("libffi" ,libffi)
427 ("ghc-testsuite"
428 ,(origin
429 (method url-fetch)
430 (uri (string-append
431 "https://www.haskell.org/ghc/dist/"
432 version "/" name "-" version "-testsuite.tar.xz"))
433 (sha256
434 (base32
435 "0qp9da9ar87zbyn6wjgacd2ic1vgzbi3cklxnhsmjqyafv9qaj4b"))))))
436 (native-inputs
437 `(("perl" ,perl)
438 ("python" ,python-2) ; for tests (fails with python-3)
439 ("ghostscript" ,ghostscript) ; for tests
440 ("patchelf" ,patchelf)
441 ;; GHC is built with GHC. Therefore we need bootstrap binaries.
442 ("ghc-binary"
443 ,(if (string-match "x86_64" (or (%current-target-system) (%current-system)))
444 ghc-bootstrap-x86_64-7.8.4
445 ghc-bootstrap-i686-7.8.4))))
446 (arguments
447 `(#:test-target "test"
448 ;; We get a smaller number of test failures by disabling parallel test
449 ;; execution.
450 #:parallel-tests? #f
451
452 ;; Don't pass --build=<triplet>, because the configure script
453 ;; auto-detects slightly different triplets for --host and --target and
454 ;; then complains that they don't match.
455 #:build #f
456
457 #:modules ((guix build gnu-build-system)
458 (guix build utils)
459 (srfi srfi-26)
460 (srfi srfi-1))
461 #:configure-flags
462 (list
463 (string-append "--with-gmp-libraries="
464 (assoc-ref %build-inputs "gmp") "/lib")
465 (string-append "--with-gmp-includes="
466 (assoc-ref %build-inputs "gmp") "/include")
467 "--with-system-libffi"
468 (string-append "--with-ffi-libraries="
469 (assoc-ref %build-inputs "libffi") "/lib")
470 (string-append "--with-ffi-includes="
471 (assoc-ref %build-inputs "libffi") "/include"))
472 ;; FIXME: The user-guide needs dblatex, docbook-xsl and docbook-utils.
473 ;; Currently we do not have the last one.
474 ;; #:make-flags
475 ;; (list "BUILD_DOCBOOK_HTML = YES")
476 #:phases
477 (let* ((ghc-bootstrap-path
478 (string-append (getcwd) "/" ,name "-" ,version "/ghc-bin"))
479 (ghc-bootstrap-prefix
480 (string-append ghc-bootstrap-path "/usr" )))
481 (alist-cons-after
482 'unpack-bin 'unpack-testsuite-and-fix-bins
483 (lambda* (#:key inputs outputs #:allow-other-keys)
484 (with-directory-excursion ".."
485 (copy-file (assoc-ref inputs "ghc-testsuite")
486 "ghc-testsuite.tar.xz")
487 (invoke "tar" "xvf" "ghc-testsuite.tar.xz"))
488 (substitute*
489 (list "testsuite/timeout/Makefile"
490 "testsuite/timeout/timeout.py"
491 "testsuite/timeout/timeout.hs"
492 "testsuite/tests/rename/prog006/Setup.lhs"
493 "testsuite/tests/programs/life_space_leak/life.test"
494 "libraries/process/System/Process/Internals.hs"
495 "libraries/unix/cbits/execvpe.c")
496 (("/bin/sh") (which "sh"))
497 (("/bin/rm") "rm"))
498 #t)
499 (alist-cons-after
500 'unpack 'unpack-bin
501 (lambda* (#:key inputs outputs #:allow-other-keys)
502 (mkdir-p ghc-bootstrap-prefix)
503 (with-directory-excursion ghc-bootstrap-path
504 (copy-file (assoc-ref inputs "ghc-binary")
505 "ghc-bin.tar.xz")
506 (invoke "tar" "xvf" "ghc-bin.tar.xz")))
507 (alist-cons-before
508 'install-bin 'configure-bin
509 (lambda* (#:key inputs outputs #:allow-other-keys)
510 (let* ((binaries
511 (list
512 "./utils/ghc-pwd/dist-install/build/tmp/ghc-pwd"
513 "./utils/hpc/dist-install/build/tmp/hpc"
514 "./utils/haddock/dist/build/tmp/haddock"
515 "./utils/hsc2hs/dist-install/build/tmp/hsc2hs"
516 "./utils/runghc/dist-install/build/tmp/runghc"
517 "./utils/ghc-cabal/dist-install/build/tmp/ghc-cabal"
518 "./utils/hp2ps/dist/build/tmp/hp2ps"
519 "./utils/ghc-pkg/dist-install/build/tmp/ghc-pkg"
520 "./utils/unlit/dist/build/tmp/unlit"
521 "./ghc/stage2/build/tmp/ghc-stage2"))
522 (gmp (assoc-ref inputs "gmp"))
523 (gmp-lib (string-append gmp "/lib"))
524 (gmp-include (string-append gmp "/include"))
525 (ncurses-lib
526 (dirname (search-input-file inputs "/lib/libncurses.so")))
527 (ld-so (search-input-file inputs ,(glibc-dynamic-linker)))
528 (libtinfo-dir
529 (string-append ghc-bootstrap-prefix
530 "/lib/ghc-7.8.4/terminfo-0.4.0.0")))
531 (with-directory-excursion
532 (string-append ghc-bootstrap-path "/ghc-7.8.4")
533 (setenv "CONFIG_SHELL" (which "bash"))
534 (setenv "LD_LIBRARY_PATH" gmp-lib)
535 ;; The binaries have "/lib64/ld-linux-x86-64.so.2" hardcoded.
536 (for-each
537 (cut invoke "patchelf" "--set-interpreter" ld-so <>)
538 binaries)
539 ;; The binaries include a reference to libtinfo.so.5 which
540 ;; is a subset of libncurses.so.5. We create a symlink in a
541 ;; directory included in the bootstrap binaries rpath.
542 (mkdir-p libtinfo-dir)
543 (symlink
544 (string-append ncurses-lib "/libncursesw.so."
545 ;; Extract "6.0" from "6.0-20170930" if a
546 ;; dash-separated version tag exists.
547 ,(let* ((v (package-version ncurses))
548 (d (or (string-index v #\-)
549 (string-length v))))
550 (version-major+minor (string-take v d))))
551 (string-append libtinfo-dir "/libtinfo.so.5"))
552
553 (setenv "PATH"
554 (string-append (getenv "PATH") ":"
555 ghc-bootstrap-prefix "/bin"))
556 (invoke
557 (string-append (getcwd) "/configure")
558 (string-append "--prefix=" ghc-bootstrap-prefix)
559 (string-append "--with-gmp-libraries=" gmp-lib)
560 (string-append "--with-gmp-includes=" gmp-include)))))
561 (alist-cons-before
562 'configure 'install-bin
563 (lambda* (#:key inputs outputs #:allow-other-keys)
564 (with-directory-excursion
565 (string-append ghc-bootstrap-path "/ghc-7.8.4")
566 (invoke "make" "install")))
567 %standard-phases)))))))
568 (native-search-paths (list (search-path-specification
569 (variable "GHC_PACKAGE_PATH")
570 (files (list
571 (string-append "lib/ghc-" version)))
572 (file-pattern ".*\\.conf\\.d$")
573 (file-type 'directory))))
574 (home-page "https://www.haskell.org/ghc")
575 (synopsis "The Glasgow Haskell Compiler")
576 (description
577 "The Glasgow Haskell Compiler (GHC) is a state-of-the-art compiler and
578 interactive environment for the functional language Haskell.")
579 (license license:bsd-3)))
580
581 (define-public ghc-8.0
582 (package
583 (name "ghc")
584 (version "8.0.2")
585 (source
586 (origin
587 (method url-fetch)
588 (uri (string-append "https://www.haskell.org/ghc/dist/"
589 version "/" name "-" version "-src.tar.xz"))
590 (sha256
591 (base32 "1c8qc4fhkycynk4g1f9hvk53dj6a1vvqi6bklqznns6hw59m8qhi"))
592 (patches
593 (search-patches "ghc-8.0-fall-back-to-madv_dontneed.patch"))))
594 (build-system gnu-build-system)
595 (supported-systems '("i686-linux" "x86_64-linux"))
596 (outputs '("out" "doc"))
597 (inputs
598 `(("gmp" ,gmp)
599 ("ncurses" ,ncurses)
600 ("libffi" ,libffi)
601 ("ghc-testsuite"
602 ,(origin
603 (method url-fetch)
604 (uri (string-append
605 "https://www.haskell.org/ghc/dist/"
606 version "/" name "-" version "-testsuite.tar.xz"))
607 (sha256
608 (base32 "1wjc3x68l305bl1h1ijd3yhqp2vqj83lkp3kqbr94qmmkqlms8sj"))))))
609 (native-inputs
610 `(("perl" ,perl)
611 ("python" ,python-2) ; for tests
612 ("ghostscript" ,ghostscript) ; for tests
613 ;; GHC is built with GHC.
614 ("ghc-bootstrap" ,ghc-7)))
615 (arguments
616 `(#:test-target "test"
617 ;; We get a smaller number of test failures by disabling parallel test
618 ;; execution.
619 #:parallel-tests? #f
620
621 ;; Don't pass --build=<triplet>, because the configure script
622 ;; auto-detects slightly different triplets for --host and --target and
623 ;; then complains that they don't match.
624 #:build #f
625
626 #:configure-flags
627 (list
628 (string-append "--with-gmp-libraries="
629 (assoc-ref %build-inputs "gmp") "/lib")
630 (string-append "--with-gmp-includes="
631 (assoc-ref %build-inputs "gmp") "/include")
632 "--with-system-libffi"
633 (string-append "--with-ffi-libraries="
634 (assoc-ref %build-inputs "libffi") "/lib")
635 (string-append "--with-ffi-includes="
636 (assoc-ref %build-inputs "libffi") "/include")
637 (string-append "--with-curses-libraries="
638 (assoc-ref %build-inputs "ncurses") "/lib")
639 (string-append "--with-curses-includes="
640 (assoc-ref %build-inputs "ncurses") "/include"))
641 #:phases
642 (modify-phases %standard-phases
643 (add-after 'unpack 'unpack-testsuite
644 (lambda* (#:key inputs #:allow-other-keys)
645 (with-directory-excursion ".."
646 (copy-file (assoc-ref inputs "ghc-testsuite")
647 "ghc-testsuite.tar.xz")
648 (zero? (system* "tar" "xvf" "ghc-testsuite.tar.xz")))))
649 (add-before 'build 'fix-lib-paths
650 (lambda _
651 (substitute*
652 (list "libraries/process/System/Process/Posix.hs"
653 "libraries/process/tests/process001.hs"
654 "libraries/process/tests/process002.hs"
655 "libraries/unix/cbits/execvpe.c")
656 (("/bin/sh") (which "sh"))
657 (("/bin/ls") (which "ls")))
658 #t))
659 (add-before 'build 'fix-environment
660 (lambda _
661 (unsetenv "GHC_PACKAGE_PATH")
662 (setenv "CONFIG_SHELL" (which "bash"))
663 #t))
664 (add-before 'check 'fix-testsuite
665 (lambda _
666 (substitute*
667 (list "testsuite/timeout/Makefile"
668 "testsuite/timeout/timeout.py"
669 "testsuite/timeout/timeout.hs"
670 "testsuite/tests/programs/life_space_leak/life.test")
671 (("/bin/sh") (which "sh"))
672 (("/bin/rm") "rm"))
673 #t)))))
674 (native-search-paths (list (search-path-specification
675 (variable "GHC_PACKAGE_PATH")
676 (files (list
677 (string-append "lib/ghc-" version)))
678 (file-pattern ".*\\.conf\\.d$")
679 (file-type 'directory))))
680 (home-page "https://www.haskell.org/ghc")
681 (synopsis "The Glasgow Haskell Compiler")
682 (description
683 "The Glasgow Haskell Compiler (GHC) is a state-of-the-art compiler and
684 interactive environment for the functional language Haskell.")
685 (license license:bsd-3)))
686
687 (define-public ghc-8.4
688 (package (inherit ghc-8.0)
689 (name "ghc")
690 (version "8.4.4")
691 (source
692 (origin
693 (method url-fetch)
694 (uri (string-append "https://www.haskell.org/ghc/dist/"
695 version "/" name "-" version "-src.tar.xz"))
696 (sha256
697 (base32 "1ch4j2asg7pr52ai1hwzykxyj553wndg7wq93i47ql4fllspf48i"))))
698 (inputs
699 (list gmp ncurses libffi))
700 (native-inputs
701 `(("perl" ,perl)
702 ("python" ,python) ; for tests
703 ("ghostscript" ,ghostscript) ; for tests
704 ;; GHC 8.4.3 is built with GHC 8.
705 ("ghc-bootstrap" ,ghc-8.0)
706 ("ghc-testsuite"
707 ,(origin
708 (method url-fetch)
709 (uri (string-append
710 "https://www.haskell.org/ghc/dist/"
711 version "/" name "-" version "-testsuite.tar.xz"))
712 (sha256
713 (base32
714 "0s8lf9sxj7n89pjagi58b3fahnp34qvmwhnn0j1fbg6955vbrfj6"))))))
715 (arguments
716 `(#:test-target "test"
717 ;; We get a smaller number of test failures by disabling parallel test
718 ;; execution.
719 #:parallel-tests? #f
720
721 ;; Don't pass --build=<triplet>, because the configure script
722 ;; auto-detects slightly different triplets for --host and --target and
723 ;; then complains that they don't match.
724 #:build #f
725
726 #:configure-flags
727 (list
728 (string-append "--with-gmp-libraries="
729 (assoc-ref %build-inputs "gmp") "/lib")
730 (string-append "--with-gmp-includes="
731 (assoc-ref %build-inputs "gmp") "/include")
732 "--with-system-libffi"
733 (string-append "--with-ffi-libraries="
734 (assoc-ref %build-inputs "libffi") "/lib")
735 (string-append "--with-ffi-includes="
736 (assoc-ref %build-inputs "libffi") "/include")
737 (string-append "--with-curses-libraries="
738 (assoc-ref %build-inputs "ncurses") "/lib")
739 (string-append "--with-curses-includes="
740 (assoc-ref %build-inputs "ncurses") "/include"))
741 #:phases
742 (modify-phases %standard-phases
743 (add-after 'unpack 'unpack-testsuite
744 (lambda* (#:key inputs #:allow-other-keys)
745 (invoke "tar" "xvf"
746 (assoc-ref inputs "ghc-testsuite")
747 "--strip-components=1")
748 #t))
749 ;; This phase patches the 'ghc-pkg' command so that it sorts the list
750 ;; of packages in the binary cache it generates.
751 (add-before 'build 'fix-ghc-pkg-nondeterminism
752 (lambda _
753 (substitute* "utils/ghc-pkg/Main.hs"
754 (("confs = map \\(path </>\\) \\$ filter \\(\".conf\" `isSuffixOf`\\) fs")
755 "confs = map (path </>) $ filter (\".conf\" `isSuffixOf`) (sort fs)"))
756 #t))
757 (add-after 'unpack-testsuite 'fix-shell-wrappers
758 (lambda _
759 (substitute* '("driver/ghci/ghc.mk"
760 "utils/mkdirhier/ghc.mk"
761 "rules/shell-wrapper.mk")
762 (("echo '#!/bin/sh'")
763 (format #f "echo '#!~a'" (which "sh"))))
764 #t))
765 ;; This is necessary because the configure system no longer uses
766 ;; “AC_PATH_” but “AC_CHECK_”, setting the variables to just the
767 ;; plain command names.
768 (add-before 'configure 'set-target-programs
769 (lambda* (#:key inputs #:allow-other-keys)
770 (let ((binutils (assoc-ref inputs "binutils"))
771 (gcc (assoc-ref inputs "gcc"))
772 (ld-wrapper (assoc-ref inputs "ld-wrapper")))
773 (setenv "CC" (string-append gcc "/bin/gcc"))
774 (setenv "CXX" (string-append gcc "/bin/g++"))
775 (setenv "LD" (string-append ld-wrapper "/bin/ld"))
776 (setenv "NM" (string-append binutils "/bin/nm"))
777 (setenv "RANLIB" (string-append binutils "/bin/ranlib"))
778 (setenv "STRIP" (string-append binutils "/bin/strip"))
779 ;; The 'ar' command does not follow the same pattern.
780 (setenv "fp_prog_ar" (string-append binutils "/bin/ar"))
781 #t)))
782 (add-before 'build 'fix-references
783 (lambda _
784 (substitute* '("testsuite/timeout/Makefile"
785 "testsuite/timeout/timeout.py"
786 "testsuite/timeout/timeout.hs"
787 "testsuite/tests/programs/life_space_leak/life.test"
788 ;; libraries
789 "libraries/process/System/Process/Posix.hs"
790 "libraries/process/tests/process001.hs"
791 "libraries/process/tests/process002.hs"
792 "libraries/unix/cbits/execvpe.c")
793 (("/bin/sh") (which "sh"))
794 (("/bin/ls") (which "ls"))
795 (("/bin/rm") "rm"))
796 #t))
797 (add-before 'build 'fix-environment
798 (lambda _
799 (unsetenv "GHC_PACKAGE_PATH")
800 (setenv "CONFIG_SHELL" (which "bash"))
801 #t)))))
802 (native-search-paths (list (search-path-specification
803 (variable "GHC_PACKAGE_PATH")
804 (files (list
805 (string-append "lib/ghc-" version)))
806 (file-pattern ".*\\.conf\\.d$")
807 (file-type 'directory))))))
808
809 (define-public ghc-8.6
810 (package (inherit ghc-8.4)
811 (name "ghc")
812 (version "8.6.5")
813 (source
814 (origin
815 (method url-fetch)
816 (uri (string-append "https://www.haskell.org/ghc/dist/"
817 version "/" name "-" version "-src.tar.xz"))
818 (sha256
819 (base32 "0qg3zsmbk4rkwkc3jpas3zs74qaxmw4sp4v1mhsbj0a0dzls2jjd"))))
820 (native-inputs
821 `(;; GHC 8.6.5 must be built with GHC >= 8.2.
822 ("ghc-bootstrap" ,ghc-8.4)
823 ("ghc-testsuite"
824 ,(origin
825 (method url-fetch)
826 (uri (string-append
827 "https://www.haskell.org/ghc/dist/"
828 version "/" name "-" version "-testsuite.tar.xz"))
829 (patches (search-patches "ghc-testsuite-dlopen-pie.patch"))
830 (sha256
831 (base32
832 "0pw9r91g2np3i806g2f4f8z4jfdd7mx226cmdizk4swa7av1qf91"))))
833 ,@(filter (match-lambda
834 (("ghc-bootstrap" . _) #f)
835 (("ghc-testsuite" . _) #f)
836 (_ #t))
837 (package-native-inputs ghc-8.4))))
838 (arguments
839 (substitute-keyword-arguments (package-arguments ghc-8.4)
840 ((#:make-flags make-flags ''())
841 `(cons "EXTRA_RUNTEST_OPTS=--skip-perf-tests"
842 ,make-flags))
843 ((#:phases phases '%standard-phases)
844 `(modify-phases ,phases
845 (add-after 'install 'remove-unnecessary-references
846 (lambda* (#:key outputs #:allow-other-keys)
847 (substitute* (find-files (string-append (assoc-ref outputs "out") "/lib/")
848 "settings")
849 (("/gnu/store/.*/bin/(.*)" m program) program))
850
851 ;; Remove references to "doc" output from "out" by rewriting
852 ;; the "haddock-interfaces" fields and removing the optional
853 ;; "haddock-html" field in the generated .conf files.
854 (let ((doc (assoc-ref outputs "doc"))
855 (out (assoc-ref outputs "out")))
856 (with-fluids ((%default-port-encoding #f))
857 (for-each (lambda (config-file)
858 (substitute* config-file
859 (("^haddock-html: .*") "\n")
860 (((format #f "^haddock-interfaces: ~a" doc))
861 (string-append "haddock-interfaces: " out))))
862 (find-files (string-append out "/lib") ".conf")))
863 ;; Move the referenced files to the "out" output.
864 (for-each (lambda (haddock-file)
865 (let* ((subdir (string-drop haddock-file (string-length doc)))
866 (new (string-append out subdir)))
867 (mkdir-p (dirname new))
868 (rename-file haddock-file new)))
869 (find-files doc "\\.haddock$")))
870 #t))
871 (add-after 'unpack-testsuite 'skip-tests
872 (lambda _
873 ;; These two tests refer to the root user, which doesn't exist
874 ;; (see <https://bugs.gnu.org/36692>).
875 (substitute* "libraries/unix/tests/all.T"
876 (("^test\\('T8108'") "# guix skipped: test('T8108'"))
877 (substitute* "libraries/unix/tests/libposix/all.T"
878 (("^test\\('posix010'") "# guix skipped: test('posix010'"))
879 #t))))))
880 (native-search-paths (list (search-path-specification
881 (variable "GHC_PACKAGE_PATH")
882 (files (list
883 (string-append "lib/ghc-" version)))
884 (file-pattern ".*\\.conf\\.d$")
885 (file-type 'directory))))))
886
887 (define-public ghc-8.8
888 (package (inherit ghc-8.6)
889 (name "ghc")
890 (version "8.8.4")
891 (source
892 (origin
893 (method url-fetch)
894 (uri (string-append "https://www.haskell.org/ghc/dist/"
895 version "/ghc-" version "-src.tar.xz"))
896 (sha256
897 (base32 "0bgwbxxvdn56l91bp9p5d083gzcfdi6z8l8b17qzjpr3n8w5wl7h"))))
898 (native-inputs
899 `(("ghc-bootstrap" ,ghc-8.6)
900 ("ghc-testsuite"
901 ,(origin
902 (method url-fetch)
903 (uri (string-append
904 "https://www.haskell.org/ghc/dist/"
905 version "/ghc-" version "-testsuite.tar.xz"))
906 (patches (search-patches "ghc-testsuite-dlopen-pie.patch"))
907 (sha256
908 (base32
909 "0c55pj2820q26rikhpf636sn4mjgqsxjrl94vsywrh79dxp3k14z"))))
910 ("git" ,git-minimal/fixed) ; invoked during tests
911 ,@(filter (match-lambda
912 (("ghc-bootstrap" . _) #f)
913 (("ghc-testsuite" . _) #f)
914 (_ #t))
915 (package-native-inputs ghc-8.6))))
916 (arguments
917 (substitute-keyword-arguments (package-arguments ghc-8.6)
918 ((#:phases phases '%standard-phases)
919 `(modify-phases ,phases
920 (add-after 'fix-references 'fix-cc-reference
921 (lambda _
922 (substitute* "utils/hsc2hs/Common.hs"
923 (("\"cc\"") "\"gcc\""))
924 #t))
925 (add-after 'unpack-testsuite 'skip-more-tests
926 (lambda _
927 ;; XXX: This test fails because our ld-wrapper script
928 ;; mangles the response file passed to the linker.
929 (substitute* "testsuite/tests/hp2ps/all.T"
930 (("^test\\('T15904'") "# guix skipped: test('T15904'"))
931 #t))))))
932 (native-search-paths (list (search-path-specification
933 (variable "GHC_PACKAGE_PATH")
934 (files (list
935 (string-append "lib/ghc-" version)))
936 (file-pattern ".*\\.conf\\.d$")
937 (file-type 'directory))))))
938
939 (define-public ghc-8.10
940 (package
941 (inherit ghc-8.8)
942 (name "ghc")
943 (version "8.10.7")
944 (source
945 (origin
946 (method url-fetch)
947 (uri (string-append "https://www.haskell.org/ghc/dist/"
948 version "/ghc-" version "-src.tar.xz"))
949 (sha256
950 (base32 "179ws2q0dinl1a39wm9j37xzwm84zfz3c5543vz8v479khigdvp3"))))
951 (native-inputs
952 `(("ghc-bootstrap" ,ghc-8.8)
953 ("ghc-testsuite"
954 ,(origin
955 (method url-fetch)
956 (uri (string-append
957 "https://www.haskell.org/ghc/dist/"
958 version "/ghc-" version "-testsuite.tar.xz"))
959 (patches (search-patches "ghc-testsuite-dlopen-pie.patch"))
960 (sha256
961 (base32
962 "1zl25gg6bpx5601k8h3cqnns1xfc0nqgwnh8jvn2s65ra3f2g1nz"))))
963 ("git" ,git-minimal/fixed) ; invoked during tests
964 ,@(filter (match-lambda
965 (("ghc-bootstrap" . _) #f)
966 (("ghc-testsuite" . _) #f)
967 (_ #t))
968 (package-native-inputs ghc-8.8))))
969 (arguments
970 (substitute-keyword-arguments (package-arguments ghc-8.8)
971 ((#:phases phases '%standard-phases)
972 `(modify-phases ,phases
973 (add-after 'unpack-testsuite 'patch-more-shebangs
974 (lambda* (#:key inputs #:allow-other-keys)
975 (let ((bash (assoc-ref inputs "bash")))
976 (substitute* '("testsuite/tests/driver/T8602/T8602.script")
977 (("/bin/sh")
978 (string-append bash "/bin/sh"))))))
979 ;; Mark failing tests as broken. Reason for failure is unknown.
980 (add-after 'skip-more-tests 'skip-even-more-tests
981 (lambda _
982 (substitute* '("testsuite/tests/driver/T16521/all.T")
983 (("extra_files" all) (string-append "[" all))
984 (("\\]\\), " all)
985 (string-append all "expect_broken(0)], ")))))
986 ;; TODO: Turn this into an undconditional patch on the next rebuild.
987 ,@(if (string-prefix? "i686" (or (%current-target-system)
988 (%current-system)))
989 '((add-after 'skip-more-tests 'skip-failing-tests-i686
990 (lambda _
991 (substitute* '("testsuite/tests/codeGen/should_compile/all.T")
992 (("(test\\('T15155l', )when\\(unregisterised\\(\\), skip\\)" all before)
993 (string-append before "when(arch('i386'), skip)")))
994 ;; Unexpected failures:
995 ;; quasiquotation/T14028.run T14028 [bad stderr] (dyn)
996 (substitute* '("testsuite/tests/quasiquotation/all.T")
997 (("unless\\(config.have_ext_interp, skip\\),")
998 "unless(config.have_ext_interp, skip), when(arch('i386'), skip),")))))
999 '())))))
1000 (native-search-paths (list (search-path-specification
1001 (variable "GHC_PACKAGE_PATH")
1002 (files (list
1003 (string-append "lib/ghc-" version)))
1004 (file-pattern ".*\\.conf\\.d$")
1005 (file-type 'directory))))))
1006
1007 ;; Versions newer than ghc defined below (i.e. the compiler
1008 ;; haskell-build-system uses) should use ghc-next as their name to
1009 ;; ensure ghc (without version specification) and ghc-* packages are
1010 ;; always compatible. See https://issues.guix.gnu.org/issue/47335.
1011
1012 (define-public ghc-8 ghc-8.10)
1013
1014 (define-public ghc ghc-8)
1015
1016 ;;; haskell.scm ends here