ocamlbuild icon indicating copy to clipboard operation
ocamlbuild copied to clipboard

0.14.2 Failure: Cannot find "ocamlbuild.cmo" in ocamlbuild -where directory.

Open SnarkBoojum opened this issue 2 years ago • 7 comments

Ocamlbuild 0.14.2 compiles successfully with "make", but at the "make test" stage, several of the tests fail with a similar error:

Warning: Won't be able to compile a native plugin
Failure: Cannot find "ocamlbuild.cmo" in ocamlbuild -where directory.

Version 0.14.1 is installed on my system, and I'm using OCaml 4.13.1.

I tested:

  1. "make && make test" in 0.14.1's source directory works on my system ;
  2. "make && make test" in 0.14.2's source directory fails on my system ;
  3. "make && make test" in 0.14.1's source directory works in a chroot without an installed ocamlbuild ;
  4. "make && make test" in 0.14.2's source directory fails in a chroot without an installed ocamlbuild.

So the problem is really something new in 0.14.2.

SnarkBoojum avatar Jun 23 '23 10:06 SnarkBoojum

Here is my understanding of the issue:

  • the bug was introduced in #319, which implemented support for OCaml 5.1
  • the issue is that, after #319, ocamlbuild.cmo is compiled in a different directory from other object files (bin/ instead of src/), while our test infrastructure assumes that all library/plugin files can be found in the same directory that is passed to ocamlbuild using the -install-lib-dir option
  • -install-lib-dir sets a single constant, I cannot pass several directories there
  • the reason why #319 moved source files around is to solve a small issue with the Makefile-based build system, that would build all source files with -for-pack Ocamlbuild_pack, even though some files were actually not packed. This used to be morally incorrect but work fine, and it is now explicitly rejected by OCaml 5.x ( see https://github.com/dbuenzli/mtime/issues/45 ).

There are two fixes that would make sense:

  1. we could consider adding support for providing several "library directories" to ocamlbuild at runtime; those are used when linking plugins
  2. or we could change the build system to store all build objects in a single directory, finding another workaround to the -for-pack issue

Approach (1) is nicer on paper but it requires more effort, and is more invasive/risky. Approach (2) is somewhat ugly but should make no observable change to ocamlbuild users (after install).

Given the fact that ocamlbuild is now in maintenance-only mode, I would vote for approach (2).

gasche avatar Jun 23 '23 12:06 gasche

Or perhaps I should wait until I upgrade to OCaml 5.1 before I upgrade to ocamlbuild 0.14.2 ?

SnarkBoojum avatar Jun 23 '23 12:06 SnarkBoojum

Yes, 0.14.1 should be fine if your OCaml version is 5.0 or older.

gasche avatar Jun 23 '23 12:06 gasche

(But I still need to fix this bug in the current codebase. Thanks for the report!)

gasche avatar Jun 23 '23 12:06 gasche

Edit. Ignore this comment

The same error message occurs on Windows but with a different root cause. Filed a bug at https://github.com/diskuv/dkml-installer-ocaml/issues/70 and submitted a PR to this ocamlbuild project.

jonahbeckford avatar Sep 19 '23 20:09 jonahbeckford

@jonahbeckford I don't understand the relation between the patches you are showing and the issue here, that I think is related to the ocamlbuild build system and testsuite layout that breaks make test. Could it be that you see the same error message, but in a different situation (not only when running make test, but also after ocamlbuild is installed)? If so, I think we should open a separate issue or stick to the PRs you are opening (thanks!), to not muddy the conversation here.

gasche avatar Sep 20 '23 06:09 gasche

Same error message. I'll stick to the PRs and edit my previous comment.

jonahbeckford avatar Sep 20 '23 06:09 jonahbeckford

This can be closed (by #328)

hhugo avatar May 17 '24 08:05 hhugo