FFI & C++ & Cygwin

Simon Peyton-Jones simonpj@microsoft.com
Mon, 13 Jan 2003 09:00:57 -0000


| It is possible to trick ghc into using cygwin's gcc in mingw-mode,
| the following steps works for me to do that:

Interesting.  The only worry is that the run-time system and libraries
are all pre-compiled with the mingw gcc.  So it's not clear to me that
the process Peter outlines will always work.  Or, if it does, why
doesn't it work using the mingw gcc all the time for Haskell files?

Here's a guess: use g++ -mno-cygwin for the C++ files and ordinary ghc
for the Haskell files.  Then, linking with ghc will give linking errors,
as Koen found, only because the g++ files expect to be linked with some
g++ runtime system code. =20

If that is the only problem, it can be solved by doing g++ -v to link,
seeing what extra link libraries are given to ld, and giving those same
libraries to the ghc link step.  Or, dually, see what libraries ghc
passes to ld, and give those to g++.

If this works, and someone will write it up, I'll add it to the users
guide.


Incidentally, on the subject of building GHC to target Cygwin (rather
than Mingw), I'm sure it's possible, because Sigbjorn has done it,
although it's not a route we support, and I just don't know understand
all the differences well enough to know what the problems are.  But, if
someone makes it work (which I'm sure is possible) I'd gladly apply
make-system patches, and add guidance notes to the building guide, in
here:
http://haskell.cs.yale.edu/ghc/docs/latest/html/building/winbuild.html

Simon

| * compile the c++-stuff with g++ -mno-cygwin
| * copy /usr/bin/gcc.exe to c:/ghc/ghc-5.04.2/gcc.exe
| * rename c:/ghc/ghc-5.04.2/gcc-lib to something else
|    (ghc feeds a -B option to gcc, which we cannot(?) override)
| * compile with "ghc -optl -mno-cygwin -lstdc++"
|    (add -optc -mno-cygwin if -fvia-C is used)
|=20
| (i.e. we would like to use /usr/bin/gcc -mno-cygwin as the linker)
|=20
| I think it should be possible to use -pgml instead of replacing
| the binary, but that didn't work for me..
|=20
| > However, I have tried to recompile the C++ libraries using
| > the Mingwin C++ compiler but it starts throwing pages of
| > error messages at me.
|=20
| However, the method above doesn't help if you really need cygwin
| for your c++-library, which you seem to do?
|=20
|=20
| /Peter
|=20
| _______________________________________________
| Glasgow-haskell-users mailing list
| Glasgow-haskell-users@haskell.org
| http://www.haskell.org/mailman/listinfo/glasgow-haskell-users