Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0006326OCamlOCamlbuild (the tool)public2014-02-18 00:142014-02-25 01:25
Reporterspyder 
Assigned Togasche 
PriorityhighSeverityminorReproducibilityalways
StatusresolvedResolutionno change required 
PlatformMac OS XOSMac OS XOS Version10.9.1
Product Version4.01.0 
Target VersionFixed in Version 
Summary0006326: mlpack file not included correctly
DescriptionI am new to OCaml, and attempting to make ocamlbuild fit in with my existing project structure. Everything appeared to be going well until I made an mlpack file.

Rather than a flat structure as most projects seem to have, I keep my source code in a "src" folder and run ocamlbuild like this:

ocamlbuild src/main.native

This fails when main depends on a packed module that is also in the src folder.
Steps To ReproduceExtract the attached packdep.zip, open a terminal in the packdep folder

run:
ocamlbuild src/main.native
Additional InformationI found the solution in this email report from 2010:
https://groups.google.com/forum/#!topic/fa.caml/c5Q8q6ZdvDw [^]

If you rename "notmyocamlbuild.ml" to "myocamlbuild.ml" then the build works. This is not an acceptable workaround for my issue as any subfolders of src containing mlpack files must be added to the hard coded list in myocamlbuild.ml.

It looks like the patch from that old email was merged:
https://github.com/ocaml/ocaml/commit/a3c8cd0170e599b4cb1fdb63a17edd1b52bb207b [^]

However I suspect my issue is subtly different (perhaps modules is not an empty list) and thus my issue still exists.
TagsNo tags attached.
Attached Fileszip file icon packdep.zip [^] (2,257 bytes) 2014-02-18 00:14

- Relationships
related to 0005752acknowledged missing dependencies at byte-code link with mlpack 

-  Notes
(0010935)
spyder (reporter)
2014-02-18 02:39

I've just found http://caml.inria.fr/mantis/view.php?id=5752 [^] which indicates the original fix hasn't been released yet. I did a build of trunk and my particular issue still exists.
(0010969)
gasche (developer)
2014-02-21 20:43

On my machine, adding the -r option to ocamlbuild, or adding an empty _tags or myocamlbuild.ml (which is another way to enable recursive traversal by default) makes your code compile fine.
(0010971)
spyder (reporter)
2014-02-23 22:39

That does fix it, but I was avoiding recursive traversal because I thought that would add the entire triangle subfolder to the namespace. However when I attempt to use module Green within main.ml, it gives me an error even with -r.

What are the rules around recursive traversal?
(0010972)
gasche (developer)
2014-02-24 05:44

There is a different between "include" and "traverse" that is more or less explained in the manual ( http://caml.inria.fr/pub/docs/manual-ocaml/ocamlbuild.html#sec388 [^] ):
- "traverse" controls which directories ocamlbuild considers to be "part of the world" (eg. hygiene), a directory that has not been traversed will not be used for anything, nor its _tags file inspected.
- "include" affects the naming of compilation units, by letting you use unqualified instead of directory-qualified module names to indicate units to ocamlbuild. For example, a file foo/lib.mllib will contain "bar/Toto" to refer to foo/bar/toto.{ml,mli}, unless foo/_tags has "<foo>: include" (or they're both included in the same parent directory from which compilation is run)

"traverse" is set to true whenever there is either a _tags or myocamlbuild.ml file at the directory from which you launch the ocamlbuild command, and false otherwise -- to avoid the "ocamlbuild takes hour to do nothing if I mistakenly run it from my /home" effect.
(0010973)
spyder (reporter)
2014-02-24 05:52

ok. That's a little bit confusing, I didn't understand include vs traverse at all from my reading of the docs until you pointed it out. But I can see the difference now.

Now that I know what's happening, I added "true: traverse" to my src/_tags file (not present in the example) which also solves the problem without asking ocamlbuild to traverse my entire project.
(0010974)
gasche (developer)
2014-02-24 07:58

Thanks for the feedback. If you have concrete suggestions for a clearer rewording of the documentation, I'm all ears.
(0010975)
spyder (reporter)
2014-02-24 11:56

That's a tough one. I don't think I've seen any other build system that can traverse for dependencies to build with but not include them in the namespace; the concepts are usually linked and that's what I expected when I was reading the docs. They didn't really explain how traversal was different to include, so I assumed they were basically the same.

You could copy/paste what you wrote here to the start of the subdirectories documentation and it would be a massive help :)
(0010976)
gasche (developer)
2014-02-24 13:04

The distinction is important in OCaml if/when several subdirectories have compilation units of the same (base)name: the compiler itself, but also the tool around it, will react very badly if a single "compilation run" see them at the same time. With the current design, you may have a prog.x86.mlpack that refers to x86/Backend, and prog.x86-64.mlpack that refer to x86-64/Backend, with both subdirectories traversed but not included at each run.
(0010977)
spyder (reporter)
2014-02-25 01:25

I'm getting it now :)

These are all concepts that are probably familiar to experienced OCaml developers but I'm still very new, having spent most of my career developing in Java. For someone like me that traversal vs include explanation you gave above would be invaluable to include in the docs.

- Issue History
Date Modified Username Field Change
2014-02-18 00:14 spyder New Issue
2014-02-18 00:14 spyder File Added: packdep.zip
2014-02-18 02:39 spyder Note Added: 0010935
2014-02-19 20:32 doligez Relationship added related to 0005752
2014-02-21 20:43 gasche Note Added: 0010969
2014-02-23 18:53 gasche Severity major => minor
2014-02-23 18:53 gasche Status new => feedback
2014-02-23 22:39 spyder Note Added: 0010971
2014-02-23 22:39 spyder Status feedback => new
2014-02-24 05:44 gasche Note Added: 0010972
2014-02-24 05:52 spyder Note Added: 0010973
2014-02-24 07:58 gasche Note Added: 0010974
2014-02-24 07:58 gasche Status new => resolved
2014-02-24 07:58 gasche Resolution open => no change required
2014-02-24 07:58 gasche Assigned To => gasche
2014-02-24 11:56 spyder Note Added: 0010975
2014-02-24 13:04 gasche Note Added: 0010976
2014-02-25 01:25 spyder Note Added: 0010977


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker