Skip to content

Instantly share code, notes, and snippets.

@billstclair
Last active September 29, 2023 06:07
Show Gist options
  • Save billstclair/5800ca0772e3375b0888d66bbc34d627 to your computer and use it in GitHub Desktop.
Save billstclair/5800ca0772e3375b0888d66bbc34d627 to your computer and use it in GitHub Desktop.
How to build the Elm 0.19 executable from Haskell source

Install Haskell version 8.2.2: https://www.haskell.org/platform/prior.html

Elm will NOT build in 8.4.2.

Do once, after installing Haskell:

cabal update

Download the compiler source:

git clone git@github.com:elm/compiler.git

Build:

cd .../compiler
cabal sandbox init
cabal install

After a while, the executable will be in .cabal-sandbox/bin/elm

To remove all the build artifacts for another clean build:

cabal clean
rm -r .cabal-sandbox

Unfortunately, building with profiling as documented below doesn't work, since the distributed Haskell libraries don't have their profiling versions. Some magic with stack, to completely rebuild the Haskell libraries, will probably fix it, but I haven't figured that out yet.

To build with profiling, which enables stack backtraces on errors, add the --enable-profiling flag:

cabal install --enable-profiling

To compile Elm code with full stack backtraces on errors:

.../compiler/.cabal-sandbox/bin/elm +RTS -xc make ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment