[MLton] Shared libraries for MLton

Matthew Fluet fluet@cs.cornell.edu
Mon, 25 Jul 2005 11:13:11 -0400 (EDT)


>   - mlton/main/main.fun
>      o Added new compiler option -shared-library
>   - mlton/control/control-flags.sig/sml
>      o added Control.sharedLibrary, which defaults to false

Fair enough, though I don't see that they are used at all within the 
compiler proper.

>   - basis-library/mlton/mlton.sml
>      o If the Control.sharedLibrary is true, then
>        the program ends with a call to returnToC otherwise
>        the program exits
>      o NOTE:
>          I couldn't figure how to import Control,
>          so right now it says true in stead of !Control.sharedLibrary

You want to use a _build_const primitive.  You ought to be able to pattern 
match the treatment of "MLton_Profile_isOn".

>   - include/c-main.h
>      o Added init_function, which is called when a shared library is
>        opened. It takes care of initializing the GC collector and
>        global variables.
>      o NOTE: main() isn't called, when the executable is opened
>              as shared library

Makes sense.

>      o NOTE: The first garbage collection provokes a crash, the
>              error is probably to be found here.

That is unfortunate.