From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sympa.inria.fr (Postfix) with ESMTPS id 8C58D7FA5F for ; Thu, 19 Jan 2017 13:24:08 +0100 (CET) Authentication-Results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=christoph.hoeger@celeraone.com; spf=Pass smtp.mailfrom=christoph.hoeger@celeraone.com; spf=None smtp.helo=postmaster@mail-it0-f47.google.com Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of christoph.hoeger@celeraone.com) identity=pra; client-ip=209.85.214.47; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="christoph.hoeger@celeraone.com"; x-sender="christoph.hoeger@celeraone.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail3-smtp-sop.national.inria.fr: domain of christoph.hoeger@celeraone.com designates 209.85.214.47 as permitted sender) identity=mailfrom; client-ip=209.85.214.47; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="christoph.hoeger@celeraone.com"; x-sender="christoph.hoeger@celeraone.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-it0-f47.google.com) identity=helo; client-ip=209.85.214.47; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="christoph.hoeger@celeraone.com"; x-sender="postmaster@mail-it0-f47.google.com"; x-conformance=sidf_compatible IronPort-PHdr: =?us-ascii?q?9a23=3Ajm7LRBFFh/YTrPxNe5ikJ51GYnF86YWxBRYc798d?= =?us-ascii?q?s5kLTJ7ypsWwAkXT6L1XgUPTWs2DsrQf2raQ7/mrAjZIyK3CmUhKSIZLWR4BhJ?= =?us-ascii?q?detC0bK+nBN3fGKuX3ZTcxBsVIWQwt1Xi6NU9IBJS2PAWK8TW94jEIBxrwKxd+?= =?us-ascii?q?KPjrFY7OlcS30P2594HObwlSijewZbx/IA+5oAnMucUbj5VuIbstxxXUpXdFZ/?= =?us-ascii?q?5Yzn5yK1KJmBb86Maw/Jp9/ClVpvks6c1OX7jkcqohVbBXAygoPG4z5M3wqBnM?= =?us-ascii?q?VhCP6WcGUmUXiRVHHQ7I5wznU5jrsyv6su192DSGPcDzULs5Vyiu47ttRRT1ji?= =?us-ascii?q?oMKjw3/3zNisFojq1brhKvqRJ8zYDJfo+aKOFzcbnBcd4AX2dNQtpdWi5HD4ih?= =?us-ascii?q?b4UPFe0BPeNAooTjp1sOtxq+BRKwBOPo0j9Ihmf50688y+QuDw7GxhErEtUSv3?= =?us-ascii?q?TUttX1NbwSUfyyzKnQzTXPdfNW2TDj54jHbB8hu+qBUq5ufsrV10YvDRnKjlKW?= =?us-ascii?q?qYP7JT+ayuMNs22C4udmSOmhhWknqwRrrTiuwMchkobJiZwPyl/Z7Cl525o1Jd?= =?us-ascii?q?q8SE5jZN6rCp1QtyeAO4RrXMwuW31otzghyr0ao5K7eSwKxIw7yBHFbvyHd5SH?= =?us-ascii?q?4hP/VOeROzt4g2hleL2nixaz90ig0Oz8WdOu3FZEtCpJisLMtmwX2BzJ9siHV+?= =?us-ascii?q?N98l262TqWyw/e7PxPL0MslafDNZIt3ro9moAQvEnDBCP6hlj6gaCMekgr+OWl?= =?us-ascii?q?7fnsbK/8qZ+GLYB0jxnzMqQwlcy7BuQ1Kg0OUHKa+eS4zbHj/FH5TKlTgv04na?= =?us-ascii?q?TUsorWJcscpq6+DA9V1pgs5wyjADeh1dQUhXgHLFRbdxKbl4XlJU3CLfTiAfq8?= =?us-ascii?q?g1mgiilny+3JM7H7DZjALGDPkLL7crZ8705cxhAzzdda559MFr4BIOjzWk7qtN?= =?us-ascii?q?zECR85Kwy0z/znCNV6yIweVnyAArWCPazOr1CI4vwgI/OWa48SvjbyNeIp6OLp?= =?us-ascii?q?jX88gVMdZ7Wm3YMLaHCkGfRrO1mWbmDpgtcFCGsKugs+TPf2iFCZSj5SZ3OyX7?= =?us-ascii?q?om6T0hCYKmC53DRoG3j7Cb0ie7BM4eWmcTJV2WHT/Ta4KAQ/IFbiTads5nnDss?= =?us-ascii?q?WrW7R8o6yRaqrArzzbwhIueCqQMCspe2/9hv5vbPkgkywhzqAMmHmzWGT3t1hX?= =?us-ascii?q?8PXz9w3KdyrkFn4lyO1aViivteGJpY4PYfAVRyDoLV0+EvU4O6YQnGZNrcEFs?= =?us-ascii?q?=3D?= X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A0CYAQDJroBYhi/WVdFeGgEBAQECAQEBA?= =?us-ascii?q?QgBAQEBFQEBAQECAQEBAQgBAQEBgxQBAQEBAUE+gQkHg0qKCJIDjHeDCoUrggw?= =?us-ascii?q?shXYCgXIHPxgBAQEBAQEBAQEBARIBAQEICwsKHTCCMxmCHgEEASMdAQETJAEEC?= =?us-ascii?q?wsLAwQwAgIiEgEFAQ4OBhMJiHIIDqMeP4saaIIlgwgBAQWHMAEBAQEBAQEBAgE?= =?us-ascii?q?BAQEBAQEZCBKLJ4RVgkAMLoJeiHwHh3GKVYZhhwKEAoJJjiWRKhQegRQPEIF+T?= =?us-ascii?q?xQFg2opIIFsPTUBiWMBAQE?= X-IPAS-Result: =?us-ascii?q?A0CYAQDJroBYhi/WVdFeGgEBAQECAQEBAQgBAQEBFQEBAQE?= =?us-ascii?q?CAQEBAQgBAQEBgxQBAQEBAUE+gQkHg0qKCJIDjHeDCoUrggwshXYCgXIHPxgBA?= =?us-ascii?q?QEBAQEBAQEBARIBAQEICwsKHTCCMxmCHgEEASMdAQETJAEECwsLAwQwAgIiEgE?= =?us-ascii?q?FAQ4OBhMJiHIIDqMeP4saaIIlgwgBAQWHMAEBAQEBAQEBAgEBAQEBAQEZCBKLJ?= =?us-ascii?q?4RVgkAMLoJeiHwHh3GKVYZhhwKEAoJJjiWRKhQegRQPEIF+TxQFg2opIIFsPTU?= =?us-ascii?q?BiWMBAQE?= X-IronPort-AV: E=Sophos;i="5.33,254,1477954800"; d="scan'208,217";a="209940665" Received: from mail-it0-f47.google.com ([209.85.214.47]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/AES128-GCM-SHA256; 19 Jan 2017 13:24:07 +0100 Received: by mail-it0-f47.google.com with SMTP id 203so138817270ith.0 for ; Thu, 19 Jan 2017 04:24:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=celeraone-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=i6tjxiqYeVXjbW6J5VWuRxpORj6G5qNSfbXkEb91wtc=; b=eMjxDDGP4N5Mp1ll13zNCA8i5dfyXZgK7cW/IDjqKxykRmUVtXCfUiUEFm+mtMpSlu 0ZlCRQA3aC2e68ZP2GQtdQi+VMCm4uM+F/YM3H39vhsnQ1cjEg/ureGIhanexrbGcXRl 4GyQvGd+QybgOWs90ZFPBEB3Rh//Hyn32TiTYxuWFnZrQwujMNFQzuNjvHB5X7qiMuKv X/arw7dCiV6O6avmyReZSbERH7F2hQ37TNY6ucpfVMant6G2lAXdFYxre51mREC8koaC dGI359ge9BUHj+QjqpdvyADiza1qcm75GJ2cGWtB+vu3x6C/5+Iamw4fEvrRFzuQ1K/2 ShOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=i6tjxiqYeVXjbW6J5VWuRxpORj6G5qNSfbXkEb91wtc=; b=Qub0rih9EQvJZpXZTrQJFJnsbOeHgdj2Iw+AxhK6G5XgcSBWjz+Lh/hpmwiGOCB+Rx xaVXwf05YtnTc6/aUmCsPVacF0SggQMwK6Xs//hkCgvvvPRyXEio4ms9X60fVpp9jHkn OjACi+mc58ZfF0mU7bcpB4iiuuXq/n65yJJg//NVS0j1knfR1RYWSKdNDtYkbovcC9Fd VoxFn2wkip9rPOX1QNB6UJbCoWRAW8X+cMdlEM8p24yiACcuD8Jpe+lafy8axTG3rjxl R4VbWrsuI2zj7oMkNugSAlQuD9D9Y95/IP31Y3EgFLofgqe1uz3ZJ3Uynd+m3ta8l8Ke 3+JA== X-Gm-Message-State: AIkVDXKKQX+TvIkSfm18dRGgkhzgJreLH30umYc03a2k5xKOtSF2OR51BdUcZFeKeVotCZZbQolT2n6f1fvc8cV0 X-Received: by 10.36.123.145 with SMTP id q139mr7684456itc.62.1484828645061; Thu, 19 Jan 2017 04:24:05 -0800 (PST) MIME-Version: 1.0 Received: by 10.107.48.211 with HTTP; Thu, 19 Jan 2017 04:24:04 -0800 (PST) In-Reply-To: <1484827880.14465.105.camel@gerd-stolpmann.de> References: <1484827880.14465.105.camel@gerd-stolpmann.de> From: =?UTF-8?Q?Christoph_H=C3=B6ger?= Date: Thu, 19 Jan 2017 13:24:04 +0100 Message-ID: To: Gerd Stolpmann Cc: caml-list@inria.fr Content-Type: multipart/alternative; boundary=001a1146f030f16d6a0546719be9 Subject: Re: [Caml-list] Manually linking generated native code --001a1146f030f16d6a0546719be9 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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? To motivate my question a little bit, I was wondering whether I could load 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 cooperate across the shared heap, but otherwise live in total isolation (in particular their garbage collectors should not interfere). On Thu, Jan 19, 2017 at 1:11 PM, Gerd Stolpmann wrote: > Am Donnerstag, den 19.01.2017, 10:44 +0100 schrieb Christoph H=C3=B6ger: > > Dear all, > > consider a simple test program: > > let _ =3D Printf.printf "Hello world!\n" > > I can generate the relevant assembly just fine, e.g.: > > ocamlopt -dstartup -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=BCck > 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 object files? > > > There's stdlib.a in the OCaml library directory. > > This is not the only problem with your approach. The OCaml linker > generates a number of functions that are global to the whole OCaml program > (in particular currying helpers). These are first known at link time and > thus generated that late. AFAIK you cannot generate these functions outsi= de > the linker step. > > The only official way how to turn OCaml code into a linkable object is > described here: http://caml.inria.fr/pub/docs/manual-ocaml/intfc. > html#s%3Aembedded-code > > Gerd > > > thanks, > > Christoph > > -- > ------------------------------------------------------------ > 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 > ------------------------------------------------------------ > > > --001a1146f030f16d6a0546719be9 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Could you elaborate a little bit, how that should wor= k? AFAIK, e.g. the curry helpers are generated in Cmmgen, which is absolute= ly sensible, since they certainly do not depend on the machine architecture= , right? So when and where does the linker use this generation?

To motivate my question a little bit, I was wondering whether I could loa= d 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 c= ooperate across the shared heap, but otherwise live in total isolation (in = particular their garbage collectors should not interfere).

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 program:

=C2=A0 let _ =3D Printf.printf "Hello wo= rld!\n"

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

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

<= div>But I cannot link it:

gcc a.out.startup.o -L$(ocamlc = -where) -lasmrun_shared
....
a.out.startup.o(.data+0x6e8): error: und= efined reference to 'camlStd_exit__frametable'
collect2: Fehler:= ld gab 1 als Ende-Status zur=C3=BCck
distcc[9960] ERROR: compile (null)= on localhost failed

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

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

There's stdlib.a in the OCaml library direc= tory.

This is not the only problem with your appro= ach. The OCaml linker generates a number of functions that are global to th= e whole OCaml program (in particular currying helpers). These are first kno= wn at link time and thus generated that late. AFAIK you cannot generate the= se functions outside the linker step.=C2=A0

The on= ly official way how to turn OCaml code into a linkable object is described = here:=C2=A0http://caml.inria.fr/pub/docs/ma= nual-ocaml/intfc.html#s%3Aembedded-code

G= erd

thanks,

Christoph

<= 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
------------------------------------------------------------


--001a1146f030f16d6a0546719be9--