Lisplog

Blogging in Lisp

Search

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. www.haskell.org/platform/prior.html

Then do the following:

$ git clone git@github.com:elm/compiler.git
$ 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 \
   2>eventlog_readable.log

Add comment   Edit post   Add post

Previous Posts:

elm-websocket-client
Server Updated to Ubuntu 16.04LTS
XKCD April Fools 2018
JSMaze Returns, in Elm!
elm-svg-button
NearlyFreeSpeech.NET Stupid Bureaucratic Rules Compliance Department
Zippy the Pinheads Careen across the Screen
elm-oauth-middleware
Haskell Joke
Twitterrific