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

bug in ocamlbuild (building a plugin with -build flag set) plus suggested fix #4410

Closed
vicuna opened this issue Oct 1, 2007 · 2 comments
Closed
Labels

Comments

@vicuna
Copy link

vicuna commented Oct 1, 2007

Original bug ID: 4410
Reporter: inalan
Assigned to: ertai
Status: closed (set by @xavierleroy on 2010-04-29T12:26:09Z)
Resolution: fixed
Priority: normal
Severity: minor
Version: 3.10.0
Fixed in version: 3.10+dev
Category: ~DO NOT USE (was: OCaml general)

Bug description

I use ocaml regularly and have been looking forward to upgrading to 3.10 and using ocamlbuild. I use a combination of windows, cygwin and mingw, and cross-compile on linux (CentOs 4) as well. I discovered a bug in ocamlbuild-0.1 (as included in the ocaml-3.10.0 distribution). When building a plugin using a myocamlbuild.ml file, if the -build-dir option is specified and the build directory does not start with an underscore ('_'), the plugin will build properly but when ocamlbuild actually compiles and executes the plugin the following error is raised:

================ BEGIN DUMP ===============
ocamlbuild -install-lib-dir "C:\devtools\ocaml-3.10\lib\ocamlbuild" -build-dir .build -no-links -log .log src/main.byte
ocamlopt -I "C:\devtools\ocaml-3.10\lib\ocamlbuild" unix.cmxa "C:\devtools\ocaml-3.10\lib\ocamlbuild/ocamlbuildlib.cmxa" myocamlbuild.ml "C:\devtools\ocaml-3.10\lib\ocamlbuild/ocamlbuild.cmx" -o myocamlbuild
SANITIZE: a total of 6 files that should probably not be in your source tree
has been found. A script shell file "sanitize.sh" 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 main.ml.depends in .build/src has suffix .ml.depends
ERROR: Leftover Ocaml compilation files:
File main.cmo in .build/src has suffix .cmo
File main.cmi in .build/src has suffix .cmi
ERROR: Leftover object files:
File myocamlbuild.o in .build has suffix .o
ERROR: Leftover Ocaml compilation files:
File myocamlbuild.cmi in .build has suffix .cmi
File myocamlbuild.cmx in .build has suffix .cmx
Exiting due to hygiene violations.
make: *** [wxO.exe] Error 1

================ END DUMP ===============

As you can see, I prefer to name my build directory ".build". This causes the above mentioned problem. Building instead using "_build" or "_bld" or any other name with an initial underscore, or not using the -build-dir flag, does not cause this problem and the plugin executes correctly. The reason for this error is the following set of lines from ocamlbuild/main.ml, in the definition of 'entry' in the proceed() function:

    (String.length name > 0 && name.[0] <> '_' && not (List.mem name !Options.exclude_dirs))

An easy fix is to add the build directory to the list of excluded paths in the invocation of ocamlbuild:

ocamlbuild -build-dir $(BUILDDIR) -X $(BUILDDIR) etc.

This seems like a less than ideal solution, however. I believe this term:

name.[0] <> '_'

should be excluded from the conditional guard/clause, and instead it should be replaced with:

name <> !Options.build_dir

or that Options.build_dir should be added to Options.exclude_dirs (this latter solution doesn't seem as good because (though this does not currently seem to be the case) exclude_dirs could be used in other places in the system or in plugins).

I thought I might submit an actual patch but I think I will not have time to test it properly, so I decided to just describe a fix instead. I searched the archive but did not find this bug anywhere. The closest match was probably 0004387 (ocamlbuild doesn't use build directory properly), but it's not really the same issue.

@vicuna
Copy link
Author

vicuna commented Nov 14, 2007

Comment author: ertai

Hi,

Thanks for your report.

In the next version <<name <> !Options.build_dir>> will be added.

However note that there is another way to specify the exclusion using the tag system:

$ cat _tags
".build": -traverse

@vicuna
Copy link
Author

vicuna commented Nov 26, 2007

Comment author: ertai

Thanks for the report. This is now fixed in the CVS (both in trunk and release310 branch).

@vicuna vicuna closed this as completed Apr 29, 2010
@vicuna vicuna added the bug label Mar 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant