caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Guillaume Hennequin <guillaume.hennequin@epfl.ch>
To: caml-list@inria.fr
Subject: Re: [Caml-list] ocamlbuild and cflags
Date: Wed, 20 Jul 2011 16:46:30 +0200	[thread overview]
Message-ID: <20110720144630.GC21796@guillaume-laptop> (raw)
In-Reply-To: <B4761F80-7768-4D2D-9B33-F45C2B99D1BC@inria.fr>

On Wed, Jul 20, 2011 at 03:06:34PM +0200, xclerc wrote:
> 
> Le 20 juil. 2011 à 14:48, Guillaume Hennequin a écrit :
> 
> > Hello,
> > 
> > I came across two ocamlbuild issues today:
> > 
> > 1) how can one give a cflag that requires an argument, like
> >    ocamlbuild -cflag -inline 2 target.native
> >   Backtrace:
> >    - failed to build the target 2
> 
> To overcome this problem you can execute either
> 	ocamlbuild -cflag -inline -cflag 2 target.native
> or
> 	ocamlbuild -cflags -inline,2 target.native
> 

thanks!

> > 2) I don't understand why ocamlbuild target.cmx would need to compile
> > target.cmo on the way... this actually prevents me from using any of the
> > ocamlopt-specific flags:
> >    ocamlbuild -cflag -S target.cmx
> >    (ocamlc itself complains it doesn't have a -S option)
> > 
> > any way around that?
> 
> This is a reported bug [1]; in your case, a workaround is to write the
> following "myocamlbuild.ml" file:
> 	open Ocamlbuild_plugin
> 
> 	let () =
> 	  dispatch begin function
> 	    | After_rules ->
> 	        tag_file "target.ml" ["myoption"];
> 	        flag ["ocaml"; "compile"; "native"; "myoption"] (A"-S");
> 	    | _ -> ()
> 	  end

thanks for pointing to [1], which also tells me that the .cmo is built
because the .cmi becomes a target for the .cmx, and that .cmi targets
can only be built with ocamlc, not also with ocamlopt, for some reason.
conclusion, writing my .mli file is also an option.

Now, for simple files for which an interface would just be copy/paste, I
can also probably just add a line in my Makefile to generate them
automatically with ocamlc -i (before running ocamlbuild).

thanks
Guillaume

> Hope this helps,
> 
> Xavier Clerc
> 
> 
> [1] http://caml.inria.fr/mantis/view.php?id=5282
> 
> -- 
> Caml-list mailing list.  Subscription management and archives:
> https://sympa-roc.inria.fr/wws/info/caml-list
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs

      reply	other threads:[~2011-07-20 14:46 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-20 12:48 Guillaume Hennequin
2011-07-20 13:06 ` xclerc
2011-07-20 14:46   ` Guillaume Hennequin [this message]

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=20110720144630.GC21796@guillaume-laptop \
    --to=guillaume.hennequin@epfl.ch \
    --cc=caml-list@inria.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;
as well as URLs for NNTP newsgroup(s).