Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A script to install stack on Raspbian
#!/bin/sh
set +ex
# A script to install stack on Raspbian
# Use stack installer script to install stack
curl -sSL https://get.haskellstack.org/ | sh
# Use apt-get to install llvm
sudo apt-get install llvm-3.7
# Write a wrapper for ghc to be called with, parameterizing GHC with ARM settings
cat > ~/.stack/programs/arm-linux/ghc-8.0.1/bin/ghc-arm-wrapper.sh <<EOF
#!/bin/sh
ghc-8.0.1 -opta-march=armv7-a $@
EOF
# Setup symlinks for stack / ghc
ln -s /usr/bin/opt-3.7 /usr/bin/opt
ln -s /usr/bin/llc-3.7 /usr/bin/llc
rm ~/.stack/programs/arm-linux/ghc-8.0.1/bin/ghc
ln ~/.stack/programs/arm-linux/ghc-8.0.1/bin/ghc-arm-wrapper.sh ~/.stack/programs/arm-linux/ghc-8.0.1/bin/ghc
@alogic0

This comment has been minimized.

Copy link

@alogic0 alogic0 commented Feb 6, 2017

Is there enough memory for compiling on Raspberry Pi?

@ppelleti

This comment has been minimized.

Copy link

@ppelleti ppelleti commented Feb 8, 2017

@alogic0, I have a 512MB Model B, and I can compile on it just fine, although it's slow, and I had to increase the swap space. Just edit the file /etc/dphys-swapfile and change CONF_SWAPSIZE=100 to something much larger, like CONF_SWAPSIZE=2048.

@ghost

This comment has been minimized.

Copy link

@ghost ghost commented Aug 31, 2017

On Raspbian Stretch (released in August 2017), I didn't have to do such a complex setup. This is all I had to do:

  1. Download second latest Stack release for Linux-Arm from official repository on GitHub.
  2. Extract it; run ./stack upgrade.
  3. sudo apt-get install llvm-3.7
@ghost

This comment has been minimized.

Copy link

@ghost ghost commented Aug 31, 2017

What does -opta-march=armv7-a do? Why was/is it neccessary? Should I also add sucha wrapper for GHC although it works fine for me?

@Spyder19

This comment has been minimized.

Copy link

@Spyder19 Spyder19 commented Feb 5, 2021

Sadly

curl -sSL https://get.haskellstack.org/ | sh

No longer works, as it points to a 64 bit version, which won't run even on the 64 bit beta version of raspbian which only has a 32 bit userland

There's got to be an easy way to do this, but I can't seem to find it

@roberocity

This comment has been minimized.

Copy link

@roberocity roberocity commented Feb 14, 2021

@Spyder19

I have a Raspberry Pi 4 and have been using it for Python and Go development for a while. I've been tinkering around with Haskell and Rust as well. Here's what I did to get Haskell on my RPi.

Details and instructions are here: https://www.haskell.org/downloads/, but sudo apt install haskell-platform installs cabal, ghc, and ghci. It does not appear to install stack. (I'm very new to Haskell so I can't say too much about cabal or stack).

~ ghc --version
The Glorious Glasgow Haskell Compilation System, version 8.4.4
~ ghc --version
The Glorious Glasgow Haskell Compilation System, version 8.4.4

I did find this package to install stack: sudo apt install haskell-stack.

Here's a bit of what is installed.

stack
Version 1.7.1 arm
...
Warning: this is an unsupported build that may use different versions of
dependencies and GHC than the officially released binaries, and therefore may
not behave identically.  If you encounter problems, please try the latest
official build by running 'stack upgrade --force-download'.

a quick list of Haskell packages available using sudo apt list *haskell* shows a few other options.

In some very quick tests (and remember, I'm a noob with Haskell, Stack, and Cabal) I had more success with Cabal than Stack, but I could very easily be doing something wrong.

@Spyder19

This comment has been minimized.

Copy link

@Spyder19 Spyder19 commented Feb 14, 2021

@roberocity

Yea, I already tried that, as well as the upgrade. I still need something newer. That's what's giving me fits

Yer not doing anything wrong (I think), we just need a better installer or upgrader. 8.6.5 is the best I can do so far, and I need at least 8.10. It kinda looks like it's possible with that command, but, something is missing. "Bindist OS key has not yet been added for linux armv7"

And google is not being very helpful

I know it's been done, I just can't figure out how

@analyticd

This comment has been minimized.

Copy link

@analyticd analyticd commented Jun 22, 2021

This, https://www.haskell.org/ghc/blog/20200515-ghc-on-arm.html, worked quick and easy for me on a RPi 4 w 8gb RAM and Raspbian

@roberocity

This comment has been minimized.

Copy link

@roberocity roberocity commented Jun 22, 2021

Thanks @analyticd I took a look. That specifically didn't work, but I made some changes that did work.

I'm running 64-bit Debian - arm64. I had to update the download package and install a few additional packages.

sudo apt install llvm-9 libncurses5 libnuma-dev 

wget http://downloads.haskell.org/~ghc/8.10.1/ghc-8.10.1-aarch64-deb9-linux.tar.xz
tar -xf ghc-8.10.1-aarch64-deb9-linux.tar.gz
cd ghc-8.10.1
./configure
sudo make install

libnurcses5 was discovered as a need during the make install command and libnuma-dev when trying to compile the Hello World application.

Now I just have ghc and ghci no cabal or stack by my very limited work in Haskell doesn't really need those. Maybe one day I'll do something complex enough in Haskell to need additional tooling.

@analyticd

This comment has been minimized.

Copy link

@analyticd analyticd commented Jun 26, 2021

I emailed the maintainer of GHC's ARM build (and that wiki page above) and he was kind enough to provide an updated URL for a pre-built cabal-install whose URL is referenced from here:

https://gitlab.haskell.org/ghc/homepage/-/commit/5076cb3b1672a99b07d891649114c434ff070475

To get the binary:
wget https://home.smart-cactus.org/~ben/ghc/cabal-install-3.4.0.0-rc4-armv7l-deb10.tar.xz

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment