From patchwork Sat Jun 27 21:16:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "vasilii.smirnov--- via Guix-patches\" via" X-Patchwork-Id: 22911 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 615AC27BBE1; Sat, 27 Jun 2020 22:17:09 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,T_DKIM_INVALID, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTP id 9953027BBE3 for ; Sat, 27 Jun 2020 22:17:08 +0100 (BST) Received: from localhost ([::1]:46760 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jpICC-00031l-3F for patchwork@mira.cbaines.net; Sat, 27 Jun 2020 17:17:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48948) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jpIC6-00031V-IG for guix-patches@gnu.org; Sat, 27 Jun 2020 17:17:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:33146) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jpIC6-0007j1-8c for guix-patches@gnu.org; Sat, 27 Jun 2020 17:17:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jpIC6-0005Wl-1p for guix-patches@gnu.org; Sat, 27 Jun 2020 17:17:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#42014] [PATCH] WIP: gnu: ghc@8.4: Support 32- and 64-bit ARM systems. References: In-Reply-To: Resent-From: Alex Griffin Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 27 Jun 2020 21:17:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 42014 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: "42014@debbugs.gnu.org" <42014@debbugs.gnu.org> Received: via spool by 42014-submit@debbugs.gnu.org id=B42014.159329258221195 (code B ref 42014); Sat, 27 Jun 2020 21:17:02 +0000 Received: (at 42014) by debbugs.gnu.org; 27 Jun 2020 21:16:22 +0000 Received: from localhost ([127.0.0.1]:44692 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jpIBR-0005Vm-TJ for submit@debbugs.gnu.org; Sat, 27 Jun 2020 17:16:22 -0400 Received: from mail-40133.protonmail.ch ([185.70.40.133]:47241) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jpIBP-0005VX-Q8 for 42014@debbugs.gnu.org; Sat, 27 Jun 2020 17:16:21 -0400 Date: Sat, 27 Jun 2020 21:16:10 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ajgrf.com; s=protonmail; t=1593292573; bh=nsyWFyqZ6av0qnMxAbtjV+44uRf9qMZ1SN6uDGOuxwU=; h=Date:To:From:Reply-To:Subject:From; b=SQFM28w1eGphkB+H/G+KXLoL/0rbc9JUejPLJm+JN+U+BYyfFdOywPmEjHxgwxdCK IUueUiXwJwSu1mUmpoNE3oYAXp1KoIsYGMaO5FH44OMFz4gDrEFTPnpOhwTe3zzIx1 JFtFY5xq8jtsDIiWW46qohSMrh7iCqeUyAwtmnlB6k9Uk02q12by4WEUWZgFGjfOp7 nb6IxkMkxS0OIoa5On9T+O7VupxdhqDG//wdExw9ZVZHm4XATIwVCQ1LueG+EAlgFy XC0VrmHYziUuKu5ZEwbmScux+Iw5zbkzjw1/gJq6wq3lEyzvlEnGiHusyoGsSwsrEo j50kfyHxDarZA== Message-ID: MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" Reply-to: Alex Griffin , Alex Griffin via Guix-patches X-Patchwork-Original-From: Alex Griffin via Guix-patches via From: "vasilii.smirnov--- via Guix-patches\" via" X-getmail-retrieved-from-mailbox: Patches 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 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