Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
ghc build directions

directions to do a release quality build of GHC == 8.0.* with the Make based build system with all the docs

context: this is a draft for planned edits / cleanups to the current mac build directions

getting setup

  1. have apple command line tools installed, as well as mactex, and your favorite OS X package manager (which for the rest of these directions we assume is brew)

  2. since we assume we're using brew, install it!

  3. go to the dejavu fonts site and download the most recent tar.bz2 of the ttf files, like this one (note: yes the download site for the fonts is source forge). there should be a ttf folder full of ttf files, highlight all of them and open them (eg cmd+o), the fontbook app should launch and you should just have to click OK to add them via ~ 6 dialogues

  4. install a ghc version 7.8 or 7.10 via whatever approach you personally prefer

  5. brew install autoconf automake; brew tap homebrew/dupes ; brew tap homebrew/versions ; brew install llvm37

  6. make sure that you have a cabal-instal 1.24 or newer (so that your cabal will play nice with ghc 8 once you've got it)

    a) if you dont have it yet, do the following

    b) git clone; cd cabal ; cabal update ; cabal install ./Cabal ./cabal-install

    c) now cabal --version should report that its some 1.24

  7. check that everything mentioned so far is visible in your path! eg recent MacTex installs to /Library/TeX/texbin/

  8. now we also want to be able to build docs, and the easiest approach is to do brew install python3 ; pip3 install sphinx after which sphinx-build should be in your path!

  9. with your fancy new cabal 1.24, also cabal install happy alex hscolour to make sure you have recent versions of those!

  10. if you want to use GCC instead of CLANG to build ghc, brew install gcc5 or brew install gcc6, which will respectively add gcc-5 or gcc-6 to your path

  11. ok, lets get started! Either you have source tree tarball from a release candidate OR you're building from a fresh git checkout

  12. git clone --recursive git:// ghc-8.0-my-ghc-tree -b ghc-8.0

  13. cd ghc-8.0-my-ghc-tree ; cp mk/ mk/

  14. add to the top of mk/ the following (make sure there is not trailing white space on these lines! Make will run wrong if any line has trailing white space)

# Full build with max optimisation and everything enabled (very slow build)
BuildFlavour = perf


# Uncomment the following to force `integer-gmp` to use the in-tree GMP 5.0.4
# (other sometimes useful configure-options: `--with-gmp-{includes,libraries}`)
libraries/integer-gmp_CONFIGURE_OPTS += --configure-option=--with-intree-gmp

# Don't strip debug and other unneeded symbols from libraries and executables.
  1. type perl boot

  2. decide if you want to use clang or gcc-5 or gcc-6, and do export CC=gcc-5 or eg (set -xl CC gcc-5) equivalent in your shell! theres valid Reasons to choose either apple clang or gcc (or the explicit path instead of just the name)

  3. set -xl MACOSX_DEPLOYMENT_TARGET 10.7 or the bash equivalent of export MACOSX_DEPLOYMENT_TARGET=10.7

a) if you're on OSX 10.11, invoke configure as ./configure -with-gcc=$pathToMyCC --with-nm=$(xcrun --find nm-classic)

b) if you're not on 10.11, but earlier, ./configure -with-gcc=$pathToMyCC suffices

  1. type ulimit -n 10000 ; make -j4 where instead of 4 choose whatever number of cores you want. The ulimit part is to circumvent a lazy io issue that impacts how haddock processes large projects at the time of this writing (April 2016, haskell/haddock#495)

  2. once the build ends, you can do make binary-dist to get a binary dist tar.xz

Copy link

cartazio commented Apr 28, 2016

Need to add cabal install hscolour to the directions

Copy link

cartazio commented Apr 28, 2016

Also need to remove the duplicates conditional or clarify it in the make paste step

Copy link

thomie commented Apr 29, 2016

Seems very complete to me. BuildFlavour = perf isn't necessary (as those settings are the default), and you should perhaps add HSCOLOUR_SRCS=YES, as per

Copy link

cartazio commented May 11, 2016

@thomie : hyperlinked-sources seems to overrule hscolour

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