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>
27 ;;; This file is part of GNU Guix.
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.
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.
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/>.
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))
73 (define-public cl-yale-haskell
74 (let ((commit "85f94c72a16c5f70301dd8db04cde9de2d7dd270")
77 (name "cl-yale-haskell")
78 (version (string-append "2.0.5-" revision "." (string-take commit 9)))
82 (url "https://git.elephly.net/software/yale-haskell.git")
84 (file-name (string-append "yale-haskell-" commit "-checkout"))
87 "0bal3m6ryrjamz5p93bhs9rp5msk8k7lpcqr44wd7xs9b9k8w74g"))))
88 (build-system gnu-build-system)
90 `(#:tests? #f ; no tests
91 ;; Stripping binaries leads to a broken executable lisp system image.
94 (list (string-append "PREFIX=" (assoc-ref %outputs "out")))
96 (modify-phases %standard-phases
99 (setenv "PRELUDE" "./progs/prelude")
100 (setenv "HASKELL_LIBRARY" "./progs/lib")
101 (setenv "PRELUDEBIN" "./progs/prelude/clisp")
102 (setenv "HASKELLPROG" "./bin/clisp-haskell")
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
110 (license license:bsd-4))))
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.
122 (uri (string-append "https://www.haskell.org/nhc98/nhc98src-"
126 "0fkgxgsd2iqxvwcgnad1702kradwlbcal6rxdrgb22vd6dnc3i8l"))
127 (patches (search-patches "nhc98-c-update.patch"))))
128 (build-system gnu-build-system)
129 (supported-systems '("i686-linux" "x86_64-linux"))
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")
138 #~(modify-phases %standard-phases
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"
152 "script/hmake-config.inst"
153 ;; TODO: can't fix this with substitute*
157 "script/nhc98-pkg.inst"
159 (("^MACHINE=.*") "MACHINE=ix86-Linux\n")))
160 (invoke "sh" "configure"
161 (string-append "--prefix=" #$output)
162 ;; Remove -m32 from compiler/linker invocation
167 (invoke "sh" "configure"
168 (string-append "--prefix=" #$output)
169 ;; Remove -m32 from compiler/linker invocation
173 (home-page "https://www.haskell.org/nhc98")
174 (synopsis "Nearly a Haskell Compiler")
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.")
181 (license:non-copyleft
182 "https://www.haskell.org/nhc98/copyright.html"))))
191 (uri (string-append "https://www.haskell.org/ghc/dist/"
192 version "/" name "-" version "-src.tar.bz2"))
195 "0ar4nxy4cr5vwvfj71gmc174vx0n3lg9ka05sa1k60c8z0g3xp1q"))
196 (patches (search-patches "ghc-4.patch"))))
197 (build-system gnu-build-system)
198 (supported-systems '("i686-linux" "x86_64-linux"))
200 `(#:system "i686-linux"
203 (modify-phases %standard-phases
205 (lambda* (#:key inputs #:allow-other-keys)
206 (delete-file "configure")
207 (delete-file "config.sub")
208 (install-file (search-input-file inputs
212 ;; Avoid dependency on "happy"
213 (substitute* "configure.in"
214 (("FPTOOLS_HAPPY") "echo sure\n"))
216 ;; Set options suggested in ghc/interpreter/README.BUILDING.HUGS.
217 (with-output-to-file "mk/build.mk"
223 # Setting this leads to building the interpreter.
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
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\\).*") ""))
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"
249 (string-append (search-input-file inputs "/lib/libbfd.a") " "
250 (search-input-file inputs "/lib/libiberty.a"))))
252 (let ((bash (which "bash")))
253 (substitute* '("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)))
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)))
270 (setenv "CONFIG_SHELL" bash)
271 (setenv "SHELL" bash))
273 ;; The 'hscpp' script invokes GCC 2.95's 'cpp' (RAWCPP), which
274 ;; segfaults unless passed '-x c'.
275 (substitute* "mk/config.mk.in"
277 "-traditional -x c"))
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")))))
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"
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)))
297 (invoke bash "./configure"
299 (string-append "--prefix=" out)
300 (string-append "--build=" build)
301 (string-append "--host=" build)))))
302 (add-before 'build 'make-boot
304 ;; CLK_TCK has been removed from recent libc.
305 (substitute* "ghc/interpreter/nHandle.c"
306 (("CLK_TCK") "sysconf (_SC_CLK_TCK)"))
308 ;; Only when building with more recent GCC
310 ;; GCC 2.95 is fine with these comments, but GCC 4.6 is not.
311 (substitute* "ghc/rts/universal_call_c.S"
314 ;; Only when using more recent Perl
316 (substitute* "ghc/driver/ghc-asm.prl"
317 (("local\\(\\$\\*\\) = 1;") "")
318 (("endef\\$/") "endef$/s")))
321 (string-append (getcwd) "/ghc/includes:"
323 (or (getenv "CPATH") "")))
324 (invoke "make" "boot")))
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
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)))))))
353 ;; Needed to support lvalue casts.
356 ;; Use an older assembler to work around this error in GMP:
357 ;; Error: `%edx' not allowed with `testb'
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.
364 (home-page "https://www.haskell.org/ghc")
365 (synopsis "The Glasgow Haskell Compiler")
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)))
376 (define ghc-bootstrap-x86_64-7.8.4
380 "https://www.haskell.org/ghc/dist/7.8.4/ghc-7.8.4-x86_64-unknown-linux-deb7.tar.xz")
383 "13azsl53xgj20mi1hj9x0xb32vvcvs6cpmvwx6znxhas7blh0bpn"))))
385 (define ghc-bootstrap-i686-7.8.4
389 "https://www.haskell.org/ghc/dist/7.8.4/ghc-7.8.4-i386-unknown-linux-deb7.tar.xz")
392 "0wj5s435j0zgww70bj1d3f6wvnnpzlxwvwcyh2qv4qjq5z8j64kg"))))
394 ;; 43 tests out of 3965 fail.
396 ;; Most of them do not appear to be serious:
398 ;; - some tests generate files referring to "/bin/sh" and "/bin/ls". I've not
399 ;; figured out how these references are generated.
401 ;; - Some tests allocate more memory than expected (ca. 3% above upper limit)
403 ;; - Some tests try to load unavailable libriries: Control.Concurrent.STM,
404 ;; Data.Vector, Control.Monad.State.
406 ;; - Test posix010 tries to check the existence of a user on the system:
407 ;; getUserEntryForName: does not exist (no such user)
415 (uri (string-append "https://www.haskell.org/ghc/dist/"
416 version "/" name "-" version "-src.tar.xz"))
419 "1x8m4rp2v7ydnrz6z9g8x7z3x3d3pxhv2pixy7i7hkbqbdsp7kal"))))
420 (build-system gnu-build-system)
421 (supported-systems '("i686-linux" "x86_64-linux"))
422 (outputs '("out" "doc"))
431 "https://www.haskell.org/ghc/dist/"
432 version "/" name "-" version "-testsuite.tar.xz"))
435 "0qp9da9ar87zbyn6wjgacd2ic1vgzbi3cklxnhsmjqyafv9qaj4b"))))))
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.
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))))
447 `(#:test-target "test"
448 ;; We get a smaller number of test failures by disabling parallel test
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.
457 #:modules ((guix build gnu-build-system)
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.
475 ;; (list "BUILD_DOCBOOK_HTML = YES")
477 (let* ((ghc-bootstrap-path
478 (string-append (getcwd) "/" ,name "-" ,version "/ghc-bin"))
479 (ghc-bootstrap-prefix
480 (string-append ghc-bootstrap-path "/usr" )))
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"))
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"))
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")
506 (invoke "tar" "xvf" "ghc-bin.tar.xz")))
508 'install-bin 'configure-bin
509 (lambda* (#:key inputs outputs #:allow-other-keys)
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"))
526 (dirname (search-input-file inputs "/lib/libncurses.so")))
527 (ld-so (search-input-file inputs ,(glibc-dynamic-linker)))
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.
537 (cut invoke "patchelf" "--set-interpreter" ld-so <>)
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)
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 #\-)
550 (version-major+minor (string-take v d))))
551 (string-append libtinfo-dir "/libtinfo.so.5"))
554 (string-append (getenv "PATH") ":"
555 ghc-bootstrap-prefix "/bin"))
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)))))
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")
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")
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)))
581 (define-public ghc-8.0
588 (uri (string-append "https://www.haskell.org/ghc/dist/"
589 version "/" name "-" version "-src.tar.xz"))
591 (base32 "1c8qc4fhkycynk4g1f9hvk53dj6a1vvqi6bklqznns6hw59m8qhi"))
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"))
605 "https://www.haskell.org/ghc/dist/"
606 version "/" name "-" version "-testsuite.tar.xz"))
608 (base32 "1wjc3x68l305bl1h1ijd3yhqp2vqj83lkp3kqbr94qmmkqlms8sj"))))))
611 ("python" ,python-2) ; for tests
612 ("ghostscript" ,ghostscript) ; for tests
613 ;; GHC is built with GHC.
614 ("ghc-bootstrap" ,ghc-7)))
616 `(#:test-target "test"
617 ;; We get a smaller number of test failures by disabling parallel test
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.
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"))
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
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")))
659 (add-before 'build 'fix-environment
661 (unsetenv "GHC_PACKAGE_PATH")
662 (setenv "CONFIG_SHELL" (which "bash"))
664 (add-before 'check 'fix-testsuite
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"))
674 (native-search-paths (list (search-path-specification
675 (variable "GHC_PACKAGE_PATH")
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")
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)))
687 (define-public ghc-8.4
688 (package (inherit ghc-8.0)
694 (uri (string-append "https://www.haskell.org/ghc/dist/"
695 version "/" name "-" version "-src.tar.xz"))
697 (base32 "1ch4j2asg7pr52ai1hwzykxyj553wndg7wq93i47ql4fllspf48i"))))
699 (list gmp ncurses libffi))
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)
710 "https://www.haskell.org/ghc/dist/"
711 version "/" name "-" version "-testsuite.tar.xz"))
714 "0s8lf9sxj7n89pjagi58b3fahnp34qvmwhnn0j1fbg6955vbrfj6"))))))
716 `(#:test-target "test"
717 ;; We get a smaller number of test failures by disabling parallel test
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.
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"))
742 (modify-phases %standard-phases
743 (add-after 'unpack 'unpack-testsuite
744 (lambda* (#:key inputs #:allow-other-keys)
746 (assoc-ref inputs "ghc-testsuite")
747 "--strip-components=1")
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
753 (substitute* "utils/ghc-pkg/Main.hs"
754 (("confs = map \\(path </>\\) \\$ filter \\(\".conf\" `isSuffixOf`\\) fs")
755 "confs = map (path </>) $ filter (\".conf\" `isSuffixOf`) (sort fs)"))
757 (add-after 'unpack-testsuite 'fix-shell-wrappers
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"))))
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"))
782 (add-before 'build 'fix-references
784 (substitute* '("testsuite/timeout/Makefile"
785 "testsuite/timeout/timeout.py"
786 "testsuite/timeout/timeout.hs"
787 "testsuite/tests/programs/life_space_leak/life.test"
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"))
797 (add-before 'build 'fix-environment
799 (unsetenv "GHC_PACKAGE_PATH")
800 (setenv "CONFIG_SHELL" (which "bash"))
802 (native-search-paths (list (search-path-specification
803 (variable "GHC_PACKAGE_PATH")
805 (string-append "lib/ghc-" version)))
806 (file-pattern ".*\\.conf\\.d$")
807 (file-type 'directory))))))
809 (define-public ghc-8.6
810 (package (inherit ghc-8.4)
816 (uri (string-append "https://www.haskell.org/ghc/dist/"
817 version "/" name "-" version "-src.tar.xz"))
819 (base32 "0qg3zsmbk4rkwkc3jpas3zs74qaxmw4sp4v1mhsbj0a0dzls2jjd"))))
821 `(;; GHC 8.6.5 must be built with GHC >= 8.2.
822 ("ghc-bootstrap" ,ghc-8.4)
827 "https://www.haskell.org/ghc/dist/"
828 version "/" name "-" version "-testsuite.tar.xz"))
829 (patches (search-patches "ghc-testsuite-dlopen-pie.patch"))
832 "0pw9r91g2np3i806g2f4f8z4jfdd7mx226cmdizk4swa7av1qf91"))))
833 ,@(filter (match-lambda
834 (("ghc-bootstrap" . _) #f)
835 (("ghc-testsuite" . _) #f)
837 (package-native-inputs ghc-8.4))))
839 (substitute-keyword-arguments (package-arguments ghc-8.4)
840 ((#:make-flags make-flags ''())
841 `(cons "EXTRA_RUNTEST_OPTS=--skip-perf-tests"
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/")
849 (("/gnu/store/.*/bin/(.*)" m program) program))
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$")))
871 (add-after 'unpack-testsuite 'skip-tests
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'"))
880 (native-search-paths (list (search-path-specification
881 (variable "GHC_PACKAGE_PATH")
883 (string-append "lib/ghc-" version)))
884 (file-pattern ".*\\.conf\\.d$")
885 (file-type 'directory))))))
887 (define-public ghc-8.8
888 (package (inherit ghc-8.6)
894 (uri (string-append "https://www.haskell.org/ghc/dist/"
895 version "/ghc-" version "-src.tar.xz"))
897 (base32 "0bgwbxxvdn56l91bp9p5d083gzcfdi6z8l8b17qzjpr3n8w5wl7h"))))
899 `(("ghc-bootstrap" ,ghc-8.6)
904 "https://www.haskell.org/ghc/dist/"
905 version "/ghc-" version "-testsuite.tar.xz"))
906 (patches (search-patches "ghc-testsuite-dlopen-pie.patch"))
909 "0c55pj2820q26rikhpf636sn4mjgqsxjrl94vsywrh79dxp3k14z"))))
910 ("git" ,git-minimal/fixed) ; invoked during tests
911 ,@(filter (match-lambda
912 (("ghc-bootstrap" . _) #f)
913 (("ghc-testsuite" . _) #f)
915 (package-native-inputs ghc-8.6))))
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
922 (substitute* "utils/hsc2hs/Common.hs"
923 (("\"cc\"") "\"gcc\""))
925 (add-after 'unpack-testsuite 'skip-more-tests
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'"))
932 (native-search-paths (list (search-path-specification
933 (variable "GHC_PACKAGE_PATH")
935 (string-append "lib/ghc-" version)))
936 (file-pattern ".*\\.conf\\.d$")
937 (file-type 'directory))))))
939 (define-public ghc-8.10
947 (uri (string-append "https://www.haskell.org/ghc/dist/"
948 version "/ghc-" version "-src.tar.xz"))
950 (base32 "179ws2q0dinl1a39wm9j37xzwm84zfz3c5543vz8v479khigdvp3"))))
952 `(("ghc-bootstrap" ,ghc-8.8)
957 "https://www.haskell.org/ghc/dist/"
958 version "/ghc-" version "-testsuite.tar.xz"))
959 (patches (search-patches "ghc-testsuite-dlopen-pie.patch"))
962 "1zl25gg6bpx5601k8h3cqnns1xfc0nqgwnh8jvn2s65ra3f2g1nz"))))
963 ("git" ,git-minimal/fixed) ; invoked during tests
964 ,@(filter (match-lambda
965 (("ghc-bootstrap" . _) #f)
966 (("ghc-testsuite" . _) #f)
968 (package-native-inputs ghc-8.8))))
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")
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
982 (substitute* '("testsuite/tests/driver/T16521/all.T")
983 (("extra_files" all) (string-append "[" 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)
989 '((add-after 'skip-more-tests 'skip-failing-tests-i686
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),")))))
1000 (native-search-paths (list (search-path-specification
1001 (variable "GHC_PACKAGE_PATH")
1003 (string-append "lib/ghc-" version)))
1004 (file-pattern ".*\\.conf\\.d$")
1005 (file-type 'directory))))))
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.
1012 (define-public ghc-8 ghc-8.10)
1014 (define-public ghc ghc-8)
1016 ;;; haskell.scm ends here