ocamlfind icon indicating copy to clipboard operation
ocamlfind copied to clipboard

Windows build fixes (MSYS2, Cygwin, etc.)

Open dra27 opened this issue 4 months ago • 1 comments

This PR fixes various issues:

  • ocamlfind does not build with OCaml 5.0+ on Cygwin (a build failure occurs owing to mishandling of the ; in path in the generation of findlib.conf). (https://github.com/ocaml/opam/pull/6732)
  • When building on mingw-w64/MSVC with OCaml 5.0+ using MSYS2 for the build environment, findlib.conf is (silently) misgenerated which causes both ocamlfind list and topfind to fail. (https://github.com/ocaml/opam-repository/issues/28636)
  • ocamlfind install contains an incorrect check for META.pkg even when metadir is not in use (which happened to affect the non-opam installation of num).
  • Two minor Windows wrinkles: -s is not a necessary, nor even always valid, flag to cygpath any more and the technically the legacy command for retrieving the Standard Library is broken on old versions of OCaml.

The opening commits are fairly straightforward. The last commit is fiddly, but enacts the following sequence of changes:

  1. The generation of findlib.conf is shifted from being a build operation to a configure operation. That requires the tracking of the native / "Unix" version of various path variables in configure, but is fundamentally simpler overall, because we only have to worry about escaping the backslashes which physically go into findlib.conf and not also escaping characters which may interfere with an escaping sed expression!
  2. That allows tools/patch to be able to assume that it has received a native path (modulo the highly legacy stuff for the MinGW environment, but this probably ought to all be removed).
  3. That then allows various variables which are no longer required the the build to be removed.

Fixes Cygwin failure in https://github.com/ocaml/opam/pull/6732 Closes https://github.com/ocaml/opam-repository/issues/28636

cc @kit-ty-kate (opam), @jmid (opam-repository), @Leonidas-from-XIV (Dune package management)

dra27 avatar Oct 18 '25 07:10 dra27

I can confirm that this fixes the annoying topkg failure on the opam repository :slightly_smiling_face:

jmid avatar Oct 20 '25 15:10 jmid