unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: Alex Griffin via Guix-patches via <guix-patches@gnu.org>
To: "42014@debbugs.gnu.org" <42014@debbugs.gnu.org>
Subject: [bug#42014] [PATCH] WIP: gnu: ghc@8.4: Support 32- and 64-bit ARM systems.
Date: Sat, 27 Jun 2020 21:16:10 +0000	[thread overview]
Message-ID: <EgF-edHWbrDu8UYMbyn1KhCeRxYHaUvcBNFI7sIlRoe3a0hZocEhHwwP0U-KvxzxK9ZoD0ueb2q72nkxbXsZXAWxNwIRoP5Fos_NmLQyaOU=@ajgrf.com> (raw)
In-Reply-To: <iqxuLyt2f_ck_2DTkqr6jKDaFGhsrSuEQQA8frhOSY4s2mymb9NgH2csILFrwNHi0mxHMNKYFBsshhyhXiKkHUgNqKI4yrmwfKixnISeU6Q=@ajgrf.com>

[-- Attachment #1: Type: text/plain, Size: 306 bytes --]

Here's the second patch. I'm making some progress on bootstrapping Haskell on ARM. Currently it builds the stage1 compiler just fine, then panics while building the stage2 compiler.

Progress is super slow, mainly because long compilation times mean I can only try 1 change per day.
--
Alex Griffin


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0002-gnu-ghc-8.4-Support-32-and-64-bit-ARM-systems.patch --]
[-- Type: text/x-patch; name=0002-gnu-ghc-8.4-Support-32-and-64-bit-ARM-systems.patch, Size: 5919 bytes --]

From 405cf569abeaa583ddf6ea3639d9f74853fee36a Mon Sep 17 00:00:00 2001
From: Alex Griffin <a@ajgrf.com>
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


  reply	other threads:[~2020-06-27 21:17 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-23  1:48 [bug#42014] [PATCH] WIP: gnu: Re-bootstrap Haskell with GHC 8.2.2 binaries Alex Griffin via Guix-patches via
2020-06-27 21:16 ` Alex Griffin via Guix-patches via [this message]
2020-06-27 21:21 ` Ricardo Wurmus
2020-06-27 22:09   ` Alex Griffin via Guix-patches via

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='EgF-edHWbrDu8UYMbyn1KhCeRxYHaUvcBNFI7sIlRoe3a0hZocEhHwwP0U-KvxzxK9ZoD0ueb2q72nkxbXsZXAWxNwIRoP5Fos_NmLQyaOU=@ajgrf.com' \
    --to=guix-patches@gnu.org \
    --cc=42014@debbugs.gnu.org \
    --cc=a@ajgrf.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).