Skip to content

Build Dune Packages #9983

In progress
In progress

Description

@rgrinberg

Currently, the way we build dune packages is by making dune spawn itself with dune build -p. For self evident reasons, this is rather inefficient. We spawn an extra process, create yet another _build directory and copy everything there, resolve all the public libraries, don't respect -j, etc.

What we could do instead is make dune setup the build rules for the downloaded sources and run them.

While the above would be ideal, the refactoring needed to achieve this would be enormous. A simpler solution which at least solves the -j problem is to create a job protocol like API over RPC and have the spawned dune use that.

Activity

  1. added
    package management
    on Feb 12, 2024
  2. shonfeder commented on Oct 10, 2025

    @shonfeder
    Member

    I think this is actually the issues @Alizter was just working on. @Alizter, since you have the context, could you link this to the other related issues, closing redundant issues if necessary, and summarizing the findings of your investigation in the best place?

  3. Alizter commented on Oct 10, 2025

    @Alizter
    Collaborator

    I have investigated the kind of refactoring needed for this, this week, and it has become apparent it will take a lot of work.

    Currently we use our Source_tree as a scaffolding for discovering dune projects and stanzas, which means we don't have infrastructure for adding non-source directories. On top of that, all the dune rules assume that they will be sourced from the source tree rather than a source directory. This means there is no clear way to load rules in arbitrary build directories as of yet. Even if we would undertake such a bold refactoring, we would have to touch lots of unrelated parts of dune which I am more hesitant to do for the purposes of getting package management released.

    On the point of -j raised here however, I no longer think that this is an issue. When we create a dune build command, which is detected during translation of the opam file, we don't actually pass the -j option in our explicit action. This means the subprocess dune uses as many processes as it pleases, which is problematic but not cache-invalidating at least.

  4. self-assigned this
    on May 28, 2026
  5. added theissue type on Jun 5, 2026
  6. removed their assignment
    on Jul 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    package management

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions