Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pkg: defer evaluating platform vars in commands #11475

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

gridbugs
Copy link
Collaborator

Package build and install commands are expressions that generate the command to run by evaluating a series of conditional statements. This allows the commands to be tailored to the current machine where the command is being run. Previously dune would evaluate platform-specific variables (e.g. os, arch) in these expressions at solve-time, producing lockfiles specialized to the machine where they are solved. This change defers evaluation of these variables until build-time.

The consequence of deferring evaluation of platform variables to build time is that lockfiles will preserve more of the conditional logic found in the corresponding opam file. Note that some variables are still evaluated, such as with-test, as these variables are not based on the platform. The benefit of deferring evaluation of platform variables is that users of computers that differ from the computer where the lockfile was generated will be able to run the build/install commands specialized for their computer, which is more likely to work than attempting to run the build/install commands specialized for the computer where the lockfile was generated.

Note that this change alone is not sufficient for making lockfiles portable, as it doesn't address the fact that the dependencies of a package can also vary depending on platform-specific variables.

Package build and install commands are expressions that generate the
command to run by evaluating a series of conditional statements. This
allows the commands to be tailored to the current machine where the
command is being run. Previously dune would evaluate platform-specific
variables (e.g. os, arch) in these expressions at solve-time, producing
lockfiles specialized to the machine where they are solved. This change
defers evaluation of these variables until build-time.

The consequence of deferring evaluation of platform variables to build
time is that lockfiles will preserve more of the conditional logic found
in the corresponding opam file. Note that some variables are still
evaluated, such as `with-test`, as these variables are not based on the
platform. The benefit of deferring evaluation of platform variables is
that users of computers that differ from the computer where the lockfile
was generated will be able to run the build/install commands specialized
for their computer, which is more likely to work than attempting to run
the build/install commands specialized for the computer where the
lockfile was generated.

Note that this change alone is not sufficient for making lockfiles
portable, as it doesn't address the fact that the dependencies of a
package can also vary depending on platform-specific variables.

Signed-off-by: Stephen Sherratt <[email protected]>
@gridbugs gridbugs requested a review from rgrinberg February 11, 2025 05:00
@gridbugs
Copy link
Collaborator Author

@rgrinberg let me know if you'd like this change to be behind a feature flag.

@rgrinberg
Copy link
Member

The last time we tried doing this, we weren't able to correctly model the semantics of opam's formula evaluation in the dune language. Did we solve those problems?

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

Successfully merging this pull request may close these issues.

3 participants