• en

OCaml 4.09.0

This page describes OCaml version 4.09.0, released on 2019-09-18. Go here for a list of all releases and here for all 4.09.* files.

This release is available as multiple OPAM switches:

  • 4.09.0 — Official release 4.09.0

  • 4.09.0+flambda — Official release 4.09.0, with flambda activated

  • 4.09.0+afl — Official release 4.09.0, with afl-fuzz instrumentation

  • 4.09.0+spacetime - Official 4.09.0 release with spacetime activated

  • 4.09.0+force-safe-string — Official release 4.09.0, with safe string forced globally

  • 4.09.0+default-unsafe-string — Official release 4.09.0, without safe strings by default

  • 4.09.0+no-flat-float-array - Official release 4.09.0, with --disable-flat-float-array

  • 4.09.0+flambda+no-flat-float-array — Official release 4.09.0, with flambda activated and --disable-flat-float-array

  • 4.09.0+fp — Official release 4.09.0, with frame-pointers

  • 4.09.0+fp+flambda — Official release 4.09.0, with frame-pointers and flambda activated

  • 4.09.0+musl+static+flambda - Official release 4.09.0, compiled with musl-gcc -static and with flambda activated

  • 4.09.0+32bit - Official release 4.09.0, compiled in 32-bit mode for 64-bit Linux and OS X hosts

  • 4.09.0+bytecode-only - Official release 4.09.0, without the native-code compiler

What's new

Some of the highlights in release 4.09 are:

  • New optimisations, in particular for affine functions in matches, for instance

          type t = A | B | C
          let affine = function
            | A -> 4
            | B -> 3
            | C -> 2
        
  • The graphics library was moved out of the compiler distribution.

  • The vmthread library was removed.

  • Support for compiler plugins was removed.

  • Many bug fixes.

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

Source distribution

  • Source tarball (.tar.gz) for compilation under Unix (including Linux and MacOS X) and Microsoft Windows (including Cygwin).
  • Also available in .tar.xz 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.
  • Bucklescript is a newer OCaml to JavaScript compiler. See its wiki for an explanation of how it differs from js_of_ocaml.
  • OCaml-java is a stable OCaml to Java compiler.

User's manual

The user's manual for OCaml can be:

Download directory

All the files are also available in this directory, along with their MD5 and SHA512 checksums.

Changes

This is the changelog.

Runtime system:

  • (breaking change) #1725, #2279: Deprecate Obj.set_tag and Obj.truncate (Stephen Dolan, review by Gabriel Scherer, Damien Doligez and Xavier Leroy)

  • (breaking change) #2240: Constify "identifier" in struct custom_operations (Cedric Cellier, review by Xavier Leroy)

  • (breaking change) #2293: Constify "caml_named_value" (Stephen Dolan, review by Xavier Leroy)

  • #8787, #8788: avoid integer overflow in caml_output_value_to_bytes (Jeremy Yallop, report by Marcello Seri)

  • #2075, #7729: rename _T macro used to support Unicode in the (Windows) runtime in order to avoid compiler warning (Nicolás Ojeda Bär, review by Gabriel Scherer and David Allsopp)

  • #2250: Remove extra integer sign-extension in compare functions (Stefan Muenzel, review by Xavier Leroy)

  • #8607: Remove obsolete macros for pre-2002 MSVC support (Stephen Dolan, review by Nicolás Ojeda Bär and David Allsopp)

  • #8656: Fix a bug in [caml_modify_generational_global_root] (Jacques-Henri Jourdan, review by Gabriel Scherer)

Standard library:

  • #2262: take precision (.<n>) and flags ('+' and ' ') into account in printf %F (Pierre Roux, review by Gabriel Scherer)

  • #6148, #8596: optimize some buffer operations (Damien Doligez, reports by John Whitington and Alain Frisch, review by Jeremy Yallop and Gabriel Scherer)

Other libraries:

  • (breaking change) #2318: Delete the graphics library. This library is now available as a separate "graphics" package in opam. Its new home is: https://github.com/ocaml/graphics (Jérémie Dimino, review by Nicolas Ojeda Bar, Xavier Leroy and Sébastien Hinderer)

  • (breaking change) #2289: Delete the vmthreads library. This library was deprecated in 4.08.0. (Jérémie Dimino)

  • #2112: Fix Thread.yield unfairness with busy threads yielding to each other. (Andrew Hunter, review by Jacques-Henri Jourdan, Spiros Eliopoulos, Stephen Weeks, & Mark Shinwell)

  • #7903, #2306: Make Thread.delay interruptible by signals again (Xavier Leroy, review by Jacques-Henri Jourdan and Edwin Török)

  • #2248: Unix alloc_sockaddr: Fix read of uninitialized memory for an unbound Unix socket. Add support for receiving abstract (Linux) socket paths. (Tim Cuthbertson, review by Sébastien Hinderer and Jérémie Dimino)

Compiler user-interface and warnings:

  • (breaking change) #2276: Remove support for compiler plugins and hooks (also adds [Dynlink.unsafe_get_global_value]) (Mark Shinwell, Xavier Clerc, review by Nicolás Ojeda Bär, Florian Angeletti, David Allsopp and Xavier Leroy)

  • #2301: Hint on type error on int literal (Jules Aguillon, review by Nicolás Ojeda Bär , Florian Angeletti, Gabriel Scherer and Armaël Guéneau)

  • (breaking change) #2314: Remove support for gprof profiling. (Mark Shinwell, review by Xavier Clerc and Stephen Dolan)

  • #2190: fix pretty printing (using Pprintast) of "lazy ..." patterns and "fun (type t) -> ..." expressions. (Nicolás Ojeda Bär, review by Gabriel Scherer)

  • #2277: Use newtype names as type variable names The inferred type of (fun (type t) (x : t) -> x) is now printed as ('t -> 't) rather than ('a -> 'a). (Matthew Ryan)

  • #2309: New options -with-runtime and -without-runtime in ocamlopt/ocamlc that control the inclusion of the runtime system in the generated program. (Lucas Pluvinage, review by Daniel Bünzli, Damien Doligez, David Allsopp and Florian Angeletti)

  • #3819, #8546 more explanations and tests for illegal permutation (Florian Angeletti, review by Gabriel Scherer)

  • #8537: fix the -runtime-variant option for bytecode (Damien Doligez, review by David Allsopp)

  • #8541: Correctly print multi-lines locations (Louis Roché, review by Gabriel Scherer)

  • #8579: Better error message for private constructors of an extensible variant type (Guillaume Bury, review by many fine eyes)

Code generation and optimizations:

  • #2278: Remove native code generation support for 32-bit Intel macOS, iOS and other Darwin targets. (Mark Shinwell, review by Nicolas Ojeda Bar and Xavier Leroy)

  • #8547: Optimize matches that are an affine function of the input. (Stefan Muenzel, review by Alain Frisch, Gabriel Scherer)

  • #1904, #7931: Add FreeBSD/aarch64 support (Greg V, review by Sébastien Hinderer, Stephen Dolan, Damien Doligez and Xavier Leroy)

  • #8507: Shorten symbol names of anonymous functions in Flambda mode (the directory portions are now hidden) (Mark Shinwell, review by Nicolás Ojeda Bär)

  • #8681, #8699, #8712: Fix code generation with nested let rec of functions. (Stephen Dolan, Leo White, Gabriel Scherer and Pierre Chambart, review by Gabriel Scherer, reports by Alexey Solovyev and Jonathan French)

Manual and documentation:

  • #7584, #8538: Document .cmt* files in the "overview" of ocaml{c,opt} (Oxana Kostikova, rewiew by Florian Angeletti)

  • #8757: Rename Pervasives to Stdlib in core library documentation. (Ian Zimmerman, review by David Allsopp)

  • #8515: manual, precise constraints on reexported types (Florian Angeletti, review by Gabriel Scherer)

Tools:

  • #2221: ocamldep will now correctly allow a .ml file in an include directory that appears first in the search order to shadow a .mli appearing in a later include directory. (Nicolás Ojeda Bär, review by Florian Angeletti)

Internal/compiler-libs changes:

  • #1579: Add a separate types for clambda primitives (Pierre Chambart, review by Vincent Laviron and Mark Shinwell)

  • #1965: remove loop constructors in Cmm and Mach (Vincent Laviron)

  • #1973: fix compilation of catches with multiple handlers (Vincent Laviron)

  • #2228, #8545: refactoring the handling of .cmi files by moving the logic from Env to a new module Persistent_env (Gabriel Scherer, review by Jérémie Dimino and Thomas Refis)

  • #2229: Env: remove prefix_idents cache (Thomas Refis, review by Frédéric Bour and Gabriel Scherer)

  • #2237, #8582: Reorder linearisation of Trywith to avoid a call instruction (Vincent Laviron and Greta Yorsh, additional review by Mark Shinwell; fix in #8582 by Mark Shinwell, Xavier Leroy and Anil Madhavapeddy)

  • #2265: Add bytecomp/opcodes.mli (Mark Shinwell, review by Nicolas Ojeda Bar)

  • #2268: Improve packing mechanism used for building compilerlibs modules into the Dynlink libraries (Mark Shinwell, Stephen Dolan, review by David Allsopp)

  • #2280: Don't make more Clambda constants after starting Cmmgen (Mark Shinwell, review by Vincent Laviron)

  • #2281: Move some middle-end files around (Mark Shinwell, review by Pierre Chambart and Vincent Laviron)

  • #2283: Add [is_prefix] and [find_and_chop_longest_common_prefix] to [Misc.Stdlib.List] (Mark Shinwell, review by Alain Frisch and Stephen Dolan)

  • #2284: Add various utility functions to [Misc] and remove functions from [Misc.Stdlib.Option] that are now in [Stdlib.Option] (Mark Shinwell, review by Thomas Refis)

  • #2286: Functorise [Consistbl] (Mark Shinwell, review by Gabriel Radanne)

  • #2291: Add [Compute_ranges] pass (Mark Shinwell, review by Vincent Laviron)

  • #2292: Add [Proc.frame_required] and [Proc.prologue_required]. Move tail recursion label creation to [Linearize]. Correctly position [Lprologue] relative to [Iname_for_debugger] operations. (Mark Shinwell, review by Vincent Laviron)

  • #2308: More debugging information on [Cmm] terms (Mark Shinwell, review by Stephen Dolan)

  • #7878, #8542: Replaced TypedtreeIter with tast_iterator (Isaac "Izzy" Avram, review by Gabriel Scherer and Nicolás Ojeda Bär)

  • #8598: Replace "not is_nonexpansive" by "maybe_expansive". (Thomas Refis, review by David Allsopp, Florian Angeletti, Gabriel Radanne, Gabriel Scherer and Xavier Leroy)

Compiler distribution build system:

  • #2267: merge generation of header programs, also fixing parallel build on Cygwin. (David Allsopp, review by Sébastien Hinderer)

  • #8514: Use boot/ocamlc.opt for building, if available. (Stephen Dolan, review by Gabriel Scherer)

Bug fixes:

  • #8864, #8865: Fix native compilation of left shift by (word_size - 1) (Vincent Laviron, report by Murilo Giacometti Rocha, review by Xavier Leroy)

  • #2296: Fix parsing of hexadecimal floats with underscores in the exponent. (Hugo Heuzard and Xavier Leroy, review by Gabriel Scherer)

  • #8800: Fix soundness bug in extension constructor inclusion (Leo White, review by Jacques Garrigue)

  • #8848: Fix x86 stack probe CFI information in caml_c_call and caml_call_gc (Tom Kelly, review by Xavier Leroy)

  • #7156, #8594: make top level use custom printers if they are available (Andrew Litteken, report by Martin Jambon, review by Nicolás Ojeda Bär, Thomas Refis, Armaël Guéneau, Gabriel Scherer, David Allsopp)

  • #3249: ocamlmklib should reject .cmxa files (Xavier Leroy)

  • #7937, #2287: fix uncaught Unify exception when looking for type declaration (Florian Angeletti, review by Jacques Garrigue)

  • #8610, #8613: toplevel printing, consistent deduplicated name for types (Florian Angeletti, review by Thomas Refis and Gabriel Scherer, reported by Xavier Clerc)

  • #8635, #8636: Fix a bad side-effect of the -allow-approx option of ocamldep. It used to turn some errors into successes (Jérémie Dimino)

  • #8701, #8725: Variance of constrained parameters causes principality issues (Jacques Garrigue, report by Leo White, review by Gabriel Scherer)

  • #8777(partial): fix position information in some polymorphic variant error messages about missing tags (Florian Angeletti, review by Thomas Refis)

  • #8779, more cautious variance computation to avoid missing cmis (Florian Angeletti, report by Antonio Nuno Monteiro, review by Leo White)

  • #8810: Env.lookup_module: don't allow creating loops (Thomas Refis, report by Leo White, review by Jacques Garrigue)

  • #8862, #8871: subst: preserve scopes (Thomas Refis, report by Leo White, review by Jacques Garrigue)

  • #8921, #8924: Fix stack overflow with Flambda (Vincent Laviron, review by Pierre Chambart and Leo White, report by Aleksandr Kuzmenko)

  • #8944: Fix "open struct .. end" on clambda backend (Thomas Refis, review by Leo White, report by Damon Wang and Mark Shinwell)