[ANN] State of OCaml Platform on Windows

Hello folks :waving_hand:

We’re happy to share the first version of the State of the OCaml Platform on Windows document with you. Please find the document here: State of OCaml Platform on Windows - Google Docs.

As part of the First-Class Windows project, we’ve been assessing the state of OCaml on Windows. This document is a summary of our investigation, including our consultations with individuals involved in Windows-related work.

This document started internally at Tarides and quickly included major contributors and users of OCaml on Windows for its drafting and review stages. Thank you to @jbeckford, @klakplok, @Vincent_Balat, @Rucikir, @lambda_foo, @rikusilvola, @kayceesrk, @dra27, @Isabella, @rjbou, @avsm, @kentookura, @oandrieu, @shonfeder, @sabine, and everyone else at Tarides for helping us shape and review this document! :folded_hands:

The immediate call to action for you is to give us your inputs and thoughts, challenge it and help us make it better. You can do this directly on that document, or by quoting into this thread.

We’ll have a window of 8 weeks to allow for this to happen. After that we will move this into the OCaml Platform section of OCaml.org to use as a reference and keep it updated over time.

Happy coding! :two_hump_camel:

/ @sudha & @leostera
on behalf of Tarides

11 Likes

As someone who is mainly interested on having the libraries I distribute work well on Windows I have the following two needs:

  1. Clarify what it means exactly to port to windows among the three possilibilites and perhaps an explanation of why this complexity is needed would be nice. I have long thought that what we need there is less choice. Choose one port, one depext mecanism and then we all promise to support it well. I would rather lean towards the msvc port since that’s what proper windows mean, and I suppose (?) that nowadays if you really need what cygwin brings you are better off using wsl.

  2. Reliable instructions on how to get a cli prompt on a windows machine from a unix operating systems using any kind of vm technology (e.g. using the images here) with a properly configured OCaml environment, which means: git and opam installed and properly working C dexpexts and internet connection.

    If you are not primarily developing on windows most OCaml software readily ports to windows. However when it’s time to tweak builds when C is involved there’s usually a painful back and forth with windows users which would often be quicker to investigate myself directly. But setting up a windows environment usually gets in the way, I’d like that to be abstracted away :–)

Thanks.

3 Likes

Thanks @dbuenzli for hitting the nail on the head.

My feeling is that offering Cygwin as a viable environment for OCaml development (and the default one, at that!) is misguided. Cygwin should be considered an implementation detail of the compiler build system only. I understand that this is done because many OPAM packages assume a Unix-like environment for their build, but still I think that sooner or later we will have to swallow that pill anyway… For one, Windows binaries produced using Cygwin are basically undistributable (users need to install Cygwin to run them); and the Cygwin emulation layer is itself a never-ending source of issues to begin with.

Just my 2c.

Cheers,
Nicolas

3 Likes

Just as a note for people reading this, because i think this might be confusing: This comment is about the Cygwin port, which is rather unused as far as i know. The MSVC and MINGW ports (which still do need Cygwin or MSYS2 to build the compiler itself on native windows) can produce redistribuable binaries (with some caviats for either ports). For example the prebuilt binaries for opam are built using the MINGW port on top of Cygwin and produces static binaries that are executable on any windows machine without any prerequisite.

Yes, thanks for the clarification. Do you confirm that this is the port that used by default by OPAM on Windows?

Cheers,
Nicolas

The native Windows build of opam (either from the published GitHub releases or from winget install OCaml.opam) provides the mingw-w64 port of OCaml by default and if Visual Studio is installed separately can also provide the MSVC port of OCaml.

At present (and for the foreseeable future), it’s not possible to build the Cygwin port of OCaml using native Windows opam (it’s technically cross-compilation). The only way to get the Cygwin port of OCaml in opam is to use the Cygwin port of opam (which is available through Cygwin’s opam package).

Thanks for the correction @dra27! The document seems to be wrong then:

Switch Initialisation Process

After running winget opam, the next step is to call opam init to initialise the installation and create your first global switch. At this point, opam needs to compile an OCaml compiler, which needs a C compiler, and it will ask you to pick between several options (Cygwin, mingw-w64, MSYS2, or MSVC) but defaults to Cygwin.

Cheers,
Nicolas