projects/guix·blob java-team · refs

2204 lines · 101.1 KiB

1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2015, 2016 Federico Beffa <[email protected]>
3;;; Copyright © 2015 Siniša Biđin <[email protected]>
4;;; Copyright © 2015 Paul van der Walt <[email protected]>
5;;; Copyright © 2015, 2019 Eric Bavier <[email protected]>
6;;; Copyright © 2016, 2018, 2019, 2021, 2026 Ludovic Courtès <[email protected]>
7;;; Copyright © 2013, 2016, 2017 Nikita <[email protected]>
8;;; Copyright © 2016, 2022, 2024 Efraim Flashner <[email protected]>
9;;; Copyright © 2015, 2016, 2017, 2018, 2019, 2020, 2022 Ricardo Wurmus <[email protected]>
10;;; Copyright © 2016, 2017 David Craven <[email protected]>
11;;; Copyright © 2017 Danny Milosavljevic <[email protected]>
12;;; Copyright © 2017 Peter Mikkelsen <[email protected]>
13;;; Copyright © 2017, 2018 Alex Vong <[email protected]>
14;;; Copyright © 2017 rsiddharth <[email protected]>
15;;; Copyright © 2017, 2018, 2019 Tobias Geerinckx-Rice <[email protected]>
16;;; Copyright © 2018 Tonton <[email protected]>
17;;; Copyright © 2018, 2019, 2020 Timothy Sample <[email protected]>
18;;; Copyright © 2018 Arun Isaac <[email protected]>
19;;; Copyright © 2018, 2019 Gabriel Hondet <[email protected]>
20;;; Copyright © 2019 Robert Vollmert <[email protected]>
21;;; Copyright © 2019 Jacob MacDonald <[email protected]>
22;;; Copyright © 2020 Marius Bakke <[email protected]>
23;;; Copyright © 2021 Matthew James Kraai <[email protected]>
24;;; Copyright © 2021 Xinglu Chen <[email protected]>
25;;; Copyright © 2021 Simon Tournier <[email protected]>
26;;; Copyright © 2023 Maxim Cournoyer <[email protected]>
27;;; Copyright © 2024 Gábor Stefanik <[email protected]>
28;;; Copyright © 2025 Janneke Nieuwenhuizen <[email protected]>
29;;; Copyright © 2026 Yarl Baudig <[email protected]>
30;;;
31;;; This file is part of GNU Guix.
32;;;
33;;; GNU Guix is free software; you can redistribute it and/or modify it
34;;; under the terms of the GNU General Public License as published by
35;;; the Free Software Foundation; either version 3 of the License, or (at
36;;; your option) any later version.
37;;;
38;;; GNU Guix is distributed in the hope that it will be useful, but
39;;; WITHOUT ANY WARRANTY; without even the implied warranty of
40;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
41;;; GNU General Public License for more details.
42;;;
43;;; You should have received a copy of the GNU General Public License
44;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
45
46(define-module (gnu packages haskell)
47 #:use-module (gnu packages)
48 #:use-module (gnu packages autotools)
49 #:use-module (gnu packages base)
50 #:use-module (gnu packages bash)
51 #:use-module (gnu packages bison)
52 #:use-module (gnu packages bootstrap)
53 #:use-module (gnu packages compression)
54 #:use-module (gnu packages elf)
55 #:use-module (gnu packages file)
56 #:use-module (gnu packages compiler-tools)
57 #:use-module (gnu packages gawk)
58 #:use-module (gnu packages gcc)
59 #:use-module (gnu packages ghostscript)
60 #:use-module (gnu packages libffi)
61 #:use-module (gnu packages linux)
62 #:use-module (gnu packages lisp)
63 #:use-module (gnu packages llvm)
64 #:use-module (gnu packages m4)
65 #:use-module (gnu packages multiprecision)
66 #:use-module (gnu packages ncurses)
67 #:use-module (gnu packages perl)
68 #:use-module (gnu packages python)
69 #:use-module (gnu packages version-control)
70 #:use-module (guix build-system gnu)
71 #:use-module (guix build-system haskell)
72 #:use-module (guix download)
73 #:use-module (guix git-download)
74 #:use-module (guix gexp)
75 #:use-module ((guix licenses) #:prefix license:)
76 #:use-module (guix packages)
77 #:use-module (guix utils)
78 #:use-module (ice-9 match)
79 #:use-module (ice-9 regex))
80
81(define-public cl-yale-haskell
82 (let ((commit "85f94c72a16c5f70301dd8db04cde9de2d7dd270")
83 (revision "1"))
84 (package
85 (name "cl-yale-haskell")
86 (version (string-append "2.0.5-" revision "." (string-take commit 9)))
87 (source (origin
88 (method git-fetch)
89 (uri (git-reference
90 (url "https://git.elephly.net/software/yale-haskell.git")
91 (commit commit)))
92 (file-name (string-append "yale-haskell-" commit "-checkout"))
93 (sha256
94 (base32
95 "0bal3m6ryrjamz5p93bhs9rp5msk8k7lpcqr44wd7xs9b9k8w74g"))))
96 (build-system gnu-build-system)
97 (arguments
98 `(#:tests? #f ; no tests
99 ;; Stripping binaries leads to a broken executable lisp system image.
100 #:strip-binaries? #f
101 #:make-flags
102 (list (string-append "PREFIX=" (assoc-ref %outputs "out")))
103 #:phases
104 (modify-phases %standard-phases
105 (replace 'configure
106 (lambda _
107 (setenv "PRELUDE" "./progs/prelude")
108 (setenv "HASKELL_LIBRARY" "./progs/lib")
109 (setenv "PRELUDEBIN" "./progs/prelude/clisp")
110 (setenv "HASKELLPROG" "./bin/clisp-haskell")
111 #t)))))
112 (inputs
113 (list clisp))
114 (home-page "https://git.elephly.net/software/yale-haskell.git")
115 (synopsis "Port of the Yale Haskell system to CLISP")
116 (description "This package provides the Yale Haskell system running on
117top of CLISP.")
118 (license license:bsd-4))))
119
120(define-public hugs
121 (package
122 (name "hugs")
123 (version "Sep2006")
124 (source
125 (origin
126 (method url-fetch)
127 (uri (string-append "https://www.haskell.org/hugs/downloads/2006-09/"
128 name "98-plus-" version ".tar.gz"))
129 (sha256
130 (base32
131 "1mdy4aq4campgmnpc2qwq7bsbfhaxfsqdghbyyz2wms4lnfcmyma"))
132 (patches (search-patches "hugs-fix-build.patch"))))
133 (build-system gnu-build-system)
134 (arguments
135 `(#:phases
136 (modify-phases %standard-phases
137 (add-before 'configure 'fix-sh-n-cp
138 (lambda _
139 (substitute*
140 '("configure"
141 "libraries/configure"
142 "packages/time/configure"
143 "packages/base/configure"
144 "packages/X11/configure"
145 "packages/HGL/configure"
146 "packages/OpenAL/configure"
147 "packages/OpenGL/configure"
148 "packages/network/configure"
149 "packages/unix/configure"
150 "packages/Cabal/tests/HSQL/configure"
151 "packages/ALUT/configure"
152 "packages/GLUT/configure"
153 "packages/base/cbits/execvpe.c"
154 "packages/base/System/Process/Internals.hs"
155 "packages/Cabal/Distribution/attic"
156 "packages/Cabal/Distribution/Simple/Register.hs"
157 "packages/Cabal/Distribution/Simple/Hugs.hs"
158 "tools/hugs-hc"
159 "src/machdep.c"
160 "libraries/Makefile.in")
161 (("/bin/sh") (which "sh")))
162 (substitute* '("demos/Makefile.in"
163 "libraries/Makefile.in")
164 (("/bin/cp") (which "cp")))
165 #t)))
166 #:tests? #f)) ; no test target
167 (native-inputs (list gcc-13))
168 (home-page "https://www.haskell.org/hugs/")
169 (synopsis "Functional programming system based on Haskell 98")
170 (description
171 "Hugs 98 is an interpreter and programming environment for developing
172Haskell programs. It provides an almost complete implementation of Haskell
17398, which includes expression and pattern syntax, primitives for monadic I/O,
174with support for simple interactive programs, handle-based I/O, and exception
175handling. Hugs has a nearly complete implementation of the Haskell module
176system and supports a number of advanced extensions.")
177 (license (license:non-copyleft "file://License"
178 "See License in the distribution."))))
179
180;; This package contains lots of generated .hc files containing C code to
181;; bootstrap the compiler without a Haskell compiler. The included .hc files
182;; cover not just the compiler sources but also all Haskell libraries.
183(define-public nhc98
184 (package
185 (name "nhc98")
186 (version "1.22")
187 (source
188 (origin
189 (method url-fetch)
190 (uri (string-append "https://www.haskell.org/nhc98/nhc98src-"
191 version ".tar.gz"))
192 (sha256
193 (base32
194 "0fkgxgsd2iqxvwcgnad1702kradwlbcal6rxdrgb22vd6dnc3i8l"))
195 (patches (search-patches "nhc98-c-update.patch"))))
196 (build-system gnu-build-system)
197 (supported-systems '("i686-linux" "x86_64-linux"))
198 (arguments
199 (list
200 #:tests? #false ;there is no test target
201 #:system "i686-linux"
202 #:parallel-build? #false ;not supported
203 #:strip-binaries? #false ;doesn't work
204 #:make-flags '(list "all-gcc")
205 #:phases
206 #~(modify-phases %standard-phases
207 (replace 'configure
208 (lambda _
209 (setenv "SHELL" (which "sh"))
210 (setenv "CPATH" (string-append
211 (getcwd) "/src/runtime/Kernel:"
212 (or (getenv "C_INCLUDE_PATH") "")))
213 (substitute* "configure"
214 (("echo '#!/bin/sh'")
215 (string-append "echo '#!" (which "sh") "'")))
216 (with-fluids ((%default-port-encoding #f))
217 (substitute* '("script/greencard.inst"
218 "script/harch.inst"
219 "script/hi.inst"
220 "script/hmake-config.inst"
221 ;; TODO: can't fix this with substitute*
222 ;"script/hmake.inst"
223 "script/hood.inst"
224 "script/hsc2hs.inst"
225 "script/nhc98-pkg.inst"
226 "script/nhc98.inst")
227 (("^MACHINE=.*") "MACHINE=ix86-Linux\n")))
228 (invoke "sh" "configure"
229 (string-append "--prefix=" #$output)
230 ;; Remove -m32 from compiler/linker invocation
231 "--ccoption="
232 "--ldoption=")))
233 (replace 'install
234 (lambda _
235 (invoke "sh" "configure"
236 (string-append "--prefix=" #$output)
237 ;; Remove -m32 from compiler/linker invocation
238 "--ccoption="
239 "--ldoption="
240 "--install"))))))
241 (home-page "https://www.haskell.org/nhc98")
242 (synopsis "Nearly a Haskell Compiler")
243 (description
244 "nhc98 is a small, standards-compliant compiler for Haskell 98, the lazy
245functional programming language. It aims to produce small executables that
246run in small amounts of memory. It produces medium-fast code, and compilation
247is itself quite fast.")
248 (license
249 (license:non-copyleft
250 "https://www.haskell.org/nhc98/copyright.html"))))
251
252(define-public ghc-4
253 (package
254 (name "ghc")
255 (version "4.08.2")
256 (source
257 (origin
258 (method url-fetch)
259 (uri (string-append "https://www.haskell.org/ghc/dist/"
260 version "/" name "-" version "-src.tar.bz2"))
261 (sha256
262 (base32
263 "0ar4nxy4cr5vwvfj71gmc174vx0n3lg9ka05sa1k60c8z0g3xp1q"))))
264 (build-system gnu-build-system)
265 (supported-systems '("i686-linux" "x86_64-linux"))
266 (arguments
267 (list
268 #:system "i686-linux"
269 #:strip-binaries? #f
270 #:parallel-build? #f
271 #:implicit-inputs? #f
272 #:modules '((guix build gnu-build-system)
273 (guix build utils)
274 (srfi srfi-1)
275 (ice-9 match))
276 #:phases
277 #~(modify-phases %standard-phases
278 (add-after 'unpack 'unpack-generated-c-code
279 (lambda* (#:key inputs #:allow-other-keys)
280 (let ((tarball
281 (match inputs
282 (((_ . locations) ...)
283 (let ((suffix (string-append "ghc-"
284 #$(package-version this-package)
285 "-x86-hc.tar.bz2")))
286 (find (lambda (location)
287 (string-suffix? suffix location))
288 locations))))))
289 (invoke "tar" "-xvf" tarball
290 "--strip-components=1"))))
291 (replace 'bootstrap
292 (lambda* (#:key inputs #:allow-other-keys)
293 (delete-file "configure")
294 (delete-file "config.sub")
295 (install-file (search-input-file inputs
296 "/bin/config.sub")
297 ".")
298
299 ;; Avoid dependency on "happy"
300 (substitute* "configure.in"
301 (("FPTOOLS_HAPPY") "echo sure\n"))
302
303 (let ((bash (which "bash")))
304 (substitute* '("configure.in"
305 "ghc/configure.in"
306 "ghc/rts/gmp/mpn/configure.in"
307 "ghc/rts/gmp/mpz/configure.in"
308 "ghc/rts/gmp/configure.in"
309 "distrib/configure-bin.in")
310 (("`/bin/sh") (string-append "`" bash))
311 (("SHELL=/bin/sh") (string-append "SHELL=" bash))
312 (("^#! /bin/sh") (string-append "#! " bash)))
313
314 (substitute* '("mk/config.mk.in"
315 "ghc/rts/gmp/mpz/Makefile.in"
316 "ghc/rts/gmp/Makefile.in")
317 (("^SHELL.*=.*/bin/sh") (string-append "SHELL = " bash)))
318 (substitute* "aclocal.m4"
319 (("SHELL=/bin/sh") (string-append "SHELL=" bash)))
320 (substitute* '("ghc/lib/std/cbits/system.c"
321 "hslibs/posix/cbits/execvpe.c")
322 (("/bin/sh") bash)
323 (("\"sh\"") (string-append "\"" bash "\"")))
324
325 (setenv "CONFIG_SHELL" bash)
326 (setenv "SHELL" bash))
327
328 ;; The 'hscpp' script invokes GCC 2.95's 'cpp' (RAWCPP), which
329 ;; segfaults unless passed '-x c'.
330 (substitute* "mk/config.mk.in"
331 (("-traditional")
332 "-traditional -x c"))
333
334 (setenv "CPP" (which "cpp"))
335 (invoke "autoreconf" "--verbose" "--force")))
336 (add-before 'configure 'configure-gmp
337 (lambda _
338 (with-directory-excursion "ghc/rts/gmp"
339 (invoke "./configure"))))
340 (replace 'configure
341 (lambda* (#:key build #:allow-other-keys)
342 (call-with-output-file "config.cache"
343 (lambda (port)
344 ;; GCC 2.95 fails to deal with anonymous unions in glibc's
345 ;; 'struct_rusage.h', so skip that.
346 (display "ac_cv_func_getrusage=no\n" port)))
347
348 ;; CLK_TCK has been removed from recent libc.
349 (substitute* "ghc/interpreter/nHandle.c"
350 (("CLK_TCK") "sysconf (_SC_CLK_TCK)"))
351 ;; Avoid duplicate definitions of execvpe
352 (substitute* "ghc/lib/std/cbits/stgio.h"
353 (("^int.*execvpe.*") ""))
354 ;; gid_t is an undefined type
355 (substitute* "hslibs/posix/PosixProcEnv.lhs"
356 (("gid_t") "int"))
357
358 ;; This is needed so that ghc/includes/Stg.h can see config.h,
359 ;; which defines values that are important for
360 ;; ghc/includes/StgTypes.h and others.
361 (setenv "CPATH"
362 (string-append (getcwd) "/ghc/includes:"
363 (getcwd) "/ghc/rts/gmp:"
364 (getcwd) "/mk:"
365 (or (getenv "CPATH") "")))
366
367 (with-output-to-file "mk/build.mk"
368 (lambda ()
369 (display "
370ProjectsToBuild = glafp-utils hslibs ghc
371GhcLibWays=
372GhcHcOpts=-DDEBUG
373GhcLibHcOpts= -O
374GhcRtsHcOpts=-optc-D_GNU_SOURCE=1 -optc-DDEBUG
375GhcRtsCcOpts=-optc-D_GNU_SOURCE=1 -optc-DDEBUG
376SplitObjs=YES
377GhcWithHscBuiltViaC=YES
378")))
379 (invoke "./configure"
380 "--enable-hc-boot" ; boot from C "source" files
381 ;; Embed the absolute file name of GCC 2.95 in the GHC
382 ;; driver script.
383 (string-append "--with-gcc=" (which "gcc"))
384 (string-append "--prefix=" #$output)
385 (string-append "--build=" build)
386 (string-append "--host=" build))))
387 ;; Build hsc
388 (add-before 'build 'make-boot
389 (lambda _
390 ;; Avoid calling happy
391 (invoke "touch" "ghc/compiler/rename/ParseIface.hs")
392 (invoke "touch" "ghc/compiler/parser/Parser.hs")
393 (invoke "make" "boot" "all")))
394 ;; Build libraries
395 (replace 'build
396 (lambda _
397 ;; Build these from their Haskell sources.
398 (invoke "sh" "-c" "echo GhcWithHscBuiltViaC=NO >>mk/build.mk")
399 (with-directory-excursion "ghc/lib"
400 (invoke "make" "clean" "boot" "all"))
401 (with-directory-excursion "hslibs"
402 (invoke "make" "clean" "boot" "all"))))
403 (add-before 'install 'do-not-strip
404 (lambda _
405 (substitute* '("install-sh"
406 "ghc/rts/gmp/install.sh")
407 (("^stripprog=.*") "stripprog=echo\n"))
408 (substitute* "mk/opts.mk"
409 (("^SRC_INSTALL_BIN_OPTS.*") "")))))))
410 (native-inputs
411 (modify-inputs (%final-inputs)
412 (delete "binutils" "gcc")
413 (prepend
414 autoconf-2.13
415 bison ;for parser.y
416 config
417
418 ;; Use an older assembler to work around this error in GMP:
419 ;; Error: `%edx' not allowed with `testb'
420 binutils-2.33
421
422 ;; Needed to support lvalue casts.
423 gcc-2.95
424
425 ;; Perl used to allow setting $* to enable multi-line matching. If
426 ;; we want to use a more recent Perl we need to patch all
427 ;; expressions that require multi-line matching. Hard to tell.
428 perl-5.6
429
430 ;; This is the secret sauce. These files are macro-heavy C
431 ;; "source" files that are used to build hsc from C. They are
432 ;; presumably the output of previous versions of GHC. Note that
433 ;; this is the "registerized" variant for x86. An "unreg" variant
434 ;; of the *.hc files also exists for building GHC for other
435 ;; architectures. The default "way" (see GhcLibWays above) to
436 ;; build and link the GHC binaries, however, is not the
437 ;; unregisterized variant. Using the unregisterized *.hc files
438 ;; with a standard build will result in segfaults.
439 (origin
440 (method url-fetch)
441 (uri (string-append "http://downloads.haskell.org/~ghc/"
442 version "/ghc-" version "-x86-hc.tar.bz2"))
443 (sha256
444 (base32
445 "0fi60bj0ak391x31cq5wp1ffwavl5w9jffyf62yv9rhxa915596b"))))))
446 (home-page "https://www.haskell.org/ghc")
447 (synopsis "The Glasgow Haskell Compiler")
448 (description
449 "The Glasgow Haskell Compiler (GHC) is a state-of-the-art compiler and
450interactive environment for the functional language Haskell.")
451 (license license:bsd-3)))
452
453(define-public ghc-6.0
454 (package
455 (name "ghc")
456 (version "6.0")
457 (source
458 (origin
459 (method url-fetch)
460 (uri (string-append "https://downloads.haskell.org/~ghc/"
461 version "/" name "-" version "-src.tar.bz2"))
462 (sha256
463 (base32
464 "06hpl8wyhhs1vz9dcdf0vbybwyzb5ifh27d59rx42q1vjs0m8zdv"))))
465 (build-system gnu-build-system)
466 (supported-systems '("i686-linux" "x86_64-linux"))
467 (arguments
468 (list
469 #:system "i686-linux"
470 #:tests? #false ;no check target
471 #:implicit-inputs? #false
472 #:parallel-build? #false ;not supported
473 #:modules '((guix build gnu-build-system)
474 (guix build utils)
475 (srfi srfi-26)
476 (srfi srfi-1))
477 #:phases
478 #~(modify-phases %standard-phases
479 (replace 'bootstrap
480 (lambda* (#:key inputs #:allow-other-keys)
481 (delete-file "configure")
482 (delete-file "config.sub")
483 (install-file (search-input-file inputs
484 "/bin/config.sub")
485 ".")
486 (let ((bash (which "bash")))
487 (substitute* '("configure.in"
488 "ghc/configure.in"
489 "ghc/rts/gmp/configure.in"
490 "distrib/configure-bin.in")
491 (("`/bin/sh") (string-append "`" bash))
492 (("SHELL=/bin/sh") (string-append "SHELL=" bash))
493 (("^#! /bin/sh") (string-append "#! " bash)))
494 (substitute* "glafp-utils/runstdtest/runstdtest.prl"
495 (("^#! /bin/sh") (string-append "#! " bash))
496 (("TimeCmd /bin/sh")
497 (string-append "TimeCmd " bash)))
498 (substitute* '("mk/config.mk.in"
499 "ghc/rts/gmp/Makefile.in")
500 (("^SHELL.*=.*/bin/sh") (string-append "SHELL = " bash)))
501 (substitute* "aclocal.m4"
502 (("SHELL=/bin/sh") (string-append "SHELL=" bash)))
503 (substitute* '"ghc/compiler/Makefile"
504 (("#!/bin/sh") (string-append "#!" bash)))
505 (substitute* '("libraries/base/cbits/system.c"
506 "libraries/unix/cbits/execvpe.c")
507 (("/bin/sh") bash)
508 (("\"sh\"") (string-append "\"" bash "\"")))
509
510 (setenv "CONFIG_SHELL" bash)
511 (setenv "SHELL" bash))
512 (invoke "autoreconf" "--verbose" "--force")))
513 (replace 'configure
514 (lambda* (#:key build #:allow-other-keys)
515 (setenv "CPATH"
516 (string-append (getcwd) "/ghc/includes:"
517 (getcwd) "/ghc/rts/gmp:"
518 (getcwd) "/mk:"
519 (or (getenv "CPATH") "")))
520 (call-with-output-file "config.cache"
521 (lambda (port)
522 ;; GCC 2.95 fails to deal with anonymous unions in glibc's
523 ;; 'struct_rusage.h':
524 ;; Stats.c: In function `pageFaults':
525 ;; Stats.c:270: structure has no member named `ru_majflt'
526 ;; Stats.c:272: warning: control reaches end of non-void function
527 (display "ac_cv_func_getrusage=no\n" port)))
528
529 ;; Socket.hsc:887: sizeof applied to an incomplete type
530 ;; Socket.hsc:893: dereferencing pointer to incomplete type
531 (substitute* "libraries/network/Network/Socket.hsc"
532 (("ifdef SO_PEERCRED")
533 "ifdef SO_PEERCRED_NEVER"))
534 (invoke "./configure"
535 "--enable-src-tree-happy"
536 (string-append "--with-gcc=" (which "gcc"))
537 (string-append "--prefix=" #$output)
538 (string-append "--build=" build)
539 (string-append "--host=" build)))))))
540 (native-search-paths (list (search-path-specification
541 (variable "GHC_PACKAGE_PATH")
542 (files (list
543 (string-append "lib/ghc-" version)))
544 (file-pattern ".*\\.conf\\.d$")
545 (file-type 'directory))))
546 (native-inputs
547 (modify-inputs (%final-inputs)
548 (delete "gcc")
549 (prepend autoconf-2.13
550 config
551 flex
552 ;; Perl used to allow setting $* to enable multi-line matching. If
553 ;; we want to use a more recent Perl we need to patch all
554 ;; expressions that require multi-line matching. Hard to tell.
555 perl-5.6
556 ghc-4
557 gcc-2.95)))
558 (home-page "https://www.haskell.org/ghc")
559 (synopsis "The Glasgow Haskell Compiler")
560 (description
561 "The Glasgow Haskell Compiler (GHC) is a state-of-the-art compiler and
562interactive environment for the functional language Haskell.")
563 (license license:bsd-3)))
564
565(define-public ghc-6.6
566 (package
567 (name "ghc")
568 (version "6.6")
569 (source
570 (origin
571 (method url-fetch)
572 (uri (string-append "https://downloads.haskell.org/~ghc/"
573 version "/" name "-" version "-src.tar.bz2"))
574 (sha256
575 (base32
576 "0znc9myxyfg9zmvdlg09sf0dq11kc2bq4616llh82v6m6s8s5ckr"))))
577 (build-system gnu-build-system)
578 (supported-systems '("i686-linux" "x86_64-linux"))
579 (arguments
580 (list
581 #:system "i686-linux"
582 #:tests? #false ;no check target
583 #:modules '((guix build gnu-build-system)
584 (guix build utils)
585 (srfi srfi-26)
586 (srfi srfi-1))
587 #:phases
588 #~(modify-phases %standard-phases
589 (replace 'bootstrap
590 (lambda* (#:key inputs #:allow-other-keys)
591 (let ((bash (which "bash")))
592 (substitute* '("configure"
593 "rts/gmp/configure"
594 "distrib/configure-bin.ac")
595 (("`/bin/sh") (string-append "`" bash))
596 (("SHELL=/bin/sh") (string-append "SHELL=" bash))
597 (("^#! /bin/sh") (string-append "#! " bash)))
598 (substitute* "utils/runstdtest/runstdtest.prl"
599 (("^#! /bin/sh") (string-append "#! " bash))
600 (("TimeCmd /bin/sh")
601 (string-append "TimeCmd " bash)))
602 (substitute* '("mk/config.mk.in"
603 "rts/gmp/Makefile.in")
604 (("^SHELL.*=.*/bin/sh") (string-append "SHELL = " bash)))
605 (substitute* "aclocal.m4"
606 (("SHELL=/bin/sh") (string-append "SHELL=" bash)))
607 (substitute* "compiler/Makefile"
608 (("#!/bin/sh") (string-append "#!" bash)))
609 (substitute* '("libraries/base/cbits/execvpe.c"
610 "libraries/Cabal/Distribution/attic"
611 "libraries/Cabal/Distribution/Simple/Register.hs"
612 "libraries/base/System/Process/Internals.hs")
613 (("/bin/sh") bash)
614 (("\"sh\"") (string-append "\"" bash "\"")))
615
616 (setenv "CONFIG_SHELL" bash)
617 (setenv "SHELL" bash))))
618 (replace 'configure
619 (lambda* (#:key build #:allow-other-keys)
620 (setenv "CPATH"
621 (string-append (getcwd) "/includes:"
622 (getcwd) "/rts/gmp:"
623 (getcwd) "/mk:"
624 (or (getenv "CPATH") "")))
625 (invoke "./configure"
626 (string-append "--with-hc=" (which "ghc"))
627 (string-append "--with-gcc=" (which "gcc"))
628 (string-append "--prefix=" #$output)
629 (string-append "--build=" build)
630 (string-append "--host=" build)))))))
631 (native-search-paths (list (search-path-specification
632 (variable "GHC_PACKAGE_PATH")
633 (files (list
634 (string-append "lib/ghc-" version)))
635 (file-pattern ".*\\.conf\\.d$")
636 (file-type 'directory))))
637 (native-inputs
638 (modify-inputs (%final-inputs)
639 (delete "gcc")
640 (prepend m4
641 ;; Perl used to allow setting $* to enable multi-line matching. If
642 ;; we want to use a more recent Perl we need to patch all
643 ;; expressions that require multi-line matching. Hard to tell.
644 perl-5.6
645 ghc-6.0
646 gcc-4.8)))
647 (home-page "https://www.haskell.org/ghc")
648 (synopsis "The Glasgow Haskell Compiler")
649 (description
650 "The Glasgow Haskell Compiler (GHC) is a state-of-the-art compiler and
651interactive environment for the functional language Haskell.")
652 (license license:bsd-3)))
653
654(define-public ghc-6.10
655 (package
656 (name "ghc")
657 (version "6.10.4")
658 (source
659 (origin
660 (method url-fetch)
661 (uri (string-append "https://downloads.haskell.org/~ghc/"
662 version "/" name "-" version "-src.tar.bz2"))
663 (sha256
664 (base32
665 "0kakv05kqi92qbfgmhr57rvag10yvp338kjwzqczhkrgax98wsnn"))
666 (modules '((guix build utils)))
667 (snippet
668 '(delete-file-recursively "libffi"))))
669 (build-system gnu-build-system)
670 (supported-systems '("i686-linux" "x86_64-linux"))
671 (arguments
672 (list
673 #:system "i686-linux"
674 #:tests? #false ;no check target
675 #:parallel-build? #false ;fails when building libraries/*
676 #:modules '((guix build gnu-build-system)
677 (guix build utils)
678 (srfi srfi-26)
679 (srfi srfi-1))
680 #:configure-flags
681 #~(list
682 (string-append "--with-gmp-libraries="
683 (assoc-ref %build-inputs "gmp") "/lib")
684 (string-append "--with-gmp-includes="
685 (assoc-ref %build-inputs "gmp") "/include"))
686 #:phases
687 #~(modify-phases %standard-phases
688 (replace 'bootstrap
689 (lambda* (#:key inputs #:allow-other-keys)
690 (let ((bash (which "bash")))
691 ;; Use our libffi package
692 (substitute* "rts/Makefile"
693 (("-I../libffi/build/include")
694 (string-append "-I"#$(this-package-input "libffi") "/include"))
695 (("-L../libffi/build/include")
696 (string-append "-L"#$(this-package-input "libffi") "/lib")))
697 (substitute* '("Makefile"
698 "distrib/Makefile")
699 (("SUBDIRS = gmp libffi")
700 "SUBDIRS = gmp")
701 (("\\$\\(MAKE\\) -C libffi.*") ""))
702 (substitute* "compiler/ghc.cabal.in"
703 (("../libffi/build/include")
704 (string-append #$(this-package-input "libffi") "/include")))
705
706 ;; Do not use libbfd, because it complicates the build and
707 ;; requires more patching. Disable all debug and profiling
708 ;; builds.
709 (substitute* "mk/config.mk.in"
710 (("GhcRTSWays \\+= debug") "")
711 (("GhcRTSWays \\+= debug_dyn thr_dyn thr_debug_dyn")
712 "GhcRTSWays += thr_dyn")
713 (("thr thr_p thr_debug") "thr")
714 (("GhcLibWays=p") "GhcLibWays="))
715
716 ;; Replace /bin/sh.
717 (substitute* '("configure"
718 "distrib/configure-bin.ac")
719 (("`/bin/sh") (string-append "`" bash))
720 (("SHELL=/bin/sh") (string-append "SHELL=" bash))
721 (("#! /bin/sh") (string-append "#! " bash)))
722 (substitute* '("mk/config.mk.in")
723 (("^SHELL.*=.*/bin/sh") (string-append "SHELL = " bash)))
724 (substitute* "aclocal.m4"
725 (("SHELL=/bin/sh") (string-append "SHELL=" bash)))
726 (substitute* '("libraries/unix/cbits/execvpe.c"
727 "libraries/Cabal/Distribution/Simple/Register.hs"
728 "libraries/process/System/Process/Internals.hs")
729 (("/bin/sh") bash)
730 (("\"sh\"") (string-append "\"" bash "\"")))))))))
731 (native-search-paths (list (search-path-specification
732 (variable "GHC_PACKAGE_PATH")
733 (files (list
734 (string-append "lib/ghc-" version)))
735 (file-pattern ".*\\.conf\\.d$")
736 (file-type 'directory))))
737 (inputs
738 (list gmp libffi))
739 (native-inputs
740 (list perl gcc-4.8 ghc-6.6))
741 (home-page "https://www.haskell.org/ghc")
742 (synopsis "The Glasgow Haskell Compiler")
743 (description
744 "The Glasgow Haskell Compiler (GHC) is a state-of-the-art compiler and
745interactive environment for the functional language Haskell.")
746 (license license:bsd-3)))
747
748(define-public ghc-7.0
749 (package
750 (inherit ghc-6.10)
751 (name "ghc")
752 (version "7.0.4")
753 (source
754 (origin
755 (method url-fetch)
756 (uri (string-append "https://downloads.haskell.org/~ghc/"
757 version "/" name "-" version "-src.tar.bz2"))
758 (sha256
759 (base32
760 "1vfhdvf9nls4pn1vy48ndy2s81klp1my6ch9dkg2373csvcpi6qs"))
761 (snippet
762 #~(begin (use-modules (guix build utils))
763 (delete-file-recursively "utils/ghc-pwd/dist-boot")
764 (delete-file-recursively "libffi")))))
765 (arguments
766 (list
767 #:system "i686-linux"
768 #:test-target "test"
769 #:tests? #false ;not yet
770 #:parallel-build? #false ;fails when building libraries/*
771 ;; Don't pass --build=<triplet>, because the configure script
772 ;; auto-detects slightly different triplets for --host and --target and
773 ;; then complains that they don't match.
774 #:build #f
775 #:validate-runpath? #f ; libraries can't find each other.
776 #:configure-flags
777 #~(list
778 (string-append "--with-gmp-libraries="
779 (assoc-ref %build-inputs "gmp") "/lib")
780 (string-append "--with-gmp-includes="
781 (assoc-ref %build-inputs "gmp") "/include"))
782 #:make-flags
783 #~(list (string-append "CONFIG_SHELL=" (assoc-ref %build-inputs "bash")
784 "/bin/bash"))
785 #:phases
786 #~(modify-phases %standard-phases
787 (replace 'bootstrap
788 (lambda* (#:key inputs #:allow-other-keys)
789 (let ((bash (which "bash")))
790 ;; Use our libffi package
791 (substitute* "rts/ghc.mk"
792 (("-Ilibffi/build/include")
793 (string-append "-I" #$(this-package-input "libffi") "/include"))
794 (("-Llibffi/build/include")
795 (string-append "-L" #$(this-package-input "libffi") "/lib"))
796 (("-DDEBUG") "")
797 (("libffi/dist-install/build/ffi.h ") ""))
798 (substitute* "rts/package.conf.in"
799 (("depends: builtin_ffi") "")
800 (("extra-libraries:") "extra-libraries:\n \t\tffi")
801 (("\"m\"") ",\"m\""))
802 (substitute* "ghc.mk"
803 (("rts/package.conf.inplace : libffi/package.conf.inplace") "")
804 ((" libffi \\\\") "\\")
805 (("^.*OTHER_LIBS.*$") "")
806 (("^.*--global-conf.*update libffi/package.conf.install.*$") "")
807 (("install_packages: libffi/package.conf.install") "install_packages:")
808 (("libffi includes") "includes"))
809 (substitute* '("Makefile"
810 "distrib/Makefile")
811 (("SUBDIRS = gmp libffi")
812 "SUBDIRS = gmp")
813 (("\\$\\(MAKE\\) -C libffi.*") ""))
814 (substitute* "compiler/ghc.cabal.in"
815 (("../libffi/build/include")
816 (string-append #$(this-package-input "libffi") "/include")))
817
818 ;; Do not use libbfd, because it complicates the build and
819 ;; requires more patching. Disable all debug and profiling
820 ;; builds. Also disable dynamic builds for a faster bootstrap.
821 (substitute* "mk/config.mk.in"
822 (("GhcRTSWays \\+= debug") "")
823 (("thr thr_debug thr_l") "thr thr_l")
824 (("dyn debug_dyn") "dyn")
825 (("thr_dyn thr_debug_dyn") "thr_dyn")
826 (("GhcLibWays \\+= dyn") "GhcLibWays +=")
827 (("GhcLibWays \\+= p") "GhcLibWays +="))
828
829 ;; Patch out -XGADTs requirement for GADT pattern matching
830 ;; (otherwise it can't build 7.6.x)
831 (substitute* "compiler/typecheck/TcPat.lhs"
832 (("gadts_on <- xoptM Opt_GADTs") "let gadts_on = True"))
833
834 ;; Replace /bin/sh.
835 (substitute* '("configure"
836 "distrib/configure.ac")
837 (("`/bin/sh") (string-append "`" bash))
838 (("SHELL=/bin/sh") (string-append "SHELL=" bash))
839 (("#! /bin/sh") (string-append "#! " bash)))
840 (substitute* '("mk/config.mk.in")
841 (("^SHELL.*=.*/bin/sh") (string-append "SHELL = " bash)))
842 (substitute* "aclocal.m4"
843 (("SHELL=/bin/sh") (string-append "SHELL=" bash)))
844 (substitute* "utils/ghc-pkg/ghc.mk"
845 (("#!/bin/sh") (string-append "#!" bash)))
846 (substitute* '("libraries/unix/cbits/execvpe.c"
847 "libraries/Cabal/Distribution/Simple/Hugs.hs"
848 "libraries/Cabal/Distribution/Simple/Program/Script.hs"
849 "libraries/process/System/Process/Internals.hs")
850 (("/bin/sh") bash)
851 (("\"sh\"") (string-append "\"" bash "\""))))))
852 (add-before 'build 'build-bootstrap
853 (lambda* (#:key make-flags #:allow-other-keys)
854 (apply invoke "make" "bootstrapping-files" make-flags))))))
855 (native-search-paths (list (search-path-specification
856 (variable "GHC_PACKAGE_PATH")
857 (files (list
858 (string-append "lib/ghc-" version)))
859 (file-pattern ".*\\.conf\\.d$")
860 (file-type 'directory))))
861 (inputs
862 (list gmp libffi ncurses perl))
863 (native-inputs
864 (list ghc-6.10 perl))))
865
866(define ghc-bootstrap-x86_64-7.8.4
867 (origin
868 (method url-fetch)
869 (uri
870 "https://www.haskell.org/ghc/dist/7.8.4/ghc-7.8.4-x86_64-unknown-linux-deb7.tar.xz")
871 (file-name "ghc-7.8.4-x86_64-binary.tar.xz")
872 (sha256
873 (base32
874 "13azsl53xgj20mi1hj9x0xb32vvcvs6cpmvwx6znxhas7blh0bpn"))))
875
876(define ghc-bootstrap-i686-7.8.4
877 (origin
878 (method url-fetch)
879 (uri
880 "https://www.haskell.org/ghc/dist/7.8.4/ghc-7.8.4-i386-unknown-linux-deb7.tar.xz")
881 (file-name "ghc-7.8.4-i386-binary.tar.xz")
882 (sha256
883 (base32
884 "0wj5s435j0zgww70bj1d3f6wvnnpzlxwvwcyh2qv4qjq5z8j64kg"))))
885
886;; 43 tests out of 3965 fail.
887;;
888;; Most of them do not appear to be serious:
889;;
890;; - some tests generate files referring to "/bin/sh" and "/bin/ls". I've not
891;; figured out how these references are generated.
892;;
893;; - Some tests allocate more memory than expected (ca. 3% above upper limit)
894;;
895;; - Some tests try to load unavailable libriries: Control.Concurrent.STM,
896;; Data.Vector, Control.Monad.State.
897;;
898;; - Test posix010 tries to check the existence of a user on the system:
899;; getUserEntryForName: does not exist (no such user)
900(define-public ghc-7
901 (package
902 (name "ghc")
903 (version "7.10.3")
904 (source
905 (origin
906 (method url-fetch)
907 (uri (string-append "https://www.haskell.org/ghc/dist/"
908 version "/" name "-" version "-src.tar.xz"))
909 (sha256
910 (base32
911 "1vsgmic8csczl62ciz51iv8nhrkm72lyhbz7p7id13y2w7fcx46g"))))
912 (build-system gnu-build-system)
913 (supported-systems '("i686-linux" "x86_64-linux"))
914 (outputs '("out" "doc"))
915 (inputs
916 (list gmp
917 ncurses
918 ;; Use a LibFFI variant without static trampolines to work around
919 ;; <https://gitlab.haskell.org/ghc/ghc/-/issues/20051>.
920 libffi-sans-static-trampolines
921 (origin
922 (method url-fetch)
923 (uri (string-append
924 "https://www.haskell.org/ghc/dist/"
925 version "/" name "-" version "-testsuite.tar.xz"))
926 (sha256
927 (base32
928 "0fk4xjw1x5lk2ifvgqij06lrbf1vxq9qfix86h9r16c0bilm3hah")))))
929 (native-inputs
930 (list
931 ;; XXX: does not compile with gcc-14 and adding
932 ;; -Wno-error=incompatible-pointer-types at the appropriate stages
933 ;; is difficult
934 gcc-13
935 perl
936 patchelf
937 ;; GHC is built with GHC. Therefore we need bootstrap binaries.
938 (if (string-match "x86_64" (or (%current-target-system) (%current-system)))
939 ghc-bootstrap-x86_64-7.8.4
940 ghc-bootstrap-i686-7.8.4)))
941 (arguments
942 (list
943 #:tests? #f ;require python@2
944
945 ;; Don't pass --build=<triplet>, because the configure script
946 ;; auto-detects slightly different triplets for --host and --target and
947 ;; then complains that they don't match.
948 #:build #f
949
950 #:modules '((guix build gnu-build-system)
951 (guix build utils)
952 (srfi srfi-26)
953 (srfi srfi-1))
954 #:configure-flags
955 #~(let* ((libgmp.so (search-input-file %build-inputs "lib/libgmp.so"))
956 (gmp (dirname (dirname libgmp.so)))
957 (libffi.so (search-input-file %build-inputs "lib/libffi.so"))
958 (ffi (dirname (dirname libffi.so))))
959 (list
960 (string-append "--with-gmp-libraries=" gmp "/lib")
961 (string-append "--with-gmp-includes=" gmp "/include")
962 "--with-system-libffi"
963 (string-append "--with-ffi-libraries=" ffi "/lib")
964 (string-append "--with-ffi-includes=" ffi "/include")))
965
966 ;; FIXME: The user-guide needs dblatex, docbook-xsl and docbook-utils.
967 ;; Currently we do not have the last one.
968 ;; #:make-flags
969 ;; (list "BUILD_DOCBOOK_HTML = YES")
970 #:phases
971 #~(let* ((ghc-bootstrap-path
972 (string-append (getcwd) "/" #$name "-" #$version "/ghc-bin"))
973 (ghc-bootstrap-prefix
974 (string-append ghc-bootstrap-path "/usr" )))
975 (modify-phases %standard-phases
976 (add-after 'unpack 'unpack-bin
977 (lambda* (#:key inputs #:allow-other-keys)
978 (let ((ghc-binary-pair (find (lambda (pair)
979 (string-suffix? "binary.tar.xz"
980 (car pair)))
981 inputs)))
982 (mkdir-p ghc-bootstrap-prefix)
983 (with-directory-excursion ghc-bootstrap-path
984 (invoke "tar" "xvf" (and=> ghc-binary-pair cdr))))))
985 (add-after 'unpack-bin 'unpack-testsuite-and-fix-bins
986 (lambda* (#:key inputs #:allow-other-keys)
987 (let ((ghc-testsuite (find (lambda (pair)
988 (string-suffix?
989 "testsuite.tar.xz"
990 (car pair)))
991 inputs)))
992 (with-directory-excursion ".."
993 (invoke "tar" "xvf" (and=> ghc-testsuite cdr))))
994 (substitute*
995 (list "testsuite/timeout/Makefile"
996 "testsuite/timeout/timeout.py"
997 "testsuite/timeout/timeout.hs"
998 "testsuite/tests/rename/prog006/Setup.lhs"
999 "testsuite/tests/programs/life_space_leak/life.test"
1000 "libraries/process/System/Process/Internals.hs"
1001 "libraries/unix/cbits/execvpe.c")
1002 (("/bin/sh") (search-input-file inputs "/bin/sh"))
1003 (("/bin/rm") "rm"))))
1004 (add-before 'configure 'install-bin
1005 (lambda _
1006 (with-directory-excursion
1007 (string-append ghc-bootstrap-path "/ghc-7.8.4")
1008 (invoke "make" "install"))))
1009 (add-before 'install-bin 'configure-bin
1010 (lambda* (#:key inputs outputs #:allow-other-keys)
1011 (let* ((binaries
1012 (list
1013 "./utils/ghc-pwd/dist-install/build/tmp/ghc-pwd"
1014 "./utils/hpc/dist-install/build/tmp/hpc"
1015 "./utils/haddock/dist/build/tmp/haddock"
1016 "./utils/hsc2hs/dist-install/build/tmp/hsc2hs"
1017 "./utils/runghc/dist-install/build/tmp/runghc"
1018 "./utils/ghc-cabal/dist-install/build/tmp/ghc-cabal"
1019 "./utils/hp2ps/dist/build/tmp/hp2ps"
1020 "./utils/ghc-pkg/dist-install/build/tmp/ghc-pkg"
1021 "./utils/unlit/dist/build/tmp/unlit"
1022 "./ghc/stage2/build/tmp/ghc-stage2"))
1023 (gmp (assoc-ref inputs "gmp"))
1024 (gmp-lib (string-append gmp "/lib"))
1025 (gmp-include (string-append gmp "/include"))
1026 (ncurses-lib
1027 (dirname (search-input-file inputs "/lib/libncurses.so")))
1028 (ld-so (search-input-file inputs #$(glibc-dynamic-linker)))
1029 (libtinfo-dir
1030 (string-append ghc-bootstrap-prefix
1031 "/lib/ghc-7.8.4/terminfo-0.4.0.0")))
1032 (with-directory-excursion
1033 (string-append ghc-bootstrap-path "/ghc-7.8.4")
1034 (setenv "CONFIG_SHELL" (which "bash"))
1035 (setenv "LD_LIBRARY_PATH" gmp-lib)
1036 ;; The binaries have "/lib64/ld-linux-x86-64.so.2" hardcoded.
1037 (for-each
1038 (cut invoke "patchelf" "--set-interpreter" ld-so <>)
1039 binaries)
1040 ;; The binaries include a reference to libtinfo.so.5 which
1041 ;; is a subset of libncurses.so.5. We create a symlink in a
1042 ;; directory included in the bootstrap binaries rpath.
1043 (mkdir-p libtinfo-dir)
1044 (symlink
1045 (string-append ncurses-lib "/libncursesw.so."
1046 ;; Extract "6.0" from "6.0-20170930" if a
1047 ;; dash-separated version tag exists.
1048 #$(let* ((v (package-version ncurses))
1049 (d (or (string-index v #\-)
1050 (string-length v))))
1051 (version-major+minor (string-take v d))))
1052 (string-append libtinfo-dir "/libtinfo.so.5"))
1053
1054 (setenv "PATH"
1055 (string-append (getenv "PATH") ":"
1056 ghc-bootstrap-prefix "/bin"))
1057 (invoke
1058 (string-append (getcwd) "/configure")
1059 (string-append "--prefix=" ghc-bootstrap-prefix)
1060 (string-append "--with-gmp-libraries=" gmp-lib)
1061 (string-append "--with-gmp-includes=" gmp-include))))))))))
1062 (native-search-paths (list (search-path-specification
1063 (variable "GHC_PACKAGE_PATH")
1064 (files (list
1065 (string-append "lib/ghc-" version)))
1066 (file-pattern ".*\\.conf\\.d$")
1067 (file-type 'directory))))
1068 (home-page "https://www.haskell.org/ghc")
1069 (synopsis "The Glasgow Haskell Compiler")
1070 (description
1071 "The Glasgow Haskell Compiler (GHC) is a state-of-the-art compiler and
1072interactive environment for the functional language Haskell.")
1073 (license license:bsd-3)))
1074
1075(define-public ghc-8.0
1076 (package
1077 (name "ghc")
1078 (version "8.0.2")
1079 (source
1080 (origin
1081 (method url-fetch)
1082 (uri (string-append "https://www.haskell.org/ghc/dist/"
1083 version "/" name "-" version "-src.tar.xz"))
1084 (sha256
1085 (base32 "1c8qc4fhkycynk4g1f9hvk53dj6a1vvqi6bklqznns6hw59m8qhi"))
1086 (patches
1087 (search-patches "ghc-8.0-fall-back-to-madv_dontneed.patch"))))
1088 (build-system gnu-build-system)
1089 (supported-systems '("i686-linux" "x86_64-linux"))
1090 (outputs '("out" "doc"))
1091 (inputs
1092 ;; Use a LibFFI variant without static trampolines to work around
1093 ;; <https://gitlab.haskell.org/ghc/ghc/-/issues/20051>.
1094 (list gmp ncurses libffi-sans-static-trampolines))
1095 (native-inputs
1096 (list
1097 ;; XXX: does not compile with gcc-14 and adding
1098 ;; -Wno-error=incompatible-pointer-types at the appropriate stages
1099 ;; is difficult
1100 gcc-13
1101 perl
1102 ;; GHC is built with GHC.
1103 ghc-7
1104 (origin
1105 (method url-fetch)
1106 (uri (string-append
1107 "https://www.haskell.org/ghc/dist/"
1108 version "/" name "-" version "-testsuite.tar.xz"))
1109 (sha256
1110 (base32 "1wjc3x68l305bl1h1ijd3yhqp2vqj83lkp3kqbr94qmmkqlms8sj")))))
1111 (arguments
1112 (list
1113 #:tests? #f ;require python@2
1114
1115 ;; Don't pass --build=<triplet>, because the configure script
1116 ;; auto-detects slightly different triplets for --host and --target and
1117 ;; then complains that they don't match.
1118 #:build #f
1119 #:modules '((guix build gnu-build-system)
1120 (guix build utils)
1121 (srfi srfi-1))
1122
1123 #:configure-flags
1124 #~(let* ((libgmp.so (search-input-file %build-inputs "lib/libgmp.so"))
1125 (gmp (dirname (dirname libgmp.so)))
1126 (libffi.so (search-input-file %build-inputs "lib/libffi.so"))
1127 (ffi (dirname (dirname libffi.so)))
1128 (libncurses.so (search-input-file %build-inputs
1129 "lib/libncurses.so"))
1130 (ncurses (dirname (dirname libncurses.so))))
1131 (list
1132 (string-append "--with-gmp-libraries=" gmp "/lib")
1133 (string-append "--with-gmp-includes=" gmp "/include")
1134 "--with-system-libffi"
1135 (string-append "--with-ffi-libraries=" ffi "/lib")
1136 (string-append "--with-ffi-includes=" ffi "/include")
1137 (string-append "--with-curses-libraries=" ncurses "/lib")
1138 (string-append "--with-curses-includes=" ncurses "/include")))
1139 #:phases
1140 #~(modify-phases %standard-phases
1141 (add-after 'unpack 'unpack-testsuite
1142 (lambda* (#:key inputs #:allow-other-keys)
1143 (let ((ghc-testsuite (find (lambda (pair)
1144 (string-suffix? "testsuite.tar.xz"
1145 (car pair)))
1146 inputs)))
1147 (with-directory-excursion ".."
1148 (invoke "tar" "xvf" (and=> ghc-testsuite cdr))))))
1149 (add-before 'build 'fix-lib-paths
1150 (lambda* (#:key inputs #:allow-other-keys)
1151 (substitute*
1152 (list "libraries/process/System/Process/Posix.hs"
1153 "libraries/process/tests/process001.hs"
1154 "libraries/process/tests/process002.hs"
1155 "libraries/unix/cbits/execvpe.c")
1156 (("/bin/sh") (search-input-file inputs "/bin/sh"))
1157 (("/bin/ls") (search-input-file inputs "/bin/ls")))))
1158 (add-before 'build 'fix-environment
1159 (lambda _
1160 (unsetenv "GHC_PACKAGE_PATH")
1161 (setenv "CONFIG_SHELL" (which "bash"))))
1162 (add-before 'check 'fix-testsuite
1163 (lambda _
1164 (substitute*
1165 (list "testsuite/timeout/Makefile"
1166 "testsuite/timeout/timeout.py"
1167 "testsuite/timeout/timeout.hs"
1168 "testsuite/tests/programs/life_space_leak/life.test")
1169 (("/bin/sh") (which "sh"))
1170 (("/bin/rm") "rm")))))))
1171 (native-search-paths (list (search-path-specification
1172 (variable "GHC_PACKAGE_PATH")
1173 (files (list
1174 (string-append "lib/ghc-" version)))
1175 (file-pattern ".*\\.conf\\.d$")
1176 (file-type 'directory))))
1177 (home-page "https://www.haskell.org/ghc")
1178 (synopsis "The Glasgow Haskell Compiler")
1179 (description
1180 "The Glasgow Haskell Compiler (GHC) is a state-of-the-art compiler and
1181interactive environment for the functional language Haskell.")
1182 (license license:bsd-3)))
1183
1184(define-public ghc-8.4
1185 (package (inherit ghc-8.0)
1186 (name "ghc")
1187 (version "8.4.4")
1188 (source
1189 (origin
1190 (method url-fetch)
1191 (uri (string-append "https://www.haskell.org/ghc/dist/"
1192 version "/" name "-" version "-src.tar.xz"))
1193 (sha256
1194 (base32 "1ch4j2asg7pr52ai1hwzykxyj553wndg7wq93i47ql4fllspf48i"))))
1195 (native-inputs
1196 (list
1197 ;; XXX: does not compile with gcc-14 and adding
1198 ;; -Wno-error=incompatible-pointer-types at the appropriate stages
1199 ;; is difficult
1200 gcc-13
1201 perl
1202 python ; for tests
1203 ghostscript ; for tests
1204 ;; GHC 8.4.4 is built with GHC >= 8.0.
1205 ghc-8.0
1206 (origin
1207 (method url-fetch)
1208 (uri (string-append
1209 "https://www.haskell.org/ghc/dist/"
1210 version "/" name "-" version "-testsuite.tar.xz"))
1211 (sha256
1212 (base32 "0s8lf9sxj7n89pjagi58b3fahnp34qvmwhnn0j1fbg6955vbrfj6"))
1213 (modules '((guix build utils)))
1214 (snippet
1215 ;; collections.Iterable was moved to collections.abc in Python 3.10.
1216 '(substitute* "testsuite/driver/testlib.py"
1217 (("collections\\.Iterable")
1218 "collections.abc.Iterable"))))))
1219 (arguments
1220 (substitute-keyword-arguments (package-arguments ghc-8.0)
1221 ((#:phases phases)
1222 #~(modify-phases #$phases
1223 ;; This phase patches the 'ghc-pkg' command so that it sorts the list
1224 ;; of packages in the binary cache it generates.
1225 (add-before 'build 'fix-ghc-pkg-nondeterminism
1226 (lambda _
1227 (substitute* "utils/ghc-pkg/Main.hs"
1228 (("confs = map \\(path </>\\) \\$ filter \\(\".conf\" `isSuffixOf`\\) fs")
1229 "confs = map (path </>) $ filter (\".conf\" `isSuffixOf`) (sort fs)"))))
1230 (add-after 'unpack-testsuite 'fix-shell-wrappers
1231 (lambda _
1232 (substitute* '("driver/ghci/ghc.mk"
1233 "utils/mkdirhier/ghc.mk"
1234 "rules/shell-wrapper.mk")
1235 (("echo '#!/bin/sh'")
1236 (format #f "echo '#!~a'" (which "sh"))))))
1237 ;; This is necessary because the configure system no longer uses
1238 ;; “AC_PATH_” but “AC_CHECK_”, setting the variables to just the
1239 ;; plain command names.
1240 (add-before 'configure 'set-target-programs
1241 (lambda* (#:key inputs #:allow-other-keys)
1242 (setenv "CC" (search-input-file inputs "bin/gcc"))
1243 (setenv "CXX" (search-input-file inputs "/bin/g++"))
1244 (setenv "LD" (search-input-file inputs "/bin/ld"))
1245 (setenv "NM" (search-input-file inputs "/bin/nm"))
1246 (setenv "RANLIB" (search-input-file inputs "/bin/ranlib"))
1247 (setenv "STRIP" (search-input-file inputs "/bin/strip"))
1248 ;; The 'ar' command does not follow the same pattern.
1249 (setenv "fp_prog_ar" (search-input-file inputs "/bin/ar"))))))))
1250 (native-search-paths (list (search-path-specification
1251 (variable "GHC_PACKAGE_PATH")
1252 (files (list
1253 (string-append "lib/ghc-" version)))
1254 (file-pattern ".*\\.conf\\.d$")
1255 (file-type 'directory))))))
1256
1257(define (ghc-testsuite-name ghc)
1258 (string-append
1259 (package-name ghc) "-" (package-version ghc) "-testsuite.tar.xz"))
1260
1261(define-public ghc-8.6
1262 (let ((ghc-bootstrap ghc-8.4))
1263 (package
1264 (inherit ghc-bootstrap)
1265 (name "ghc")
1266 (version "8.6.5")
1267 (source
1268 (origin
1269 (method url-fetch)
1270 (uri (string-append "https://www.haskell.org/ghc/dist/"
1271 version "/" name "-" version "-src.tar.xz"))
1272 (sha256
1273 (base32 "0qg3zsmbk4rkwkc3jpas3zs74qaxmw4sp4v1mhsbj0a0dzls2jjd"))))
1274 (native-inputs
1275 ;; It's not possible to set this using modify-inputs because it's
1276 ;; necessary to also modify the label for further inheritance issues.
1277 (cons* (list
1278 (ghc-testsuite-name this-package)
1279 (origin
1280 (method url-fetch)
1281 (uri (string-append
1282 "https://www.haskell.org/ghc/dist/"
1283 version "/" name "-" version "-testsuite.tar.xz"))
1284 (patches (search-patches "ghc-testsuite-dlopen-pie.patch"
1285 "ghc-testsuite-grep-compat.patch"))
1286 (sha256
1287 (base32
1288 "0pw9r91g2np3i806g2f4f8z4jfdd7mx226cmdizk4swa7av1qf91"))
1289 (modules '((guix build utils)))
1290 (snippet
1291 ;; collections.Iterable was moved to collections.abc in Python 3.10.
1292 '(substitute* "testsuite/driver/testlib.py"
1293 (("collections\\.Iterable")
1294 "collections.abc.Iterable")))))
1295 (modify-inputs (package-native-inputs ghc-bootstrap)
1296 ;; GHC 8.6.5 must be built with GHC >= 8.2.
1297 (replace "ghc" ghc-bootstrap)
1298 (delete (ghc-testsuite-name ghc-bootstrap)))))
1299 (arguments
1300 (substitute-keyword-arguments (package-arguments ghc-8.4)
1301 ((#:make-flags make-flags ''())
1302 #~(cons "EXTRA_RUNTEST_OPTS=--skip-perf-tests"
1303 #$make-flags))
1304 ((#:phases phases '%standard-phases)
1305 #~(modify-phases #$phases
1306 (add-after 'install 'remove-unnecessary-program-references
1307 (lambda* (#:key outputs #:allow-other-keys)
1308 (substitute* (find-files (string-append #$output "/lib/")
1309 "settings")
1310 (("/gnu/store/.*/bin/(.*)" m program) program))))
1311 (add-after 'install 'remove-unnecessary-haddock-references
1312 (lambda* (#:key outputs #:allow-other-keys)
1313 ;; Remove references to "doc" output from "out" by rewriting
1314 ;; the "haddock-interfaces" fields and removing the optional
1315 ;; "haddock-html" field in the generated .conf files.
1316 (let ((doc (assoc-ref outputs "doc"))
1317 (out (assoc-ref outputs "out")))
1318 (with-fluids ((%default-port-encoding #f))
1319 (for-each
1320 (lambda (config-file)
1321 (substitute* config-file
1322 (("^haddock-html: .*") "\n")
1323 (((format #f "^haddock-interfaces: ~a" doc))
1324 (string-append "haddock-interfaces: " out))))
1325 (find-files (string-append out "/lib") ".conf")))
1326 ;; Move the referenced files to the "out" output.
1327 (for-each
1328 (lambda (haddock-file)
1329 (let* ((subdir (string-drop haddock-file
1330 (string-length doc)))
1331 (new (string-append out subdir)))
1332 (mkdir-p (dirname new))
1333 (rename-file haddock-file new)))
1334 (find-files doc "\\.haddock$")))))
1335 (add-after 'unpack-testsuite 'skip-tests
1336 (lambda _
1337 ;; These two tests refer to the root user, which doesn't exist
1338 ;; (see <https://bugs.gnu.org/36692>).
1339 (substitute* "libraries/unix/tests/all.T"
1340 (("^test\\('T8108'") "# guix skipped: test('T8108'"))
1341 (substitute* "libraries/unix/tests/libposix/all.T"
1342 (("^test\\('posix010'") "# guix skipped: test('posix010'"))))
1343 ;; [email protected] warns for execstack deprecation by default, causing
1344 ;; some tests to fail ; explicitely disable during linking instead.
1345 (add-after 'unpack-testsuite 'fix-tests-with-binutils@2.39
1346 (lambda _
1347 (substitute* "testsuite/mk/test.mk"
1348 (("^TEST_HC_OPTS = ")
1349 "TEST_HC_OPTS = -optl -Wl,-z,noexecstack "))))))))
1350 (native-search-paths (list (search-path-specification
1351 (variable "GHC_PACKAGE_PATH")
1352 (files (list
1353 (string-append "lib/ghc-" version)))
1354 (file-pattern ".*\\.conf\\.d$")
1355 (file-type 'directory)))))))
1356
1357(define-public ghc-8.8
1358 (let ((ghc-bootstrap ghc-8.6))
1359 (package
1360 (inherit ghc-bootstrap)
1361 (name "ghc")
1362 (version "8.8.4")
1363 (source
1364 (origin
1365 (method url-fetch)
1366 (uri (string-append "https://www.haskell.org/ghc/dist/"
1367 version "/ghc-" version "-src.tar.xz"))
1368 (sha256
1369 (base32 "0bgwbxxvdn56l91bp9p5d083gzcfdi6z8l8b17qzjpr3n8w5wl7h"))))
1370 (native-inputs
1371 (modify-inputs (package-native-inputs ghc-bootstrap)
1372 ;; GHC 8.6.5 must be built with GHC >= 8.2.
1373 (replace "ghc" ghc-bootstrap)
1374 (replace (ghc-testsuite-name ghc-bootstrap)
1375 (origin
1376 (method url-fetch)
1377 (uri (string-append
1378 "https://www.haskell.org/ghc/dist/"
1379 version "/ghc-" version "-testsuite.tar.xz"))
1380 (patches (search-patches "ghc-testsuite-dlopen-pie.patch"
1381 "ghc-testsuite-grep-compat.patch"))
1382 (sha256
1383 (base32
1384 "0c55pj2820q26rikhpf636sn4mjgqsxjrl94vsywrh79dxp3k14z"))
1385 (modules '((guix build utils)))
1386 (snippet
1387 ;; collections.Iterable was moved to collections.abc in Python 3.10.
1388 '(substitute* "testsuite/driver/testlib.py"
1389 (("collections\\.Iterable")
1390 "collections.abc.Iterable")))))
1391 (append git-minimal/pinned))) ; invoked during tests
1392 (arguments
1393 (substitute-keyword-arguments (package-arguments ghc-bootstrap)
1394 ((#:phases phases '%standard-phases)
1395 #~(modify-phases #$phases
1396 (add-before 'build 'fix-cc-reference
1397 (lambda _
1398 (substitute* "utils/hsc2hs/Common.hs"
1399 (("\"cc\"") "\"gcc\""))))
1400 (add-after 'unpack-testsuite 'skip-more-tests
1401 (lambda _
1402 ;; XXX: This test fails because our ld-wrapper script
1403 ;; mangles the response file passed to the linker.
1404 (substitute* "testsuite/tests/hp2ps/all.T"
1405 (("^test\\('T15904'") "# guix skipped: test('T15904'"))))))))
1406 (native-search-paths (list (search-path-specification
1407 (variable "GHC_PACKAGE_PATH")
1408 (files (list
1409 (string-append "lib/ghc-" version)))
1410 (file-pattern ".*\\.conf\\.d$")
1411 (file-type 'directory)))))))
1412
1413(define-public ghc-8.10
1414 (let ((ghc-bootstrap ghc-8.6))
1415 (package
1416 (inherit ghc-8.8)
1417 (name "ghc")
1418 (version "8.10.7")
1419 (source
1420 (origin
1421 (method url-fetch)
1422 (uri (string-append "https://www.haskell.org/ghc/dist/"
1423 version "/ghc-" version "-src.tar.xz"))
1424 (sha256
1425 (base32 "179ws2q0dinl1a39wm9j37xzwm84zfz3c5543vz8v479khigdvp3"))))
1426 (native-inputs
1427 (cons* (list
1428 (ghc-testsuite-name this-package)
1429 (origin
1430 (method url-fetch)
1431 (uri (string-append
1432 "https://www.haskell.org/ghc/dist/"
1433 version "/ghc-" version "-testsuite.tar.xz"))
1434 (patches (search-patches "ghc-testsuite-dlopen-pie.patch"
1435 "ghc-testsuite-grep-compat.patch"))
1436 (sha256
1437 (base32
1438 "1zl25gg6bpx5601k8h3cqnns1xfc0nqgwnh8jvn2s65ra3f2g1nz"))
1439 (modules '((guix build utils)))
1440 (snippet
1441 ;; collections.Iterable was moved to collections.abc in Python 3.10.
1442 '(substitute* "testsuite/driver/testlib.py"
1443 (("collections\\.Iterable")
1444 "collections.abc.Iterable")))))
1445 (modify-inputs (package-native-inputs ghc-bootstrap)
1446 ;; GHC 8.10.7 must be built with GHC >= 8.6.
1447 (replace "ghc" ghc-bootstrap)
1448 (delete (ghc-testsuite-name ghc-bootstrap))
1449 (append git-minimal/pinned)))) ; invoked during tests
1450 (arguments
1451 (substitute-keyword-arguments (package-arguments ghc-8.8)
1452 ((#:phases phases '%standard-phases)
1453 #~(modify-phases #$phases
1454 (add-after 'unpack-testsuite 'patch-more-shebangs
1455 (lambda* (#:key inputs #:allow-other-keys)
1456 (substitute* '("testsuite/tests/driver/T8602/T8602.script")
1457 (("/bin/sh")
1458 (search-input-file inputs "/bin/sh")))))
1459 ;; Mark failing tests as broken. Reason for failure is unknown.
1460 (add-after 'skip-more-tests 'skip-even-more-tests
1461 (lambda _
1462 (substitute* '("testsuite/tests/driver/T16521/all.T")
1463 (("extra_files" all) (string-append "[" all))
1464 (("\\]\\), " all)
1465 (string-append all "expect_broken(0)], ")))))
1466 (add-after 'skip-more-tests 'skip-failing-tests-i686
1467 (lambda _
1468 (substitute* '("testsuite/tests/codeGen/should_compile/all.T")
1469 (("(test\\('T15155l', )when\\(unregisterised\\(\\), skip\\)" all before)
1470 (string-append before "when(arch('i386'), skip)")))
1471 ;; Unexpected failures:
1472 ;; quasiquotation/T14028.run T14028 [bad stderr] (dyn)
1473 (substitute* '("testsuite/tests/quasiquotation/all.T")
1474 (("unless\\(config.have_ext_interp, skip\\),")
1475 "unless(config.have_ext_interp, skip), when(arch('i386'), skip),"))))
1476 ;; i686 fails on CI, but (sometimes and with generous timeouts) completes
1477 ;; locally. The issue seems to be that the testsuite tries to run some very
1478 ;; broad regular expressions on output files of several megabytes in size,
1479 ;; which takes a long time. Since the expressions never match anything on
1480 ;; our builds anyways, remove them.
1481 ;; TODO: Merge with 'skip-failing-tests-i686 or move into snippets on
1482 ;; next rebuild. Note that they are required for GHC 8.10 and 9.2.
1483 #$@(if (string-prefix? "i686" (or (%current-target-system)
1484 (%current-system)))
1485 #~((add-after 'skip-failing-tests-i686 'skip-more-failing-tests-i686
1486 (lambda _
1487 (substitute* '("testsuite/tests/profiling/should_run/all.T")
1488 (("test\\('T11627a', \\[ ")
1489 "test('T11627a', [ when(arch('i386'), skip), "))
1490 (substitute* '("testsuite/driver/testlib.py")
1491 ((".*changes being made to the file will invalidate the code signature.*")
1492 "")
1493 ((".*warning: argument unused during compilation:.*")
1494 "")))))
1495 #~())))))
1496 (native-search-paths (list (search-path-specification
1497 (variable "GHC_PACKAGE_PATH")
1498 (files (list
1499 (string-append "lib/ghc-" version)))
1500 (file-pattern ".*\\.conf\\.d$")
1501 (file-type 'directory)))))))
1502
1503(define-public ghc-8 ghc-8.10)
1504
1505(define ghc-bootstrap-aarch64-8.10.7
1506 (origin
1507 (method url-fetch)
1508 (uri
1509 "https://downloads.haskell.org/ghc/8.10.7/ghc-8.10.7-aarch64-deb10-linux.tar.xz")
1510 (sha256
1511 (base32 "0m8fklyqcd8xrmhwnimyhyg3b5h82kkc0yfyiazk6li9kdzl3lps"))))
1512
1513(define-public binary-ghc-8.10.7
1514 (package
1515 ;; Named like this to be able to install it in profile without
1516 ;; ghc-package-cache-file (guix profiles) trying to install ghc...
1517 (name "binary-ghc")
1518 (version "8.10.7")
1519 (source ghc-bootstrap-aarch64-8.10.7)
1520 (build-system gnu-build-system)
1521 (supported-systems '("aarch64-linux"))
1522 ;; We need llvm until 9.2 which introduce aarch64 native code generation.
1523 ;; Make sure you have installed LLVM between [9 and 13)
1524 (inputs (list gcc-13 gmp llvm-12 ncurses/tinfo numactl))
1525 (native-inputs
1526 (list patchelf perl))
1527 (arguments
1528 (list
1529 #:configure-flags
1530 #~(list
1531 (string-append "--with-gmp-libraries="
1532 (assoc-ref %build-inputs "gmp") "/lib")
1533 (string-append "--with-gmp-includes="
1534 (assoc-ref %build-inputs "gmp") "/include"))
1535 #:phases
1536 #~(modify-phases %standard-phases
1537 (delete 'build)
1538 ;; We don't run the check phase on binary inputs.
1539 (delete 'check)
1540 (add-before 'configure 'fix-lnuma
1541 (lambda* (#:key inputs outputs #:allow-other-keys)
1542 (substitute* "rts/package.conf.in"
1543 (("FFI_LIB_DIR")
1544 (string-append
1545 "FFI_LIB_DIR "
1546 (assoc-ref inputs "numactl") "/lib")))))
1547 (add-after 'fix-lnuma 'add-rpaths
1548 (lambda* (#:key inputs outputs #:allow-other-keys)
1549 (let* ((libraries
1550 (cons* "rts/dist/build/libffi.so"
1551 (find-files "." "-ghc8\\.10\\.7\\.so$")))
1552 (binaries
1553 (list "ghc/stage2/build/tmp/ghc-stage2"
1554 "utils/ghc-cabal/dist-install/build/tmp/ghc-cabal"
1555 "utils/ghc-pkg/dist-install/build/tmp/ghc-pkg"
1556 "utils/haddock/dist/build/tmp/haddock"
1557 "utils/hp2ps/dist-install/build/tmp/hp2ps"
1558 "utils/hpc/dist-install/build/tmp/hpc"
1559 "utils/hsc2hs/dist-install/build/tmp/hsc2hs"
1560 "utils/iserv/stage2/build/tmp/ghc-iserv"
1561 "utils/iserv/stage2_dyn/build/tmp/ghc-iserv-dyn"
1562 "utils/iserv/stage2_p/build/tmp/ghc-iserv-prof"
1563 "utils/runghc/dist-install/build/tmp/runghc"
1564 "utils/unlit/dist-install/build/tmp/unlit"))
1565 (ld-so (search-input-file inputs #$(glibc-dynamic-linker))))
1566 (for-each
1567 (lambda (b)
1568 (invoke "patchelf" "--add-rpath"
1569 (string-append #$gmp "/lib") b)
1570 (invoke "patchelf" "--add-rpath"
1571 (string-append (assoc-ref inputs "ncurses-with-tinfo") "/lib") b)
1572 (invoke "patchelf" "--add-rpath"
1573 (string-append #$gcc-13:lib "/lib") b)
1574 (invoke "patchelf" "--add-rpath"
1575 (string-append #$numactl "/lib") b))
1576 (append libraries binaries))
1577 ;; The binaries have "/lib64/ld-linux-aarch64.so.1" hardcoded.
1578 (for-each
1579 (lambda (b)
1580 (invoke "patchelf" "--set-interpreter" ld-so b))
1581 binaries))))
1582 (add-before 'add-rpaths 'set-target-programs
1583 (lambda* (#:key inputs #:allow-other-keys)
1584 (setenv "CC" (search-input-file inputs "/bin/gcc"))
1585 (setenv "fp_prog_ar" (search-input-file inputs "/bin/ar"))
1586 (setenv "LD" (search-input-file inputs "/bin/ld"))
1587 (setenv "LLC" (search-input-file inputs "/bin/llc"))
1588 (setenv "OPT" (search-input-file inputs "/bin/opt")))))))
1589 (native-search-paths
1590 (list (search-path-specification
1591 (variable "GHC_PACKAGE_PATH")
1592 (files (list (string-append "lib/ghc-" version)))
1593 (file-pattern "\\.conf\\.d$")
1594 (file-type 'directory))))
1595 (home-page "https://www.haskell.org/ghc/")
1596 (synopsis "The Glasgow Haskell Compiler")
1597 (description
1598 "The Glasgow Haskell Compiler (GHC) is a state-of-the-art compiler and
1599interactive environment for the functional language Haskell.")
1600 (properties '((hidden? . #t)))
1601 (license license:bsd-3)))
1602
1603(define-public ghc-9.0
1604 (package
1605 (inherit ghc-8.10)
1606 (name "ghc")
1607 (version "9.0.2")
1608 (supported-systems '("i686-linux" "x86_64-linux" "aarch64-linux"))
1609 (source (origin
1610 (method url-fetch)
1611 (uri (string-append "https://www.haskell.org/ghc/dist/" version
1612 "/ghc-" version "-src.tar.xz"))
1613 (sha256
1614 (base32
1615 "15wii8can2r3dcl6jjmd50h2jvn7rlmn05zb74d2scj6cfwl43hl"))
1616 (patches (search-patches "ghc-9-StgCRunAsm-only-when-needed.patch"))))
1617 (arguments
1618 (substitute-keyword-arguments arguments
1619 ((#:phases phases '%standard-phases)
1620 #~(modify-phases #$phases
1621 ;; Add store path references instead of plain program names...
1622 (add-before 'configure 'set-target-llvm-programs
1623 (lambda* (#:key inputs #:allow-other-keys)
1624 (setenv "LLC" (search-input-file inputs "/bin/llc"))
1625 (setenv "OPT" (search-input-file inputs "/bin/opt"))))
1626 ;; ... and preserve them while pruning build tool references
1627 (replace 'remove-unnecessary-program-references
1628 (lambda* (#:key outputs #:allow-other-keys)
1629 (substitute* (find-files (string-append (assoc-ref outputs "out") "/lib/")
1630 "settings")
1631 (("/gnu/store/.*/bin/([^\"]*)" m program)
1632 (if (member program '("llc" "opt")) m program)))))
1633 (add-after 'skip-more-tests 'skip-T21694-i686
1634 (lambda _
1635 (substitute* '("testsuite/tests/simplCore/should_compile/all.T")
1636 (("^test\\('T21694', \\[ " all)
1637 (string-append all "when(arch('i386'), skip), ")))))
1638 #$@(if (target-aarch64?)
1639 ;; Eats up all memory then fail
1640 #~((add-after 'skip-more-tests 'skip-T16992-aarch64
1641 (lambda _
1642 (substitute* "libraries/ghc-compact/tests/all.T"
1643 (("^test\\('T16992', \\[" all)
1644 (string-append all "when(arch('aarch64'), skip), ")))))
1645 ;; The RTS linker does not find __aarch64_*_sync symbols,
1646 ;; Fixed in 9.12 :
1647 ;; https://gitlab.haskell.org/ghc/ghc/-/commit/7db8c9927fae3369fc4ecff68f80c4cb32eea757
1648 (add-before 'configure 'no-outline-atomics
1649 (lambda _
1650 (with-output-to-file "mk/build.mk"
1651 (lambda ()
1652 (display "
1653SRC_HC_OPTS += -optc-mno-outline-atomics
1654 "))))))
1655 '())))
1656 ;; Increase verbosity, so running the test suite does not time out on CI.
1657 ((#:make-flags make-flags ''())
1658 #~(cons "VERBOSE=4" #$make-flags))))
1659 ;; We need llvm until 9.2 which introduce aarch64 native code generation.
1660 ;; Make sure you have installed LLVM between [9 and 13)
1661 (inputs (list llvm-12 gmp ncurses libffi))
1662 (native-inputs
1663 (cons*
1664 (list (ghc-testsuite-name this-package)
1665 (origin
1666 (method url-fetch)
1667 (uri (string-append
1668 "https://www.haskell.org/ghc/dist/"
1669 version "/ghc-" version "-testsuite.tar.xz"))
1670 (sha256
1671 (base32
1672 "1m5fzhr4gjn9ni8gxx7ag3fkbw1rspjzgv39mnfb0nkm5mw70v3s"))
1673 (patches (search-patches "ghc-9.2-grep-warnings.patch"
1674 "ghc-testsuite-recomp015-execstack.patch"))
1675 (modules '((guix build utils)))
1676 (snippet
1677 ;; collections.Iterable was moved to collections.abc in Python 3.10.
1678 '(substitute* "testsuite/driver/testlib.py"
1679 (("collections\\.Iterable")
1680 "collections.abc.Iterable")))))
1681 (modify-inputs (package-native-inputs ghc-8.10)
1682 ;; GHC 9.0.2 must be built with GHC >= 8.8
1683 (replace "ghc" (if (target-aarch64?)
1684 binary-ghc-8.10.7
1685 ghc-8.10))
1686 (delete (ghc-testsuite-name ghc-8.10)))))
1687 (properties '((max-silent-time . 36000))) ; 10 hours, for i686.
1688 (native-search-paths
1689 (list (search-path-specification
1690 (variable "GHC_PACKAGE_PATH")
1691 (files (list (string-append "lib/ghc-" version)))
1692 (file-pattern ".*\\.conf\\.d$")
1693 (file-type 'directory))))))
1694
1695(define-public ghc-9.2
1696 ;; Use 8.10 to shorten the build chain.
1697 (let ((base ghc-8.10))
1698 (package
1699 (inherit base)
1700 (name "ghc")
1701 (version "9.2.8")
1702 (supported-systems '("i686-linux" "x86_64-linux" "aarch64-linux"))
1703 (source (origin
1704 (method url-fetch)
1705 (uri (string-append "https://www.haskell.org/ghc/dist/" version
1706 "/ghc-" version "-src.tar.xz"))
1707 (sha256
1708 (base32
1709 "18b7ln4gx2vy62jpv3z5slv3zfxmxnmkgajznks15zglddwd24sz"))
1710 (patches (search-patches "ghc-9.2-cabal-support-package-path.patch"
1711 "ghc-9-StgCRunAsm-only-when-needed.patch"))))
1712 (arguments
1713 (substitute-keyword-arguments arguments
1714 ((#:phases phases '%standard-phases)
1715 #~(modify-phases #$phases
1716 ;; File Common.hs has been moved to src/ in this release.
1717 (replace 'fix-cc-reference
1718 (lambda _
1719 (substitute* "utils/hsc2hs/src/Common.hs"
1720 (("\"cc\"") "\"gcc\""))))
1721 (add-after 'skip-more-tests 'skip-T21694-i686
1722 (lambda _
1723 (substitute* '("testsuite/tests/simplCore/should_compile/all.T")
1724 (("^test\\('T21694', \\[ " all)
1725 (string-append all "when(arch('i386'), skip), ")))))
1726 #$@(if (target-aarch64?)
1727 ;; Eats up all memory then fail
1728 #~((add-after 'skip-more-tests 'skip-T16992-aarch64
1729 (lambda _
1730 (substitute* "libraries/ghc-compact/tests/all.T"
1731 (("^test\\('T16992', \\[" all)
1732 (string-append all "when(arch('aarch64'), skip), ")))))
1733 ;; The RTS linker does not find __aarch64_*_sync symbols,
1734 ;; Fixed in 9.12 :
1735 ;; https://gitlab.haskell.org/ghc/ghc/-/commit/7db8c9927fae3369fc4ecff68f80c4cb32eea757
1736 (add-before 'configure 'no-outline-atomics
1737 (lambda _
1738 (with-output-to-file "mk/build.mk"
1739 (lambda ()
1740 (display "
1741SRC_HC_OPTS += -optc-mno-outline-atomics
1742 "))))))
1743 '())))
1744 ;; Increase verbosity, so running the test suite does not time out on CI.
1745 ((#:make-flags make-flags ''())
1746 #~(cons "VERBOSE=4" #$make-flags))))
1747 (native-inputs
1748 (cons* (list
1749 (ghc-testsuite-name this-package)
1750 (origin
1751 (method url-fetch)
1752 (uri (string-append
1753 "https://www.haskell.org/ghc/dist/"
1754 version "/ghc-" version "-testsuite.tar.xz"))
1755 (sha256
1756 (base32
1757 "0cmmwhcwv9fjzvmgjj85d354858qqbmqfzaz5160xqj4yl9zk225"))
1758 (patches (search-patches "ghc-9.2-grep-warnings.patch"))))
1759 (modify-inputs (package-native-inputs base)
1760 ;; GHC 8.10.7 must be built with GHC >= 8.6.
1761 (replace "ghc" (if (target-aarch64?)
1762 binary-ghc-8.10.7
1763 base))
1764 (delete (ghc-testsuite-name base)))))
1765 (properties '((max-silent-time . 36000))) ; 10 hours, for i686.
1766 (native-search-paths
1767 (list (search-path-specification
1768 (variable "GHC_PACKAGE_PATH")
1769 (files (list (string-append "lib/ghc-" version)))
1770 (file-pattern ".*\\.conf\\.d$")
1771 (file-type 'directory)))))))
1772
1773;; 9.4 is the last version to support the make-based build system,
1774;; but it boot with 9.2, only 9.0 is supported.
1775(define ghc-bootstrap-for-9.4 ghc-9.0)
1776
1777;; We need two extra dependencies built with ghc-bootstrap-for-9.4,
1778;; which are duplicated here from haskell-xyz to make sure the
1779;; bootstraping process always works.
1780(define-public ghc-alex-bootstrap-for-9.4
1781 (hidden-package
1782 (package
1783 (name "ghc-alex")
1784 (version "3.2.6")
1785 (source
1786 (origin
1787 (method url-fetch)
1788 (uri (hackage-uri "alex" version))
1789 (sha256
1790 (base32
1791 "042lrkn0dbpjn5ivj6j26jzb1fwrj8c1aj18ykxja89isg0hiali"))))
1792 (build-system haskell-build-system)
1793 (arguments
1794 (list #:tests? #f
1795 #:haskell ghc-bootstrap-for-9.4))
1796 (native-inputs
1797 (list which))
1798 (home-page "https://www.haskell.org/alex/")
1799 (synopsis
1800 "Tool for generating lexical analysers in Haskell")
1801 (description
1802 "Alex is a tool for generating lexical analysers in Haskell. It takes a
1803 description of tokens based on regular expressions and generates a Haskell
1804 module containing code for scanning text efficiently. It is similar to the
1805 tool lex or flex for C/C++.")
1806 (license license:bsd-3))))
1807
1808(define-public ghc-happy-bootstrap-for-9.4
1809 (hidden-package
1810 (package
1811 (name "ghc-happy")
1812 (version "1.20.0")
1813 (source
1814 (origin
1815 (method url-fetch)
1816 (uri (hackage-uri "happy" version))
1817 (sha256
1818 (base32
1819 "1346r2x5ravs5fqma65bzjragqbb2g6v41wz9maknwm2jf7kl79v"))))
1820 (build-system haskell-build-system)
1821 (arguments
1822 (list #:haskell ghc-bootstrap-for-9.4
1823 #:tests? #f))
1824 (home-page "https://hackage.haskell.org/package/happy")
1825 (synopsis "Parser generator for Haskell")
1826 (description "Happy is a parser generator for Haskell. Given a grammar
1827 specification in BNF, Happy generates Haskell code to parse the grammar.
1828 Happy works in a similar way to the yacc tool for C.")
1829 (license license:bsd-3))))
1830
1831(define-public ghc-9.4
1832 (let ((base ghc-bootstrap-for-9.4))
1833 (package
1834 (inherit base)
1835 (name "ghc")
1836 (version "9.4.3")
1837 (source (origin
1838 (method url-fetch)
1839 (uri (string-append "https://www.haskell.org/ghc/dist/" version
1840 "/ghc-" version "-src.tar.xz"))
1841 (sha256
1842 (base32
1843 "0nlhx2cbq1jh2yr6zk475lavjkh9sncj57qp77p51pkfad4kkxpa"))
1844 (patches (search-patches "ghc-9-StgCRunAsm-only-when-needed.patch"))))
1845 (arguments
1846 (substitute-keyword-arguments arguments
1847 ((#:phases phases '%standard-phases)
1848 #~(modify-phases #$phases
1849 ;; Files don’t exist any more.
1850 (delete 'skip-tests)
1851 ;; File Common.hs has been moved to src/ in the 9.2 release.
1852 (replace 'fix-cc-reference
1853 (lambda _
1854 (substitute* "utils/hsc2hs/src/Common.hs"
1855 (("\"cc\"") "\"gcc\""))))))
1856 ((#:tests? _ #f)
1857 #f)))
1858 (native-inputs
1859 (cons*
1860 (list
1861 (ghc-testsuite-name this-package)
1862 (origin
1863 (method url-fetch)
1864 (uri (string-append
1865 "https://www.haskell.org/ghc/dist/"
1866 version "/ghc-" version "-testsuite.tar.xz"))
1867 (sha256
1868 (base32
1869 "1xbps33pq6mg2bwp5gvmc4qhgdq52yng5993if99b9s3fylqk86l"))))
1870 (modify-inputs (package-native-inputs base)
1871 ;; GHC 9.4 must be built with GHC >= 9.0.
1872 (replace "ghc" base)
1873 (append ghc-alex-bootstrap-for-9.4)
1874 (append ghc-happy-bootstrap-for-9.4)
1875 (delete (ghc-testsuite-name base)))))
1876 (native-search-paths
1877 (list (search-path-specification
1878 (variable "GHC_PACKAGE_PATH")
1879 (files (list (string-append "lib/ghc-" version)))
1880 (file-pattern ".*\\.conf\\.d$")
1881 (file-type 'directory)))))))
1882
1883;;; GHC >= 9.6 must be built using it's new haskell-written Hadrian build
1884;;; system. Use this opportunity to cut the inheritance chain to simplify
1885;;; understanding what building ghc requires with the new build system.
1886
1887(define-public ghc-9.8
1888 (let ((ghc-bootstrap ghc-9.4))
1889 (package
1890 (name "ghc")
1891 (version "9.8.1")
1892 (supported-systems '("i686-linux" "x86_64-linux" "aarch64-linux"))
1893 (source (origin
1894 (method url-fetch)
1895 (uri (string-append "https://downloads.haskell.org/~ghc/" version
1896 "/ghc-" version "-src.tar.xz"))
1897 (sha256
1898 (base32
1899 "0l87yb8hmd350klrp6lw2h9hjlla11pgzx1n4jlrfdvkgxmyvy5j"))))
1900 (outputs (list "out" "doc"))
1901 (arguments
1902 (list
1903 #:make-flags #~(list "-V" "--docs=no-sphinx")
1904 #:configure-flags
1905 #~(list
1906 (string-append "--with-gmp-libraries="
1907 (assoc-ref %build-inputs "gmp") "/lib")
1908 (string-append "--with-gmp-includes="
1909 (assoc-ref %build-inputs "gmp") "/include")
1910 "--with-system-libffi"
1911 (string-append "--with-ffi-libraries="
1912 (assoc-ref %build-inputs "libffi") "/lib")
1913 (string-append "--with-ffi-includes="
1914 (assoc-ref %build-inputs "libffi") "/include")
1915 (string-append "--with-curses-libraries="
1916 (assoc-ref %build-inputs "ncurses") "/lib")
1917 (string-append "--with-curses-includes="
1918 (assoc-ref %build-inputs "ncurses") "/include"))
1919 #:phases
1920 #~(modify-phases %standard-phases
1921 (add-before 'build 'fix-iserv-rpath
1922 (lambda _
1923 (mkdir-p "_build")
1924 (call-with-output-file
1925 "_build/hadrian.settings"
1926 (lambda (port)
1927 (display
1928 (string-append
1929 "*.iserv.ghc.link.opts += -optl-Wl,-rpath,"
1930 #$output "/lib/ghc-" #$(package-version this-package)
1931 "/lib/" #$(match (gnu-triplet->nix-system
1932 (or (%current-target-system)
1933 (%current-system)))
1934 ("i686-linux" "i386-linux")
1935 (x x))
1936 "-ghc-" #$(package-version this-package) "/")
1937 port)))))
1938 ;; This phase patches the 'ghc-pkg' command so that it sorts the list
1939 ;; of packages in the binary cache it generates.
1940 (add-before 'build 'fix-ghc-pkg-nondeterminism
1941 (lambda _
1942 (substitute* "utils/ghc-pkg/Main.hs"
1943 (("confs = map \\(path </>\\) \\$ filter \\(\".conf\" `isSuffixOf`\\) fs")
1944 "confs = map (path </>) $ filter (\".conf\" `isSuffixOf`) (sort fs)"))))
1945 (add-after 'unpack 'unpack-testsuite
1946 (lambda* (#:key inputs #:allow-other-keys)
1947 (with-directory-excursion ".."
1948 (invoke "tar" "xvf" (assoc-ref inputs "ghc-testsuite.tar.xz")))))
1949 (add-after 'unpack-testsuite 'fix-/bin/sh-references
1950 (lambda* (#:key inputs #:allow-other-keys)
1951 (substitute*
1952 (list "hadrian/src/Rules/BinaryDist.hs"
1953 "hadrian/src/Rules/Test.hs"
1954 "libraries/process/System/Process/Posix.hs"
1955 "libraries/process/jsbits/process.js"
1956 "libraries/unix/cbits/execvpe.c"
1957 "testsuite/tests/driver/T8602/T8602.script"
1958 "testsuite/timeout/timeout.py")
1959 (("/bin/sh") (search-input-file inputs "/bin/sh")))))
1960 (add-after 'unpack-testsuite 'fix-cc-reference
1961 (lambda* (#:key inputs #:allow-other-keys)
1962 (substitute*
1963 (list "utils/hsc2hs/src/Common.hs")
1964 (("\"cc\"") "\"gcc\""))))
1965 ;; XXX: something causes ld-wrapper to see test\ \ \ spaces/... and
1966 ;; look for the files "test\", "\", "\" and "spaces/...", which obviously
1967 ;; don't exist
1968 (add-after 'unpack-testsuite 'fix-testsuite
1969 (lambda _
1970 (substitute*
1971 (list "testsuite/driver/runtests.py")
1972 (("'test spaces'") "'dont-test-spaces'"))))
1973 (add-before 'configure 'set-target-programs
1974 (lambda* (#:key inputs #:allow-other-keys)
1975 (let ((binutils (assoc-ref inputs "binutils"))
1976 (gcc (assoc-ref inputs "gcc"))
1977 (ld-wrapper (assoc-ref inputs "ld-wrapper")))
1978 (setenv "CC" (string-append gcc "/bin/gcc"))
1979 (setenv "CXX" (string-append gcc "/bin/g++"))
1980 (setenv "LD" (string-append ld-wrapper "/bin/ld"))
1981 (setenv "NM" (string-append binutils "/bin/nm"))
1982 (setenv "RANLIB" (string-append binutils "/bin/ranlib"))
1983 (setenv "STRIP" (string-append binutils "/bin/strip"))
1984 ;; The 'ar' command does not follow the same pattern.
1985 (setenv "fp_prog_ar" (string-append binutils "/bin/ar")))))
1986 (add-before 'build 'build-hadrian
1987 (lambda* (#:key (inputs '()) #:allow-other-keys)
1988 (invoke "./hadrian/bootstrap/bootstrap.py"
1989 "-s" (assoc-ref inputs "hadrian-bootstrap-sources.tar.gz")
1990 "-w" (which "ghc"))))
1991 (add-before 'build-hadrian 'fix-environment
1992 (lambda _
1993 (unsetenv "GHC_PACKAGE_PATH")
1994 (setenv "CONFIG_SHELL" (which "bash"))))
1995 (replace 'build
1996 (lambda* (#:key (parallel-build? #f) (make-flags '())
1997 #:allow-other-keys)
1998 (apply invoke "_build/bin/hadrian"
1999 `("binary-dist-dir"
2000 ,@(if parallel-build?
2001 (list (string-append
2002 "-j" (number->string
2003 (parallel-job-count)))))
2004 ,@make-flags))))
2005 (replace 'check
2006 (lambda* (#:key (tests? #t) (parallel-tests? #f) (make-flags '())
2007 #:allow-other-keys)
2008 (if tests?
2009 (apply invoke "_build/bin/hadrian"
2010 `(,@(if parallel-tests?
2011 (list (string-append
2012 "-j"
2013 (number->string (parallel-job-count))))
2014 '())
2015 ,@make-flags
2016 "test"
2017 ,(string-append
2018 "--broken-test="
2019 (string-join
2020 (list "T15904" ; ld-wrapper, apparently
2021 "T16521" ; no idea
2022 ;; These fail due to gcc
2023 ;; -Wincompatible-pointer-types, which
2024 ;; apparently is not used in GHC's CI
2025 ;; https://gitlab.haskell.org/ghc/ghc/-/issues/22263
2026 "hs_try_putmvar001"
2027 "list_threads_and_misc_roots"
2028 "testwsdeque")))
2029 "--skip-perf"))
2030 (format #t "test suite not run~%"))))
2031 (replace 'install
2032 (lambda* (#:key (make-flags '()) #:allow-other-keys)
2033 (apply invoke "_build/bin/hadrian"
2034 `("install"
2035 ,@make-flags
2036 ,(string-append "--prefix=" #$output)))))
2037 (add-after 'install 'remove-unnecessary-references
2038 (lambda* (#:key outputs #:allow-other-keys)
2039 (substitute* (find-files (string-append (assoc-ref outputs "out") "/lib/")
2040 "settings")
2041 (("/gnu/store/.*/bin/(.*)" m program) program))
2042
2043 ;; Remove references to "doc" output from "out" by rewriting
2044 ;; the "haddock-interfaces" fields and removing the optional
2045 ;; "haddock-html" field in the generated .conf files.
2046 (let ((doc (assoc-ref outputs "doc"))
2047 (out (assoc-ref outputs "out")))
2048 (with-fluids ((%default-port-encoding #f))
2049 (for-each (lambda (config-file)
2050 (substitute* config-file
2051 (("^haddock-html: .*") "\n")
2052 (((format #f "^haddock-interfaces: ~a" doc))
2053 (string-append "haddock-interfaces: " out))))
2054 (find-files (string-append out "/lib") ".conf")))
2055 ;; Move the referenced files to the "out" output.
2056 (for-each (lambda (haddock-file)
2057 (let* ((subdir (string-drop haddock-file (string-length doc)))
2058 (new (string-append out subdir)))
2059 (mkdir-p (dirname new))
2060 (rename-file haddock-file new)))
2061 (find-files doc "\\.haddock$")))))
2062 (add-after 'install 'replace-$pkgroot
2063 (lambda* (#:key outputs #:allow-other-keys)
2064 ((@ (srfi srfi-11) let*-values)
2065 (((out) (assoc-ref outputs "out"))
2066 ((_ version) (package-name->name+version
2067 (strip-store-file-name out))))
2068 ;; We split out the version because we want this to also work
2069 ;; with packages named "ghc-next" instead of "ghc"
2070 (substitute*
2071 (find-files
2072 (string-append (assoc-ref outputs "out") "/lib/ghc-"
2073 version "/lib/package.conf.d/")
2074 "^.*\\.conf$")
2075 (("\\$\\{pkgroot\\}/")
2076 (string-append (assoc-ref outputs "out") "/lib/ghc-"
2077 version "/lib/")))))))))
2078 (build-system gnu-build-system)
2079 (inputs (list bash-minimal gmp ncurses libffi))
2080 (native-inputs
2081 (list perl
2082 python
2083 git-minimal/pinned
2084 which
2085 ghostscript
2086 autoconf
2087 automake
2088
2089 ghc-bootstrap
2090 ghc-alex-bootstrap-for-9.4
2091 ghc-happy-bootstrap-for-9.4
2092 (origin
2093 (method url-fetch)
2094 (uri (string-append
2095 "https://www.haskell.org/ghc/dist/"
2096 version "/ghc-" version "-testsuite.tar.xz"))
2097 (file-name "ghc-testsuite.tar.xz")
2098 (sha256
2099 (base32
2100 "1hxylm3nhxzl7yidarlavvcg1240w4bk0hy5jnvwna24jyxz69i6"))
2101 (patches (search-patches "ghc-testsuite-recomp015-execstack.patch")))
2102 (origin
2103 (method url-fetch)
2104 (uri (string-append "https://downloads.haskell.org/~ghc/"
2105 version "/hadrian-bootstrap-sources/"
2106 "hadrian-bootstrap-sources-"
2107 (package-version ghc-bootstrap) ".tar.gz"))
2108 (file-name "hadrian-bootstrap-sources.tar.gz")
2109 (sha256
2110 (base32
2111 "14dkxif9x4hy85phcj3j0glf95k04g4ab6hfchpw9vxgvk97syi1")))))
2112 (native-search-paths
2113 (list (search-path-specification
2114 (variable "GHC_PACKAGE_PATH")
2115 (files (list (string-append "lib/ghc-" version)))
2116 (file-pattern ".*\\.conf\\.d$")
2117 (file-type 'directory))))
2118 (home-page "https://www.haskell.org/ghc")
2119 (synopsis "The Glasgow Haskell Compiler")
2120 (description
2121 "The Glasgow Haskell Compiler (GHC) is a state-of-the-art compiler and
2122interactive environment for the functional language Haskell.")
2123 (license license:bsd-3))))
2124
2125(define-public ghc-9.10
2126 (let ((base ghc-9.8))
2127 (package
2128 (inherit base)
2129 (name "ghc")
2130 (version "9.10.2")
2131 (source
2132 (origin
2133 (method url-fetch)
2134 (uri (string-append "https://downloads.haskell.org/~ghc/" version
2135 "/ghc-" version "-src.tar.xz"))
2136 (sha256
2137 (base32
2138 "1pm84cgr3yg99r3srdjllgz6zig8h7dbwa597srwcnjp0nh41zam"))))
2139 (arguments
2140 (substitute-keyword-arguments (package-arguments base)
2141 ((#:phases phases #~%standard-phases)
2142 #~(modify-phases #$phases
2143 (replace 'check
2144 (lambda* (#:key (tests? #t) (parallel-tests? #f) (make-flags '())
2145 #:allow-other-keys)
2146 (if tests?
2147 (apply invoke "_build/bin/hadrian"
2148 `(,@(if parallel-tests?
2149 (list (string-append
2150 "-j"
2151 (number->string (parallel-job-count))))
2152 '())
2153 ,@make-flags
2154 "test"
2155 ,(string-append
2156 "--broken-test="
2157 (string-join
2158 (list "T15904" ; ld-wrapper, apparently
2159 "T16521" ; no idea
2160 ;; These fail due to gcc
2161 ;; -Wincompatible-pointer-types, which
2162 ;; apparently is not used in GHC's CI
2163 ;; https://gitlab.haskell.org/ghc/ghc/-/issues/22263
2164 "list_threads_and_misc_roots"
2165 "stack_misc_closures")))
2166 "--skip-perf"))
2167 (format #t "test suite not run~%"))))))))
2168 (native-inputs
2169 (modify-inputs (package-native-inputs base)
2170 (replace "ghc" base)
2171 (replace "ghc-testsuite.tar.xz"
2172 (origin
2173 (method url-fetch)
2174 (uri (string-append
2175 "https://downloads.haskell.org/~ghc/"
2176 version "/ghc-" version "-testsuite.tar.xz"))
2177 (sha256
2178 (base32
2179 "143ifc4g3jc6s9hcry5qha913rzwg4hpsvk6pqvxk5r0qigfxjwx"))
2180 (patches (search-patches "ghc-testsuite-recomp015-execstack.patch"))))
2181 (replace "hadrian-bootstrap-sources.tar.gz"
2182 (origin
2183 (method url-fetch)
2184 (uri (string-append "https://downloads.haskell.org/~ghc/" version
2185 "/hadrian-bootstrap-sources/"
2186 "hadrian-bootstrap-sources-"
2187 (package-version base) ".tar.gz"))
2188 (sha256
2189 (base32
2190 "162lbafvdamfhx1jldax3shgk8jbbqn4an97ny363lxbdjgdn708"))))))
2191 (native-search-paths
2192 (list (search-path-specification
2193 (variable "GHC_PACKAGE_PATH")
2194 (files (list (string-append "lib/ghc-" version)))
2195 (file-pattern ".*\\.conf\\.d$")
2196 (file-type 'directory)))))))
2197
2198;; Versions newer than ghc defined below (i.e. the compiler
2199;; haskell-build-system uses) should use ghc-next as their name to
2200;; ensure ghc (without version specification) and ghc-* packages are
2201;; always compatible. See https://issues.guix.gnu.org/issue/47335.
2202(define-public ghc ghc-9.10)
2203
2204;;; haskell.scm ends here