hsc2hs problem

Duncan Coutts duncan.coutts at worc.ox.ac.uk
Fri Dec 5 15:14:20 EST 2008

On Fri, 2008-12-05 at 10:05 -0600, Creighton Hogg wrote:
> On Fri, Dec 5, 2008 at 9:49 AM, Duncan Coutts
> <duncan.coutts at worc.ox.ac.uk> wrote:
> > On Thu, 2008-12-04 at 13:06 -0600, Creighton Hogg wrote:
> >> Hello,
> >> Since hsc2hs is distributed with GHC, I thought this might be a decent
> >> place to ask.  I tried to run hsc2hs on a file that I know worked with
> >> my 6.8.3 installation, but now I'm getting the error
> >> /usr/local/lib/ghc-6.10.1/hsc2hs-0.67/template-hsc.h:4:19: error:
> >> HsFFI.h: No such file or directory
> >
> > Unfortunately the hsc2hs instance is specific to one ghc version. You've
> > presumably got ghc-6.8.3 and ghc-6.10.1 installed. You're building stuff
> > using ghc-6.8.3 but the hsc2hs from ghc-6.10.1 and so hsc2hs is getting
> > passed the wrong include paths. If you use the hsc2hs from the ghc-6.8.3
> > installation then it should work.
> >
> > We should look into making it more independent of the ghc version.
> Funny you'd mention this!  I was worried that this was the problem, so
> I cleaned out all my ghc instances & then reinstalled ghc 6.10.1 from
> the binaries.  I still had the same problem after that.  Perhaps
> something was still lingering?  I'm not sure what, though.

So it turns out that it does indeed fail by default. The reason nobody
else noticed is because they do not run it directly. They run it via
Cabal and it passes a load of extra flags, all the include dirs for all
the packages a package depends on. This of course includes the base and
rts packages. It's the rts package that has the HsFFI.h file.

So the problem is that hsc2hs by default uses gcc as it's C compiler but
the default template #includes HsFFI.h. These two things are in
conflict. I wonder why the default template does include HsFFI.h since
it appears that nothing in the template uses anything from it.

The hsc2hs tool is supposed to be independent of the haskell
implementation. It is supposed to work with hugs and nhc too. Hugs comes
with hsc2hs too and it's template-hsc.h also uses HsFFI.h. It's not
clear to me how it finds the hugs/include/HsFFI.h file by default.


More information about the Glasgow-haskell-users mailing list