ocamlbuild icon indicating copy to clipboard operation
ocamlbuild copied to clipboard

lib.mllib with lib.mli but no lib.ml doesn't build

Open dsheets opened this issue 9 years ago • 6 comments

If you have a lib.mllib file for an archive which is to contain Lib from lib.mli but the lib.mli file does not have a corresponding lib.ml file, ocamlbuild will refuse to build the archive by saying it knows of no rules to build target lib.cmo.

dsheets avatar Jan 25 '16 09:01 dsheets

I'm a bit confused, I thought that archives were just collection of compiled implementation units, and that you had to provide the .cmi on the side anyway for the type-checker to find. Does it make sense to have a .mli with no .ml in an archive? How does that work when directly invoking the compiler?

gasche avatar Jan 25 '16 13:01 gasche

That is true but the archive will still be built (but lacking the implementation-less modules) in the other cases. Perhaps the correct solution is to make .mllib files which contain modules without implementations to always fail? There is a disparity between the behaviors when the archive and the implementation-less module share the same name.

dsheets avatar Jan 25 '16 15:01 dsheets

Perhaps the correct solution is to make .mllib files which contain modules without implementations to always fail?

Yes, at least that is the behaviour I would expect.

gasche avatar Jan 25 '16 15:01 gasche

Generally, to use .mli without .ml leads to multiple problems; better to put the content of the .mli in the .ml. I'm not saying that ocamlbuild shouldn't support this use case.

bobot avatar Jan 25 '16 16:01 bobot

If the compiler supports it and libraries use it, I think the rest of the tools should at least try to support it.

dsheets avatar Jan 26 '16 09:01 dsheets

There is no debate here, ocamlbuild does support .mli without .ml.

gasche avatar Jan 26 '16 10:01 gasche