Re: [MLton] Compiling static or dynamic libraries from MLton

Matthew Fluet <[email protected]> Sun, 13 Dec 2020 11:21:24 -0500
Newsgroups gmane.comp.lang.ml.mlton.devel
Message-ID <CAMrhFL42Ca+Xentgdn1+Fab8nQEEdT=kY48pYwU5+w6w+XFF8A@mail.gmail.com>
Yes, you can use the `-format` compile option to compile to various
kinds of libraries.  The SML "program" should include one or more
`_export` expressions evaluated at the top-level.  To use the
resulting library, the C code should call `libname_open()` before
calling any of the `_export`ed functions (this will startup the SML
runtime system and evaluate the SML program to initialize state and
register the `_export`ed functions).  After `libname_open()` returns,
you should be able to call any of the `_export`ed functions.  To
properly shutdown, `libname_close()` should be called.  The name of
the library is controlled by the `-libname` compile option, but
defaults to the name of the SML program being compiled.

On Sun, Dec 13, 2020 at 10:03 AM Phil Clayton via MLton-devel
<[email protected]> wrote:
>
> I'm sure others can provide more details but did you see
> http://www.mlton.org/LibrarySupport
> "MLton supports both linking to _and creating system-level libraries_..."
>
> Phil
>
> On 13/12/20 06:37, Morten Olsen Lysgaard wrote:
> > As far as I understand it is not possible to produce static or dynamic
> > libraries from MLton today, only executables.
> >
> > I would like to be able to produce these and then be able to link them
> > with other code and use the exposed functions.
> >
> > I have found this archived mail of someone trying to create a patch to
> > do this back in 2008, but I guess it stalled.
> >
> > Let's say one in the first case limits the api possible to expose from
> > a library to function who takes a tuple of C primitve types. This
> > should be easily mappable one-to-one from C to SML.
> >
> > I have some questions:
> >
> > 1) Would anyone else be interested in such a feature?
> > 2) What requirements would the MLton runtime put on the consumers of
> > such libraries?
> > 3) Would someone with deeper insight into MLton, be willing to help on
> > the high level design and guidance of how to achieve such a feature?
> >
> > Have a nice day - Morten
> >
> >
> >
> >
> > _______________________________________________
> > MLton-devel mailing list
> > [email protected]; [email protected]
> > https://lists.sourceforge.net/lists/listinfo/mlton-devel
>
>
>
>
> _______________________________________________
> MLton-devel mailing list
> [email protected]; [email protected]
> https://lists.sourceforge.net/lists/listinfo/mlton-devel