From: Efraim Flashner <efraim@flashner.co.il>
To: Konrad Hinsen <konrad.hinsen@fastmail.net>
Cc: Saku Laesvuori <saku@laesvuori.fi>, Guix Devel <guix-devel@gnu.org>
Subject: Re: Debugging missing architecture support
Date: Fri, 16 Feb 2024 12:34:02 +0200 [thread overview]
Message-ID: <Zc86GrDeGXx-3XPk@3900XT> (raw)
In-Reply-To: <m134tuqau4.fsf@fastmail.net>
[-- Attachment #1.1: Type: text/plain, Size: 1070 bytes --]
On Thu, Feb 15, 2024 at 11:29:55AM +0100, Konrad Hinsen wrote:
> Hi Saku,
>
> > Maybe someone else can give more general or Guix specific advice on
> > finding out the cause of such problems, but I believe that in this case
> > the fix would just be packaging GHC for aarch64-linux. It should[1] be
> > possible but it will require some work.
> >
> > [1]: https://gitlab.haskell.org/ghc/ghc/-/wikis/platforms
>
> Thanks for the pointer! It looks indeed like GHC already support
> aarch64, so it's just a matter of integrating that support into Guix.
> I'll see if I can find someone motivated and competent to do that.
I've been carrying around this diff for a while but I don't think I'm
currently ready to finish it off. It adds aarch64 and armhf bootstrap
binaries for GHC and gets started on the path to building ghc-8.6 with
them.
--
Efraim Flashner <efraim@flashner.co.il> רנשלפ םירפא
GPG key = A28B F40C 3E55 1372 662D 14F7 41AA E7DC CA3D 8351
Confidentiality cannot be guaranteed on emails sent or received unencrypted
[-- Attachment #1.2: ghc-aarch64-support.diff --]
[-- Type: text/plain, Size: 13866 bytes --]
diff --git a/gnu/packages/haskell.scm b/gnu/packages/haskell.scm
index 62815efbb1..92ba976189 100644
--- a/gnu/packages/haskell.scm
+++ b/gnu/packages/haskell.scm
@@ -57,6 +57,7 @@ (define-module (gnu packages haskell)
#:use-module (gnu packages libffi)
#:use-module (gnu packages linux)
#:use-module (gnu packages lisp)
+ #:use-module (gnu packages llvm)
#:use-module (gnu packages m4)
#:use-module (gnu packages multiprecision)
#:use-module (gnu packages ncurses)
@@ -699,6 +852,24 @@ (define ghc-bootstrap-i686-7.8.4
(base32
"0wj5s435j0zgww70bj1d3f6wvnnpzlxwvwcyh2qv4qjq5z8j64kg"))))
+(define ghc-bootstrap-armhf-8.2.2
+ (origin
+ (method url-fetch)
+ (uri
+ "https://downloads.haskell.org/~ghc/8.2.2/ghc-8.2.2-armv7-deb8-linux.tar.xz")
+ (sha256
+ (base32
+ "1jmv8qmnh5bn324fivbwdcaj55kvw7cb2zq9pafmlmv3qwwx7s46"))))
+
+(define ghc-bootstrap-aarch64-8.2.2
+ (origin
+ (method url-fetch)
+ (uri
+ "https://downloads.haskell.org/~ghc/8.2.2/ghc-8.2.2-aarch64-deb8-linux.tar.xz")
+ (sha256
+ (base32
+ "1k2amylcp1ad67c75h1pqf7czf9m0zj1i7hdc45ghjklnfq9hrk7"))))
+
;; 43 tests out of 3965 fail.
;;
;; Most of them do not appear to be serious:
@@ -1057,10 +1228,115 @@ (define-public ghc-8.4
(file-pattern ".*\\.conf\\.d$")
(file-type 'directory))))))
+(define ghc-8.4-bootstrap
+ (package
+ (inherit ghc-8.4)
+ (name "ghc")
+ (version "8.4.4")
+ (supported-systems '("aarch64-linux" "armhf-linux"))
+ (native-inputs
+ `(;("clang" ,clang)
+ ("gcc:lib" ,gcc "lib")
+ ("ghc-bootstrap" ,(if (target-aarch64?)
+ ghc-bootstrap-aarch64-8.2.2
+ ghc-bootstrap-armhf-8.2.2))
+ ("llvm" ,llvm-9)
+ ("patchelf" ,patchelf)
+ ;("ld-wrapper" ,(@ (gnu packages commencement) ld-gold-wrapper)) ; for arm
+ ,@(filter (match-lambda
+ (("ghc-bootstrap" . _) #f)
+ (_ #t))
+ (package-native-inputs ghc-8.4))))
+ (arguments
+ (substitute-keyword-arguments (package-arguments ghc-8.4)
+ ((#:modules _ #~%gnu-build-system-modules)
+ '((guix build gnu-build-system)
+ (guix build utils)
+ (srfi srfi-26)
+ (srfi srfi-1)))
+ ((#:phases phases)
+ #~(let* ((ghc-bootstrap-path
+ (string-append (getcwd) "/" #$name "-" #$version "/ghc-bin"))
+ (ghc-bootstrap-prefix
+ (string-append ghc-bootstrap-path "/usr")))
+ (modify-phases #$phases
+ (add-after 'unpack 'unpack-bin
+ (lambda* (#:key inputs #:allow-other-keys)
+ (mkdir-p ghc-bootstrap-prefix)
+ (with-directory-excursion ghc-bootstrap-path
+ (invoke "tar" "xvf" (assoc-ref inputs "ghc-bootstrap")))))
+ (add-before 'configure 'install-bin
+ (lambda _
+ (with-directory-excursion
+ (string-append ghc-bootstrap-path "/ghc-8.2.2")
+ (invoke "make" "install"))))
+ (add-before 'install-bin 'configure-bin
+ (lambda* (#:key inputs outputs #:allow-other-keys)
+ (let* ((binaries
+ (list "ghc/stage2/build/tmp/ghc-stage2"
+ "iserv/stage2/build/tmp/ghc-iserv"
+ "iserv/stage2_dyn/build/tmp/ghc-iserv-dyn"
+ "iserv/stage2_p/build/tmp/ghc-iserv-prof"
+ "utils/ghc-cabal/dist-install/build/tmp/ghc-cabal"
+ "utils/ghc-pkg/dist-install/build/tmp/ghc-pkg"
+ ;"utils/haddock/dist/build/tmp/haddock" ; not on arm
+ "utils/hp2ps/dist/build/tmp/hp2ps"
+ "utils/hpc/dist-install/build/tmp/hpc"
+ "utils/hsc2hs/dist-install/build/tmp/hsc2hs"
+ "utils/runghc/dist-install/build/tmp/runghc"
+ "utils/unlit/dist/build/tmp/unlit"))
+ (gmp (assoc-ref inputs "gmp"))
+ (gmp-lib (string-append gmp "/lib"))
+ (gmp-include (string-append gmp "/include"))
+ (ncurses-lib
+ (dirname (search-input-file inputs "/lib/libncurses.so")))
+ (ld-so (search-input-file inputs #$(glibc-dynamic-linker)))
+ (libtinfo-dir
+ (string-append ghc-bootstrap-prefix
+ "/lib/ghc-8.2.2/terminfo-0.4.1.0")))
+ (with-directory-excursion
+ (string-append ghc-bootstrap-path "/ghc-8.2.2")
+ (setenv "CONFIG_SHELL" (which "bash"))
+ (setenv "LD_LIBRARY_PATH"
+ (string-append gmp-lib ":"
+ (assoc-ref inputs "gcc:lib") "/lib"))
+ ;; The binaries have "/lib64/ld-linux-x86-64.so.2" hardcoded.
+ (for-each
+ (cut invoke "patchelf" "--set-interpreter" ld-so <>)
+ binaries)
+ ;; The binaries include a reference to libtinfo.so.5 which
+ ;; is a subset of libncurses.so.5. We create a symlink in a
+ ;; directory included in the bootstrap binaries rpath.
+ (mkdir-p libtinfo-dir)
+ (symlink
+ (string-append ncurses-lib "/libncursesw.so."
+ ;; Extract "6.2" from "6.2.20210619" if a
+ ;; dash-separated version tag exists.
+ #$(let* ((v (package-version ncurses))
+ (d (or (string-index v #\-)
+ (string-length v))))
+ (version-major+minor (string-take v d))))
+ (string-append libtinfo-dir "/libtinfo.so.5"))
+
+ (setenv "PATH"
+ (string-append (getenv "PATH") ":"
+ ghc-bootstrap-prefix "/bin"))
+ (invoke
+ (string-append (getcwd) "/configure")
+ (string-append "--prefix=" ghc-bootstrap-prefix)))))))))))
+ (native-search-paths (list (search-path-specification
+ (variable "GHC_PACKAGE_PATH")
+ (files (list
+ (string-append "lib/ghc-" version)))
+ (file-pattern ".*\\.conf\\.d$")
+ (file-type 'directory))))))
+
(define-public ghc-8.6
(package (inherit ghc-8.4)
(name "ghc")
(version "8.6.5")
+ (supported-systems (append (package-supported-systems ghc-8.4)
+ (package-supported-systems ghc-8.4-bootstrap)))
(source
(origin
(method url-fetch)
@@ -1070,7 +1346,10 @@ (define-public ghc-8.6
(base32 "0qg3zsmbk4rkwkc3jpas3zs74qaxmw4sp4v1mhsbj0a0dzls2jjd"))))
(native-inputs
`(;; GHC 8.6.5 must be built with GHC >= 8.2.
- ("ghc-bootstrap" ,ghc-8.4)
+ ("ghc-bootstrap" ,(if (member (%current-system)
+ (package-supported-systems ghc-8.4-bootstrap))
+ ghc-8.4-bootstrap
+ ghc-8.4))
("ghc-testsuite"
,(origin
(method url-fetch)
@@ -1140,6 +1419,105 @@ (define-public ghc-8.6
(file-pattern ".*\\.conf\\.d$")
(file-type 'directory))))))
+(define ghc-8.6-bootstrap
+ (package
+ (inherit ghc-8.6)
+ (name "ghc")
+ (version "8.6.5")
+ (supported-systems '("aarch64-linux" "armhf-linux"))
+ (native-inputs
+ `(;("clang" ,clang)
+ ("gcc:lib" ,gcc "lib")
+ ("ghc-bootstrap" ,(if (target-aarch64?)
+ ghc-bootstrap-aarch64-8.2.2
+ ghc-bootstrap-armhf-8.2.2))
+ ("llvm" ,llvm)
+ ("patchelf" ,patchelf)
+ ,@(filter (match-lambda
+ (("ghc-bootstrap" . _) #f)
+ (_ #t))
+ (package-native-inputs ghc-8.6))))
+ (arguments
+ (substitute-keyword-arguments (package-arguments ghc-8.6)
+ ((#:modules _ #~%gnu-build-system-modules)
+ '((guix build gnu-build-system)
+ (guix build utils)
+ (srfi srfi-26)
+ (srfi srfi-1)))
+ ((#:phases phases)
+ #~(let* ((ghc-bootstrap-path
+ (string-append (getcwd) "/" #$name "-" #$version "/ghc-bin"))
+ (ghc-bootstrap-prefix
+ (string-append ghc-bootstrap-path "/usr")))
+ (modify-phases #$phases
+ (add-after 'unpack 'unpack-bin
+ (lambda* (#:key inputs #:allow-other-keys)
+ (mkdir-p ghc-bootstrap-prefix)
+ (with-directory-excursion ghc-bootstrap-path
+ (invoke "tar" "xvf" (assoc-ref inputs "ghc-bootstrap")))))
+ (add-before 'configure 'install-bin
+ (lambda _
+ (with-directory-excursion
+ (string-append ghc-bootstrap-path "/ghc-8.2.2")
+ (invoke "make" "install"))))
+ (add-before 'install-bin 'configure-bin
+ (lambda* (#:key inputs outputs #:allow-other-keys)
+ (let* ((binaries
+ (list "ghc/stage2/build/tmp/ghc-stage2"
+ "utils/ghc-cabal/dist-install/build/tmp/ghc-cabal"
+ "utils/ghc-pkg/dist-install/build/tmp/ghc-pkg"
+ "utils/haddock/dist/build/tmp/haddock"
+ "utils/hp2ps/dist/build/tmp/hp2ps"
+ "utils/hpc/dist-install/build/tmp/hpc"
+ "utils/hsc2hs/dist-install/build/tmp/hsc2hs"
+ "utils/runghc/dist-install/build/tmp/runghc"
+ "utils/unlit/dist/build/tmp/unlit"))
+ (gmp (assoc-ref inputs "gmp"))
+ (gmp-lib (string-append gmp "/lib"))
+ (gmp-include (string-append gmp "/include"))
+ (ncurses-lib
+ (dirname (search-input-file inputs "/lib/libncurses.so")))
+ (ld-so (search-input-file inputs #$(glibc-dynamic-linker)))
+ (libtinfo-dir
+ (string-append ghc-bootstrap-prefix
+ "/lib/ghc-8.2.2/terminfo-0.4.1.0")))
+ (with-directory-excursion
+ (string-append ghc-bootstrap-path "/ghc-8.2.2")
+ (setenv "CONFIG_SHELL" (which "bash"))
+ (setenv "LD_LIBRARY_PATH"
+ (string-append gmp-lib ":"
+ (assoc-ref inputs "gcc:lib") "/lib"))
+ ;; The binaries have "/lib64/ld-linux-x86-64.so.2" hardcoded.
+ (for-each
+ (cut invoke "patchelf" "--set-interpreter" ld-so <>)
+ binaries)
+ ;; The binaries include a reference to libtinfo.so.5 which
+ ;; is a subset of libncurses.so.5. We create a symlink in a
+ ;; directory included in the bootstrap binaries rpath.
+ (mkdir-p libtinfo-dir)
+ (symlink
+ (string-append ncurses-lib "/libncursesw.so."
+ ;; Extract "6.2" from "6.2.20210619" if a
+ ;; dash-separated version tag exists.
+ #$(let* ((v (package-version ncurses))
+ (d (or (string-index v #\-)
+ (string-length v))))
+ (version-major+minor (string-take v d))))
+ (string-append libtinfo-dir "/libtinfo.so.5"))
+
+ (setenv "PATH"
+ (string-append (getenv "PATH") ":"
+ ghc-bootstrap-prefix "/bin"))
+ (invoke
+ (string-append (getcwd) "/configure")
+ (string-append "--prefix=" ghc-bootstrap-prefix)))))))))))
+ (native-search-paths (list (search-path-specification
+ (variable "GHC_PACKAGE_PATH")
+ (files (list
+ (string-append "lib/ghc-" version)))
+ (file-pattern ".*\\.conf\\.d$")
+ (file-type 'directory))))))
+
(define-public ghc-8.8
(package (inherit ghc-8.6)
(name "ghc")
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
prev parent reply other threads:[~2024-02-16 10:34 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-14 13:26 Debugging missing architecture support Konrad Hinsen
2024-02-14 18:12 ` Efraim Flashner
2024-02-14 20:33 ` Ricardo Wurmus
2024-02-15 10:06 ` Konrad Hinsen
2024-02-24 16:35 ` Ludovic Courtès
2024-02-25 17:22 ` Konrad Hinsen
2024-02-14 20:26 ` Saku Laesvuori
2024-02-15 10:29 ` Konrad Hinsen
2024-02-16 10:34 ` Efraim Flashner [this message]
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=Zc86GrDeGXx-3XPk@3900XT \
--to=efraim@flashner.co.il \
--cc=guix-devel@gnu.org \
--cc=konrad.hinsen@fastmail.net \
--cc=saku@laesvuori.fi \
/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).