Blogging in Lisp


Building the Elm compiler

Submitted by Bill St. Clair on Fri, 07 Sep 2018 07:01:51 GMT

I learned how to build the Elm version 0.19 compiler, in an effort to get it to provide full backtraces of a bug I was tickling. I failed at getting the full backtraces, but I succeeded in adding some debugging output. Anyway, here's how to do it.

First, you need to install Haskell on your machine. You need version 8.2.2 for the Elm 0.19 compiler.

Then do the following:

$ git clone
$ cd compiler
$ cabal sandbox init
$ cabal install

The Elm executable will be in .cabal-sandbox/bin/elm.

The first build takes a while, as it needs to download and build all the dependenies. After that, it gets faster. cabal sandbox delete lets you start over.

After making changes to the source, run cabal install again, and it will compile only the changed files and files that depend on them.

To build the entire Haskell stack, with stack backtraces enabled, from @mfeineis on the Elm Slack channel (I haven't tried this):

Init with stack:

$ stack init --resolver lts-11.20

Add options in elm.cabal:

Executable elm
    if flag(dev)
        ghc-options: -O0 -Wall -Werror -rtsopts -eventlog

Build with stack:

$ stack build --flag elm:dev --profile

Run with RTS options:

$ elm make ./src/Main.elm \
   --output=./dist/app.js +RTS -xc -lu -RTC \

Add comment   Edit post   Add post

Previous Posts:

Server Updated to Ubuntu 16.04LTS
XKCD April Fools 2018
JSMaze Returns, in Elm!
NearlyFreeSpeech.NET Stupid Bureaucratic Rules Compliance Department
Zippy the Pinheads Careen across the Screen
Haskell Joke