caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] ocamlbuild and cflags
@ 2011-07-20 12:48 Guillaume Hennequin
  2011-07-20 13:06 ` xclerc
  0 siblings, 1 reply; 3+ messages in thread
From: Guillaume Hennequin @ 2011-07-20 12:48 UTC (permalink / raw)
  To: caml-list

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

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?

cheers,
Guillaume.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Caml-list] ocamlbuild and cflags
  2011-07-20 12:48 [Caml-list] ocamlbuild and cflags Guillaume Hennequin
@ 2011-07-20 13:06 ` xclerc
  2011-07-20 14:46   ` Guillaume Hennequin
  0 siblings, 1 reply; 3+ messages in thread
From: xclerc @ 2011-07-20 13:06 UTC (permalink / raw)
  To: caml users; +Cc: xclerc Clerc


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


> 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


Hope this helps,

Xavier Clerc


[1] http://caml.inria.fr/mantis/view.php?id=5282

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Caml-list] ocamlbuild and cflags
  2011-07-20 13:06 ` xclerc
@ 2011-07-20 14:46   ` Guillaume Hennequin
  0 siblings, 0 replies; 3+ messages in thread
From: Guillaume Hennequin @ 2011-07-20 14:46 UTC (permalink / raw)
  To: caml-list

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-07-20 14:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-20 12:48 [Caml-list] ocamlbuild and cflags Guillaume Hennequin
2011-07-20 13:06 ` xclerc
2011-07-20 14:46   ` Guillaume Hennequin

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).