-
Notifications
You must be signed in to change notification settings - Fork 407
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
dune variants - how they are supposed to work and scale? #10460
dune variants - how they are supposed to work and scale? #10460
Comments
This comment was marked as outdated.
This comment was marked as outdated.
I can investigate the issue, but the example has to be simplified further. Try to shave off all the unnecessary dependencies in your repro |
Thanks Rudi. I've a much better intuition and will shortly follow up with a much smaller case. |
So, a smaller case is at: https://github.com/hannesm/dune-variants-test (1) We have dune variant In (4), my expectation is that since I chose Here, if you
I have to admit, at the end of the day, I observed the following intuition:
Unfortunately today I was not able to reconstruct this test case (yet?). |
Managed to confirm your repro. The issue is that since default implementations must live in the same package as the virtual libraries, we need to resolve more eagerly than normal libraries. Thus the error that the magic library is missing is coming from that check. Even though you don't need the default implementation as you're correctly overriding it with something else. I suppose we could improve this check not to require the dependencies of the default implementation library to be resolved to check what package it belongs to. As you've alluded though, this is unlikely to be related to your original issue. |
Dear Rudi, thanks for looking into that. If you could point me to a branch where the "check not to require the dependencies of the default implementation library to be resolved" is done, I'd be happy to try this out -- since to me it sounds it may be the same issue... |
You can try the following patch as a start:
This removes the check altogether. |
Back to this issue, I managed to find a smaller reproduction case -- please let me know if this is still too much. The repository at https://github.com/hannesm/dune-variant reproduces the initial issue reported here. It would be great if you can take a look at that. What virtual_modules are used?
|
I tried understanding the example, but there's still too many dependencies for me to really understand what's happening. I can at least start that the following error:
Is caused by the cross compilation setup. The |
Dear @rgrinberg, thanks for looking into it.
This is correct.
What can we do about it? If it helps, we could have a (video)chat about it? My intuition (if this helps)From my perspective, the following should happen: And these variants are marked as optional -- but their dependencies are present (and even mentioned in the dune.build again -- there's
My intuition about "unavailable dependencies" doesn't seem to be accurate -- otherwise dune wouldn't consider In any case, how should we proceed? Would a screen shared session to debug it further help? Would a videochat help? I tried the approach to start from 0 (in the earlier repository) trying to reproduce the issue, but wasn't successful with that. I also was not successful to reproduce without the cross-compilation setup (but I can try again). Maybe others (who know more about dune and mirage -- @samoht @TheLortex ?) could try to minimize the repository? |
I think I managed to reproduce the issue here #10580 |
When compiling an implementation of a virtual library, there's a check that makes sure we don't the virtual library doesn't exist in the closure of the implementation. This check tried to compute the linking closure of the library to do so. However, the linking closure might not be complete if the implementation contains other virtual library. To fix the issue, we use a "partial" linking closure that tries to compute the closure as much as possible, but doesn't fail on missing implementation. Fix #10460 Signed-off-by: Rudi Grinberg <me@rgrinberg.com> <!-- ps-id: eed8cded-17bc-425f-95b8-3e0337e2881d -->
You can try the fix at #10581 |
Thanks @rgrinberg, I tested your PR locally, and it solves the issue I reported here. It would be amazing to have that merged and released soon (since it will allow me to push forward with some other work) :D 🚀 |
When compiling an implementation of a virtual library, there's a check that makes sure we don't the virtual library doesn't exist in the closure of the implementation. This check tried to compute the linking closure of the library to do so. However, the linking closure might not be complete if the implementation contains other virtual library. To fix the issue, we use a "partial" linking closure that tries to compute the closure as much as possible, but doesn't fail on missing implementation. Fix #10460 Signed-off-by: Rudi Grinberg <me@rgrinberg.com>
When compiling an implementation of a virtual library, there's a check that makes sure we don't the virtual library doesn't exist in the closure of the implementation. This check tried to compute the linking closure of the library to do so. However, the linking closure might not be complete if the implementation contains other virtual library. To fix the issue, we use a "partial" linking closure that tries to compute the closure as much as possible, but doesn't fail on missing implementation. Fix ocaml#10460 Signed-off-by: Rudi Grinberg <me@rgrinberg.com>
CHANGES: ### Added - allow libraries with the same `(name ..)` in projects as long as they don't conflict during resolution (via `enabled_if`). (ocaml/dune#10307, @anmonteiro, @jchavarri) - `dune describe pp` now finds the exact module and the stanza it belongs to, instead of guessing the name of the preprocessed file. (ocaml/dune#10321, @anmonteiro) - Print the result of `dune describe pp` with the respective dialect printer. (ocaml/dune#10322, @anmonteiro) - Add new flag `--context` to `dune ocaml-merlin`, which allows to select a Dune context when requesting Merlin config. Add `dune describe contexts` subcommand. Introduce a field `generate_merlin_rules` for contexts declared in the workspace, that allows to optionally produce Merlin rules for other contexts besides the one selected for Merlin (ocaml/dune#10324, @jchavarri) - melange: add include paths for private library `.cmj` files during JS emission. (ocaml/dune#10416, @anmonteiro) - `dune ocaml-merlin`: communicate additional directives `SOURCE_ROOT`, `UNIT_NAME` (the actual name with wrapping) and `INDEX` with the paths to the index(es). (ocaml/dune#10422, @voodoos) - Add a new alias `@ocaml-index` that uses the `ocaml-index` binary to generate indexes that can be read by tools such as Merlin to provide project-wide references search. (ocaml/dune#10422, @voodoos) - merlin: add optional `(merlin_reader CMD)` construct to `(dialect)` stanza to configure a merlin reader (ocaml/dune#8567, @andreypopp) ### Changed - melange: treat private libraries with `(package ..)` as public libraries, fixing an issue where `import` paths were wrongly emitted. (ocaml/dune#10415, @anmonteiro) - install `.glob` files for Coq theories too (ocaml/dune#10602, @ejgallego) ### Fixed - Don't try to document non-existent libraries in doc-new target (ocaml/dune#10319, fixes ocaml/dune#10056, @jonludlam) - Make `dune-site`'s `load_all` function look for `META` files so that it doesn't fail on empty directories in the plugin directory (ocaml/dune#10458, fixes ocaml/dune#10457, @shym) - Fix incorrect warning for libraries defined inside non-existant directories using `(subdir ..)` and used by executables using `dune-build-info` (ocaml/dune#10525, @rgrinberg) - Don't try to take build lock when running `coq top --no-build` (ocaml/dune#10547, fixes ocaml/dune#7671, @lzy0505) - Make sure to truncate dune's lock file after locking and unlocking so that users cannot observe incorrect pid's (ocaml/dune#10575, @rgrinberg) - mdx: link mdx binary with `byte_complete`. This fixes `(libraries)` with foreign archives on Linux. (ocaml/dune#10586, fixes ocaml/dune#10582, @anmonteiro) - virtual libraries: fix an issue where linking an executable involving several virtual libries would cause an error. (ocaml/dune#10581, fixes ocaml/dune#10460, @rgrinberg)
CHANGES: ### Added - allow libraries with the same `(name ..)` in projects as long as they don't conflict during resolution (via `enabled_if`). (ocaml/dune#10307, @anmonteiro, @jchavarri) - `dune describe pp` now finds the exact module and the stanza it belongs to, instead of guessing the name of the preprocessed file. (ocaml/dune#10321, @anmonteiro) - Print the result of `dune describe pp` with the respective dialect printer. (ocaml/dune#10322, @anmonteiro) - Add new flag `--context` to `dune ocaml-merlin`, which allows to select a Dune context when requesting Merlin config. Add `dune describe contexts` subcommand. Introduce a field `generate_merlin_rules` for contexts declared in the workspace, that allows to optionally produce Merlin rules for other contexts besides the one selected for Merlin (ocaml/dune#10324, @jchavarri) - melange: add include paths for private library `.cmj` files during JS emission. (ocaml/dune#10416, @anmonteiro) - `dune ocaml-merlin`: communicate additional directives `SOURCE_ROOT`, `UNIT_NAME` (the actual name with wrapping) and `INDEX` with the paths to the index(es). (ocaml/dune#10422, @voodoos) - Add a new alias `@ocaml-index` that uses the `ocaml-index` binary to generate indexes that can be read by tools such as Merlin to provide project-wide references search. (ocaml/dune#10422, @voodoos) - merlin: add optional `(merlin_reader CMD)` construct to `(dialect)` stanza to configure a merlin reader (ocaml/dune#8567, @andreypopp) ### Changed - melange: treat private libraries with `(package ..)` as public libraries, fixing an issue where `import` paths were wrongly emitted. (ocaml/dune#10415, @anmonteiro) - install `.glob` files for Coq theories too (ocaml/dune#10602, @ejgallego) ### Fixed - Don't try to document non-existent libraries in doc-new target (ocaml/dune#10319, fixes ocaml/dune#10056, @jonludlam) - Make `dune-site`'s `load_all` function look for `META` files so that it doesn't fail on empty directories in the plugin directory (ocaml/dune#10458, fixes ocaml/dune#10457, @shym) - Fix incorrect warning for libraries defined inside non-existant directories using `(subdir ..)` and used by executables using `dune-build-info` (ocaml/dune#10525, @rgrinberg) - Don't try to take build lock when running `coq top --no-build` (ocaml/dune#10547, fixes ocaml/dune#7671, @lzy0505) - Make sure to truncate dune's lock file after locking and unlocking so that users cannot observe incorrect pid's (ocaml/dune#10575, @rgrinberg) - mdx: link mdx binary with `byte_complete`. This fixes `(libraries)` with foreign archives on Linux. (ocaml/dune#10586, fixes ocaml/dune#10582, @anmonteiro) - virtual libraries: fix an issue where linking an executable involving several virtual libries would cause an error. (ocaml/dune#10581, fixes ocaml/dune#10460, @rgrinberg)
First of all, thanks for your work on dune! This is an amazing piece of work.
I recently wanted to remove a lot of functors from MirageOS, since they're not really necessary -- we have at runtime only one thing around anyways (i.e. the network interface for xen will always be one thing -- while the network interface when compiling for unix will be something else). This sounded to me like a perfect use case for your dune variant feature. To a small scale it seemed to work fine, but once I "variantified" the TCP/IP stack, I get not very nice results.
Expected Behavior
I'd expect from a
dune
file with anexecutable
statement that depends on some variants that those will be used across the compilation.Actual Behavior
So, instead of the variant specified in the
executable
statement, the default variant is used. :(Reproduction
Unfortunately, this is rather big at the moment, but let me try:
With all of that, I try to compile the "device-usage/network" unikernel from https://github.com/hannesm/mirage-skeleton/tree/variants
So, the step(s) to reproduce is:
Variant specifications
At the moment, I specify the default_implementation to be "mirage-net.unix", but in the generated dune file, there is:
(libraries ... mirage-net.solo5 ...
.I have no idea, why, as seen above, dune thinks that tcp.icmpv4-direct requires a mirage-net implementation at all, and furthermore how it decides to try the
.unix
one.Debug avenues - remove default_implementation
I tried to remove the
default_implementation
from the above mentioned packages. This results in the following error:Still,
mirage-net.solo5
is a dependency in thedune
file.Move all default_implementations to those I want to use
Yes, this indeed works. But it is pretty unpleasant (would need a shell script for postprocessing), since I had hoped the variant feature would exactly provide me with this:
Quo vadis?
So, any pointers how I can debug this issue further? Or do I hit an intended limit of dune variants that I was not aware of?
Thanks a lot for your time reading this issue. 🐫 🐫
The text was updated successfully, but these errors were encountered: