[Haskell-cafe] Haskell (GHC 7) on ARM

Ben Gamari bgamari.foss at gmail.com
Sun Jun 10 15:06:57 CEST 2012

Joshua Poehls <joshua at poehls.me> writes:

> Hello Ben,

Sorry for the latency. I'm currently on vacation in Germany so I haven't
had terribly consistent Internet access.

I've Cc'd haskell-cafe@ as I've been meaning to document my experiences
anyways and your email seems like a good excuse to do this.

> I just got a Raspberry Pi and I'm interested in running Haskell on it. So
> far I'm running Arch Linux ARM and I noticed there is is a GHC package
> available, but it is version 6.12.3.
> Doing research online I saw that you did some work on adding GHCi support
> for ARM in GHC 7.4. I was wondering if you had anything to share related to
> running GHC/GHCI 7.4 on ARM, specifically Arch Linux ARM.

Indeed my ARM linker patch was merged into GHC 7.4.2. This means that
ARM is now a fully supported target platform for GHC, complete with GHCi
support (which is pretty much necessary for many ubuiquitous packages).

My ARM development environment consists of a PandaBoard (and before this
a BeagleBoard) running Linaro's Ubuntu distribution. For this reason,
I'm afraid I won't be of terribly much help in the case of Arch. That
being said, GHC has a wonderful build system which has never given me
trouble (except in cases of my own stupidity). Just installing the
required development packages and following the build instructions on
Wiki[1] is generally quite sufficient. I've also have some notes of my
own[2] where I've collected my own experiences.

As you likely know, GHC doesn't have a native ARM code generator of its
own, instead relying on LLVM for low-level code generation. For this
reason, you'll first need to have a working LLVM build. I have found
that the ARM backend in the 3.0 release is a bit buggy and therefore
generally pull directly from git (HEAD on my development box is
currently sitting at 7750ff1e3cbb which seems to be stable). That being
said, I haven't done much work in this space recently and it's quite
likely that the 3.1 release is better in this respect.

Compiling LLVM is one case where I have found the limited memory of my
BeagleBoard (which is I believe is similar to the Raspberry Pi) to be
quite troublesome. There are cases during linking where over a gigabyte
of memory is necessary. At this stage the machine can sit for hours
thrashing against its poor SD card making little progress. For this
reason, I would strongly recommend that you cross-compile LLVM. The
process is pretty straightforward and I have collected some notes on the

The size of GHC means that in principle one would prefer to
cross-compile. Unfortunately, support[4] for this is very new (and
perhaps not even working/complete[5]?) so we have to make due with what
we have.  The build process itself is quite simple. You will want to be
very careful to ensure that the ghc/libraries/ trees are sitting on the
same branch as your ghc/ tree (with the ghc/sync-all
script). Inconsistency here can lead to very ambiguous build
failures. Otherwise, the build is nearly foolproof (insofar as this word
can describe any build process). The build takes the better part of a
day on my dual-core Pandaboard. I can't recall what the maximum memory
consumption was but I think it might fit
in 512MB.

Lastly, if I recall correctly, you will find that you'll need to first
build GHC 7.0 bootstrapped from 6.12 before you can build 7.4 (which
requires a fairly new stage 0 GHC).

Let the list know if you encounter any issues. I'll try to dust off my
own development environment once I get back to the states next week to
ensure that everything still works. I've been meaning to setup the
PandaBoard as a build slave as Karel's has been failing for some time
now (perhaps you could look into this, Karel?). Moreover, perhaps I can
find a way to produce redistributable binaries to help others get


- Ben

[1] http://hackage.haskell.org/trac/ghc/wiki/Building
[2] http://bgamari.github.com/posts/ghc-llvm-arm.html
[3] http://bgamari.github.com/posts/cross-compiling_llvm.html
[4] http://hackage.haskell.org/trac/ghc/wiki/CrossCompilation
[5] http://www.haskell.org/pipermail/cvs-ghc/2012-February/070791.html

More information about the Haskell-Cafe mailing list