Skip to content

fix(ml-sources): check that a library is available before tracking it - #10355

Merged
anmonteiro merged 1 commit into
ocaml:mainfrom
anmonteiro:anmonteiro/ml-sources-handle-optional-libraries
Apr 15, 2024
Merged

anmonteiro merged 1 commit into
ocaml:mainfrom
anmonteiro:anmonteiro/ml-sources-handle-optional-libraries

Conversation

@anmonteiro

Copy link
Copy Markdown
Collaborator

Since #10307, dune started allowing libraries to share the same name.

Thus, checking enabled_if isn't enough for libraries; dune now needs to check whether the library is available before tracking it in ml_sources.

addresses #10307 (comment)

@anmonteiro
anmonteiro force-pushed the anmonteiro/ml-sources-handle-optional-libraries branch 2 times, most recently from bed7faa to c660244 Compare April 2, 2024 07:03
@anmonteiro

Copy link
Copy Markdown
Collaborator Author

@rgrinberg

Copy link
Copy Markdown
Member

One issue with this PR is that it's introducing a library database look up before we're able to resolve the sources of a library. That now has the potential for cycles. E.g:

(rule
 (with-stdout-to foo "m_%{lib-available:bar"))
(library
 (name foo)
 (modules %{read:foo}))

It would be better to delay this availability check until the source is needed by somebody

@anmonteiro

Copy link
Copy Markdown
Collaborator Author

One issue with this PR is that it's introducing a library database look up before we're able to resolve the sources of a library. That now has the potential for cycles. E.g:

(rule
 (with-stdout-to foo "m_%{lib-available:bar"))
(library
 (name foo)
 (modules %{read:foo}))

It would be better to delay this availability check until the source is needed by somebody

This cycle is present even if I revert my diff. Are you suggesting that we're adding to it rather than causing it?

@anmonteiro
anmonteiro force-pushed the anmonteiro/ml-sources-handle-optional-libraries branch from c660244 to cea6fcc Compare April 3, 2024 00:47
@anmonteiro

Copy link
Copy Markdown
Collaborator Author

I changed the implementation to delay querying Lib.DB.available_by_id until we query for modules_and_obj_dir. The implementation is fairly minimal, but it makes modules_and_obj_dir return a Memo.t and an extra Lib.DB.t argument, which make the diff a bit larger.

@anmonteiro
anmonteiro requested a review from jchavarri April 3, 2024 00:48
@anmonteiro
anmonteiro force-pushed the anmonteiro/ml-sources-handle-optional-libraries branch 5 times, most recently from 55d7708 to 0a42bd7 Compare April 4, 2024 21:49
@anmonteiro

Copy link
Copy Markdown
Collaborator Author

@rgrinberg I think this is still waiting for another look.

@rgrinberg

Copy link
Copy Markdown
Member

I'll try and take a look again this week

@anmonteiro
anmonteiro force-pushed the anmonteiro/ml-sources-handle-optional-libraries branch 2 times, most recently from c1766de to 027131a Compare April 12, 2024 22:18
Comment thread src/dune_rules/ml_sources.mli Resolved
Since ocaml#10307, dune started allowing libraries to share the same name.
Thus, checking `enabled_if` isn't enough for libraries; dune now needs
to check whether the library is available before tracking it in
ml_sources

Signed-off-by: Antonio Nuno Monteiro <[email protected]>
@anmonteiro
anmonteiro force-pushed the anmonteiro/ml-sources-handle-optional-libraries branch from 027131a to e1f08ed Compare April 15, 2024 20:46
@anmonteiro
anmonteiro merged commit 2a0d4e8 into ocaml:main Apr 15, 2024
@anmonteiro
anmonteiro deleted the anmonteiro/ml-sources-handle-optional-libraries branch April 15, 2024 21:03
@Alizter Alizter added this to the 3.16.0 milestone Jul 9, 2026
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.

4 participants