Skip to content

Instantly share code, notes, and snippets.

@cartazio
Last active July 5, 2019 04:26
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cartazio/32038db09222a2aac767cb5c03b406c6 to your computer and use it in GitHub Desktop.
Save cartazio/32038db09222a2aac767cb5c03b406c6 to your computer and use it in GitHub Desktop.
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 https://github.com/haskell/cabal.git; 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://git.haskell.org/ghc.git ghc-8.0-my-ghc-tree -b ghc-8.0

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

  14. add to the top of mk/build.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
EXTRA_HADDOCK_OPTS=--hyperlinked-source
HADDOCK_DOCS       = YES
BUILD_SPHINX_HTML  = YES
BUILD_SPHINX_PDF   = YES


BUILD_DPH=NO

# 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.
STRIP_CMD = :
  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

@cartazio
Copy link
Author

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

@thomie
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 https://ghc.haskell.org/trac/ghc/wiki/MakingReleases#Makingthebinarybuilds.

@cartazio
Copy link
Author

@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