{"id":232,"date":"2016-09-02T02:40:25","date_gmt":"2016-09-02T01:40:25","guid":{"rendered":"https:\/\/blogs.ncl.ac.uk\/andreymokhov\/?p=232"},"modified":"2018-11-01T19:39:15","modified_gmt":"2018-11-01T19:39:15","slug":"building-ghc-on-windows","status":"publish","type":"post","link":"https:\/\/blogs.ncl.ac.uk\/andreymokhov\/building-ghc-on-windows\/","title":{"rendered":"Build GHC on Windows using Hadrian and Stack"},"content":{"rendered":"<p>To build GHC on Windows you usually <a href=\"https:\/\/ghc.haskell.org\/trac\/ghc\/wiki\/Building\/Preparation\/Windows\">need to jump through a lot of hoops<\/a>, which may be <a href=\"https:\/\/mail.haskell.org\/pipermail\/ghc-devs\/2016-June\/012340.html\">confusing even for experienced GHC developers<\/a>.<\/p>\n<p><a href=\"https:\/\/github.com\/snowleopard\/hadrian\">Hadrian<\/a> to the rescue!<\/p>\n<p>Hadrian, a new build system for GHC that I&#8217;ve been developing, is written in Haskell and can therefore be built and run via <a href=\"https:\/\/www.haskellstack.org\/\">Stack<\/a> that can install appropriate bootstrapping GHC and MSYS2 environment in an automated and robust way. This was first <a href=\"http:\/\/neilmitchell.blogspot.co.uk\/2016\/03\/compiling-ghc-on-windows.html\">pointed out by Neil Mitchell<\/a>, and I&#8217;ve recently simplified build instructions even further. The latest version of the instructions is maintained <a href=\"https:\/\/github.com\/snowleopard\/hadrian\/blob\/master\/doc\/windows.md\">here<\/a>.<\/p>\n<p><!--more--><\/p>\n<p>\u265f Get GHC sources:<code><br \/>\ngit clone --recursive git:\/\/git.haskell.org\/ghc.git<br \/>\ncd ghc<br \/>\n<\/code><\/p>\n<p>\u265e\u00a0Download and install the bootstrapping GHC and MSYS2:<code><br \/>\ncd hadrian<br \/>\nstack setup<br \/>\n<\/code><\/p>\n<p>\u265c Install utilities required during the GHC build process:<code><br \/>\nstack exec -- pacman -S autoconf automake-wrapper make patch tar --noconfirm<br \/>\n<\/code><\/p>\n<p>\u265b Build Hadrian and dependencies (including GHC dependencies Alex and Happy):<code><br \/>\nstack build<br \/>\n<\/code><\/p>\n<p>\u265a Build GHC:<code><br \/>\nstack exec hadrian -- --directory \"..\" -j --flavour=quickest --configure<br \/>\n<\/code><\/p>\n<p>\u265d Test GHC:<code><br \/>\ncd ..<br \/>\n_build\\stage1\\bin\\ghc -e 1+2<br \/>\n<\/code><\/p>\n<p>This takes about 20 minutes and builds GHC without optimisations. If you need an optimised GHC, drop the <code>--flavour=quickest<\/code> flag from the build command line (this will slow down the build to about an hour).<\/p>\n<p>The above instructions work on a clean machine with Git and Stack installed (tested with default installation settings), which you can get from <a href=\"https:\/\/git-scm.com\/download\/win\">here<\/a> and <a href=\"https:\/\/www.stackage.org\/stack\/windows-x86_64-installer\">here<\/a>, respectively.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>To build GHC on Windows you usually need to jump through a lot of hoops, which may be confusing even for experienced GHC developers. Hadrian to the rescue! Hadrian, a new build system for GHC that I&#8217;ve been developing, is written in Haskell and can therefore be built and run via Stack that can install &hellip; <a href=\"https:\/\/blogs.ncl.ac.uk\/andreymokhov\/building-ghc-on-windows\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Build GHC on Windows using Hadrian and Stack<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1174,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[14,4],"class_list":["post-232","post","type-post","status-publish","format-standard","hentry","category-coding","tag-build","tag-haskell"],"_links":{"self":[{"href":"https:\/\/blogs.ncl.ac.uk\/andreymokhov\/wp-json\/wp\/v2\/posts\/232","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.ncl.ac.uk\/andreymokhov\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.ncl.ac.uk\/andreymokhov\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.ncl.ac.uk\/andreymokhov\/wp-json\/wp\/v2\/users\/1174"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.ncl.ac.uk\/andreymokhov\/wp-json\/wp\/v2\/comments?post=232"}],"version-history":[{"count":15,"href":"https:\/\/blogs.ncl.ac.uk\/andreymokhov\/wp-json\/wp\/v2\/posts\/232\/revisions"}],"predecessor-version":[{"id":827,"href":"https:\/\/blogs.ncl.ac.uk\/andreymokhov\/wp-json\/wp\/v2\/posts\/232\/revisions\/827"}],"wp:attachment":[{"href":"https:\/\/blogs.ncl.ac.uk\/andreymokhov\/wp-json\/wp\/v2\/media?parent=232"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.ncl.ac.uk\/andreymokhov\/wp-json\/wp\/v2\/categories?post=232"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.ncl.ac.uk\/andreymokhov\/wp-json\/wp\/v2\/tags?post=232"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}