hsc2hs and #include

Simon Marlow marlowsd at gmail.com
Mon Aug 8 17:41:07 CEST 2011


On 07/08/2011 02:18, Evan Laforge wrote:
>> On Sat, Jul 30, 2011 at 9:25 PM, Ian Lynagh<igloo at earth.li>  wrote:
>>> But I also think we may as well just remove most of these conditionals.
>>> The GHC<  4.09 tests can surely be removed, and likewise the GHC<  6.3
>>> tests. Personally I'd remove the GHC<  6.10 test too, but perhaps that
>>> will be more contentious.
>>>
>>> Any opinions?
>>
>> That was going to be my first suggestion.  Maybe the only reason these
>> are needed is that the hsc2hs binary itself isn't versioned, otherwise
>> you simply run the one that came with your ghc, and if it's for ghc-4
>> then it should be producing code ghc-4 understands.
>>
>> So the problem would be with code that knows to specifically invoke an
>> older ghc, but still picks up the hsc2hs symlink which points to a
>> newer one.  I don't know of any framework for compiling with multiple
>> versions, but I'd think it should be smart enough to find the
>> appropriate ghc lib directory and run the various utilities out of
>> there.
>
> So what's the consensus here?  Does dropping all backwards
> compatibility from hsc2hs make sense?  Presumably it's there for a
> reason so I may be missing something.
>
> In any case, though I like the idea of dropping all the #ifdef, I
> think the specific instance for omitting #includes is incorrect, and
> I'm not sure why other people aren't seeing that.. I don't understand
> what's going on with __GLASGOW_HASKELL__.  Maybe something funny with
> my install?
>
> Should I try to send a patch for the remove all backward compatibility
> thing?  Or one for the specific #include problem I've been having?

I've lost track of all the details here.  But perhaps there's some 
historical cruft lying around because hsc2hs used to call GHC to compile 
its C files, and hence __GLASGOW_HASKELL__ would have been defined.

In fact, the GHC build system passes 
--cflag=-D__GLASGOW_HASKELL__=<version> to hsc2hs when it runs it. 
Maybe Cabal should do the same.  Does it?

The problem with making the INCLUDE pragma conditional is that you can 
only do conditional pragmas using CPP, which requires the CPP extension, 
and moreover older versions of GHC did not support conditional 
compilation of pragmas (I forget which version added this, maybe 6.12).

Cheers,
	Simon



More information about the Glasgow-haskell-users mailing list