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

Ocamlbuild finds erroneous sanitization errors when using the -build-dir option #4502

vicuna opened this issue Feb 12, 2008 · 1 comment


Copy link

@vicuna vicuna commented Feb 12, 2008

Original bug ID: 4502
Reporter: Bardou
Assigned to: @gasche
Status: closed (set by @xavierleroy on 2015-12-11T18:19:50Z)
Resolution: fixed
Priority: normal
Severity: minor
Version: 3.11+dev
Target version: 4.01.0+dev
Category: ~DO NOT USE (was: OCaml general)
Duplicate of: #5503

Bug description

I use ocamlbuild with the -build-dir option. In my project, to get the bug, I compile once, using ocamlbuild with option "-build-dir bin", from a clean directory and everything's fine. Then I compile using the same command and the hygiene test finds not hygienous files in the "bin" directory. Which is absolutely normal, because it is the build directory. The "bin" directory is not included using -I or anything.

Using -no-hygiene allows to compile correctly, and cached files are used correctly.

I was unable to reproduce exactly the same bug in a small example. However, I did manage to get something very similar by changing the -build-dir directory between the two commands. I found that the _tags file is needed for the bug to happen. Here is how to reproduce the bug:

~/caml/test> ls
a _tags
~/caml/test> ls a
~/caml/test> cat _tags
: include
~/caml/test> cat a/
print_int 1; print_newline ();;
~/caml/test> ocamlbuild -build-dir bli test.byte
Finished, 3 targets (0 cached) in 00:00:00.
~/caml/test> ocamlbuild -build-dir bla test.byte
SANITIZE: a total of 3 files that should probably not be in your source tree
has been found. A script shell file "bla/" is being created.
Check this script and run it to remove unwanted files or use other options
(such as defining hygiene exceptions or using the -no-hygiene option).
IMPORTANT: I cannot work with leftover compiled files.
ERROR: Leftover dependency files:
File in bli/a has suffix .ml.depends
ERROR: Leftover Ocaml compilation files:
File test.cmo in bli/a has suffix .cmo
File test.cmi in bli/a has suffix .cmi
Exiting due to hygiene violations.
Compilation unsuccessful after building 0 targets (0 cached) in 00:00:00.

Copy link

@vicuna vicuna commented Jun 17, 2013

Comment author: @gasche

There was a problem with the test excluding the build directory from hygiene checking. Funnily enough, this problem was introduced when fixing #5503, that is after the initial report here.

I'm not exactly sure which problem Romain originally run into, but I fixed the build_dir issue (and added a regression test for this in Wojciech's wonderful testsuite).

Note that ocamlbuild has "true: traverse" enabled (which happens when you have either a _tags or a in the directory), the following will still fail in general:
ocamlbuild hello.byte -build-dir titi # succeeds
ocamlbuild hello.byte -build-dir toto # hygiene problem with 'titi'

The reason for the failure is that the first command creates a new directory 'titi', which will not be excluded from the second run (it is not the build directory anymore), and will therefore be checked for hygiene. If you do that, you need to tag with "-traverse".

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

Successfully merging a pull request may close this issue.

None yet
2 participants