Cross-compiling Template Haskell via -fexternal-interpreter and IPC

Alberto Valverde alberto at
Wed Jul 6 13:00:22 UTC 2016


I'm trying to put together a GHC 8.0.1 cross-compiler with Template Haskell
support. Initially to target Windows (32bits) from a Linux host but a
similar procedure should enable to target other platforms too. I'd like to
contribute the patches back so I'm asking for advice on how to implement it
in order to increase the chances of them being accepted.

I've managed to get a working stage 1 cross-compiler with some patches
which correctly builds all stage1 libs and GHC + stage 2 compiler and
ghc-iserv.exe. However, compiling TH by using wine and ghc-iserver.exe
fails because the file descriptor ids that GHC passes as arguments to "wine
ghc-iserv.exe" don't make sense in the emulated windows world.

I've hacked around this to test the feasibility of the approach by using
stdin/stdout instead of creating new pipes and, surprisingly, managed to
cross-compile a simple Template Haskell program.

I'm considering using a socket for communicating between both processes as
a more permanent solution but this would incur in a dependency on the
"network" package. Would this be acceptable?

Named pipes have also crossed my mind but I'm not sure how well they're
supported by wine.

Thanks for your attention.

Code is in the "cross-mingw-hacks" branches of these repositories and is
based on the ghc-8.0.1-release tag:

A Docker image script here that builds it is here:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the ghc-devs mailing list