[jhc] including C source files?

David Roundy roundyd at physics.oregonstate.edu
Fri Sep 18 10:27:12 EDT 2009


On Fri, Sep 18, 2009 at 09:24:34AM -0400, Mark Wotton wrote:
> On 18/09/2009, at 7:31 AM, David Roundy wrote:
>> Hi all,
>>
>> I was wondering what we are supposed to do to include C source files,
>> accessed via the FFI? Including them on the command line (as I was
>> tempted to do) just results in a complaint that they aren't haskell.
>> Do I need to compile it separately with gcc and then pass the object
>> file on the command line? I guess I could just experiment, but I'm
>> feeling lazy, so I'm asking instead...
>
> I was doing that for Hubris. Worked ok.
> Linking JHC-created objects manually isn't as complicated as linking  
> GHC's objects.

Hmmm.  That'll work fine for executables (although it still needs to
be implemented), but doesn't seem like it'll work at all for
jhc-written haskell libraries, at least, it won't work if they're to
be cross-compile-friendly.  For that, it'd be better to include the C
code itself in the .hl file, so that it can be built alongside the
haskell code with whatever compiler is being used...

Of course, I'm not sure how cross-compile-friendly jhc libraries can
be built, unless they themselves need to do nothing platform-specific.
It seems like a tough problem, but one that would be worth solving.
e.g. preprocessing is done at compile time, so we can't use
preprocessor directives to build code based on the target platform.
Is there a plan for handling this sort of case? e.g. a very simple
library that reexports some platform-specific API in a cross-platform
way, e.g. handling emailing via MAPI on win32, but via sendmail on
unixy systems.

David


More information about the jhc mailing list