[MLton] MLNLFFI doesn't link on MinGW(?)

Matthew Fluet fluet at cs.cornell.edu
Thu Nov 23 12:18:57 PST 2006


>> Obviously libdl is missing (adding -ldl just complains that the library
>> can not be found) so the dl* functions do not exist.  Does anyone know
>> whether libdl is ported to MinGW?  However, what surprises me is that
>> dl* calls are made even when I specify -linkage static.  I tried just
>> replacing the dl* imports (in MLNLFFI source) into dummy (exception
>> raising) functions, but then the executable failed dynamically (with an
>> exception without exception history even with Exn.keepHistory true).
>
> I finally got an exception history and saw that the dl* calls are made
> from CMemAlloc (memalloc-a4-unix.sml), which uses them to get access to
> malloc and free.  The source file also contained replacements that used
> MLton's FFI to (statically) import malloc and free.  Is there some reason
> why malloc and free must/should be obtained through dl* functions?

I simply followed the SML/NJ implementation as closely as I could.  That 
implemenation uses the dl* functions to grab malloc/free, but I probably 
tried out the static versions for exactly the situation you are 
considering: using -linkage static to avoid dl* entirely.

I've never used the Cygwin port extensively or used the MinGW port at all. 
And, the NLFFI stuff has really only been tested on linux; I know others 
have used it on other platforms, and I suspect that all the Unix variants 
work pretty well.  But, they all use the Unix-style dynamic linking 
library.

If you look at the SML/NJ implementation, they have a little more support 
for win32 than what is in the MLton implementation.  You might get some 
inspiration looking there.



More information about the MLton mailing list