MSYS2 package for GHC 7.10.1

Hi everyone. After finally putting some uninterruped effort into it, I managed to create (hopefully) working prototypes of two GHC-related packages for MSYS2, namely ghc[1] and cabal-install[2]. I've prepared recipes (PKGBUILDs) for building from source, but 64-bit binaries[5][6] are also provided for those who'd like to test my build without building it themselves. With this post, I'd like to start some work towards the following goals (I hope we can get some Windows discussion going again): - verify that the build is reproducible (see below for instructions) - make tests pass - fix known issues (see below for list) - discover and fix unknown issues - review and upstream as many patches as possible - make it easier for people on Windows to start hacking on GHC I'll be glad to read any responses, notes, results, hints, comments and/or criticisms. Please note that I'm writing this after being submerged in the matter for some time, so don't be surprised to see any glaring omissions or obvious mistakes. Known issues ============ Configure has a problem with docbook - This mean Haddock is not built. It's probably some silliness on the part of MSYS2's docbook. Integer-gmp object file has a reference to __mingw_vsnprintf - Compiling seems to work fine, presumably because the final link command includes -lmingwex, but `runhaskell Setup.lhs` in the text package source tree gave me an undefined reference error, causing inability to load integer-gmp module. I don't know where to start fixing this, as I have not yet reached the depth of understanding of GHC source needed for that. Wildly untested - I didn't try building with LLVM and the testsuite is currently failing to start, giving some weird errors. Trying cross compiling or compiling a cross compiler didn't even cross my mind (har har). Patches ======= A lot of the patches deal with the directory structure -- I tried to mirror the common FHS layout as closely as possible while still retaining the advantages of relocatability. I also removed the bundled toolchain and perl, in favor of packages included with MSYS2. I assume these changes are somewhat controversial for upstreaming, but it'd be nice to see the official bindists to adopt this layout. There are several patches that I think are more of straight-forward fixes rather than design changes, namely numbers 0007, 0010, 0014 and 0015. Build instructions ================== General build instructions[3] are available at our wiki. For convenience, I've compiled a sequence of commands that should get you the ghc and cabal-install packages, given that you start with an up-to-date installation of MSYS2 and a working GHC in PATH. Refer to our guide[4] for correct way of getting/upgrading your MSYS2. ## start MSYS2 shell pacman --needed -S base-devel mingw-w64-x86_64-toolchain mingw-w64-i686-toolchain git clone https://github.com/elieux/mingw-packages cd mingw-packages git checkout ghc pushd mingw-w64-ghc makepkg-mingw -sLf pacman -U mingw-w64-*-ghc-*-any.pkg.tar.xz ## remove old GHC from PATH popd pushd mingw-w64-cabal-install makepkg-mingw -sLf pacman -U mingw-w64-*-cabal-install-*-any.pkg.tar.xz popd If you prefer to build only for one architecture, export a variable named MINGW_INSTALLS with a value of "mingw32" or "mingw64" before building. == [1] https://github.com/elieux/mingw-packages/tree/ghc/mingw-w64-ghc [2] https://github.com/elieux/mingw-packages/tree/ghc/mingw-w64-cabal-install [3] http://sourceforge.net/p/msys2/wiki/Contributing%20to%20MSYS2/ [4] http://sourceforge.net/p/msys2/wiki/MSYS2%20installation/ [5] https://dl.dropboxusercontent.com/u/59899181/mingw-w64-x86_64-cabal-install-... [6] https://dl.dropboxusercontent.com/u/59899181/mingw-w64-x86_64-ghc-7.10.1-1-a... -- David Macek

With the helpful pointers from ezyang on IRC, I pushed this a bit forward. I converted most of the patches into more reasonable commits including short descriptions and created a git branch for it. See https://github.com/ghc/ghc/compare/ghc-7.10.1-release...elieux:msys2-pkgbuil.... As mentioned previously, the changes should be uncontroversial except for two big changes: removing bundled mingw, perl and touchy and changing the directory layout. While the directory layout change is mostly self-contained (barring any tools hardcoding ..\lib), the bundled dependency removal will required major changes to the build process. My proposals follow. For hacking on GHC ================== 1. Get MSYS2, update and install dependencies (including the bootstrapping ghc that would come as a MSYS2 package) 2. Get a GHC repository ready 3. Hack, hack, hack 4. Build and test as usual 5. GOTO 3 Alternatively, this could be replaced with a makepkg-based flow: 1. Get MSYS2, update and install dependencies (including the bootstrapping ghc that would come as a MSYS2 package) 2. Get a mingw-w64-ghc-git PKGBUILD 3. $ makepkg-mingw --nobuild # clone the repositories 4. Go to src/ghc and hack, hack, hack 5. $ makepkg-mingw --noextract --noprepare --noarchive # build and test 6. GOTO 4 For binary release ================== Phase 1: pacman package. This can be done in coordination with the MSYS2 maintainers, or a separate GHC-owned pacman repository can be created. 1. Get MSYS2, update and install dependencies (including the bootstrapping ghc that would come as a MSYS2 package) 2. Update the mingw-w64-ghc PKGBUILD to point to the new source release 3. $ makepkg-mingw # build a package 4. Upload the package to a pacman repository Phase 2: stand-alone bindist 1. Download the package and its dependencies 2. Extract them into a temporary directory 3. Create a tarball or an installer from that 4. Upload to GHC servers This is essentially what the new Git for Windows does (and what some other projects that use MSYS2 as their build environment do). -- David Macek

Wow, this sounds great!
Just to clarify - this would still be a mingw-w64 build
and not require the msys2 DLLs, correct?
Thanks,
Yitz
On May 21, 2015 23:53, "David Macek"
With the helpful pointers from ezyang on IRC, I pushed this a bit forward.
I converted most of the patches into more reasonable commits including short descriptions and created a git branch for it. See < https://github.com/ghc/ghc/compare/ghc-7.10.1-release...elieux:msys2-pkgbuil...
.
As mentioned previously, the changes should be uncontroversial except for two big changes: removing bundled mingw, perl and touchy and changing the directory layout. While the directory layout change is mostly self-contained (barring any tools hardcoding ..\lib), the bundled dependency removal will required major changes to the build process. My proposals follow.
For hacking on GHC ==================
1. Get MSYS2, update and install dependencies (including the bootstrapping ghc that would come as a MSYS2 package) 2. Get a GHC repository ready 3. Hack, hack, hack 4. Build and test as usual 5. GOTO 3
Alternatively, this could be replaced with a makepkg-based flow:
1. Get MSYS2, update and install dependencies (including the bootstrapping ghc that would come as a MSYS2 package) 2. Get a mingw-w64-ghc-git PKGBUILD 3. $ makepkg-mingw --nobuild # clone the repositories 4. Go to src/ghc and hack, hack, hack 5. $ makepkg-mingw --noextract --noprepare --noarchive # build and test 6. GOTO 4
For binary release ==================
Phase 1: pacman package. This can be done in coordination with the MSYS2 maintainers, or a separate GHC-owned pacman repository can be created.
1. Get MSYS2, update and install dependencies (including the bootstrapping ghc that would come as a MSYS2 package) 2. Update the mingw-w64-ghc PKGBUILD to point to the new source release 3. $ makepkg-mingw # build a package 4. Upload the package to a pacman repository
Phase 2: stand-alone bindist
1. Download the package and its dependencies 2. Extract them into a temporary directory 3. Create a tarball or an installer from that 4. Upload to GHC servers
This is essentially what the new Git for Windows does (and what some other projects that use MSYS2 as their build environment do).
-- David Macek
_______________________________________________ ghc-devs mailing list ghc-devs@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs

Hi David,
You may want to work closely with the minghc project which seems to be the
best Haskell Windows installer at the moment: https://github.com/fpco/minghc
Thanks,
Greg Weber
On Fri, May 22, 2015 at 9:53 AM, David Macek
On 22. 5. 2015 15:58, Yitzchak Gale wrote:
Wow, this sounds great!
Just to clarify - this would still be a mingw-w64 build and not require the msys2 DLLs, correct?
Correct.
-- David Macek
_______________________________________________ ghc-devs mailing list ghc-devs@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs

On 24. 5. 2015 8:43, someone wrote:
Hi,
Hi. First off, let me note that I proposed multiple things and each affects this in a different way (and some not at all).
I saw your email at ghc-devs (I couldnt reply to your email because I wasnt subscribed at the time, hence this email) regarding msys2, and was wondering how it would affect the msys instructions at :
Note that these steps results in a setup roughly equivalent to the one MinGHC provides.
Currently I use these instructions to setup ghc in msys2, but I suspect these would change following your modifications.
If the mingw-unbundling proposal goes through and the MSYS2 package gets sanctioned, the new steps would be: 1. Install MSYS2 and update using pacman 2. Install ghc and cabal-install packages using pacman For usage inside a POSIX shell, launch mingw64_shell.bat. For usage outside of MSYS2, add `$msysroot/mingw64/bin` to PATH. -- David Macek
participants (3)
-
David Macek
-
Greg Weber
-
Yitzchak Gale