Skip to content

Overlapping Dependencies in Lock Directory ("in and out problem") #8652

Description

@rgrinberg

Apologies for the title, better suggestions are welcome. The issue is best understood by an example.

Consider the following setup:

$ cat dune.lock/b.pkg
(depends c)
$ cat dune-project
...
(package
 (name a)
 (deps b))
(package
 (name c))

So a and c exist in the workspace while b is fetched via the lock directory. If you follow the dependency edges of a, you will go through the lock directory and back to the workspace. Such dependencies edges are currently not allowed in dune.

The reason is the following cycle:

  1. To build anything in the workspace, we need to lookup some library, say x.
  2. Looking up x requires us to build every single package in the lock directory
  3. If a package in the lock directory depends on a package in the workspace, that will immediately result in a cycle.

We could do better by limiting the search to a subset of packages in some situations. For example, if we're building foo.lib in package foo, we look at the package dependencies of foo to determine the set of packages that need to be built to resolve the library.

This of course only works for building libraries or executables inside packages. A private library or executable belongs to no package so the trick above fails (However, implementing #8650 would allow this to work anyway).

Anyway, if we manage to get over the cycles, we'll need some additional setup to make the build work. In the example above, package b needs the installed layout of c. We essentially already have this in _build/install, but it needs to be subset of files needed by b (otherwise we'll run into different cycles). In particular, we only need the install rules for c. That's not a problem, we just need to setup the install rules again for every package in the workspace in _private/ individually. So in practice, we'll just have rules in _private/default/.pkg/$pkg for every package in the workspace.

Pinned by ElectreAAS

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

package managementDune's package management — `(pkg)` stanza, lockdirs, `dune pkg` commands

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions