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

Morten Olsen Lysgaard <[email protected]> Mon, 14 Dec 2020 08:34:50 +0100
Newsgroups gmane.comp.lang.ml.mlton.devel
Message-ID <CAOujwNEUMOCYEgus1Joxx1WGHWbP-K8yWTjNaaFRRN6Va6QT1w@mail.gmail.com>
--===============2820296758358156407==
Content-Type: multipart/alternative; boundary="0000000000000215e705b667aed3"

--0000000000000215e705b667aed3
Content-Type: text/plain; charset="UTF-8"

Ah, see i have not studied MLton well enough.

Thank you both for explaining the dylib feature for me. It is exactly what
I wanted.

Regards Morten

On Sun, Dec 13, 2020, 17:27 Matthew Fluet <[email protected]> wrote:

> 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
>
>
> _______________________________________________
> MLton-devel mailing list
> [email protected]; [email protected]
> https://lists.sourceforge.net/lists/listinfo/mlton-devel
>

--0000000000000215e705b667aed3
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"auto">Ah, see i have not studied MLton well enough.<div dir=3D"=
auto"><br><div dir=3D"auto">Thank you both for explaining the dylib feature=
 for me. It is exactly what I wanted.</div><div dir=3D"auto"><br></div><div=
 dir=3D"auto">Regards Morten</div></div></div><br><div class=3D"gmail_quote=
"><div dir=3D"ltr" class=3D"gmail_attr">On Sun, Dec 13, 2020, 17:27 Matthew=
 Fluet &lt;<a href=3D"mailto:[email protected]">[email protected]=
om</a>&gt; wrote:<br></div><blockquote class=3D"gmail_quote" style=3D"margi=
n:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Yes, you can use =
the `-format` compile option to compile to various<br>
kinds of libraries.=C2=A0 The SML &quot;program&quot; should include one or=
 more<br>
`_export` expressions evaluated at the top-level.=C2=A0 To use the<br>
resulting library, the C code should call `libname_open()` before<br>
calling any of the `_export`ed functions (this will startup the SML<br>
runtime system and evaluate the SML program to initialize state and<br>
register the `_export`ed functions).=C2=A0 After `libname_open()` returns,<=
br>
you should be able to call any of the `_export`ed functions.=C2=A0 To<br>
properly shutdown, `libname_close()` should be called.=C2=A0 The name of<br=
>
the library is controlled by the `-libname` compile option, but<br>
defaults to the name of the SML program being compiled.<br>
<br>
On Sun, Dec 13, 2020 at 10:03 AM Phil Clayton via MLton-devel<br>
&lt;<a href=3D"mailto:[email protected]" target=3D"_blank" =
rel=3D"noreferrer">[email protected]</a>&gt; wrote:<br>
&gt;<br>
&gt; I&#39;m sure others can provide more details but did you see<br>
&gt; <a href=3D"http://www.mlton.org/LibrarySupport" rel=3D"noreferrer nore=
ferrer" target=3D"_blank">http://www.mlton.org/LibrarySupport</a><br>
&gt; &quot;MLton supports both linking to _and creating system-level librar=
ies_...&quot;<br>
&gt;<br>
&gt; Phil<br>
&gt;<br>
&gt; On 13/12/20 06:37, Morten Olsen Lysgaard wrote:<br>
&gt; &gt; As far as I understand it is not possible to produce static or dy=
namic<br>
&gt; &gt; libraries from MLton today, only executables.<br>
&gt; &gt;<br>
&gt; &gt; I would like to be able to produce these and then be able to link=
 them<br>
&gt; &gt; with other code and use the exposed functions.<br>
&gt; &gt;<br>
&gt; &gt; I have found this archived mail of someone trying to create a pat=
ch to<br>
&gt; &gt; do this back in 2008, but I guess it stalled.<br>
&gt; &gt;<br>
&gt; &gt; Let&#39;s say one in the first case limits the api possible to ex=
pose from<br>
&gt; &gt; a library to function who takes a tuple of C primitve types. This=
<br>
&gt; &gt; should be easily mappable one-to-one from C to SML.<br>
&gt; &gt;<br>
&gt; &gt; I have some questions:<br>
&gt; &gt;<br>
&gt; &gt; 1) Would anyone else be interested in such a feature?<br>
&gt; &gt; 2) What requirements would the MLton runtime put on the consumers=
 of<br>
&gt; &gt; such libraries?<br>
&gt; &gt; 3) Would someone with deeper insight into MLton, be willing to he=
lp on<br>
&gt; &gt; the high level design and guidance of how to achieve such a featu=
re?<br>
&gt; &gt;<br>
&gt; &gt; Have a nice day - Morten<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt; _______________________________________________<br>
&gt; &gt; MLton-devel mailing list<br>
&gt; &gt; <a href=3D"mailto:[email protected]" target=3D"_b=
lank" rel=3D"noreferrer">[email protected]</a>; <a href=3D"=
mailto:[email protected]" target=3D"_blank" rel=3D"noreferrer">mlton-de=
[email protected]</a><br>
&gt; &gt; <a href=3D"https://lists.sourceforge.net/lists/listinfo/mlton-dev=
el" rel=3D"noreferrer noreferrer" target=3D"_blank">https://lists.sourcefor=
ge.net/lists/listinfo/mlton-devel</a><br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; _______________________________________________<br>
&gt; MLton-devel mailing list<br>
&gt; <a href=3D"mailto:[email protected]" target=3D"_blank"=
 rel=3D"noreferrer">[email protected]</a>; <a href=3D"mailt=
o:[email protected]" target=3D"_blank" rel=3D"noreferrer">mlton-devel@m=
lton.org</a><br>
&gt; <a href=3D"https://lists.sourceforge.net/lists/listinfo/mlton-devel" r=
el=3D"noreferrer noreferrer" target=3D"_blank">https://lists.sourceforge.ne=
t/lists/listinfo/mlton-devel</a><br>
<br>
<br>
_______________________________________________<br>
MLton-devel mailing list<br>
<a href=3D"mailto:[email protected]" target=3D"_blank" rel=
=3D"noreferrer">[email protected]</a>; <a href=3D"mailto:ml=
[email protected]" target=3D"_blank" rel=3D"noreferrer">mlton-devel@mlton=
.org</a><br>
<a href=3D"https://lists.sourceforge.net/lists/listinfo/mlton-devel" rel=3D=
"noreferrer noreferrer" target=3D"_blank">https://lists.sourceforge.net/lis=
ts/listinfo/mlton-devel</a><br>
</blockquote></div>

--0000000000000215e705b667aed3--


--===============2820296758358156407==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline


--===============2820296758358156407==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
MLton-devel mailing list
[email protected]; [email protected]
https://lists.sourceforge.net/lists/listinfo/mlton-devel

--===============2820296758358156407==--