caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] ocamldep  problem with .cmo vs .cmx
@ 2002-08-07  0:06 Henri Dubois-Ferriere
  2002-08-07 10:41 ` Alain Frisch
  0 siblings, 1 reply; 2+ messages in thread
From: Henri Dubois-Ferriere @ 2002-08-07  0:06 UTC (permalink / raw)
  To: caml-list

Hi,

I have noticed that ocamldep fills in dependencies differently for a .cmo
than for a .cmx

Say my file main.ml does a "open mylib"

then ocamldep will produce the following dependencies:

main.cmo: mylib.cmi
(depends on *interface* of included module)
main.cmx: mylib.cmx
(depends on compiled *object code* of included module)

mylib.cmo: mylib.cmi
mylib.cmx: mylib.cmi

So, in the cmx case, we have the full dependency file so that a makefile
target like

main_opt: main.cmx
	$(OCAMLOPT) $(OBJ_FILES) ... ..

will follow all the dependencies and compile mylib.cmi and mylib.cmx
(assuming the right implicit rules etc).

whereas if we have a target for the bytecode version like:

main_bcode: main.cmo
	$(OCAMLC) $(BC_OBJ_FILES) ... ..

make will only compile mylib.cmi and not mylib.cmo, so one would have to
explicitly add mylib.cmo as a dependency of main_bcode. This is painful in
itself, on top of forcing bytecode and native rules to be different.

So the question is:
In the example above, why doesn't ocamldep output
main.cmo: mylib.cmo
instead of
main.cmo: mylib.cmi

? This would make .cmx and .cmo treatment consistent, as well as simplify
makefile writing.

thanks
henri

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


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

* Re: [Caml-list] ocamldep  problem with .cmo vs .cmx
  2002-08-07  0:06 [Caml-list] ocamldep problem with .cmo vs .cmx Henri Dubois-Ferriere
@ 2002-08-07 10:41 ` Alain Frisch
  0 siblings, 0 replies; 2+ messages in thread
From: Alain Frisch @ 2002-08-07 10:41 UTC (permalink / raw)
  To: Henri DF; +Cc: caml-list

On Wed, 7 Aug 2002, Henri Dubois-Ferriere wrote:

> So the question is:
> In the example above, why doesn't ocamldep output
> main.cmo: mylib.cmo
> instead of
> main.cmo: mylib.cmi

Because you don't need to rebuild main.cmo when you change the
implementation of Mylib (the link between the two modules is
resolved at ... link time). Native-code compilation performs
some cross-modules optimizations (not sure, but probably constant
propagation and function inlining), which need the implementation of
Mylib when you compile main.ml. Hence the difference.

Anyway, you have to specify even on ocamlopt command line the full
list of .cmx files you want to put in the result. So it's not a big
deal to have the list of .cmo/.cmx files in the dependencies.


-- Alain

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


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

end of thread, other threads:[~2002-08-07 10:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-08-07  0:06 [Caml-list] ocamldep problem with .cmo vs .cmx Henri Dubois-Ferriere
2002-08-07 10:41 ` Alain Frisch

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