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

Stop treating toolchains as packages in pkg rules #10534

Conversation

gridbugs
Copy link
Collaborator

This grew out of the work I'm doing to read toolchain information from the opam repo rather than hardcoding it (https://github.com/tarides/team-build-system/issues/11), but the main benefit of this change is that it removes a bunch of special cases I needed to add so that packages containing toolchains were ignored by most of the package rules.

It's also going to make it easier to thread the extra information needed to represent the ocaml-variants toolchain to the parts of the code where it's needed in a later change.

src/dune_rules/pkg_rules.ml Outdated Show resolved Hide resolved
src/dune_rules/pkg_rules.ml Outdated Show resolved Hide resolved
src/dune_pkg/toolchain.ml Outdated Show resolved Hide resolved
src/dune_rules/pkg_rules.ml Show resolved Hide resolved
src/dune_rules/pkg_rules.ml Outdated Show resolved Hide resolved
Previously toolchains were treated as special packages by the package
rules logic. This change removes toolchains from the package
dependency graph used by package rules (but not from any other part of
dune such as the solver or lockfiles). This separation lets us remove
a bunch of special treatment for packages that contain toolchains.

Signed-off-by: Stephen Sherratt <[email protected]>
@gridbugs gridbugs force-pushed the stop-treating-toolchains-as-packages-in-pkg-rules branch from a061aa4 to 97f0934 Compare May 20, 2024 10:21
@gridbugs
Copy link
Collaborator Author

@Leonidas-from-XIV can you take a second look at this please

Copy link
Collaborator

@Leonidas-from-XIV Leonidas-from-XIV left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fairly good with the new generalized lock.

src/dune_engine/scheduler.mli Outdated Show resolved Hide resolved
| Error e -> Fiber.return @@ Error e
| Ok `Success -> Fiber.return (Ok `Success)
| Ok `Failure ->
let sleep_duration_s = 0.1 in
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could possibly be pulled out of the function. I don't know, even in the original code it is an admittedly ugly bit.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've split this into two mutually recursive closures to avoid needing to pass as much info from one recursive call to the next.

let fd =
Unix.openfile
(Path.to_string lock_path)
[ Unix.O_CREAT; O_WRONLY; O_SHARE_DELETE; Unix.O_CLOEXEC ]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That second Unix there can be removed.

src/dune_pkg/toolchain.ml Outdated Show resolved Hide resolved
Signed-off-by: Stephen Sherratt <[email protected]>
@gridbugs gridbugs force-pushed the stop-treating-toolchains-as-packages-in-pkg-rules branch from 97f0934 to 020b2ec Compare May 21, 2024 01:52
Signed-off-by: Stephen Sherratt <[email protected]>
This prevents multiple concurrent instances of dune interfering with
one another while installing toolchains.

Signed-off-by: Stephen Sherratt <[email protected]>
@gridbugs gridbugs force-pushed the stop-treating-toolchains-as-packages-in-pkg-rules branch from 5712586 to c740f6a Compare May 22, 2024 08:28
@gridbugs gridbugs merged commit 04fdc9c into ocaml:toolchains May 22, 2024
24 of 28 checks passed
@gridbugs gridbugs deleted the stop-treating-toolchains-as-packages-in-pkg-rules branch May 22, 2024 09:25
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.

None yet

2 participants