[wg-windows] Improving the state of OCaml on Windows

Török Edwin edwin+ml-ocaml at etorok.net
Fri May 29 20:00:22 BST 2015


On 05/29/2015 06:10 PM, Thomas Braibant wrote:
> Hi,
> 
> Thanks for joining this working group. Its goal is to find out how to
> improve the state of OCaml and its ecosystem on Windows.
> 
> Some of the tasks that we might address (this list is by no mean
> meant to be exhaustive nor normative):
> 
> - Gather information from the community  about the use of the various
> versions of OCaml available on Windows, and understand what kind of
> environment people are working with. (BTW, I think a good way to get
> the discussion rolling might be to describe each other's setup to use
> OCaml on Windows.)

I don't use Windows myself at all, but I've been recently asked how to build an OCaml application on windows.
Here is my very short experience with OCaml on Windows:
 - I used WODI with Cygwin64/Cygwin32 and OCaml 4.02.1 due to the large number of OCaml and C libraries available (notably Lwt and OpenSSL)
 - I tried to build my application however it failed due to path errors (more on this below)
 - I tried building opam from git, and it succeeded, although almost any package I tried to opam install failed to build
 - for some reason Cygwin64 executables keep crashing
 - I gave up after WODI was shutdown, waiting until opam has official Windows support 

Path errors
-----------

The errors looked like this, and it took me a while to figure out that this is because the build system is Cygwin but ocamlfind is a Win32 application
and has no knowledge of what /cygdrive is:
ocamlfind: Bad configuration: Cannot mkdir /cygdrive/c/libre/source/_build/lib/ocaml/site-lib\re because a path component does not exist or is not a directory
File "dynlink_wrapper.ml", line 1, characters 13-14: Illegal character (\000)

I worked this around by using `cygpath -m` in my build system in a few places, normalizing all paths to use / and replacing symlinks with cp.

The path separators are also mixed (/ vs \, because build system uses / in queries like `pwd`, and Filename.concat uses \),  but IIRC this actually worked.
I think native Win32 apps might support a path made all of / these days, not sure why we have to go through all the trouble of trying to use \, but as a Unix person I probably miss some details here.

Cygwin64 unreliability
----------------------

I don't know if the bug is in Windows, Cygwin64 or my VM configuration but the build system itself crashes a lot and randomly
(there seems to be plenty of RAM available).
Even things like make.exe or rm.exe crash with: segfault, fork: resource unavailable, exit code -1073741819.
Restarting the cygwin shell helps sometimes but the errors are soon back, even when using just make -j1.
The situation was bad enough that I had to repeat the build  4-5 times until it finally succeeded as it kept crashing in different places.
Someone else tried WODI32 and didn't see such errors there, so that seems like a more reliable build system.
Was about to report this as a bug in Cygwin64, but next week WODI was shutdown so that ended my Windows testing as well.

Functions not implemented in Unix module
----------------------------------------

Although the build system was cygwin I got a native Win32 executable apparently, as it failed at runtime as various functions from the Unix module are not implemented.
Luckily this is all well documented, so after adding some conditional code I was able to make some progress. Would be better if I could override these functions
with a dummy implementation to make sure I don't get runtime errors.

> 
> - Finalize OPAM support for Windows (this is listed on the OPAM 1.3
> roadmap). When this support is in place, many OCaml packages should
> work out of the box (with the proviso that many packages assume a
> unix-ish environment for their build system).

Is there a way to have the build system and ocamlfind/ocamlopt/ocamlc agree on the format of paths?
(i.e. either both of them are Cygwin or both of them native Win32 apps but not a mix)

> 
> - Discuss how to help package developers improve Windows support. One
> way to do that could be to provide know-how about how to setup
> continuous integration on services like Appveyor to check that
> packages build on typical Windows setups.
> 
> - Find a solution for users of WODI, the GODI based OCaml
> distribution for Windows, which has been shutdown. WODI was able to
> compile OCaml related software (using Cygwin as an environment), but
> was also able to install binary packages. (In some cases, some
> non-trivial patches  were applied to make package usable on Windows.)
> Some of the sources needed to use WODI are still available, but the
> system does not work out of the box now that the server has gone
> offline. With a little work, we might be able to bring it back, to
> smooth the transition.
> 
> - Discuss the state of cross compilation to Windows.

This seems similar to the Android cross-compilation repository:
https://github.com/vouillon/opam-windows-repository

Best regards,
--Edwin


More information about the wg-windows mailing list