Skip to content

Conversation

gridbugs
Copy link
Collaborator

@gridbugs gridbugs commented Oct 3, 2025

This allows the dependencies of the project to be shared with dev tools, preventing unnecessarily rebuilding dependencies while building a tool if an identical version of the package has already been built or vice versa.

This requires storing build artifacts of dependencies of dev tools and the project (when built in the "default" context) in a single directory, since their relative path within the _build directory is part of the key used to cache build artifacts. Previously the build artifacts of a package were placed in a directory named after that package, however since dev tools and the project may depend on different versions of the same package, directories needed to be renamed to avoid collisions. Even if the project and dev tools rely on the same version of some package, it may still need to be rebuilt on occasion due to the presence/absence of depopts, or due to manual modification to lockfiles. For this reason, the directories containing package build artifacts contain in their name, a hash of the contents of the lockfile of the metadata in the package's transitive dependency closure.

This change introduces the contents of a "package slug" which is a unique directory name for a package comprising its name, version, and dependency closure hash. The DB type used to store metadata while building packages has been updated to be keyed based on slugs, and to store package metadata for dev tools and the project's default build context in the same table to allow dependencies to be shared.

Fixes #12491

This allows the dependencies of the project to be shared with dev tools,
preventing unnecessarily rebuilding dependencies while building a tool
if an identical version of the package has already been built or vice
versa.

This requires storing build artifacts of dependencies of dev tools and
the project (when built in the "default" context) in a single directory,
since their relative path within the _build directory is part of the key
used to cache build artifacts. Previously the build artifacts of a
package were placed in a directory named after that package, however
since dev tools and the project may depend on different versions of the
same package, directories needed to be renamed to avoid collisions. Even
if the project and dev tools rely on the same version of some package,
it may still need to be rebuilt on occasion due to the presence/absence
of depopts, or due to manual modification to lockfiles. For this reason,
the directories containing package build artifacts contain in their
name, a hash of the contents of the lockfile of the metadata in the
package's transitive dependency closure.

This change introduces the contents of a "package slug" which is a
unique directory name for a package comprising its name, version, and
dependency closure hash. The DB type used to store metadata
while building packages has been updated to be keyed based on slugs, and
to store package metadata for dev tools and the project's default build
context in the same table to allow dependencies to be shared.

Signed-off-by: Stephen Sherratt <[email protected]>
@rgrinberg
Copy link
Member

Do you mind rebasing? I'll do a more complete review then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Installing the ocamllsp dev tool rebuilds the compiler unnecessarily
2 participants