Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.cmo files are generated even for native compilation #5282

Closed
vicuna opened this issue Jun 4, 2011 · 6 comments
Closed

.cmo files are generated even for native compilation #5282

vicuna opened this issue Jun 4, 2011 · 6 comments

Comments

@vicuna
Copy link

vicuna commented Jun 4, 2011

Original bug ID: 5282
Reporter: Camarade_Tux
Status: resolved (set by @damiendoligez on 2017-02-27T13:03:56Z)
Resolution: not a bug
Priority: normal
Severity: minor
Version: 3.12.0
Target version: later
Category: -for ocamlbuild use https://github.com/ocaml/ocamlbuild/issues
Duplicate of: #4613
Related to: #4991
Monitored by: mehdi @ygrek @glondu @jberdine @hcarty @Chris00

Bug description

When compiling native targets, ocamlbuild also compiles .cmo files.

Example on an empty folder:

% touch a.ml
% ocamlbuild -classic-display a.native
/opt/ocaml/bin/ocamldep.opt -modules a.ml > a.ml.depends
/opt/ocaml/bin/ocamlc.opt -c -o a.cmo a.ml # calls ocamlc.opt
/opt/ocaml/bin/ocamlopt.opt -c -o a.cmx a.ml
/opt/ocaml/bin/ocamlopt.opt a.cmx -o a.native

With many more complex files, this can lead to a substantial slow-down.

@vicuna
Copy link
Author

vicuna commented Jun 5, 2011

Comment author: ertai

We acknowledge this is a limitation. However this is not a bug, it is a design choice with a simple and recommendable workaround. Indeed you observe this behavior only because you have no .mli for this file. There is technical reasons to not accept .cmi to be generated by both ocamlc and ocamlopt. So we impose them to be always generated by ocamlc. If you have a .mli then you see no drawbacks of this method.

In short we recommend you the good practice of having .mli files.

@vicuna
Copy link
Author

vicuna commented Apr 21, 2012

Comment author: goswin

"There is technical reasons to not accept .cmi to be generated by both ocamlc and ocamlopt."

So for the sake of documenting this what are those reasons?

@vicuna
Copy link
Author

vicuna commented Jun 17, 2013

Comment author: @glondu

What about having a command (or command-line option to an existing one) generating only the .cmi (and not .cmo) for a .ml file?

@vicuna
Copy link
Author

vicuna commented Jul 28, 2013

Comment author: @gasche

One problem with having both ocamlc and ocamlopt produce .cmi files is discussed in #4991: it creates a race condition during parallel builds.

@vicuna
Copy link
Author

vicuna commented Feb 20, 2017

Comment author: @xavierleroy

Un-assigning from xclerc

@vicuna
Copy link
Author

vicuna commented Feb 27, 2017

Comment author: @damiendoligez

This PR was marked "no change required" by @Ertai in 2011...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant