From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.4 required=5.0 tests=AWL autolearn=disabled version=3.1.3 Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id EA725BBAF for ; Thu, 16 Oct 2008 10:43:58 +0200 (CEST) X-IronPort-AV: E=Sophos;i="4.33,422,1220220000"; d="scan'208";a="30398880" Received: from peray.inria.fr (HELO ausone.inria.fr) ([128.93.8.98]) by mail4-relais-sop.national.inria.fr with SMTP; 16 Oct 2008 10:43:58 +0200 Received: by ausone.inria.fr (sSMTP sendmail emulation); Thu, _d Oct 2008 10:43:11 +0200 From: "Nicolas Pouillard" Content-Type: text/plain; charset=UTF-8 Cc: Josh Berdine , Caml_mailing list Subject: Re: [Caml-list] ocamlbuild: ml -> cmx & cmi & o ? To: romain.bardou References: <857DD0FDAC042B4485F9F5F4EA6751041E4CEEEDBC@EA-EXMSG-C332.europe.corp.microsoft.com> <48F6FBB9.7030107@lri.fr> In-Reply-To: <48F6FBB9.7030107@lri.fr> Date: Thu, 16 Oct 2008 10:43:11 +0200 Message-Id: <1224146385-sup-4057@ausone.inria.fr> User-Agent: Sup/git X-Spam: no; 0.00; cmx:01 cmi:01 cmx:01 cmi:01 mli:01 cmo:01 ocamlc:01 ocamlopt:01 ocamlopt:01 mli:01 ocamlc:01 ocaml:01 plug-in:98 caml-list:01 short:01 Excerpts from romain.bardou's message of Thu Oct 16 10:30:49 +0200 2008: > > I observe that ocamlbuild does not build cmx cmi and o files from a ml > > file (which has no associated mli) directly. Do others see different > > behavior? Instead it builds cmo and cmi from the ml using ocamlc, and > > then builds the cmx and o files from there using ocamlopt. Is there a > > reason I’m missing that ocamlbuild does not have a default rule for this > > case, using only one call to ocamlopt? If so, is there an easy way to > > do this with a plugin? There is a deep reason for this, the short answer is: "if you want native-compilation only, then all your .ml files must have a .mli" Indeed ocamlbuild only generates .cmi from .ml using ocamlc, this is to avoid conflicting defaulting rules in the engine. > I observe the same behavior. I think it's just a matter of reordering > the rules in ocaml_specific.ml, as the following plug-in solves the > problem thanks to "~insert: `top": > > open Ocamlbuild_plugin > > let () = dispatch begin function > | After_rules -> > rule "ml -> cmx" > ~dep: "%.ml" > ~prods: ["%.cmx"; "%.o"; "%.cmi"] > ~insert: `top > begin fun env _ -> > let ml = env "%.ml" in > Cmd(S[!Options.ocamlopt; A "-c"; P ml]) > end > | _ -> () > end I won't recommend that. -- Nicolas Pouillard aka Ertai