[darcs-users] C code

Donald Bruce Stewart dons at cse.unsw.edu.au
Wed May 12 12:45:54 UTC 2004

> > > Can ghc compile haskell to portable C? If yes, I think it would
> > > be a very good idea to provide a tarball containing the C sources
> > > of the latest darcs version on the webpage. This way people with
> > > unusual architectures can install darcs without having to install
> > > ghc.
> AFAIK ghc can compile via C, so one could try to keep the intermediate 
> C files:
> 	ghc -c -fvia-C -keep-hc-files file.lhs
> I'm, however, not sure whether how the C code looks like and whether 
> it is portable...
> You can get further info from the ghc manual:
> http://www.haskell.org/ghc/docs/latest/html/users_guide/separate-compilation.html#KEEPING-INTERMEDIATES

Hmm. Short answer: no.

Long answer: it's possible, but still no.

As long as you already have GHC installed with its libraries, then you
could compile with -fvia-C --keep-hc-files, getting the same .hc files
that are used to bootstrap GHC, and its utility programs. You then
compile these .hc files via gcc. But you still need GHC installed,
because you have to link in the runtime system, *and* any libraries that
darcs users.

So you can't compile to ghc-independent C: you still need GHC rts and

However, It would seem possible to distribute the .hc files from darcs,
along with the rts, and .hc versions of only those libraries need by
darcs. You'd be essentially distributing the haskell runtime system,
and any needed libs. GHC can't do that automatically.  Nice project for

However, for non-portable, ghc-independent C, try this:

;) Don

More information about the darcs-users mailing list