Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: "Nicolas Pouillard" <nicolas.pouillard@gmail.com>
To: romain.bardou <romain.bardou@lri.fr>
Cc: Josh Berdine <jjb@microsoft.com>,
	Caml_mailing list <caml-list@yquem.inria.fr>
Subject: Re: [Caml-list] ocamlbuild: ml -> cmx & cmi & o ?
Date: Thu, 16 Oct 2008 10:43:11 +0200	[thread overview]
Message-ID: <1224146385-sup-4057@ausone.inria.fr> (raw)
In-Reply-To: <48F6FBB9.7030107@lri.fr>

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


  reply	other threads:[~2008-10-16  8:43 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-15 11:00 Josh Berdine
2008-10-16  8:30 ` [Caml-list] " Romain Bardou
2008-10-16  8:43   ` Nicolas Pouillard [this message]
2008-10-16  8:53     ` Romain Bardou

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1224146385-sup-4057@ausone.inria.fr \
    --to=nicolas.pouillard@gmail.com \
    --cc=caml-list@yquem.inria.fr \
    --cc=jjb@microsoft.com \
    --cc=romain.bardou@lri.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox