Skip to content

Add library field (excluded_modules)#13682

Open
nojb wants to merge 3 commits intoocaml:mainfrom
nojb:excluded_modules
Open

Add library field (excluded_modules)#13682
nojb wants to merge 3 commits intoocaml:mainfrom
nojb:excluded_modules

Conversation

@nojb
Copy link
Collaborator

@nojb nojb commented Feb 26, 2026

This PR (which arose from a local patch that we have at LexiFi) adds a new field to the (library) stanza: (excluded_modules). This field (which is similar to (private_modules)) specifies a list of modules that:

  • are compiled when the library is compiled,
  • are not "seen" by non-excluded modules,
  • are able to "see" all modules (excluded and non-excluded),
  • are not linked into the final library, nor installed, etc

In our setting inside LexiFi, we define a library which contains the main part of our application code where the exact list of modules can vary from client to client, so we generate the list of modules dynamically using (:include). However, we want to make sure that the rest of the modules (which are not "active" for the current client) continue to compile. This feature is useful whenever you have "inactive" modules that you wish to make sure they still compile.

This feature can be simulated by introducing a second library, but doing so incurs in a substantial penalty due to the unnecessary recompilations caused by Dune's coarse-grained inter-library dependency approximation, as well as extra linking steps which can be quite slow.

Doc and tests are included.

nojb added 3 commits February 26, 2026 10:43
Signed-off-by: Nicolas Ojeda Bar <n.oje.bar@gmail.com>
Signed-off-by: Nicolas Ojeda Bar <n.oje.bar@gmail.com>
Signed-off-by: Nicolas Ojeda Bar <n.oje.bar@gmail.com>
@Alizter Alizter self-requested a review February 27, 2026 11:48
@rgrinberg
Copy link
Member

At first glance, this seems like a rather niche feature that's not going to be beneficial to many users. On the other hand, it does seem like there's something missing here in dune. Is it so difficult to keep this patch in your fork while we're still thinking of a way to generalize this feature?

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.

2 participants