Stack on Linux aarch64

Hello! I am trying to compile an existing Haskell project on my Apple Silicon machine. The project is dependent on various Linux tools and components and will not compile in macOS, so I have been using Docker. However, the project also uses stack as its build system, and per this it seems that stack is unsupported on aarch64. I have had success with the ghcup version of stack on macOS, but it fails to install inside of my Ubuntu Docker container. I have also been unable to install stack via cabal install stack. Is there any way to use stack on a Linux aarch64 system?

1 Like

I don’t know if it is relevant, and I hope I’m not off-topic, but I tried to cross-compile for a Raspberry Pi a while ago (it has this architecture), and I remember finding myself in murky waters. Here is the link of the thread if you’re interested: Using stack on Raspberry Pi - #8 by cloudyhug

At that time I had to compile on another machine as stack was not working on the M1 architecture. Now it does when installing through ghcup, which is great, but I don’t know about the status of cross-compiling for Linux aarch64.

Good luck!

What exactly went wrong with this approach?

1 Like

The command cabal install stack seemed to install stack-0.0.0. It did install some binary, but whenever I ran any stack command (including stack --version, stack build, etc) it would just print “The Haskell Tool Stack” and immediately quit without doing anything.

Try being more specific, cabal install stack-2.7.3?

It fails with the following output:

Resolving dependencies...
cabal: Could not resolve dependencies:
[__0] trying: stack-2.7.3 (user goal)
[__1] trying: memory-0.16.0 (dependency of stack)
[__2] next goal: base (dependency of stack)
[__2] rejecting: base-4.16.0.0/installed-4.16.0.0 (conflict: memory =>
base<4.16)
[__2] skipping: base-4.16.0.0 (has the same characteristics that caused the
previous version to fail: excluded by constraint '<4.16' from 'memory')
[__2] rejecting: base-4.15.1.0, base-4.15.0.0, base-4.14.3.0, base-4.14.2.0,
base-4.14.1.0, base-4.14.0.0, base-4.13.0.0, base-4.12.0.0, base-4.11.1.0,
base-4.11.0.0, base-4.10.1.0, base-4.10.0.0, base-4.9.1.0, base-4.9.0.0,
base-4.8.2.0, base-4.8.1.0, base-4.8.0.0, base-4.7.0.2, base-4.7.0.1,
base-4.7.0.0, base-4.6.0.1, base-4.6.0.0, base-4.5.1.0, base-4.5.0.0,
base-4.4.1.0, base-4.4.0.0, base-4.3.1.0, base-4.3.0.0, base-4.2.0.2,
base-4.2.0.1, base-4.2.0.0, base-4.1.0.0, base-4.0.0.0, base-3.0.3.2,
base-3.0.3.1 (constraint from non-upgradeable package requires installed
instance)
[__2] fail (backjumping, conflict set: base, memory, stack)
After searching the rest of the dependency tree exhaustively, these were the
goals I've had most trouble fulfilling: base, stack, memory

A similar error arises with cabal install stack-2.7.1 which seems to be the most recent release with Linux/aarch64 binaries on github

ghcup install ghc 9.0.2, then cabal install -w ghc-9.0.2 stack-2.7.3?
(Edited: no need to --set)

Ah, right, stack-2.7.3 cannot be built with GHC 9.0 (current stack fails to build with Cabal-3.4 · Issue #5670 · commercialhaskell/stack · GitHub). Then please try

ghcup install ghc 8.10.7
cabal install -w ghc-8.10.7 stack-2.7.3

This is gonna take ages, unfortunately.

2 Likes

Why is stack still lagging behind?

This worked! Thank you so much :smiley:

The docker image takes about 30 minutes to build and is huge (5GB or so). But stack runs correctly. I will put it on the dockerhub and include a link in this thread once it’s pushed.

Hopefully stack is updated to fully support linux on aarch64 and this is no longer needed!

ghcup has unofficial binaries for stack on aarch64, so all you need to do is ghcup install stack really.