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

Add support for coqdep flags. #11094

Merged
merged 2 commits into from
Nov 13, 2024
Merged

Add support for coqdep flags. #11094

merged 2 commits into from
Nov 13, 2024

Conversation

rlepigre
Copy link
Contributor

@rlepigre rlepigre commented Nov 4, 2024

This includes the following:

  • A coqdep_flags field in the env stanza (under coq).
  • A coqdep_flags field in the coq.theory stanza.

CC @ejgallego @Alizter.

@rlepigre
Copy link
Contributor Author

rlepigre commented Nov 4, 2024

We could discuss whether :standard should be -w +all for coqdep_flags, which I think would make sense.

@Alizter
Copy link
Collaborator

Alizter commented Nov 4, 2024

Does coqdep from 8.16 support warnings? If not, you might need to guard these features by the Coq version too.

@Alizter Alizter added the coq label Nov 4, 2024
@rlepigre rlepigre force-pushed the coqdep-flags branch 2 times, most recently from 7e7ed7d to c025041 Compare November 4, 2024 14:24
@rlepigre
Copy link
Contributor Author

rlepigre commented Nov 4, 2024

Does coqdep from 8.16 support warnings? If not, you might need to guard these features by the Coq version too.

This feature is not about warnings specifically, so it should still be relevant for any Coq version. However, my test relies on warnings, which are not supported in 8.16 though (they are supported since 8.19.

The easiest solution for me would probably to bump the version of Coq used in CI to 8.19.0. How hard would it be?

@rlepigre
Copy link
Contributor Author

The easiest solution for me would probably to bump the version of Coq used in CI to 8.19.0. How hard would it be?

@Alizter do you know what would need to happen for that?

@Alizter
Copy link
Collaborator

Alizter commented Nov 11, 2024

I think rather than relying on a particular behaviour of coqdep, we should just observe the flags passed to coqdep instead. Have a look at how I did this for coqdoc in coqdoc-flags.t. You can pass nonsense flags if you like since we are just inspecting _build/log and seeing what arguments are there.

Bumping 8.16 will be a whole other issue for now, since many tests will need to be updated. It's also good to keep this lower bound in the dune CI. Dune + Coq is tested upstream in nixpkgs and coq-nix-toolbox FTR.

@rlepigre
Copy link
Contributor Author

OK, I went with a slightly different approach for the test, so now everything seems to be fine. Funnily enough, this revealed a bug: I was duplicating the flags coming from the coq.theory stanza. This is now fixed, and as far as I am concerned this MR is ready.

@Alizter Alizter self-requested a review November 12, 2024 18:06
@Alizter
Copy link
Collaborator

Alizter commented Nov 12, 2024

Looks good. Only two things missing. Firstly, there is a small coq lang changelog in coq.rst that needs updating; secondly, this needs a regular changelog entry in doc/changes/.

This includes the following:
- A [coqdep_flags] field in the [env] stanza (under [coq]).
- A [coqdep_flags] field in the [coq.theory] stanza.

Signed-off-by: Rodolphe Lepigre <[email protected]>
@rlepigre
Copy link
Contributor Author

Looks good. Only two things missing. Firstly, there is a small coq lang changelog in coq.rst that needs updating; secondly, this needs a regular changelog entry in doc/changes/.

OK, done.

@ejgallego
Copy link
Collaborator

ejgallego commented Nov 12, 2024

Thanks @rlepigre , I will have a look tho I'm sure the code is good.

I'm wondering tho if we want to add this new field, is there a valid use case beyond workarounding Coq bugs?

IMHO coqdep is something internal to Coq and shouldn't be exposed to the Dune user.

@ejgallego ejgallego self-assigned this Nov 12, 2024
@Alizter
Copy link
Collaborator

Alizter commented Nov 12, 2024

@ejgallego Now that coqdep can have warnings enabled/disabled it makes sense for the user to be able to pass flags to it.

@rlepigre
Copy link
Contributor Author

@ejgallego: warnings are the main reasons for me to want to be able to configure coqdep.

@ejgallego
Copy link
Collaborator

ejgallego commented Nov 12, 2024

I assumed warnings where the culprit indeed. I am OK to add this, but in principle, we should not need this option.

As of today, coqdep master has 5 warnings:

  • "cannot-locate-home-dir": this is not relevant to dune, should be always disabled (and in fact, this feature likely removed from coqdep)
  • "unknown-option": this should be an error, added to support sloppy makefiles
  • "module-not-found": this should be an error, Coq PR already submitted
  • "legacy-loading-removed-coqdep": this is indeed a legitimate use case, but Coq could warn about it too. In a couple of versions this could be made an error
  • "project-file": related to _CoqProject, should be removed from coqdep

So indeed, I'd still prefer if somehow we document this flag as "internal", as I don't see a real use case for adding warnings to coqdep.

What do you think folks?

@Alizter
Copy link
Collaborator

Alizter commented Nov 12, 2024

I think put a "We discourage tweaking the flags of coqdep" in the doc and be done with it. If we don't add this, users complain that they cannot hack around Coq issues. If we add it, then we risk encouraging users to do hacky things. I think we keep it and document it as discouraged unless you know what you are doing.

@rlepigre
Copy link
Contributor Author

I see your point @ejgallego, I don't know what's best at this point. On the other hand, we can indeed do what @Alizter proposes and add a warning in the documentation. We can always remove the feature for version 1.0 if that makes more sense at that point. In the meantime, we need to address more important issues like proper package metadata (as proposed in coq/rfcs#101).

@ejgallego
Copy link
Collaborator

Documenting this as "internal" sounds good to me.

@ejgallego
Copy link
Collaborator

I think put a "We discourage tweaking the flags of coqdep" in the doc and be done with it.

I have no problem with the above, but what do you folks think about:

  • adding a sub-section, at the end of the stanza documentation "internal fields"
  • adding the new field to this section, and writing something like "this flag exists for transient use cases, in particular for disabling coqdep warnings, but it should not be used in normal operation"

Meanwhile I will try to remove two of these warnings from coqdep already from upstream.

I'm unfortunately very very busy with unplanned stuff, please feel free to merge if I don't do it myself before Sat.

Copy link
Collaborator

@ejgallego ejgallego left a comment

Choose a reason for hiding this comment

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

Thanks a lot!

@rlepigre let me know if you would like to update the docs as suggested, otherwise this is ready to go IMHO.

@rlepigre
Copy link
Contributor Author

Cool, thanks @ejgallego and @Alizter! I tweaked the documentation, let me know if that's enough.

@ejgallego ejgallego merged commit 38c2300 into ocaml:main Nov 13, 2024
27 of 28 checks passed
@ejgallego
Copy link
Collaborator

Looks good to me, thanks @rlepigre !

maiste added a commit to maiste/opam-repository that referenced this pull request Nov 25, 2024
CHANGES:

### Fixed

- Show the context name for errors happening in non-default contexts.
  (ocaml/dune#10414, fixes ocaml/dune#10378, @jchavarri)

- Correctly declare dependencies of indexes so that they are rebuilt when
  needed. (ocaml/dune#10623, @voodoos)

- Don't depend on coq-stdlib being installed when expanding variables
  of the `coq.version` family (ocaml/dune#10631, fixes ocaml/dune#10629, @gares)

- Error out if no files are found when using `copy_files`. (ocaml/dune#10649, @jchavarri)

- Re_export dune-section private library in the dune-site library stanza,
  in order to avoid failure when generating and building sites modules
  with implicit_transitive_deps = false. (ocaml/dune#10650, fixes ocaml/dune#9661, @MA0100)

- Expect test fixes: support multiple modes and fix dependencies when there is
  a custom runner (ocaml/dune#10671, @vouillon)

- In a `(library)` stanza with `(extra_objects)` and `(foreign_stubs)`, avoid
  double linking the extra object files in the final executable.
  (ocaml/dune#10783, fixes ocaml/dune#10785, @nojb)

- Map `(re_export)` library dependencies to the `exports` field in `META` files,
  and vice-versa. This field was proposed in to
  https://discuss.ocaml.org/t/proposal-a-new-exports-field-in-findlib-meta-files/13947.
  The field is included in Dune-generated `META` files only when the Dune lang
  version is >= 3.17.
  (ocaml/dune#10831, fixes ocaml/dune#10830, @nojb)

- Fix staged pps preprocessors on Windows (which were not working at all
  previously) (ocaml/dune#10869, fixes ocaml/dune#10867, @nojb)

- Fix `dune describe` when an executable is disabled with `enabled_if`.
  (ocaml/dune#10881, fixes ocaml/dune#10779, @moyodiallo)

- Fix an issue where C stubs would be rebuilt whenever the stderr of Dune was
  redirected. (ocaml/dune#10883, fixes ocaml/dune#10882, @nojb)

- Format long lists in s-expressions to fill the line instead of formatting
  them in a vertical way (ocaml/dune#10892, fixes ocaml/dune#10860, @nojb)

- Fix the URL opened by the command `dune ocaml doc`. (ocaml/dune#10897, @gridbugs)

- Fix the file referred to in the error/warning message displayed due to the
  dune configuration version not supporting a particular configuration
  stanza in use. (ocaml/dune#10923, @H-ANSEN)

- Fix `enabled_if` when it uses `env` variable. (ocaml/dune#10936, fixes ocaml/dune#10905, @moyodiallo)

- Fix exec -w for relative paths with --root argument (ocaml/dune#10982, @gridbugs)

- Do not ignore the `(locks ..)` field in the `test` and `tests` stanza
  (ocaml/dune#11081, @rgrinberg)

- Tolerate files without extension when generating merlin rules.
  (ocaml/dune#11128, @anmonteiro)

### Added

- Make Merlin/OCaml-LSP aware of "hidden" dependencies used by
  `(implicit_transitive_deps false)` via the `-H` compiler flag. (ocaml/dune#10535, @voodoos)

- Add support for the -H flag (introduced in OCaml compiler 5.2) in dune
  (requires lang versions 3.17). This adaptation gives
  the correct semantics for `(implicit_transitive_deps false)`.
  (ocaml/dune#10644, fixes ocaml/dune#9333, ocsigen/tyxml#274, ocaml/dune#2733, ocaml/dune#4963, @MA0100)

- Add support for specifying Gitlab organization repositories in `source`
  stanzas (ocaml/dune#10766, fixes ocaml/dune#6723, @H-ANSEN)

- New option to control jsoo sourcemap generation in env and executable stanza
  (ocaml/dune#10777, fixes ocaml/dune#10673, @hhugo)

- One can now control jsoo compilation_mode inside an executable stanza
  (ocaml/dune#10777, fixes ocaml/dune#10673, @hhugo)

- Add support for specifying default values of the `authors`, `maintainers`, and
  `license` stanzas of the `dune-project` file via the dune config file. Default
  values are set using the `(project_defaults)` stanza (ocaml/dune#10835, @H-ANSEN)

- Add names to source tree events in performance traces (ocaml/dune#10884, @jchavarri)

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

- `dune runtest` can now run individual tests with `dune runtest mytest.t`
  (ocaml/dune#11041, @Alizter).

- Wasm_of_ocaml support (ocaml/dune#11093, @vouillon)

- Add a `coqdep_flags` field to the `coq` field of the `env` stanza, and to the `coq.theory` stanza, allowing to configure `coqdep` flags.
  (ocaml/dune#11094, @rlepigre)

### Changed

- Remove all remnants of the experimental `patch-back-source-tree`. (ocaml/dune#10771,
  @rgrinberg)

- Change the preset value for author and maintainer fields in the
  `dune-project` file to encourage including emails. (ocaml/dune#10848, @punchagan)

- Tweak the preset value for tags in the `dune-project` file to hint at topics
  not having a special meaning. (ocaml/dune#10849, @punchagan)

- Change some colors to improve readability in light-mode terminals
  (ocaml/dune#10890, @gridbugs)

- Forward the linkall flag to jsoo in whole program compilation as well (ocaml/dune#10935, @hhugo)

- Configurator uses `pkgconf` as pkg-config implementation when available
  and forwards it the `target` of `ocamlc -config`. (ocaml/dune#10937, @pirbo)

- Enable Dune cache by default. Add a new Dune cache setting
  `enabled-except-user-rules`, which enables the Dune cache, but excludes
  user-written rules from it. This is a conservative choice that can avoid
  breaking rules whose dependencies are not correctly specified. This is the
  current default. (ocaml/dune#10944, ocaml/dune#10710, @nojb, @ElectreAAS)

- Do not add `dune` dependency in `dune-project` when creating projects with
  `dune init proj`. The Dune dependency is implicitely added when generating
  opam files (ocaml/dune#11129, @Leonidas-from-XIV)
maiste added a commit to maiste/opam-repository that referenced this pull request Nov 27, 2024
CHANGES:

### Fixed

- Show the context name for errors happening in non-default contexts.
  (ocaml/dune#10414, fixes ocaml/dune#10378, @jchavarri)

- Correctly declare dependencies of indexes so that they are rebuilt when
  needed. (ocaml/dune#10623, @voodoos)

- Don't depend on coq-stdlib being installed when expanding variables
  of the `coq.version` family (ocaml/dune#10631, fixes ocaml/dune#10629, @gares)

- Error out if no files are found when using `copy_files`. (ocaml/dune#10649, @jchavarri)

- Re_export dune-section private library in the dune-site library stanza,
  in order to avoid failure when generating and building sites modules
  with implicit_transitive_deps = false. (ocaml/dune#10650, fixes ocaml/dune#9661, @MA0100)

- Expect test fixes: support multiple modes and fix dependencies when there is
  a custom runner (ocaml/dune#10671, @vouillon)

- In a `(library)` stanza with `(extra_objects)` and `(foreign_stubs)`, avoid
  double linking the extra object files in the final executable.
  (ocaml/dune#10783, fixes ocaml/dune#10785, @nojb)

- Map `(re_export)` library dependencies to the `exports` field in `META` files,
  and vice-versa. This field was proposed in to
  https://discuss.ocaml.org/t/proposal-a-new-exports-field-in-findlib-meta-files/13947.
  The field is included in Dune-generated `META` files only when the Dune lang
  version is >= 3.17.
  (ocaml/dune#10831, fixes ocaml/dune#10830, @nojb)

- Fix staged pps preprocessors on Windows (which were not working at all
  previously) (ocaml/dune#10869, fixes ocaml/dune#10867, @nojb)

- Fix `dune describe` when an executable is disabled with `enabled_if`.
  (ocaml/dune#10881, fixes ocaml/dune#10779, @moyodiallo)

- Fix an issue where C stubs would be rebuilt whenever the stderr of Dune was
  redirected. (ocaml/dune#10883, fixes ocaml/dune#10882, @nojb)

- Fix the URL opened by the command `dune ocaml doc`. (ocaml/dune#10897, @gridbugs)

- Fix the file referred to in the error/warning message displayed due to the
  dune configuration version not supporting a particular configuration
  stanza in use. (ocaml/dune#10923, @H-ANSEN)

- Fix `enabled_if` when it uses `env` variable. (ocaml/dune#10936, fixes ocaml/dune#10905, @moyodiallo)

- Fix exec -w for relative paths with --root argument (ocaml/dune#10982, @gridbugs)

- Do not ignore the `(locks ..)` field in the `test` and `tests` stanza
  (ocaml/dune#11081, @rgrinberg)

- Tolerate files without extension when generating merlin rules.
  (ocaml/dune#11128, @anmonteiro)

### Added

- Make Merlin/OCaml-LSP aware of "hidden" dependencies used by
  `(implicit_transitive_deps false)` via the `-H` compiler flag. (ocaml/dune#10535, @voodoos)

- Add support for the -H flag (introduced in OCaml compiler 5.2) in dune
  (requires lang versions 3.17). This adaptation gives
  the correct semantics for `(implicit_transitive_deps false)`.
  (ocaml/dune#10644, fixes ocaml/dune#9333, ocsigen/tyxml#274, ocaml/dune#2733, ocaml/dune#4963, @MA0100)

- Add support for specifying Gitlab organization repositories in `source`
  stanzas (ocaml/dune#10766, fixes ocaml/dune#6723, @H-ANSEN)

- New option to control jsoo sourcemap generation in env and executable stanza
  (ocaml/dune#10777, fixes ocaml/dune#10673, @hhugo)

- One can now control jsoo compilation_mode inside an executable stanza
  (ocaml/dune#10777, fixes ocaml/dune#10673, @hhugo)

- Add support for specifying default values of the `authors`, `maintainers`, and
  `license` stanzas of the `dune-project` file via the dune config file. Default
  values are set using the `(project_defaults)` stanza (ocaml/dune#10835, @H-ANSEN)

- Add names to source tree events in performance traces (ocaml/dune#10884, @jchavarri)

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

- `dune runtest` can now run individual tests with `dune runtest mytest.t`
  (ocaml/dune#11041, @Alizter).

- Wasm_of_ocaml support (ocaml/dune#11093, @vouillon)

- Add a `coqdep_flags` field to the `coq` field of the `env` stanza, and to the `coq.theory` stanza, allowing to configure `coqdep` flags.
  (ocaml/dune#11094, @rlepigre)

### Changed

- Remove all remnants of the experimental `patch-back-source-tree`. (ocaml/dune#10771,
  @rgrinberg)

- Change the preset value for author and maintainer fields in the
  `dune-project` file to encourage including emails. (ocaml/dune#10848, @punchagan)

- Tweak the preset value for tags in the `dune-project` file to hint at topics
  not having a special meaning. (ocaml/dune#10849, @punchagan)

- Change some colors to improve readability in light-mode terminals
  (ocaml/dune#10890, @gridbugs)

- Forward the linkall flag to jsoo in whole program compilation as well (ocaml/dune#10935, @hhugo)

- Configurator uses `pkgconf` as pkg-config implementation when available
  and forwards it the `target` of `ocamlc -config`. (ocaml/dune#10937, @pirbo)

- Enable Dune cache by default. Add a new Dune cache setting
  `enabled-except-user-rules`, which enables the Dune cache, but excludes
  user-written rules from it. This is a conservative choice that can avoid
  breaking rules whose dependencies are not correctly specified. This is the
  current default. (ocaml/dune#10944, ocaml/dune#10710, @nojb, @ElectreAAS)

- Do not add `dune` dependency in `dune-project` when creating projects with
  `dune init proj`. The Dune dependency is implicitely added when generating
  opam files (ocaml/dune#11129, @Leonidas-from-XIV)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants