Skip to content

Windows build fixes (MSYS2, Cygwin, etc.) - #121

Open
dra27 wants to merge 15 commits into
masterfrom
win-fixes
Open

Windows build fixes (MSYS2, Cygwin, etc.)#121
dra27 wants to merge 15 commits into
masterfrom
win-fixes

Conversation

@dra27

@dra27 dra27 commented Jul 16, 2026

Copy link
Copy Markdown
Member

This PR (which is simply a repeat of #112 opened directly) 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). (GHA: Add OCaml 5.4 to the test matrix opam#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. (MSys2 fails to compile topkg.1.1.0  opam-repository#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 ocaml/opam#6732
Closes ocaml/opam-repository#28636

@dra27

dra27 commented Jul 17, 2026

Copy link
Copy Markdown
Member Author

On subsequent review of this since #112 while working on #122, I've added commits here which remove the mingw_lib and pure_mingw stuff, having determined that that definitely related to pre-MSYS2 times. I've also moved read_ldconf from the Frontend module of ocamlfind into Findlib, as that allows it to be easily tested in CI

dra27 and others added 15 commits July 18, 2026 07:23
Check for META.pkg was executed even when metadir is unset - the effect
is that ocamlfind install would fail if there was a META.pkg in the
current directory... which happens to be the case for the num package!
They've never been used - tracking the paths we need to know about is
hard enough!
Group all the commands generating findlib.conf into a single subshell
invocation.
Possibly an attempt to avoid spaces or unusual characters, but somewhat
dated.
Eliminate the USE_CYGPATH variable by manipulating native paths on
Windows directly in configure. This has two important side-effects:
1. Native paths coming from OCaml are used directly
2. Semi-colon handling in OCaml 5.x is fixed for the Cygwin port
MSYS2 configures GCC correctly.
MSYS2 uses cygpath in the same way as Cygwin, and the install command is
a Cygwin-style command.
- Add OCaml 5.5 to the testing matrix
- Display paths generated in Makefile.config
- Display resulting findlib.conf after opam installation
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.

MSys2 fails to compile topkg.1.1.0

2 participants