Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save i-am-the-slime/5c23ede12bb56984c93c53592e5c8204 to your computer and use it in GitHub Desktop.
Save i-am-the-slime/5c23ede12bb56984c93c53592e5c8204 to your computer and use it in GitHub Desktop.
How to build an Apple Silicon version of the PureScript compiler

How to build an Apple Silicon version of the PureScript compiler

Updates:

2022-07-01

Add prebuilt binary for 0.15.4

2022-06-24

I changed ghc to be installed with ghcup and ghc version to 9.2.3 to match PS 0.15.3 added the RELEASE flag.

Install ghc

brew install ghcup
ghcup install ghc 9.2.3

Install llvm

brew install llvm

Get opt and llc on your $PATH

sudo ln -s /opt/homebrew/Cellar/llvm/13.0.0_1/bin/opt ~/.local/bin/opt
sudo ln -s /opt/homebrew/Cellar/llvm/13.0.0_1/bin/llc ~/.local/bin/llc

Clone purescript

git clone https://github.com/purescript/purescript.git

Changes to stack.yaml

system-ghc: true
compiler: ghc-9.2.3
compiler-check: match-exact

Install the compiler!

stack install --flag=purescript:RELEASE

Tweak PureScript extension settings in VSCode

Add NPM path: Disable

This file has been truncated, but you can view the full file.
View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

@sigma-andex
Copy link

Additional info, check that the ghc compiler version matches. (e.g. at the time of my writing it is 8.10.7)

@YanikCeulemans
Copy link

I had to build with stack redirecting output to /dev/null like so: stack install > /dev/null. I was running into segmentation faults without the redirect.

environment:

  • M1 Pro
  • zsh
  • brew installed haskell-stack

@purefunctor
Copy link

Tiny bump on this, specifying stack install --flag=purescript:RELEASE makes the build "closer" (it really just changes purs --version) to the actual release builds and also stops segfaults with stack install on zsh, for some reason...

@purefunctor
Copy link

Bump again, cabal builds also work on this. I usually run cabal install --install-method=copy --overwrite-policy=always -frelease and it'll live under ~/.cabal/bin/purs

@i-am-the-slime
Copy link
Author

@purefunctor

I get this:

Failed to build language-javascript-0.7.0.0. The failure occurred during the
configure step.
Build log (
/Users/mark/.cabal/logs/ghc-9.2.3/lngg-jvscrpt-0.7.0.0-93afcc6e.log ):
Configuring library for language-javascript-0.7.0.0..
Warning: Packages using 'cabal-version: >= 1.10' and before 'cabal-version:
3.4' must specify the 'default-language' field for each component (e.g.
Haskell98 or Haskell2010). If a component uses different languages in
different modules then list the other ones in the 'other-languages' field.
cabal-3.6.2.0: The program 'happy' version >=1.19 is required but the version
of /Users/mark/.cabal/store/ghc-9.2.3/hppy-1.20.0-000be3eb/bin/happy could not
be determined.

cabal: Failed to build language-javascript-0.7.0.0 (which is required by
exe:purs from purescript-0.15.4). See the build log above for details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment