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

Ensure that dune describe computes a transitively closed set of libraries #5395

Closed
wants to merge 14 commits into from

Conversation

esope
Copy link
Collaborator

@esope esope commented Jan 31, 2022

The intention is that, for every library UID that is listed as a
requirement, there must exist a library item with that very UID in the
output of dune describe.

Example:

With an empty foo.ml file, and the following dune file:

(library
 (name foo)
 (preprocess (pps ppx_deriving.ord)))

the dune describe command currently produces the following output:

((library
  ((name foo)
   (uid 5dd4bd87ad37b4f5713085aff4bee9c9)
   (local true)
   (requires (3c8689902dffccb8da94f1a9821d4753))
   (source_dir _build/default)
   (modules
    (((name Foo)
      (impl (_build/default/foo.ml))
      (intf ())
      (cmt (_build/default/.foo.objs/byte/foo.cmt))
      (cmti ()))))
   (include_dirs (_build/default/.foo.objs/byte))))
 (library
  ((name ppx_deriving.runtime)
   (uid 3c8689902dffccb8da94f1a9821d4753)
   (local false)
   (requires (62cfd7aaad132264861d2b6e82476877))
   (source_dir /home/bmontagu/.opam/4.13.1/lib/ppx_deriving/runtime)
   (modules ())
   (include_dirs (/home/bmontagu/.opam/4.13.1/lib/ppx_deriving/runtime)))))

That is to say, the external library ppx_deriving.runtime has a
dependency to another library with UID
62cfd7aaad132264861d2b6e82476877, and that is not listed in the
list of libraries.

With the proposed PR, dune describe now outputs:

((library
  ((name foo)
   (uid 5dd4bd87ad37b4f5713085aff4bee9c9)
   (local true)
   (requires (3c8689902dffccb8da94f1a9821d4753))
   (source_dir _build/default)
   (modules
    (((name Foo)
      (impl (_build/default/foo.ml))
      (intf ())
      (cmt (_build/default/.foo.objs/byte/foo.cmt))
      (cmti ()))))
   (include_dirs (_build/default/.foo.objs/byte))))
 (library
  ((name ppx_deriving.runtime)
   (uid 3c8689902dffccb8da94f1a9821d4753)
   (local false)
   (requires (62cfd7aaad132264861d2b6e82476877))
   (source_dir /home/bmontagu/.opam/4.13.1/lib/ppx_deriving/runtime)
   (modules ())
   (include_dirs (/home/bmontagu/.opam/4.13.1/lib/ppx_deriving/runtime))))
 (library
  ((name result)
   (uid 62cfd7aaad132264861d2b6e82476877)
   (local false)
   (requires ())
   (source_dir /home/bmontagu/.opam/4.13.1/lib/result)
   (modules ())
   (include_dirs (/home/bmontagu/.opam/4.13.1/lib/result)))))

where the missing library result is now part of the output.

This PR is a complement to PR#5376, that adds to the output the libraries used by executables (and that are missing so far).

Signed-off-by: Benoît Montagu benoit.montagu@inria.fr

…ibraries.

The intention is that, for every library UID that is listed as a
requirement, there must exist a library item with that very UID in the
output of ``dune describe``.

Example:

With an empty ``foo.ml`` file, and the following ``dune`` file:
(library
 (name foo)
 (preprocess (pps ppx_deriving.ord)))

the ``dune describe command`` currently produces the following output:

((library
  ((name foo)
   (uid 5dd4bd87ad37b4f5713085aff4bee9c9)
   (local true)
   (requires (3c8689902dffccb8da94f1a9821d4753))
   (source_dir _build/default)
   (modules
    (((name Foo)
      (impl (_build/default/foo.ml))
      (intf ())
      (cmt (_build/default/.foo.objs/byte/foo.cmt))
      (cmti ()))))
   (include_dirs (_build/default/.foo.objs/byte))))
 (library
  ((name ppx_deriving.runtime)
   (uid 3c8689902dffccb8da94f1a9821d4753)
   (local false)
   (requires (62cfd7aaad132264861d2b6e82476877))
   (source_dir /home/bmontagu/.opam/4.13.1/lib/ppx_deriving/runtime)
   (modules ())
   (include_dirs (/home/bmontagu/.opam/4.13.1/lib/ppx_deriving/runtime)))))

That is to say, the external library ``ppx_deriving.runtime`` has a
dependency to another library with UID
``62cfd7aaad132264861d2b6e82476877``, and that is not listed in the
list of libraries.

With the proposed PR, ``dune describe`` now outputs:

((library
  ((name foo)
   (uid 5dd4bd87ad37b4f5713085aff4bee9c9)
   (local true)
   (requires (3c8689902dffccb8da94f1a9821d4753))
   (source_dir _build/default)
   (modules
    (((name Foo)
      (impl (_build/default/foo.ml))
      (intf ())
      (cmt (_build/default/.foo.objs/byte/foo.cmt))
      (cmti ()))))
   (include_dirs (_build/default/.foo.objs/byte))))
 (library
  ((name ppx_deriving.runtime)
   (uid 3c8689902dffccb8da94f1a9821d4753)
   (local false)
   (requires (62cfd7aaad132264861d2b6e82476877))
   (source_dir /home/bmontagu/.opam/4.13.1/lib/ppx_deriving/runtime)
   (modules ())
   (include_dirs (/home/bmontagu/.opam/4.13.1/lib/ppx_deriving/runtime))))
 (library
  ((name result)
   (uid 62cfd7aaad132264861d2b6e82476877)
   (local false)
   (requires ())
   (source_dir /home/bmontagu/.opam/4.13.1/lib/result)
   (modules ())
   (include_dirs (/home/bmontagu/.opam/4.13.1/lib/result)))))

where the missing library ``result`` is now part of the output.

Signed-off-by: Benoît Montagu <benoit.montagu@inria.fr>
bin/describe.ml Show resolved Hide resolved
esope and others added 2 commits January 31, 2022 12:08
@esope
Copy link
Collaborator Author

esope commented Feb 5, 2022

@bobot are you happy with the fix I pushed?

@bobot
Copy link
Collaborator

bobot commented Feb 7, 2022

I'm happy but @rgrinberg would be more expert to judge it, and I don't remember if it should be kept behind an option or who should be warned of changes in the format.

@bobot bobot requested a review from rgrinberg February 7, 2022 14:51
@esope
Copy link
Collaborator Author

esope commented Feb 7, 2022

I'm happy but @rgrinberg would be more expert to judge it, and I don't remember if it should be kept behind an option or who should be warned of changes in the format.

Importantly, the format is the same as before.
The only effect is that new library items might now belong to the output (and there are always external libraries).

@rgrinberg rgrinberg self-assigned this Feb 7, 2022
@rgrinberg
Copy link
Member

The fix itself looks quite good to me. Could you add a test though? It's not obvious that this should be part of the specification of dune describe so a test should witness that.

@esope
Copy link
Collaborator Author

esope commented Feb 10, 2022

This test would trigger non-reproducible outputs, as described in this related PR. I'm first waiting for a solution to that issue, since that issue contains the test you're asking for.

esope and others added 2 commits February 15, 2022 10:08
The tests now include an example where transitive dependencies make a difference.

Signed-off-by: Benoît Montagu <benoit.montagu@inria.fr>
@esope
Copy link
Collaborator Author

esope commented Feb 15, 2022

The other PR I've mentioned was recently merged. I updated the tests.
The tests now contain an example, where the transitive closure of dependencies matters (a PPX rewriter depends on some libs from JaneStreet, that were not part of the non-transitively-closed output of dune describe).

… that must be transitively closed.

Added a test to witness the change.

Signed-off-by: Benoît Montagu <benoit.montagu@inria.fr>
@esope
Copy link
Collaborator Author

esope commented Feb 15, 2022

I integrated the changes from PR#5376.
@rgrinberg: I consider the current PR complete.

@rgrinberg
Copy link
Member

Looks good. Could you update CHANGES?

@rgrinberg rgrinberg added this to the 3.1.0 milestone Feb 16, 2022
Signed-off-by: Benoît Montagu <benoit.montagu@inria.fr>
@esope
Copy link
Collaborator Author

esope commented Feb 16, 2022

Sure. Done.

@rgrinberg
Copy link
Member

Cherry picked onto master. Thanks.

@rgrinberg rgrinberg closed this Feb 16, 2022
@esope esope deleted the describe_trans branch February 17, 2022 08:16
rgrinberg added a commit to rgrinberg/opam-repository that referenced this pull request Apr 15, 2022
…ne-site, dune-rpc, dune-rpc-lwt, dune-private-libs, dune-glob, dune-configurator, dune-build-info and dune-action-plugin (3.1.0)

CHANGES:

- Add `sourcehut` as an option for defining project sources in dune-project
  files. For example, `(source (sourcehut user/repo))`. (ocaml/dune#5564, @rgrinberg)

- Add `dune coq top` command for running a Coq toplevel (ocaml/dune#5457, @rlepigre)

- Fix dune exec dumping database in wrong directory (ocaml/dune#5544, @bobot)

- Always output absolute paths for locations in RPC reported diagnostics
  (ocaml/dune#5539, @rgrinberg)

- Add `(deps <deps>)` in ctype field (ocaml/dune#5346, @bobot)

- Add `(include <file>)` constructor to dependency specifications. This can be
  used to introduce dynamic dependencies (ocaml/dune#5442, @anmonteiro)

- Ensure that `dune describe` computes a transitively closed set of
  libraries (ocaml/dune#5395, @esope)

- Add direct dependencies to $ dune describe output (ocaml/dune#5412, @esope)

- Show auto-detected concurrency on Windows too (ocaml/dune#5502, @MisterDA)

- Fix operations that remove folders with absolute path. This happens when
  using esy (ocaml/dune#5507, @EduardoRFS)

- Dune will not fail if some directories are non-empty when uninstalling.
  (ocaml/dune#5543, fixes ocaml/dune#5542, @nojb)

- `coqdep` now depends only on the filesystem layout of the .v files,
  and not on their contents (ocaml/dune#5547, helps with ocaml/dune#5100, @ejgallego)

- The mdx stanza 0.2 can now be used with `(implicit_transitive_deps false)`
  (ocaml/dune#5558, fixes ocaml/dune#5499, @emillon)

- Fix missing parenthesis in printing of corresponding terminal command for
  `(with-outputs-to )` (ocaml/dune#5551, fixes ocaml/dune#5546, @Alizter)
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

3 participants