Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0005851OCamlOCamlbuild (the tool)public2012-12-12 01:092014-05-25 20:20
ReporterMatthieu Lemerre 
Assigned Toxclerc 
PrioritynormalSeverityminorReproducibilityalways
StatusassignedResolutionopen 
PlatformOSOS Version
Product Version3.12.1 
Target Version4.02.0+devFixed in Version 
Summary0005851: Ocamlbuild cannot resolve dependencies when there are no _tags file (but can with an empty _tags file)
DescriptionThere is a difference in behaviour between no _tags file and an empty one. Ocamlbuild succeed in building a simple project only if there is an empty _tags file in the directory.
Steps To ReproduceFirst create a project with the following files:

File: plu/bla.ml
#+begin_src ocaml
let bla = 3;;
#+end_src

File: plu/bli.ml
#+begin_src ocaml
let bli = Bla.bla;;
#+end_src

File: plu.mlpack
#+begin_example
plu/Bla
plu/Bli
#+end_example

File: use.ml
#+begin_src ocaml
Plu.Bla.bli
#+end_src


Try to compile:

#+begin_example
ocamlbuild use.byte
/usr/bin/ocamlc -c -o use.cmo use.ml
+ /usr/bin/ocamlc -c -o use.cmo use.ml
File "use.ml", line 1, characters 0-11:
Error: Unbound module Plu
Command exited with code 2.
#+end_example

It seems that the ocamlbuild solver does
not know how to build the =.cmo= out of the =.mlpack=:

#+begin_example
ocamlbuild plu.cmo
Solver failed:
#+end_example

However, if you create (even an empty) =_tags= file at the root of the
project, then everything works:

#+begin_example
ocamlbuild use.byte
/usr/bin/ocamldep -modules plu/bla.ml > plu/bla.ml.depends
/usr/bin/ocamldep -modules plu/bli.ml > plu/bli.ml.depends
/usr/bin/ocamlc -c -I plu -o plu/bla.cmo plu/bla.ml
/usr/bin/ocamlc -c -I plu -o plu/bli.cmo plu/bli.ml
/usr/bin/ocamlc -pack plu/bla.cmo plu/bli.cmo -o plu.cmo
/usr/bin/ocamlc -c -o use.cmo use.ml
/usr/bin/ocamlc plu.cmo use.cmo -o use.byte
#+end_example
TagsNo tags attached.
Attached Files

- Relationships

-  Notes
(0008598)
xclerc (developer)
2012-12-12 17:09

It is arguably a design choice. As of today, the subdirectories
of the current directory are marked as "traverse" iff there is
either a "_tags", or a "myocamlbuild.ml" file.

Of course, this default behavior could as well be changed.
I am pondering the implications of such a change over
existing projects. Any advice is welcome.
(0008601)
Matthieu Lemerre (reporter)
2012-12-13 14:42

I was not aware of this "traverse" tag, this solves my problem. But this behavior is quite surprising: adding _tags file seems unrelated to the notion of traversing subdirectories.

I am not sure of how "traverse" interacts with the rest of the system, or what is its purpose. Is this only to improve performance by avoiding directory traversal?

It seems that directories added by the -I flag are traversed (at least, "ocamlbuild -I plu use.byte" works in my case), so I think the .mlpack case is comparable: at least the directories present in the .mlpack files should be traversable (or a warning/error should be issued if a referenced directory is not traversable).
(0008605)
xclerc (developer)
2012-12-13 18:23

> I was not aware of this "traverse" tag, this solves my problem. But this behavior is quite surprising:
> adding _tags file seems unrelated to the notion of traversing subdirectories.

I do agree that is seems strange at first, and think it would be a good thing to
change that. I am just afraid of breaking something...


> I am not sure of how "traverse" interacts with the rest of the system, or what is its purpose. Is this
> only to improve performance by avoiding directory traversal?

That is also my understanding.


> It seems that directories added by the -I flag are traversed (at least, "ocamlbuild -I plu use.byte"
> works in my case), so I think the .mlpack case is comparable: at least the directories present in the
> .mlpack files should be traversable (or a warning/error should be issued if a referenced directory is
> not traversable).

OK, fixing the problem this way could indeed be better.
(0009864)
meyer (developer)
2013-07-26 10:37

This needs to be triaged again.
(0009867)
william (reporter)
2013-07-26 18:10

from the documentation :

camlbuild used to traverse by default any subdirectory not explicitly excluded. This is no longer the case. Note that you can still have a fine grained control using your _tags file and the traverse tag.

There is no longer the true: traverse tag declaration by default. To make ocamlbuild recursive use one of these:
    Give the -r flag to ocamlbuild.
    Have a _tags or myocamlbuild.ml file in your top directory.

The reason is given in gallium website :
The problem with this default setting (true:traverse) is that when starting, ocamlbuild wants to read deeply the whole current directory. For instance running ocamlbuild -documentation in your home could take a while.


- There is the question of having traverse or not by default
- but the behaviour where creating a _tags file makes ocamlbuild recursive is bad IMHO
(0009870)
william (reporter)
2013-07-26 18:48

I see two options :

Either set the "traverse" by default, even if no _tags or myocamlbuild.ml file is present.
- it is already what happens for anyone having a _tags or myocamlbuild.ml file, that is to say 95% of people
- it works "out of the box"
- the drawback is that it is most likely ocamlbuild would not be setup in an optimal way, as user would not know that ocamlbuild would traverse all files

Either forbid the traverse by default, even if _tags or myocamlbuild.ml file is present. And add a message when ocamlbuild fails, along with the error message and the backtrace, that indicates which directories are traversed.
- it would break many user configurations
- it would require most people to add a "true:traverse" tag to their project
- but it would ensure people use ocamlbuild in a more optimal way

- Issue History
Date Modified Username Field Change
2012-12-12 01:09 Matthieu Lemerre New Issue
2012-12-12 17:09 xclerc Note Added: 0008598
2012-12-12 17:09 xclerc Assigned To => xclerc
2012-12-12 17:09 xclerc Status new => feedback
2012-12-13 14:42 Matthieu Lemerre Note Added: 0008601
2012-12-13 14:42 Matthieu Lemerre Status feedback => assigned
2012-12-13 18:23 xclerc Note Added: 0008605
2013-07-11 22:51 doligez Target Version => 4.02.0+dev
2013-07-12 18:15 doligez Target Version 4.02.0+dev => 4.01.1+dev
2013-07-26 10:37 meyer Note Added: 0009864
2013-07-26 18:10 william Note Added: 0009867
2013-07-26 18:48 william Note Added: 0009870
2014-05-25 20:20 doligez Target Version 4.01.1+dev => 4.02.0+dev


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker