On Windows, GHC is distributed with gcc and g++, e.g. under ghc-7.6.3\mingw\bin
. From the download page, it is also noted under the windows binary download that the build for Windows "also includes support for compiling C++ files."
I could imagine that distributing these compilers is just for convenience, since Windows doesn't come with any. I could also imagine it is necessary for using the FFI, but I'm not 100% sure. For instance, although GHC will compile .c and .cpp files using it's own gcc/g++ compilers, GHC also provides options to choose whichever compiler and linker you want. And indeed, you can specify your own gcc/g++ and it seems to work. You can even cut GHC out of the loop a little further by compiling the .c/.cpp files in advance, and only invoking GHC to compile the Haskell code and link it all using -pgml
(although the overall effect is the same as using -pgmc
and -pgml
).
Now that seems to work, but does it rely on pure luck that you specify -pgml
and -pgmc
to be a version of gcc that is compatible with what GHC has in mind? In other words, when I use the FFI, am I really only supposed to compile and link everything with GHC invocations?