From 405cf569abeaa583ddf6ea3639d9f74853fee36a Mon Sep 17 00:00:00 2001 From: Alex Griffin Date: Sat, 27 Jun 2020 16:01:14 -0500 Subject: [PATCH 2/2] gnu: ghc@8.4: Support 32- and 64-bit ARM systems. * gnu/packages/haskell.scm (ghc-bootstrap-aarch64-8.2.2, ghc-bootstrap-armhf-8.2.2): New variables. (ghc-8.4)[supported-systems]: Add armhf-linux and aarch64-linux. [inputs, native-inputs]: Add extra dependencies for ARM builds. [arguments]: Use gold linker, add libgcc_s to LD_LIBRARY_PATH, and don't call patchelf on non-existent files. --- gnu/packages/haskell.scm | 52 +++++++++++++++++++++++++++++++++++----- 1 file changed, 46 insertions(+), 6 deletions(-) diff --git a/gnu/packages/haskell.scm b/gnu/packages/haskell.scm index ac5ad14320..533d82ae44 100644 --- a/gnu/packages/haskell.scm +++ b/gnu/packages/haskell.scm @@ -39,11 +39,14 @@ (define-module (gnu packages haskell) #:use-module (gnu packages) + #:use-module (gnu packages base) #:use-module (gnu packages bootstrap) #:use-module (gnu packages elf) + #:use-module (gnu packages gcc) #:use-module (gnu packages ghostscript) #:use-module (gnu packages libffi) #:use-module (gnu packages lisp) + #:use-module (gnu packages llvm) #:use-module (gnu packages multiprecision) #:use-module (gnu packages ncurses) #:use-module (gnu packages perl) @@ -115,6 +118,24 @@ top of CLISP.") (base32 "08w2ik55dp3n95qikmrflc91lsiq01xp53ki3jlhnbj8fqnxfrwy")))) +(define ghc-bootstrap-aarch64-8.2.2 + (origin + (method url-fetch) + (uri + "https://www.haskell.org/ghc/dist/8.2.2/ghc-8.2.2-aarch64-deb8-linux.tar.xz") + (sha256 + (base32 + "1k2amylcp1ad67c75h1pqf7czf9m0zj1i7hdc45ghjklnfq9hrk7")))) + +(define ghc-bootstrap-armhf-8.2.2 + (origin + (method url-fetch) + (uri + "https://www.haskell.org/ghc/dist/8.2.2/ghc-8.2.2-armv7-deb8-linux.tar.xz") + (sha256 + (base32 + "1jmv8qmnh5bn324fivbwdcaj55kvw7cb2zq9pafmlmv3qwwx7s46")))) + (define-public ghc-8.4 (package (name "ghc") @@ -127,12 +148,21 @@ top of CLISP.") (sha256 (base32 "1ch4j2asg7pr52ai1hwzykxyj553wndg7wq93i47ql4fllspf48i")))) (build-system gnu-build-system) - (supported-systems '("i686-linux" "x86_64-linux")) + (supported-systems '("i686-linux" "x86_64-linux" + "armhf-linux" "aarch64-linux")) (outputs '("out" "doc")) (inputs `(("gmp" ,gmp) ("ncurses" ,ncurses) - ("libffi" ,libffi))) + ("libffi" ,libffi) + ,@(match (or (%current-target-system) (%current-system)) + ((or "aarch64-linux" "armhf-linux") + `(("gcc:lib" ,gcc "lib") + ("gold-wrapper" + ,(make-ld-wrapper "gold-wrapper" + #:binutils binutils-gold)) + ("llvm" ,llvm))) + (_ '())))) (native-inputs `(("perl" ,perl) ("python" ,python) ; for tests @@ -142,7 +172,9 @@ top of CLISP.") ("ghc-binary" ,(match (or (%current-target-system) (%current-system)) ("x86_64-linux" ghc-bootstrap-x86_64-8.2.2) - ("i686-linux" ghc-bootstrap-i686-8.2.2))) + ("i686-linux" ghc-bootstrap-i686-8.2.2) + ("aarch64-linux" ghc-bootstrap-aarch64-8.2.2) + ("armhf-linux" ghc-bootstrap-armhf-8.2.2))) ("ghc-testsuite" ,(origin (method url-fetch) @@ -226,7 +258,8 @@ top of CLISP.") (lambda* (#:key inputs #:allow-other-keys) (let ((binutils (assoc-ref inputs "binutils")) (gcc (assoc-ref inputs "gcc")) - (ld-wrapper (assoc-ref inputs "ld-wrapper"))) + (ld-wrapper (or (assoc-ref inputs "gold-wrapper") + (assoc-ref inputs "ld-wrapper")))) (setenv "CC" (string-append gcc "/bin/gcc")) (setenv "CXX" (string-append gcc "/bin/g++")) (setenv "LD" (string-append ld-wrapper "/bin/ld")) @@ -271,11 +304,16 @@ top of CLISP.") "./utils/ghc-pkg/dist-install/build/tmp/ghc-pkg" "./utils/unlit/dist/build/tmp/unlit" "./ghc/stage2/build/tmp/ghc-stage2")) + (gcclib (assoc-ref inputs "gcc:lib")) (gmp (assoc-ref inputs "gmp")) (gmp-lib (string-append gmp "/lib")) (gmp-include (string-append gmp "/include")) (ncurses-lib (string-append (assoc-ref inputs "ncurses") "/lib")) + (ld-lib-path (cons gmp-lib + (if gcclib + (list (string-append gcclib "/lib")) + '()))) (ld-so (string-append (assoc-ref inputs "libc") ,(glibc-dynamic-linker))) (libtinfo-dir @@ -283,10 +321,12 @@ top of CLISP.") "/lib/ghc-8.2.2/terminfo-0.4.1.0"))) (with-directory-excursion (string-append ghc-bootstrap-path "/ghc-8.2.2") - (setenv "LD_LIBRARY_PATH" gmp-lib) + (setenv "LD_LIBRARY_PATH" (string-join ld-lib-path ":")) ;; The binaries have "/lib64/ld-linux-x86-64.so.2" hardcoded. (for-each - (cut invoke "patchelf" "--set-interpreter" ld-so <>) + (lambda (binary) + (when (file-exists? binary) + (invoke "patchelf" "--set-interpreter" ld-so binary))) binaries) ;; The binaries include a reference to libtinfo.so.5 which ;; is a subset of libncurses.so.5. We create a symlink in a -- 2.26.2