hugs ffi (nov 2002 on windows )

Alastair Reid alastair@reid-consulting-uk.ltd.uk
Sun, 29 Dec 2002 21:23:58 +0000


> On windows, hugs +G (or ffihugs +G, not sure) links and compiles
> using microsoft tools ("cl"). It used to just generate the stubs,
> and leave it to you to do the rest. This way is smoother, but does
> depend on owning visual studio. 

I changed it because it let me centralize the unpleasant task of
configuring and building ffi code instead of many individual library
maintainers having to figure it out and maintain it themselves.

> This is a non-issue for me, since I do have visual studio, but how
> would you proceed using the borland tools or cygwin or some other
> free tools? Do you have to build hugs using those tools to get it to
> work?

That would be the simplest option.  I believe it works with cygwin.
[It used to work with Borland too but I think it's about 5 years since
it was tested last.]

If we wanted to let users override the choice of compiler, there's a
bunch of options:

1) Provide a flag which means 'generate the code but don't compile and
   link it'.  This would make Hugs behave the way it did this summer.

2) Provide a mechanism (command line option or environment variable) to
   override the C compiler invocation string at runtime.
   The configuration string is in config.h[.in] and looks like this:

    /* C compiler invocation use to build a dynamically loadable library.
     * Typical value: "gcc -shared"
     * Must evaluate to a literal C string.
     */
    #define MKDLL_CMD "gcc -shared"

3) Some kind of dynamic test determines which compiler is used.  
   I'm not at all keen on this - just bug reports and bugs waiting to
   happen.

Both options are pretty easy.  I think the second option would fit
best with some kind of GHC/NHC-like package mechanism (which I think
I'd like to add to Hugs).

> Or are [borland tools or cygwin] just not supported?

I'd love to add support for other compilers to Hugs (both on Windows
and on other platforms).

If you or anyone else is in a position to test new configure options,
start by tweaking hugs98/src/config.h to try out new flags.  Once you
find something that works, mail it to me and I'll make the appropriate
changes to hugs98/src/configure.in.

--
Alastair Reid                 alastair@reid-consulting-uk.ltd.uk  
Reid Consulting (UK) Limited  http://www.reid-consulting-uk.ltd.uk/alastair/