I'm working on a few haskell projects that run on a raspberry pi 2 and the version of ghc that you can install with apt-get from raspbian (7.4.1). It has no GHCi though, which prevents some vital packages (like Vector) from compiling. I've seen a few rumors about being able to get later versions of ghc (with ghci) onto the pi, but nothing recent. The entry on the haskell wiki looks a couple years out of date. Has anyone had any luck with this?
1 Answers
I have had some luck with this!
sagemuej@sagemuej-Aspire-5742G:~$ ssh pi-loc
Linux raspberrypi 3.12.28+ #709 PREEMPT Mon Sep 8 15:28:00 BST 2014 armv6l
The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Wed Apr 1 00:24:44 2015 from sagemuej-aspire-5742g.localdomain
pi@raspberrypi:~$ ghci
GHCi, version 7.8.2: http://www.haskell.org/ghc/ :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Prelude> :m +Data.Vector
Prelude Data.Vector> fromList [1,2,3]
Loading package array-0.5.0.0 ... linking ... done.
Loading package deepseq-1.3.0.2 ... linking ... done.
Loading package primitive-0.5.2.1 ... linking ... done.
Loading package vector-0.10.9.1 ... linking ... done.
fromList [1,2,3]
Ain't it nice?
It is a full GHC 7.8. I had to bootstrap it from source, though. Worked pretty fine by the normal setup instructions if I recall correctly – though it took ages to build (like, half a week).
The main issue is memory: for some of the larger modules, the compiler needs more than the π can offer even when running without X. What I did was simply, I connected a USB hard drive and set up a swap partition on it. Of course, swapping makes everything even slower, but eventually it'll succeed. Did for me, at least.

- 117,950
- 5
- 174
- 319
-
That's great news! Would you consider making the compiled binaries available? – jhickner Apr 01 '15 at 01:11
-
1I suppose I should, shouldn't I? I've never packaged any binaries, but I reckon it can't be so difficult. I'll think about it... – leftaroundabout Apr 01 '15 at 09:16
-
1You people are crazy!... I approve. – MathematicalOrchid Apr 01 '15 at 10:24
-
I'm trying 7.8.4 right now! @leftaroundabout did you build on a pi or pi2? I'm hoping the extra cores will speed things up. I ran make with 5 jobs. Also I chose the quick build option which leaves out profiling. – jhickner Apr 01 '15 at 20:33
-
rpi 1 model B. – As I said, the biggest hurdle was memory, so it'll probably compile _much_ faster on the π 2. (In my case, the time spent swapping was probably by far the biggest contribution.) – leftaroundabout Apr 01 '15 at 21:18
-
I got all the way to the final stage on 7.8.4 in 3 hours with `make -j 5`, but then compilation failed on a "strange closure" error. Giving 7.8.2 a try now. – jhickner Apr 01 '15 at 22:35
-
I certainly can't recall “strange closure” or something like that happening. Might be a 7.8.4 issue. But if there are errors with the 7.8.2 install, don't hesitate to post them... perhaps I did experience them too, just forgot. – leftaroundabout Apr 01 '15 at 22:44
-
7.8.2 failed with a similar error: `dll-split: internal error: evacuate(static): strange closure type 6744 (GHC version 7.8.2 for arm_unknown_linux)` – jhickner Apr 02 '15 at 17:40
-
Hm... now it somehow rings a bell. Sure this is not actually an out-of-memory error? I seem to recall that gave a cryptic error message in my case as well. If it is memory, first try to compile _singlethreaded_; if that doesn't help, you'll need to attach extra memory, like I did with a swap HDD. – leftaroundabout Apr 02 '15 at 17:43
-
Google searching for the error I see some discussion about the linker used during compilation. Do you remember having to switch to the "gold" linker? I'll try with more swap just in case right now. – jhickner Apr 02 '15 at 17:49
-
I added a 4gb swap file, but watching with top, no swap was actually being used when the error hit. The pi 2 has 1gb ram. – jhickner Apr 02 '15 at 17:55
-
I _had_ to switch to the gold linker for something I did in the past. Let's see... _bingo_, there's an [`mk-fixed-gold-ld.sh`](https://gist.github.com/bgamari/9399430) script in the ghc folder on the pi. Gee, it's not even a year ago and I'd quite forgotten this... – leftaroundabout Apr 02 '15 at 20:42
-
Still no luck. No matter what I do, I get strange closure errors during the final phase, even using that script to switch linkers. I've tried with and without `--enable-unregisterised` and with and without using `integer-simple` instead of gmp. There must be another piece to the puzzle. – jhickner Apr 06 '15 at 17:28
-
Hum. I really don't think I had that problem, no... but wish that I had properly logged what I did in a blog! — Afraid I won't have the time to go through the installation anew right now, and anyway I don't think I'd be able to reproduce your error... but at any rate, [here's](http://dime-chime.com/misc-unrelated-junk/ghc-7.8.2_install.tar.xz) the compiled binary install dir if that helps you for the moment (unpack and link `/usr/local/lib/ghc-7.8.2` to the `install` folder). – leftaroundabout Apr 06 '15 at 21:51
-
Thanks for the binaries! Unfortunately the architecture changed from Arm6 to Arm7 in the new pi, so I can't get them to run. But the good news is I finally got a successful compile. I'd been doing quick or quick-llvm builds for speed, and I finally just tried a regular perf build and everything worked. I wish I'd done that earlier! – jhickner Apr 07 '15 at 21:12
-
Great to hear you've got it to compile! Perhaps you'd like to sum up how you did it in an extra answer, for future reference? Really, my post doesn't answer the question very well... – leftaroundabout Apr 07 '15 at 22:21
-
I will, I'll also post binary distributions for 7.8.4 and Cabal – jhickner Apr 08 '15 at 22:17
-
The debian unstable repository now has ghc-7.8.4 with ghci and TH! [Reddit announcement here](http://www.reddit.com/r/haskell/comments/35bw0b/at_last_debian_unstable_has_working_arm_ghci_and/) and works on my RPi 2 - can't comment on RPi 1. – dbeacham May 09 '15 at 19:13
-
@dbeacham, can you share your steps? I tried installing ghc and cabal-install from debian sid, and my GHCi works, with TH, but I can't get GHC itself to work, and so I can't cabal install any packages. – Doug McClean May 14 '15 at 15:51