ocaml / opam

opam is a source-based package manager. It supports multiple simultaneous compiler installations, flexible package constraints, and a Git-friendly development workflow.
https://opam.ocaml.org
Other
1.21k stars 348 forks source link

Relax error 31 for non-tautological dependencies #5928

Open dra27 opened 2 months ago

dra27 commented 2 months ago

The compiler's packages presently contain:

depends: [
  "ocaml-option-bytecode-only" {arch = "x86_32"}
]
depopts : [
  "ocaml-option-bytecode-only"
]
build : [
  [ "./configure" "--disable-native-compiler" {ocaml-option-bytecode-only:installed}]
]

This package correctly contains ocaml-option-bytecode-only in both depends and depopts. It is a limited dependency and if arch != "x86_32" it must be treated as a depopt in order to trigger a recompilation. This scheme above does not trigger lint error 31, because the use of ocaml-option-bytecode-only in depends is guarded with a filter.

Upgrades for Windows packaging change this pattern slightly, adding an additional depends formula:

depends: [
  ("ocaml-arch-x86_32" {os = "win32"} & "ocaml-option-bytecode-only")
  "ocaml-option-bytecode-only" {arch = "x86_32"}
]

This does trigger lint error 31, and this is an error. Lint error 31 should only trigger when we can prove that the package atom is always a dependency. Likewise, it should not trigger for a formula such as ("ocaml-arch-x86_64" | "ocaml-arch-x86_32" & "ocaml-option-bytecode-only") i.e. it's not just about the presence of a filter - the point is that there is a way of satisfying the dependency formula which does not depend on ocaml-option-bytecode-only so it's valid in the depopt list.

I'm not sure why this has always been an error, rather than a warning, though @AltGr? I've worked around it in the compiler packages simply by adding an unnecessary {os = "win32"} to the "ocaml-option-bytecode-only".