caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Re: [Caml-list] a question about "ocamlopt" and "ocamldep"
@ 2012-03-14 10:31 Matej Košík
  2012-03-14 11:23 ` Gabriel Scherer
  0 siblings, 1 reply; 8+ messages in thread
From: Matej Košík @ 2012-03-14 10:31 UTC (permalink / raw)
  To: Caml List

On 03/13/2012 06:34 PM, Matthias Puech wrote:
> This is consistent with how ocamlc/ocamlopt work: separate compilation 
> is ensured the way you think by bytecode .cmo compilation: to build a 
> module, you only need the *interfaces* of its dependencies, but it is 
> unfortunately not ensured when compiling to native code, because of the 
> global (inter-modules) optimizations performed (inlining AFAIK). Thus, 
> to build a .cmx module, you need to be aware of the actual *code* of its 
> dependencies.

:-(

^ permalink raw reply	[flat|nested] 8+ messages in thread
* [Caml-list] a question about "ocamlopt" and "ocamldep"
@ 2012-03-13 18:19 Matej Košík
  2012-03-13 18:34 ` Matthias Puech
  0 siblings, 1 reply; 8+ messages in thread
From: Matej Košík @ 2012-03-13 18:19 UTC (permalink / raw)
  To: caml-list

Hi,

The "ocamldep" tool generates Makefile dependencies for both situations:
- when we use "ocamlc"
- as well as when we use "ocamlopt"

Dependencies, generated for "*.cmo" files,
are corresponding "*.cmi" files.

This is not surprising.

However, dependencies, generated for "*.cmx" files,
are always other "*.cmx" files.

This is surprising.

Why "*.cmx" files do not depend on "*.cmi" files?

I have noticed this in a bigger project but this phenomenon appear to
happen for arbitrarily small projects.

Consider the following ocamldep-generated couple of rules:

src/ml2c/typing/printtyp.cmo: src/ml2c/typing/types.cmi \
    src/ml2c/typing/primitive.cmi src/ml2c/typing/predef.cmi \
    src/ml2c/typing/path.cmi src/ml2c/typing/outcometree.cmi \
    src/ml2c/typing/oprint.cmi src/ml2c/utils/misc.cmi \
    src/ml2c/parsing/longident.cmi src/ml2c/typing/ident.cmi \
    src/ml2c/typing/env.cmi src/ml2c/typing/ctype.cmi \
    src/ml2c/utils/clflags.cmi src/ml2c/typing/btype.cmi \
    src/ml2c/parsing/asttypes.cmi src/ml2c/typing/printtyp.cmi
src/ml2c/typing/printtyp.cmx: src/ml2c/typing/types.cmx \
    src/ml2c/typing/primitive.cmx src/ml2c/typing/predef.cmx \
    src/ml2c/typing/path.cmx src/ml2c/typing/outcometree.cmx \
    src/ml2c/typing/oprint.cmx src/ml2c/utils/misc.cmx \
    src/ml2c/parsing/longident.cmx src/ml2c/typing/ident.cmx \
    src/ml2c/typing/env.cmx src/ml2c/typing/ctype.cmx \
    src/ml2c/utils/clflags.cmx src/ml2c/typing/btype.cmx \
    src/ml2c/parsing/asttypes.cmx src/ml2c/typing/printtyp.cmi

The second rule seems to be unnecessarily demanding (unless it makes no
sense to compile *.cmi files if we use ocamlopt). It should read:

src/ml2c/typing/printtyp.cmx: src/ml2c/typing/types.cmi \
    src/ml2c/typing/primitive.cmi src/ml2c/typing/predef.cmi \
    src/ml2c/typing/path.cmi src/ml2c/typing/outcometree.cmi \
    src/ml2c/typing/oprint.cmi src/ml2c/utils/misc.cmi \
    src/ml2c/parsing/longident.cmi src/ml2c/typing/ident.cmi \
    src/ml2c/typing/env.cmi src/ml2c/typing/ctype.cmi \
    src/ml2c/utils/clflags.cmi src/ml2c/typing/btype.cmi \
    src/ml2c/parsing/asttypes.cmi src/ml2c/typing/printtyp.cmi

Shouldn't it?

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

end of thread, other threads:[~2012-03-14 17:12 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-14 10:31 [Caml-list] a question about "ocamlopt" and "ocamldep" Matej Košík
2012-03-14 11:23 ` Gabriel Scherer
2012-03-14 12:38   ` Matej Košík
2012-03-14 13:19     ` Virgile Prevosto
2012-03-14 17:12       ` Gabriel Scherer
  -- strict thread matches above, loose matches on Subject: below --
2012-03-13 18:19 Matej Košík
2012-03-13 18:34 ` Matthias Puech
2012-03-13 19:26   ` Gabriel Scherer

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