Supported range of OCaml compiler

I am looking for general community opinions around:

What range of OCaml compiler versions do you expect a package to support?
Which version of OCaml do you typically use for local development or at work?

I admit I typically like to sit on the latest version and typically encourage work project not to fall too far behind.

1 Like

I would expect (hope) the OCaml packaged in Debian stable and Ubuntu LTS be supported. Those binary packages are much faster to install compared to building from source by opam, so I generally use those in CI.

At the moment, it is 4.02.3 for both Debian Stretch and Ubuntu Xenial.


my range is: 4.02.3 to 4.05.0 inclusive

We typically use the latest available, though 4.06 is a tough version, since it switches to -safe-strings by default, so many packages are still lagging behind and need update.

Side note: right now I’m keeping MacPorts OCaml compiler at 4.05 because there are still a lot of -safe-strings issues in the world, but I’d really really like to update to 4.06.1 as soon as I can.

Oh, and to answer the other question, I do all my work in 4.06.1.

I use 4.04.2 since I had problems with all the later versions, but I’m contemplating switching to 4.06.
Depending on how much of the standard library you use, I suspect supporting more than one version could be difficult since things got changed around a lot.

The safe strings change, and just generally changes in the String/Bytes module are the main reason I wanted to drop older pre 4.04 version support. Is there a good approach for doing conditional compilation around the changes? eg String.capitalize v String.capitalise_ascii

When I need to support both I tend to use cppo


Expected range: depends on the importance and popularity; for small packages, a few years of compiler versions (e.g. currently 4.04+) seems just fine, but for more important ones, ideally Ubuntu LTS range (4.02.3+).

Version used: 4.02.3, the oldest we currently support due to user requests, to avoid accidentally using newer features. Also, there’s a small but noticeable impact in performance: starting with 4.03, compilation is about 10-20% slower, for several reasons. When compiling dozens of times a day, you notice the difference…

4.02.3: make -j 8  167.40s user 37.03s system 474% cpu 43.072 total
4.03.0: make -j 8  229.46s user 43.07s system 507% cpu 53.676 total
4.06.1: make -j 8  221.75s user 44.05s system 477% cpu 55.719 total

Have you seen StdCompat ?


Hadn’t seen either StdCompat or cppo, thanks for the links.

For the record, Batteries and containers also try to provide access to newer OCaml functions in the range of versions they support.


We need to have StdCompat automatically included with every package on OPAM. That way, we potentially no longer need to worry about stdlib changes.