All Releases

OCaml 5.1.1

This page describes OCaml version 5.1.1, released on Dec 8, 2023. Go here for a list of all releases.

This is a bug-fix release of OCaml 5.1.0.

Installation Instructions

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

opam update
opam switch create 5.1.1

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 sanitiser
  • ocaml-option-leak-sanitizer: Set OCaml to be compiled with leak sanitiser
  • ocaml-option-fp: Set OCaml to be compiled with frame pointers

For instance, one can install a switch with both flambda and the --disable-flat-float-array option with

opam switch create 5.1.0+flambda+nffa ocaml-variants.5.1.0+options ocaml-option-flambda ocaml-option-no-flat-float-array

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.


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

Standard library:

  • (Breaking Change) #12562, #12734, #12783: Remove the Marshal.Compression flag to the Marshal.to_* functions introduced in 5.1 by #12006, as it cannot be implemented without risking to link -lzstd with all ocamlopt-generated executables. The compilers are still able to use ZSTD compression for compilation artefacts. (Xavier Leroy and David Allsopp, report by Kate Deplaix, review by Nicolás Ojeda Bär, Kate Deplaix, and Damien Doligez).

Bug Fixes:

  • #11800, #12707: Fix an assertion race condition in install_backup_thread (Jan Midtgaard, review by Gabriel Scherer)

  • #12318: GC: simplify the meaning of custom_minor_max_size: blocks with out-of-heap memory above this limit are now allocated directly in the major heap. (Damien Doligez, report by Stephen Dolan, review by Gabriel Scherer)

  • #12439: Finalise and collect dead custom blocks during minor collection (Damien Doligez, review by Xavier Leroy, Gabriel Scherer, and KC Sivaramakrishnan)

  • #12486, #12535: Fix delivery of unhandled effect exceptions on AMD64 with --enable-frame-pointers (Miod Vallat, report by Jan Midtgaard, review by Gabriel Scherer)

  • #12581, #12609: Fix error on uses of packed modules outside their pack to correctly handle nested packs (Vincent Laviron, report by Javier Chávarri, review by Pierre Chambart)

  • #12590, #12595: Move caml_collect_gc_stats_sample in caml_empty_minor_heap_promote before barrier arrival. (B. Szilvasy, review by Gabriel Scherer)

  • #12623: Fix the computation of variance composition (Florian Angeletti, report by Vesa Karvonen, review by Gabriel Scherer)

  • #12645, #12649: Fix error messages for cyclic type definitions in presence of the -short-paths flag. (Florian Angeletti, report by Vesa Karvonen, review by Gabriel Scherer)

  • #12712, #12742: Fix an assertion boundary case in caml_reset_young_limit (Jan Midtgaard, review by Guillaume Munch-Maccagnoni)

  • #12713, #12715: Disable common subexpression elimination for atomic loads (Gabriel Scherer and Vincent Laviron, review by Vincent Laviron, KC Sivaramakrishnan and Xavier Leroy, report by Vesa Karvonen and Carine Morel)

  • #12757: Fix ocamlnat (native toplevel) by registering frametables correctly (Stephen Dolan, Nick Barnes and Mark Shinwell, review by Vincent Laviron and Sébastien Hinderer)

  • #12791: extern is applied to definitions of caml_builtin_cprim and caml_names_of_builtin_cprim when linking bytecode -custom executables with a C++ linker. (Shayne Fletcher, review by Antonin Décimo and Xavier Leroy)

  • #12491, #12493, #12500, #12754: Do not change GC pace when creating subarrays of Bigarrays (Xavier Leroy, report by Ido Yariv, analysis by Gabriel Scherer, review by Gabriel Scherer and Fabrice Buoro)