From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id EA966BB81 for ; Mon, 26 Sep 2005 07:13:50 +0200 (CEST) Received: from kurims.kurims.kyoto-u.ac.jp (kurims.kurims.kyoto-u.ac.jp [130.54.16.1]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id j8Q5Dmx9001940 for ; Mon, 26 Sep 2005 07:13:50 +0200 Received: from localhost (suiren [130.54.16.25]) by kurims.kurims.kyoto-u.ac.jp (8.13.1/8.13.1) with ESMTP id j8Q5DcVc003208; Mon, 26 Sep 2005 14:13:39 +0900 (JST) Date: Mon, 26 Sep 2005 14:14:30 +0900 (JST) Message-Id: <20050926.141430.59032287.garrigue@math.nagoya-u.ac.jp> To: jonathan.roewen@gmail.com Cc: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Dynamic linking From: Jacques Garrigue In-Reply-To: References: X-Mailer: Mew version 4.2 on Emacs 21.3 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Miltered: at concorde with ID 4337838C.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 ocaml:01 runtime:01 ocaml:01 cmi:01 cmx:01 cmi:01 runtime:01 struct:01 compilenv:01 cmx:01 dynlink:01 asmdynlink:01 bytecode:01 bytecode:01 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.4 required=5.0 tests=DNS_FROM_RFC_ABUSE autolearn=disabled version=3.0.3 From: Jonathan Roewen > We're trying to figure out how to provide some sort of dynamic linker > for DST to load ocaml native code at runtime on an ocaml native code > kernel. > > Is there any document that details the format of .cmi/.cmx files; > also, are these (esp .cmi) able to provide the necessary details on > the symbols in the kernel for building a dynamic linker that can > resolve symbols to kernel functions in ocaml code loaded at runtime? No document that I know, but the code is clear enough. You may have a look at Env.read_pers_struct for .cmi and Compilenv.read_unit_info for .cmx. However I'm not sure it would help you very much in practice. There are at least two other problems before you can do dynamic linking of native code in ocaml: * the code generator is geared toward static code, which means that it cannot be handled by the runtime linker on many architectures (I only know of a patch for x86) * some glue code is generated at link time So this looks like a rather difficult task... > I know Dynlink module doesn't work with native code, and if I'm > correct, the unsupported Asmdynlink module provided a runtime > environment for bytecode ocaml code in native code programs right? > Which is not what we'd be looking for. Yet another approach would be to use bytecode + JIT. But this won't give you the performance of native code. Jacques