[ANN] New release of Windows DKML with system compiler and easy Opam switch creation

Version 0.3.0 of Diskuv OCaml (DKML) is out. DKML is a distribution that, among other things, can do a scripted install of OCaml and a Microsoft compiler on Windows. It is in preview right now.

In an earlier release with-dkml was introduced. Placing with-dkml in front of most OCaml tools will let those tools transparently have access to Unix binaries and the Microsoft compiler (examples: 1. dune buildwith-dkml dune build; 2. opam installwith-dkml opam install; or 3. with-dkml bash opens a Unix environment in the current Windows directory).

Now if you upgrade to 0.3.0 you get more:

  • There is a new Opam plugin bundled that will create a Windows local switch. You can just do mkdir playground, cd playground and opam dkml init to create a new switch configured with Windows code repositories and the Microsoft compiler. Thanks to @kit-ty-kate for writing the opam-build plugin which helped in understanding how Opam plugins work, and @dbuenzli for many OCaml packages leveraged in both the plugin and with-dkml.
  • The 4.12.1 OCaml compiler and runtime are installed once to the “system”, which means that if you create an Opam local switch the OCaml compiler+runtime do not have to be recompiled. The huge waste of time doing recompilation is now gone. All credit goes to @dra27 who created scripts in Opam that do almost the same thing. There will be a generally available Windows OCaml system compiler sometime next year (that is, you won’t need DKML), so consider the DKML version to be an early and temporary preview of the Windows system compiler.

Links:

Known issues:

7 Likes

Hi Jonah,
I was wondering, what is the default build mode when I call dune build ? Does it use the Debug or Release mode ?

Have a nice day,
Clement

I suspect I placed my “Warning: The remainder of the SDK Projects documentation is not ready for consumption” after you installed; basically that table is for ./makeit build types which shouldn’t be used since you can now just directly call dune build or perhaps with-dkml dune build on Windows (which you are already doing).

dune build by default should use a “dev” profile. The other profile for Dune is the “release” profile. Have a look at Dune’s docs here: Dune - Quick Start - Setting the OCaml compilation flags globally

So if I want to make a my program faster, I need to use Flambda optimization and to do that I just need this in my dune

(env
 (dev
  (flags (:standard -w +42)))
 (release
  (flags (:standard -O3))))

And use --profile release when I build ?

Ah I see. I didn’t expose flambda as an option when creating a switch with opam dkml init. I’ll put it in there for next release. Use opam dkml init --build-type=Release which will include the flambda optimizations. That is the only difference on Windows between --build-type=Debug and --build-type=Release. I’ll document that better when you do opam dkml init --help in the next release.

That is a bit general (and there are a zillion people who would be better at optimizing OCaml than myself). It may help to create a standalone “New Topic”; use the “Learning” category, paste a link to your code and identify what part of it is slow.

I don’t think there is any guarantee that using Dune’s release profile will go faster, but it shouldn’t hurt to try.

1 Like

v0.3.3 has been released. There are no new features for Windows but it does restore the behavior that was present in v0.3.0 (the ANN announcement) but was broken in unannounced versions 0.3.1 and 0.3.2. It also contains a couple bug fixes which help the installation on older Windows machines.