Skip to content

Conversation

@ejgallego
Copy link
Collaborator

@ejgallego ejgallego commented Jun 27, 2025

We now install a rocq-package file for each Rocq theory. This way, when Rocq developments build with Dune are globally installed, we can find out additional metadata, such as the list of their dependencies.

Fixes #11012 fixes #11483

TODO:

  • update changelog
  • update documentation

Note: rebased on top of #12035

Joint work with @Lysxia

@ejgallego ejgallego added the coq label Jun 27, 2025
let+ theory = create_from_coqpath ~boot_id cp in
Legacy theory
let db = assert false in
let dir = assert false in
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ejgallego What should those be?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dir and db are useful in the memo table as to distinguish stanzas that may appear (and be private) in different composed builds.

I think we can have a case where two identical stanzas live in two separate directories, if these are private. I'm not sure why dir is not enough here tho, I'd dare to say that stanzas are uniquely identified by the pair (dir, stanza)

We can ask Rudy once we get the patch more advanced, I guess for now we can pass db = installed_db and dir the directory we found the rocq-package file.

;;

let create_from_stanza_impl (coq_db, db, dir, (s : Coq_stanza.Theory.t)) =
let create_from_coq_package_impl (coq_db, db, dir, (s : Coq_package.meta)) =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our initial idea was to convert a Coq_package into a Coq_stanza but some fields don't seem easy to populate, so I am trying the other way around. However this memo table relies on physical equality of Coq_stanza so I'm not sure this still works as expected.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which fields are not easy to populate? I think we should record enough info in the Coq_package as to be able to do so.

Indeed the equality here is tricky; I'll have a look later on.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

project: DuneProject.t is the one I was having trouble with.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see! This is indeed not needed for the db, I'd suggest to make it an option for now, there are already some codepaths where we use get_exn for it.

@Lysxia
Copy link
Contributor

Lysxia commented Jun 30, 2025

I made some progress. Now it looks like I broke the finding of plugins:

File "test/blackbox-tests/test-cases/coq/compose-installed-plugin.t/run.t", line 1, characters 0-0:
...
+  File "$TESTCASE_ROOT/lib/coq/user-contrib/Bar/rocq-package", line 3, characters 9-22:
+  3 | (plugins global.plugin)
+               ^^^^^^^^^^^^^
+  Error: Library "global.plugin" not found.
+  -> required by theory Bar in
+     $TESTCASE_ROOT/lib/coq/user-contrib/Bar/rocq-package:2
+  -> required by _build/default/.Foo.theory.d
+  -> required by alias all

@ejgallego
Copy link
Collaborator Author

I made some progress. Now it looks like I broke the finding of plugins:

File "test/blackbox-tests/test-cases/coq/compose-installed-plugin.t/run.t", line 1, characters 0-0:
...
+  File "$TESTCASE_ROOT/lib/coq/user-contrib/Bar/rocq-package", line 3, characters 9-22:
+  3 | (plugins global.plugin)
+               ^^^^^^^^^^^^^
+  Error: Library "global.plugin" not found.
+  -> required by theory Bar in
+     $TESTCASE_ROOT/lib/coq/user-contrib/Bar/rocq-package:2
+  -> required by _build/default/.Foo.theory.d
+  -> required by alias all

I think this test-case is for the deprecated method of installing plugins in user-contrib, so IMHO it is fine if it broken.

You could fix it by scanning the cmxs files, but given that Rocq 9 doesn't support this anymore, IMHO not worth it.

@ejgallego
Copy link
Collaborator Author

You could fix it by scanning the cmxs files, but given that Rocq 9 doesn't support this anymore, IMHO not worth it.

I'm sorry I'll be away for the rest of the week, but as soon as I'm back I'll rebase this on top of `(lang rocq ...) which should avoid this problem.

@ejgallego ejgallego added rocq and removed coq labels Jul 17, 2025
@ejgallego ejgallego force-pushed the rocq_package branch 4 times, most recently from c313f84 to 0e8877f Compare July 18, 2025 16:10
(** Our final final resolve is used externally, and should return the
library data found from the previous iterations. *)
let resolve rocq_db (loc, name) =
let resolve ~db rocq_db (loc, name) =
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the db parameter here may not be right, note what we do for the case in Found_stanza, but I'm not a 100% sure.

In principle, it indeed seems wrong for us to resolve the OCaml plugin information with the library DB that belongs to a stanza, in this case for example, private ML libraries would be present. So I guess we should have the code to capture the right DB here.

However, this requires a bit more thinking.

@Lysxia
Copy link
Contributor

Lysxia commented Nov 17, 2025

Just rebased on main along with #12035, still wip.

ejgallego and others added 2 commits November 25, 2025 22:26
We now install a `rocq-package` file for each Rocq theory. This way,
when Rocq developments build with Dune are globally installed, we can
find out additional metadata, such as the list of their dependencies.

Fixes ocaml#11012 fixes ocaml#11483

TODO:

- update changelog
- update documentation

Co-authored-by: Li-yao Xia <[email protected]>
Signed-off-by: Emilio Jesus Gallego Arias <[email protected]>
Signed-off-by: Emilio Jesus Gallego Arias <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dune-Coq: support transitive dependencies even for installed theories Coq cannot find the cmxs file for transitive ocaml dependencies

2 participants