fix(melange): depend on selected impl when setting up JS rules for virtual lib#10051
Conversation
0f31513 to
225564d
Compare
| `virt_lib` depend on `concrete_lib`, such that Melange can find | ||
| the correct `.cmj` file, which is needed to emit the correct | ||
| path in `import` / `require`. *) | ||
| lib :: requires_link |
There was a problem hiding this comment.
the callout here is:
- the JS targets of the virtual lib depend on the library artifacts (e.g.
.cm{i,j,t}) of the selected (concrete) implementation
This is analogous to adding the correct .cmx to the link path in native compilation.
| @@ -1 +1 @@ | |||
| print_endline Virt.t | |||
| let () = print_endline Vlib_impl.hello | |||
There was a problem hiding this comment.
just changed this to be the same as the ml implementation. Vlib_impl calls Virt anyway, preserving what we want to test.
jchavarri
left a comment
There was a problem hiding this comment.
The fix and explanation make sense to me, the dependency flow (impl lib depends on virtual lib artifacts) seems "natural".
I wonder if there are cases where the newly added dependency can lead to cycles?
| melc vlib/.vlib.objs/melange/vlib_impl.{cmi,cmj,cmt} (exit 2) | ||
| File "vlib/vlib_impl.ml", line 1: | ||
| Error: Virt not found, it means either the module does not exist or it is a namespace | ||
| melc vlib/.vlib.objs/melange/vlib_impl.{cmi,cmj,cmt} |
There was a problem hiding this comment.
I think the description in line 22 needs to be updated.
It’s actually the other way around: virtual lib JS depends on concrete lib artifacts (because it might call it) |
I wondered about it too, and I think it could only be a problem if there were more than 1 concrete implementations, which is why I opened #10049 to verify it’s not possible. |
a030134 to
7f90d9f
Compare
|
this is now ready for review. Not sure if @rgrinberg needs to take a look? here's a summary of the included commits: |
…rtual lib chore: add changelog entry Signed-off-by: Antonio Nuno Monteiro <anmonteiro@gmail.com>
fix: unrelated melange private-lib-dep test due to output change Signed-off-by: Antonio Nuno Monteiro <anmonteiro@gmail.com>
da68148 to
903a8f3
Compare
CHANGES: ### Added - Add link flags to to `ocamlmklib` for ctypes stubs (ocaml/dune#8784, @frejsoya) - Remove some unnecessary limitations in the expansions of percent forms in install stanza. For example, the `%{env:..}` form can be used to select files to be installed. (ocaml/dune#10160, @rgrinberg) - Allow artifact expansion percent forms (`%{cma:..}`, `%{cmo:..}`, etc.) in more contexts. Previously, they would be randomly forbidden in some fields. (ocaml/dune#10169, @rgrinberg) - Allow `%{inline_tests}` in more contexts (ocaml/dune#10191, @rgrinberg) - Remove limitations on percent forms in the `(enabled_if ..)` field of libraries (ocaml/dune#10250, @rgrinberg) - Support dialects in `dune describe pp` (ocaml/dune#10283, @emillon) - Allow defining executables or melange emit stanzas with the same name in the same folder under different contexts. (ocaml/dune#10220, @rgrinberg, @jchavarri) ### Fixed - coq: Delay Coq rule setup checks so OCaml-only packages can build in hybrid Coq/OCaml projects when `coqc` is not present. Thanks to @vzaliva for the test case and report (ocaml/dune#9845, fixes ocaml/dune#9818, @rgrinberg, @ejgallego) - Fix conditional source selection with `select` on `bigarray` in OCaml 5 (ocaml/dune#10011, @moyodiallo) - melange: fix inconsistency in virtual library implementation. Concrete modules within a virtual library can now refer to its virtual modules too (ocaml/dune#10051, fixes ocaml/dune#7104, @anmonteiro) - melange: fix a bug that would cause stale `import` paths to be emitted when moving source files within `(include_subdirs ..)` (ocaml/dune#10286, fixes ocaml/dune#9190, @anmonteiro) - Dune file formatting: output utf8 if input is correctly encoded (ocaml/dune#10113, fixes ocaml/dune#9728, @moyodiallo) - Fix expanding dependencies and locks specified in the cram stanza. Previously, they would be installed in the context of the cram test, rather than the cram stanza itself (ocaml/dune#10165, @rgrinberg) - Fix bug with `dune exec --watch` where the working directory would always be set to the project root rather than the directory where the command was run (ocaml/dune#10262, @gridbugs) - Regression fix: sign executables that are promoted into the source tree (ocaml/dune#10263, fixes ocaml/dune#9272, @emillon) - Fix crash when decoding dune-package for libraries with `(include_subdirs qualified)` (ocaml/dune#10269, fixes ocaml/dune#10264, @emillon) ### Changed - Remove the `--react-to-insignificant-changes` option. (ocaml/dune#10083, @rgrinberg)
CHANGES: ### Added - Add link flags to to `ocamlmklib` for ctypes stubs (ocaml/dune#8784, @frejsoya) - Remove some unnecessary limitations in the expansions of percent forms in install stanza. For example, the `%{env:..}` form can be used to select files to be installed. (ocaml/dune#10160, @rgrinberg) - Allow artifact expansion percent forms (`%{cma:..}`, `%{cmo:..}`, etc.) in more contexts. Previously, they would be randomly forbidden in some fields. (ocaml/dune#10169, @rgrinberg) - Allow `%{inline_tests}` in more contexts (ocaml/dune#10191, @rgrinberg) - Remove limitations on percent forms in the `(enabled_if ..)` field of libraries (ocaml/dune#10250, @rgrinberg) - Support dialects in `dune describe pp` (ocaml/dune#10283, @emillon) - Allow defining executables or melange emit stanzas with the same name in the same folder under different contexts. (ocaml/dune#10220, @rgrinberg, @jchavarri) ### Fixed - coq: Delay Coq rule setup checks so OCaml-only packages can build in hybrid Coq/OCaml projects when `coqc` is not present. Thanks to @vzaliva for the test case and report (ocaml/dune#9845, fixes ocaml/dune#9818, @rgrinberg, @ejgallego) - Fix conditional source selection with `select` on `bigarray` in OCaml 5 (ocaml/dune#10011, @moyodiallo) - melange: fix inconsistency in virtual library implementation. Concrete modules within a virtual library can now refer to its virtual modules too (ocaml/dune#10051, fixes ocaml/dune#7104, @anmonteiro) - melange: fix a bug that would cause stale `import` paths to be emitted when moving source files within `(include_subdirs ..)` (ocaml/dune#10286, fixes ocaml/dune#9190, @anmonteiro) - Dune file formatting: output utf8 if input is correctly encoded (ocaml/dune#10113, fixes ocaml/dune#9728, @moyodiallo) - Fix expanding dependencies and locks specified in the cram stanza. Previously, they would be installed in the context of the cram test, rather than the cram stanza itself (ocaml/dune#10165, @rgrinberg) - Fix bug with `dune exec --watch` where the working directory would always be set to the project root rather than the directory where the command was run (ocaml/dune#10262, @gridbugs) - Regression fix: sign executables that are promoted into the source tree (ocaml/dune#10263, fixes ocaml/dune#9272, @emillon) - Fix crash when decoding dune-package for libraries with `(include_subdirs qualified)` (ocaml/dune#10269, fixes ocaml/dune#10264, @emillon) ### Changed - Remove the `--react-to-insignificant-changes` option. (ocaml/dune#10083, @rgrinberg)
fixes #7104
TODO:
.cmjwhen trying to inline external field melange-re/melange#1067. need to:Even though the PR is in draft, I'm requesting your reviews to make sure the approach makes sense.