0

I've been developing a side project (a small web app). I'm developing on a Macbook M1 Pro, however, I need to compile it to test against a linux/amd64 environment. I'm trying to use docker for that. I know it is emulated via VM in this case and performance will suffer, but it's not a big deal for me since it's just a toy project.

I'm using stack as build tool and GHC 9.6.

The stack build command errors, hinting that it could be out of memory.

root@c5f07dbd83dc:/opt/app# stack build --fast -j 4 --allow-different-user
...
Error: [S-7282]
       Stack failed to execute the build plan.

       While executing the build plan, Stack encountered the error:

       [S-7011]
       While building package rinha-0.1.0.0 (scroll up to its section to see the error) using:
       /root/.stack/setup-exe-cache/x86_64-linux/Cabal-simple_6HauvNHV_3.10.3.0_ghc-9.6.5 --verbose=1 --builddir=.stack-work/dist/x86_64-linux/ghc-9.6.5 build lib:rinha exe:rinha-exe --ghc-options " -fdiagnostics-color=always"
       Process exited with code: ExitFailure (-9) (THIS MAY INDICATE OUT OF MEMORY)

Initially, I thought it really could be out of memory as I'm using colima and had default configuration. Then I started colima giving it 4 CPUs and 16GiB memory:

$ colima start --cpu 4 --memory 16 -a x86_64 -t vz --vz-rosetta

Tried again, but no success!

The project starts building, stays like that for almost 1h, and then this error happens.

I wouldn't like to spin up a server just to build a project that I will be running on my laptop, but I see myself without alternatives and I'm finding it weird since I never had such a problem with other languages and it's the first time I see it while doing some Haskell.

Any tips?

3
  • Can you verify whether it is indeed running out of memory? If so, you may be able to improve things by reducing the number of children (perhaps stack supports -j1 or similar?) and/or by asking GHC to run with a smaller heap (with +RTS -A4G or similar, though I don't know whether the usual GHC installations have RTS options enabled). Commented Jul 12, 2024 at 18:24
  • I know this is a horrible "use a different tool" style comment, but I have had an easy time cross compiling using nix in the past. It might require more effort than solving the problem by plugging away at the current solution path, just a thought. Commented Jul 13, 2024 at 8:42
  • Thanks for the tip @DanielWagner. I set the flags, but no luck. So I decided to remove one level of abstraction to give it a try with lima instead of colima and it worked! I ran limactl start template://docker --arch x86_64 and did a docker-compose build and all went well. Commented Jul 14, 2024 at 21:04

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.