Can someone explain the text about multi-packages repositories in the dune README? (https://github.com/ocaml/dune#gracefully-handles-multi-package-repositories)
In particular, it says:
When building via Opam, it is able to correctly use libraries that were previously installed, even if they are already present in the source tree
I have an opam file for pkg1
that lives in the same repository as pkg2
and depends on it.
["dune" "build" "--display=short" "-p" "pkg1,pkg2" "-j" jobs]
Now if I do opam install pkg1
, it first installs pkg2
(as expected), but then when it installs pkg1
it recompiles all the files from pkg2
as well! Based on the text above I would expect that dune automatically detects the situation and does not compile pkg2
twice. Can someone explain what is going on?
If I just use
["dune" "build" "-p" "pkg1" "-j" jobs]
I get the following error:
# File "theories/lang/dune", line 7, characters 4-11:
# 7 | (theories pkg2)
# ^^^^
# Error: Theory pkg2 not found
are these Coq packages? Compositional builds don't work for Coq
you can still get the effects but that requires some surgery: basically, remove all dune-project
but the top-level one.
_However_, even then I'm surprised by (theories pkg2)
, because theories
takes a list of logical prefixes.
For instance, I've locally used (theories iris.heap_lang)
to let Iron depend on iris heap_lang
Yes, these are Coq packages (for context, this is the concrete MR I am working on: https://gitlab.mpi-sws.org/iris/refinedc/-/merge_requests/129)
There is only one dune-project
. I am not sure what you mean with theories taking a list of logical prefixes. Doesn't it just take a list of names of other coq.theory
?
See e.g. https://gitlab.mpi-sws.org/iris/refinedc/-/blob/1b6606a3870798ddc8ed1643d42f95d03974916d/theories/lang/dune
(Note that the MR currently contains a hack to remove all mentions of pkg2
/ coq-lithium
in the dune
files when installing, but I would like to not use that hack.)
Doesn't it just take a list of names of other coq.theory?
Nevermind, same thing [those names are passed to -Q
/-R
as well as "logical prefixes" (the manual uses "logical directory" instead, not sure where I picked this up)].
Anyway, you wrote (theories lithium)
not (theories coq-lithium)
, while the other pkg2
is coq-lithium
— so that part seems alright.
I am not 100% confident, but I suspect this cannot be fixed without compositional builds. What that text means is that for OCaml, when pkg2 is installed, dune notices (with ocamlfind) and resolves your dependency against installed libraries. For Coq, it'd need to do the same, but coqfind
is not a thing.
and I guess opam stops the build artifacts from pkg2 to be used for pkg1, hence the recompilation
I see, thanks for the explanation!
Paolo Giarrusso said:
I am not 100% confident, but I suspect this cannot be fixed without compositional builds. What that text means is that for OCaml, when pkg2 is installed, dune notices (with ocamlfind) and resolves your dependency against installed libraries. For Coq, it'd need to do the same, but
coqfind
is not a thing.
Actually, dune creates a dummy ocamlfind
package here. I've had a look at the issue, and it seems that the problem comes from the fact that dune
searches for the coq-lithium
package locally, and not from its installed version. I suspect that this could be fixed by filtering all members of the (theories ...)
stanza that are part of other packages.
(I mean, when building a single package.)
Does that dummy ocamlfind
package lists which theories
are included?
because that could indeed help (even if Emilio might have wanted to do a cleaner fix)
No it does not, but my hope was that changing (theories coq-lithium)
into (libraries coq-lithium)
would help. But it does not.
But really, dune should be able to detect that the coq-lithium
package (providing the lithium
theory) is installed, and thus do not look for it locally.
Indeed, that sounds like be the best solution.
I will get back to you folks, but indeed, if you check where the libraries are scanned, we don't cross "scopes"
a scope is something with a dune-project
root
the way we do things now, each scope gets its independent databse
for ocaml, there is a fallback database
so all libraries are in the scope-db
but in the fallback database, only _public_ libs are
there is a tree here
See two prototypes here https://github.com/ejgallego/dune/tree/coq+compose_interscope and https://github.com/ejgallego/dune/tree/coq+compose_interscope2
main trick is actually ordering of initialation
Last updated: Jun 04 2023 at 22:30 UTC