From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id 977E37FA5F for ; Thu, 19 Jan 2017 14:11:06 +0100 (CET) Authentication-Results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=info@gerd-stolpmann.de; spf=None smtp.mailfrom=info@gerd-stolpmann.de; spf=None smtp.helo=postmaster@mout.kundenserver.de Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of info@gerd-stolpmann.de) identity=pra; client-ip=212.227.126.135; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="info@gerd-stolpmann.de"; x-sender="info@gerd-stolpmann.de"; x-conformance=sidf_compatible Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of info@gerd-stolpmann.de) identity=mailfrom; client-ip=212.227.126.135; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="info@gerd-stolpmann.de"; x-sender="info@gerd-stolpmann.de"; x-conformance=sidf_compatible Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@mout.kundenserver.de) identity=helo; client-ip=212.227.126.135; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="info@gerd-stolpmann.de"; x-sender="postmaster@mout.kundenserver.de"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A0BkAQCNuoBYf4d+49ReGgEBAQECAQEBA?= =?us-ascii?q?QgBAQEBgz8BAQEBAX+BCYNRighykRCMd4g1ggwshXYCgXk/GAECAQEBAQEBARM?= =?us-ascii?q?BAQkLCwobMkIBBAeEGwEBAQMBIwQuJAULCxIGKgICSQ4GEwmIcgwBCa9hgWs6i?= =?us-ascii?q?j0BAQEBAQEEAQEBAQEBEw+FWoVfhFWCQDqCXgWIdweHcYpVgVEChQ6HAoZLh2K?= =?us-ascii?q?GQ5JwDxCBYR4UOoQDgjVyAYUqgRuDHgEBAQ?= X-IPAS-Result: =?us-ascii?q?A0BkAQCNuoBYf4d+49ReGgEBAQECAQEBAQgBAQEBgz8BAQE?= =?us-ascii?q?BAX+BCYNRighykRCMd4g1ggwshXYCgXk/GAECAQEBAQEBARMBAQkLCwobMkIBB?= =?us-ascii?q?AeEGwEBAQMBIwQuJAULCxIGKgICSQ4GEwmIcgwBCa9hgWs6ij0BAQEBAQEEAQE?= =?us-ascii?q?BAQEBEw+FWoVfhFWCQDqCXgWIdweHcYpVgVEChQ6HAoZLh2KGQ5JwDxCBYR4UO?= =?us-ascii?q?oQDgjVyAYUqgRuDHgEBAQ?= X-IronPort-AV: E=Sophos;i="5.33,254,1477954800"; d="asc'?scan'208,217";a="256247795" Received: from mout.kundenserver.de ([212.227.126.135]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Jan 2017 14:10:40 +0100 Received: from office1.lan.sumadev.de ([85.183.69.161]) by mrelayeu.kundenserver.de (mreue005 [212.227.15.167]) with ESMTPSA (Nemesis) id 0M9cAV-1ch5KC1dRH-00CzVT; Thu, 19 Jan 2017 14:10:39 +0100 Received: from e130 (e130.fritz.box [192.168.5.100]) by office1.lan.sumadev.de (Postfix) with ESMTPSA id C4911DC05D; Thu, 19 Jan 2017 14:10:38 +0100 (CET) Message-ID: <1484831431.14465.110.camel@gerd-stolpmann.de> From: Gerd Stolpmann To: Christoph =?ISO-8859-1?Q?H=F6ger?= Cc: caml-list@inria.fr Date: Thu, 19 Jan 2017 14:10:31 +0100 In-Reply-To: References: <1484827880.14465.105.camel@gerd-stolpmann.de> Content-Type: multipart/signed; micalg="pgp-sha256"; protocol="application/pgp-signature"; boundary="=-wEZjvzQn/2k2rufKboHA" X-Mailer: Evolution 3.18.5.2-0ubuntu3 Mime-Version: 1.0 X-Provags-ID: V03:K0:uBV+zFkaIZEUEONoaqLAKZ8CmakK0MPGaZFdlAQUA5mqt68xrQh iCC6xhx+ewvy7mCv70Yr40YAHU2DiS7AJRlsCv5G7XspkHy8AzDTCJvuSBhPuMPWnm0rrTS gziIuCXfkfLe8juFZ/Tqv2hRYK4FGt9N+BHiBudOM7awpgDlulemZA5b3SCrPmxdyrxGeD4 Pw7QAZLVuNwPEm3z/bD3w== X-UI-Out-Filterresults: notjunk:1;V01:K0:cG3d0DqBX8E=:UgS+hX5Wjq4IGT7fwTluVW V9b5Bq+mpF5h5Lnev0OfA7N0yFObZrHoNyzKlMVJUKaGbV8697VjBHN87ltL6o/wIQrwdim0z lH52VGXXWeMgcYYlZ2IhV4Acy5DY3tKZvB2YtHF8YF95brxa5Fw44APuDkHBoQ7qTjm7ws5B0 Szr9vg/XlHLTt6HR1HCBw80r1UOWCTLhOM4rtepTfWym8faUUkcml2nRsaH0EaxTVT/eUH+gR 2ZRJdT/izbw15Og9FqVhKPiFdblOYnSissVBwqgKnp94FoX2Jn9FsOc82lkSFCKgsXWzcDuEW fSd7+27ac57trebiT+S0ulBM7VBZMrBUg0mHP8UBsT7ohuJ8JSbVOsipmdo8jqJfQYLuVLJ/3 eVkwkhEm6O3KuvQzTxbqJU0cydRjKPzEOHr3afUd3DnTqXEJ1Ilku2j5tYT3wtI3W9JPj8hbC BbpfapO5x+ig85dbvb6k/vZqlUNjiEJ4tm98TI4TnG6/bJtkf//CYxSxVXrvgCs3Fk2s+YQDx Wfkxsp9xAy6fhGW3ReHHKxnkZcrvNFLYF7p2NmVMvt2g3lEoQiwsc/6t5Pa9eBCwBEqbEAszg tKU0TUYHaQ2L1JgGUkQz6v8QBnlgeR0/Ghn049zB9FLQWwIL5luq2CldFh4ZQ4vVVkUcMs+yN Dj2ORVx+z3WwevHLF4PJJwHWkW/Xq17TMpRnl9zymGCcF5yD+ScJIkfSBdMvBEbO8GQo= Subject: Re: [Caml-list] Manually linking generated native code --=-wEZjvzQn/2k2rufKboHA Content-Type: multipart/alternative; boundary="=-lztDPg0shMbKgFYEtVpO" --=-lztDPg0shMbKgFYEtVpO Content-Type: text/plain; charset="ISO-8859-15" Content-Transfer-Encoding: quoted-printable Am Donnerstag, den 19.01.2017, 13:24 +0100 schrieb Christoph H=F6ger: > Could you elaborate a little bit, how that should work? AFAIK, e.g. > the curry helpers are generated in Cmmgen, which is absolutely > sensible, since they certainly do not depend on the machine > architecture, right? So when and where does the linker use this > generation? What I know is that the linker gathers up the required functions from the cmx and cmxa files. E.g. that could be a helper that returns the closure for a 5-argument function that is called with only 3 arguments. Such helpers are only needed once for the whole program. > > To motivate my question a little bit, I was wondering whether I could l= oad two different OCaml executables inside the same process by using LLVM's= runtime linker. In principle, when I load them, they should be able to coo= perate across the shared heap, but otherwise live in total isolation (in pa= rticular their garbage collectors should not interfere). Well, you could try whether the object file emitted by "ocamlopt -output-obj" works. This object contains everything but the main program and the additional libraries needed (like libasmrun). Gerd > On Thu, Jan 19, 2017 at 1:11 PM, Gerd Stolpmann > > wrote: > > Am Donnerstag, den 19.01.2017, 10:44 +0100 schrieb Christoph H=F6ger: > > > Dear all,> > >=20 > > > consider a simple test program:> > >=20 > > > =A0 let _ =3D Printf.printf "Hello world!\n"> > >=20 > > > I can generate the relevant assembly just fine, e.g.:> > >=20 > > > ocamlopt -dstartup -S test.ml> > > gcc -c a.out.startup.s -c> > >=20 > > > But I cannot link it:> > >=20 > > > gcc a.out.startup.o -L$(ocamlc -where) -lasmrun_shared > > > .... > > > a.out.startup.o(.data+0x6e8): error: undefined reference to 'camlStd_= exit__frametable' > > > collect2: Fehler: ld gab 1 als Ende-Status zur=FCck > > > distcc[9960] ERROR: compile (null) on localhost failed> > >=20 > > > It seems that the whole Pervasives is missing (which is kind of expec= ted). > > >=20 > > > How do I link it, manually? Where are the relevant object files? > > > > There's stdlib.a in the OCaml library directory. > > > > This is not the only problem with your approach. The OCaml linker g= enerates a number of functions that are global to the whole OCaml program (= in particular currying helpers). These are first known at link time and thu= s generated that late. AFAIK you cannot generate these functions outside th= e linker step.=A0 > > > > The only official way how to turn OCaml code into a linkable object= is described here:=A0http://caml.inria.fr/pub/docs/manual-ocaml/intfc.html= #s%3Aembedded-code > > > > Gerd > > > > > > > > thanks,> > >=20 > > > Christoph> > >=20 > > >=20 > > --=20 > > ------------------------------> > ------------------------------ > > Gerd Stolpmann, Darmstadt, Germany gerd@gerd-stolpmann.de > >=20 > > My OCaml site: http://www.camlcity.org > >=20 > > Contact details: http://www.camlcity.org/contact.html > >=20 > > Company homepage: http://www.gerd-stolpmann.de > >=20 > > ------------------------------> > ------------------------------ > >=20 > >=20 >=20 --=20 ------------------------------------------------------------ Gerd Stolpmann, Darmstadt, Germany gerd@gerd-stolpmann.de My OCaml site: http://www.camlcity.org Contact details: http://www.camlcity.org/contact.html Company homepage: http://www.gerd-stolpmann.de ------------------------------------------------------------ --=-lztDPg0shMbKgFYEtVpO Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: quoted-printable
Am Donnerstag, den 19.01.2017, 13:24 +0100 sc= hrieb Christoph H=C3=B6ger:
Could you elaborate a little bit, how that should work? AFAIK, e.g. t= he curry helpers are generated in Cmmgen, which is absolutely sensible, sin= ce they certainly do not depend on the machine architecture, right? So when= and where does the linker use this generation?

What I know is that the linker gathers up the required= functions from the cmx and cmxa files. E.g. that could be a helper that re= turns the closure for a 5-argument function that is called with only 3 argu= ments. Such helpers are only needed once for the whole program.
<= br>

To motiv= ate my question a little bit, I was wondering whether I could load two diff= erent OCaml executables inside the same process by using LLVM's runtime lin= ker. In principle, when I load them, they should be able to cooperate acros= s the shared heap, but otherwise live in total isolation (in particular the= ir garbage collectors should not interfere).
Well, you could try whether the object file emitted by "ocamlop= t -output-obj" works. This object contains everything but the main program = and the additional libraries needed (like libasmrun).

<= div>Gerd


On Thu, Jan 19, 2017 at 1:11 PM, Gerd= Stolpmann <info@gerd-stolpmann.de> wrote:
Am Donnerstag, den 19.01.2017, = 10:44 +0100 schrieb Christoph H=C3=B6ger:
Dear all,

consider a simple test prog= ram:

  let _ =3D Printf.printf "Hello world!\n"

I = can generate the relevant assembly just fine, e.g.:

ocamlopt -d= startup -S test.ml
gcc -c a.out.startup.s -c

But I cannot link it:
gcc a.out.startup.o -L$(ocamlc -where) -lasmrun_shared
.= ...
a.out.startup.o(.data+0x6e8): error: undefined reference to 'camlStd= _exit__frametable'
collect2: Fehler: ld gab 1 als Ende-Status zur=C3=BCc= k
distcc[9960] ERROR: compile (null) on localhost failed

It seems that the whole Pervasives is missing (which is kind of expected= ).

How do I link it, manually? Where are the relevant ob= ject files?

There's = stdlib.a in the OCaml library directory.

This is n= ot the only problem with your approach. The OCaml linker generates a number= of functions that are global to the whole OCaml program (in particular cur= rying helpers). These are first known at link time and thus generated that = late. AFAIK you cannot generate these functions outside the linker step.&nb= sp;

The only official way how to turn OCaml code i= nto a linkable object is described here: ht= tp://caml.inria.fr/pub/docs/manual-ocaml/intfc.html#s%3Aembedded-= code

Gerd


thanks,

Ch= ristoph

<= div>
--=20
------------------------------------------------------------
Gerd Stolpmann, Darmstadt, Germany    gerd@gerd-stolpmann.de
My OCaml site:          http://www.camlcity.org
Contact details:        http://www.camlcity.org/contact.html
Company homepage:       http://www.gerd-stolpmann.de
------------------------------------------------------------



--=20
------------------------------------------------------------
Gerd Stolpmann, Darmstadt, Germany    gerd@gerd-stolpmann.de
My OCaml site:          http://www.camlcity.org
Contact details:        http://www.camlcity.org/contact.html
Company homepage:       http://www.gerd-stolpmann.de
------------------------------------------------------------

= --=-lztDPg0shMbKgFYEtVpO-- --=-wEZjvzQn/2k2rufKboHA Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAABCAAGBQJYgLrHAAoJEAaM4b9ZLB5T0OgH/jFitkL/ycr+0F5uIELminiq SZpTtZcFebU0NWsqdey42b40rwffQi1BP2BfrJCEhlfYiheyNzdKiHoPjcfQjBc9 i265fsUVcWK49DWz/hxaX1Vgu07r9wxxwuqbV+GPrZz2yeqiAya+OeqM90lUzUdC me+1UOZ4ttl7AcMbvwqEUvMONibFQP0PF52wlCvduBCDyPJGnHGZCau/qH2TkLeq lHzHRAwa3Znay7OprQpj2i7sYoHiXtwWEv/VBFRn5Tht/w2Ko80CpnrD14v2/3LZ EPUcEUGqYftD8vNBpDex0TwJYkcXvxKaZ57ibopo84NbmpvvHCSoq8090HdpIMQ= =9NZ3 -----END PGP SIGNATURE----- --=-wEZjvzQn/2k2rufKboHA--