Back to Releases

OCaml 5.0.0

This page describes OCaml version 5.0.0, released on 2022-12-16. Go here for a list of all releases.

This release is available as an opam package.

What's new

OCaml 5.0.0 introduces a completely new runtime system with support for shared memory parallelism and effect handlers.

As a language, OCaml 5 is fully compatible with OCaml 4 down to the performance characteristics of your programs. In other words, any code that works with OCaml 4 should work the same with OCaml 5.

The currently known exceptions to this rule are:

  • the removal of many long-deprecated functions and modules
  • changes to the internal runtime API
  • the performance of ephemerons is currently (and temporarily) strongly degraded.

For a comprehensive list of changes and details on all new features, bug fixes, optimizations, etc., please consult the changelog.


Installation Instructions

The base compiler can be installed as an opam switch with the following commands:

opam update
opam switch create 5.0.0

It might be also interesting to check the new support for parallelism by installing the domainslib library with

opam install domainslib

The source code for the release candidate is also directly available on:

Configuration options

The configuration of the installed opam switch can be tuned with the following options:

  • ocaml-option-afl: set OCaml to be compiled with afl-fuzz instrumentation
  • ocaml-option-bytecode-only: compile OCaml without the native-code compiler
  • ocaml-option-flambda: set OCaml to be compiled with flambda activated
  • ocaml-option-musl: set OCaml to be compiled with musl-gcc
  • ocaml-option-no-flat-float-array: set OCaml to be compiled with --disable-flat-float-array
  • ocaml-option-static :set OCaml to be compiled with musl-gcc -static
  • ocaml-option-address-sanitizer: set OCaml to be compiled with address sanitizer
  • ocaml-option-leak-sanitizer: set OCaml to be compiled with leak sanitizer

For instance, one can install a switch with both flambda and the naked-pointer checker enabled with

opam switch create 5.0.0+flambda+nnpchecker --package=ocaml-variants.5.0.0+options,ocaml-option-flambda,ocaml-option-nnpchecker

or with opam 2.1:

opam switch create 5.0.0+flambda+nnpchecker ocaml-variants.5.0.0+options ocaml-option-flambda ocaml-option-nnpchecker

Source distribution

  • Source tarball (.tar.gz) for compilation under Unix (including Linux and MacOS X) and Microsoft Windows (including Cygwin).
  • Also available in .zip format.
  • OPAM is a source-based distribution of OCaml and many companion libraries and tools. Compilation and installation are automated by powerful package managers.
  • The official development repo is hosted on GitHub.

The INSTALL file of the distribution provides detailed compilation and installation instructions — see also the Windows release notes for instructions on how to build under Windows.

Alternative Compilers

Additionally, the following projects allow you to compile OCaml code to targets traditionally associated with other languages:

  • Js_of_ocaml is a stable OCaml to JavaScript compiler.

User's manual

The user's manual for OCaml can be:

Changes

This is the changelog. (Changes that can break existing programs are marked with a "breaking change" warning)