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 yquem.inria.fr (Postfix) with ESMTP id 2F14EBC37 for ; Fri, 1 Jan 2010 19:17:05 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AiEBAHPKPUvUnwdjjmdsb2JhbACbTAEBAQEJCwgJEQa3FIQxBA X-IronPort-AV: E=Sophos;i="4.47,486,1257116400"; d="scan'208";a="40592077" Received: from relay.pcl-ipout01.plus.net ([212.159.7.99]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-SHA; 01 Jan 2010 19:17:04 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApoEAHPKPUvUnw4S/2dsb2JhbADTIIQxBA Received: from pih-relay05.plus.net ([212.159.14.18]) by relay.pcl-ipout01.plus.net with ESMTP; 01 Jan 2010 18:17:04 +0000 Received: from [87.114.35.173] (helo=leper.local) by pih-relay05.plus.net with esmtp (Exim) id 1NQm3c-000405-6o for caml-list@yquem.inria.fr; Fri, 01 Jan 2010 18:17:04 +0000 From: Jon Harrop Organization: Flying Frog Consultancy Ltd. To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] ocaml, llvm and generating code at runtime Date: Fri, 1 Jan 2010 19:31:27 +0000 User-Agent: KMail/1.9.9 References: <405ED4B9-9B3C-4BAA-9C79-C18BB8FDDB4D@gmail.com> In-Reply-To: <405ED4B9-9B3C-4BAA-9C79-C18BB8FDDB4D@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <201001011931.27980.jon@ffconsultancy.com> X-Plusnet-Relay: f97078e865324ad857cfffed9758daa3 X-Spam: no; 0.00; ocaml:01 runtime:01 ocaml:01 bindings:01 runtime:01 stub:01 stubs:01 compiler:01 scalable:01 frog:98 wrote:01 compile:01 caml-list:01 functions:01 ast:02 On Friday 01 January 2010 16:45:34 Joel Reymont wrote: > Does anybody have example code that shows how to generate OCaml bindings at > runtime with LLVM? The OCaml Journal article "Calling C code from OCaml" (10th July 2008) described an OCaml program that invoked a C function both via a stub written in C and via JIT compiled interface code using LLVM (no more stinking C stubs!). I would like to write more on JIT-compiled interface code in the future and perhaps write a library to make it easy. > My goal is to compile an AST into code that uses OCaml functions within the > same binary that's doing the compiling. > > I don't think it can be done with OCaml since it requires a standalone > assembler, linker, etc. Correct me if I'm wrong, though. Mine is a > web-based compiler with potentially many concurrent sessions. Running gas, > ld, etc. seems a much heavier and less scalable approach that generating > code at runtime. Sounds like you really want HLVM. :-) > Thanks and Happy New Year, Joel Happy New Year! -- Dr Jon Harrop, Flying Frog Consultancy Ltd. http://www.ffconsultancy.com/?e