I have the pleasure of announcing the release of OCaml version 4.11.0,
dedicated to the memory of Blaise Pascal on the anniversary of his death.
Some of the highlights in this release are:
- Statmemprof: a new statistical memory profiler
- A new instrumented runtime that logs runtime statistics in a standard format
- A native backend for the RISC-V architecture
- Improved backtraces that refer to function names
- Support for recursive and yet unboxed types
- A quoted extension syntax for ppxs.
- Many quality of life improvements
- Many bug fixes.
The full list of change can be found in the changelog below:
OCaml 4.11.0 (19 August 2020)
(Changes that can break existing programs are marked with a â*breaking changeâ warning)
Runtime system:
-
#9096: Print function names in backtraces.
Old output:Called from file âfoo.mlâ, line 16, characters 42-53
New output:
Called from Foo.bar in file âfoo.mlâ, line 16, characters 42-53
(Stephen Dolan, review by Leo White and Mark Shinwell)
-
#9082: The instrumented runtime now records logs in the CTF format.
A new API is available in the runtime to collect runtime statistics,
replacing the previous instrumented runtime macros.
Gc.eventlog_pause and Gc.eventlog_resume were added to allow user to control
instrumentation in a running program.
See the manual for more information on how to use this instrumentation mode.
(Enguerrand Decorne and Stephen Dolan, with help and review from
David Allsopp, SĂ©bastien Hinderer, review by Anil Madhavapeddy,
NicolĂĄs Ojeda BĂ€r, Shakthi Kannan, KC Sivaramakrishnan, Gabriel Scherer,
Guillaume Munch-Maccagnoni, Damien Doligez, Leo White, Daniel BĂŒnzli
and Xavier Leroy) -
#9230, #9362: Memprof support for native allocations.
(Jacques-Henri Jourdan and Stephen Dolan, review by Gabriel Scherer) -
#8920, #9238, #9239, #9254, #9458: New API for statistical memory profiling
in Memprof.Gc. The new version does no longer use ephemerons and allows
registering callbacks for promotion and deallocation of memory
blocks.
The new API no longer gives the block tags to the allocation callback.
(Stephen Dolan and Jacques-Henri Jourdan, review by Damien Doligez
and Gabriel Scherer) -
#9353: Reimplement
output_value
and theMarshal.to_*
functions
using a hash table to detect sharing, instead of temporary in-place
modifications. This is a prerequisite for Multicore OCaml.
(Xavier Leroy and Basile Clément, review by Gabriel Scherer and
Stephen Dolan) -
#9119: Make [caml_stat_resize_noexc] compatible with the [realloc]
API when the old block is NULL.
(Jacques-Henri Jourdan, review by Xavier Leroy) -
#9233: Restore the bytecode stack after an allocation.
(Stephen Dolan, review by Gabriel Scherer and Jacques-Henri Jourdan) -
#9249: restore definition of ARCH_ALIGN_INT64 in m.h if the architecture
requires 64-bit integers to be double-word aligned (autoconf regression)
(David Allsopp, review by SĂ©bastien Hinderer) -
#9259: Made
Ephemeron.blit_key
andWeak.blit
faster. They are now
linear in the size of the range being copied instead of depending on the
total sizes of the ephemerons or weak arrays involved.
(Arseniy Alekseyev, design advice by Leo White, review by François Bobot
and Damien Doligez) -
#9279: Memprof optimisation.
(Stephen Dolan, review by Jacques-Henri Jourdan) -
#9280: Micro-optimise allocations on amd64 to save a register.
(Stephen Dolan, review by Xavier Leroy) -
#9426: build the Mingw ports with higher levels of GCC optimization
(Xavier Leroy, review by SĂ©bastien Hinderer)
- [breaking change] #9483: Remove accidental inclusion of <stdio.h> in <caml/misc.h>
The only release with the inclusion of stdio.h has been 4.10.0
(Christopher Zimmermann, review by Xavier Leroy and David Allsopp)
-
#9282: Make Cconst_symbol have typ_int to fix no-naked-pointers mode.
(Stephen Dolan, review by Mark Shinwell, Xavier Leroy and Vincent Laviron) -
#9497: Harmonise behaviour between bytecode and native code for
recursive module initialisation in one particular case (fixes #9494).
(Mark Shinwell, David Allsopp, Vincent Laviron, Xavier Leroy,
Geoff Reedy, original bug report by Arlen Cox) -
#8791: use a variable-length encoding when marshalling bigarray dimensions,
avoiding overflow.
(Jeremy Yallop, Stephen Dolan, review by Xavier Leroy)
Code generation and optimizations:
-
#9441: Add RISC-V RV64G native-code backend.
(NicolĂĄs Ojeda BĂ€r, review by Xavier Leroy and Gabriel Scherer) -
#9316, #9443, #9463, #9782: Use typing information from Clambda
for mutable Cmm variables.
(Stephen Dolan, review by Vincent Laviron, Guillaume Bury, Xavier Leroy,
and Gabriel Scherer; temporary bug report by Richard Jones) -
#8637, #8805, #9247, #9296: Record debug info for each allocation.
(Stephen Dolan and Jacques-Henri Jourdan, review by Damien Doligez,
KC Sivaramakrishnan and Xavier Leroy) -
#9193: Make tuple matching optimisation apply to Lswitch and Lstringswitch.
(Stephen Dolan, review by Thomas Refis and Gabriel Scherer) -
#9392: Visit registers at most once in Coloring.iter_preferred.
(Stephen Dolan, review by Pierre Chambart and Xavier Leroy) -
#9549, #9557: Make -flarge-toc the default for PowerPC and introduce
-fsmall-toc to enable the previous behaviour.
(David Allsopp, report by Nathaniel Wesley Filardo, review by Xavier Leroy)
Language features
-
#8820, #9166: quoted extensions: {%foo|âŠ|} is lighter syntax for
[%foo {||}], and {%foo bar|âŠ|bar} for [%foo {bar|âŠ|bar}].
(Gabriel Radanne, Leo White, Gabriel Scherer and Pieter Goetschalckx,
request by Bikal Lem) -
#7364, #2188, #9592, #9609: improvement of the unboxability check for types
with a single constructor. Mutually-recursive type declarations can
now contain unboxed types. This is based on the paper
[1811.02300] Unboxing Mutually Recursive Type Definitions in OCaml
(Gabriel Scherer and Rodolphe Lepigre,
review by Jeremy Yallop, Damien Doligez and Frédéric Bour) -
#1154, #1706: spellchecker hints and type-directed disambiguation
for extensible sum type constructors
(Florian Angeletti, review by Alain Frisch, Gabriel Radanne, Gabriel Scherer
and Leo White) -
#6673, #1132, #9617: Relax the handling of explicit polymorphic types.
This improves error messages in some polymorphic recursive definition,
and requires less polymorphic annotations in some cases of
mutually-recursive definitions involving polymorphic recursion.
(Leo White, review by Jacques Garrigue and Gabriel Scherer) -
#9232: allow any class type paths in #-types,
For instance, âval f: #F(X).t â unitâ is now allowed.
(Florian Angeletti, review by Gabriel Scherer, suggestion by Leo White)
Standard library:
-
#9077: Add Seq.cons and Seq.append
(SĂ©bastien Briais, review by Yawar Amin and Florian Angeletti) -
#9235: Add Array.exists2 and Array.for_all2
(Bernhard Schommer, review by Armaël Guéneau) -
#9226: Add Seq.unfold.
(Jeremy Yallop, review by Hezekiah M. Carty, Gabriel Scherer and
Gabriel Radanne) -
#9059: Added List.filteri function, same as List.filter but
with the index of the element.
(LĂ©o AndrĂšs, review by Alain Frisch) -
#8894: Added List.fold_left_map function combining map and fold.
(Bernhard Schommer, review by Alain Frisch and github user @cfcs) -
#9365: Set.filter_map and Map.filter_map
(Gabriel Scherer, review by Stephen Dolan and NicolĂĄs Ojeda BĂ€r) -
#9248: Add Printexc.default_uncaught_exception_handler
(Raphael Sousa Santos, review by Daniel BĂŒnzli) -
#8771: Lexing: add set_position and set_filename to change (fake)
the initial tracking position of the lexbuf.
(Konstantin Romanov, Miguel Lumapat, review by Gabriel Scherer,
SĂ©bastien Hinderer, and David Allsopp) -
#9237:
Format.pp_update_geometry ppf (fun geo -> {geo with ...})
for formatter geometry changes that are robust to new geometry fields.
(Gabriel Scherer, review by Josh Berdine and Florian Angeletti) -
#7110: Added Printf.ikbprintf and Printf.ibprintf
(Muskan Garg, review by Gabriel Scherer and Florian Angeletti) -
#9266: Install pretty-printer for the exception Fun.Finally_raised.
(Guillaume Munch-Maccagnoni, review by Daniel BĂŒnzli, Gabriel Radanne,
and Gabriel Scherer)
Other libraries:
-
#9106: Register printer for Unix_error in win32unix, as in unix.
(Christopher Zimmermann, review by David Allsopp) -
#9183: Preserve exception backtrace of exceptions raised by top-level phrases
of dynlinked modules.
(NicolĂĄs Ojeda BĂ€r, review by Xavier Clerc and Gabriel Scherer) -
#9320, #9550: under Windows, make sure that the Unix.exec* functions
properly quote their argument lists.
(Xavier Leroy, report by André Maroneze, review by Nicolås Ojeda BÀr
and David Allsopp) -
#9490, #9505: ensure proper rounding of file times returned by
Unix.stat, Unix.lstat, Unix.fstat.
(Xavier Leroy and Guillaume Melquiond, report by David Brown,
review by Gabriel Scherer and David Allsopp)
Tools:
-
#9283, #9455, #9457: add a new toplevel directive
#use_output "<command>"
to
run a command and evaluate its output.
(Jérémie Dimino, review by David Allsopp) -
#6969: Argument -nocwd added to ocamldep
(Muskan Garg, review by Florian Angeletti) -
#8676, #9594: turn debugger off in programs launched by the program
being debugged
(Xavier Leroy, report by Michael Soegtrop, review by Gabriel Scherer) -
#9057: aid debugging the debugger by preserving backtraces of unhandled
exceptions.
(David Allsopp, review by Gabriel Scherer) -
#9276: objinfo: cma print extra C options, objects and dlls in
the order given on the cli. Follow up to #4949.
(Daniel BĂŒnzli, review by Gabriel Scherer) -
#463: objinfo: better errors on object files coming
from a different (older or newer), incompatible compiler version.
(Gabriel Scherer, review by Gabriel Radanne and Damien Doligez) -
#9181: make objinfo work on Cygwin and look for the caml_plugin_header
symbol in both the static and the dynamic symbol tables.
(SĂ©bastien Hinderer, review by Gabriel Scherer and David Allsopp)
- [breaking change] #9197: remove compatibility logic from #244 that was designed to
synchronize toplevel printing margins with Format.std_formatter,
but also resulted in unpredictable/fragile changes to formatter
margins.
Setting the margins on the desired formatters should now work.
typically onFormat.std_formatter
.
Note that there currently is no robust way to do this from the
toplevel, as applications may redirect toplevel printing. In
a compiler/toplevel driver, one should instead access
Location.formatter_for_warnings
; it is not currently exposed
to the toplevel.
(Gabriel Scherer, review by Armaël Guéneau)
-
#9207, #9210: fix ocamlyacc to work correctly with up to 255 entry
points to the grammar.
(Andreas Abel, review by Xavier Leroy) -
#9482, #9492: use diversions (@file) to work around OS limitations
on length of Sys.command argument.
(Xavier Leroy, report by Jérémie Dimino, review by David Allsopp) -
#9552: restore ocamloptp build and installation
(Florian Angeletti, review by David Allsopp and Xavier Leroy)
Manual and documentation:
-
#9141: beginning of the ocamltest reference manual
(SĂ©bastien Hinderer, review by Gabriel Scherer and Thomas Refis) -
#9228: Various Map documentation improvements: add missing key argument in
the âmergeâ example; clarify the relationship between input and output keys
in âunionâ; note that find and find_opt return values, not bindings.
(Jeremy Yallop, review by Gabriel Scherer and Florian Angeletti) -
#9255, #9300: reference chapter, split the expression grammar
(Florian Angeletti, report by Harrison Ainsworth, review by Gabriel Scherer) -
#9325: documented base case for
List.for_all
andList.exists
(Glenn Slotte, review by Florian Angeletti) -
#9410, #9422: replaced naive fibonacci example with gcd
(Anukriti Kumar, review by San Vu Ngoc, Florian Angeletti, LĂ©o AndrĂšs) -
#9541: Add a documentation page for the instrumented runtime;
additional changes to option names in the instrumented runtime.
(Enguerrand Decorne, review by Anil Madhavapeddy, Gabriel Scherer,
Daniel BĂŒnzli, David Allsopp, Florian Angeletti,
and SĂ©bastien Hinderer) -
#9610: manual, C FFI: naked pointers are deprecated, detail the
forward-compatible options for handling out-of-heap pointers.
(Xavier Leroy, review by Mark Shinwell, David Allsopp and Florian Angeletti) -
#9618: clarify the Format documentation on the margin and maximum indentation
limit
(Florian Angeletti, review by Josh Berdine) -
#8644: fix formatting comment about @raise in stdlibâs mli files
(Ălie Brami, review by David Allsopp) -
#9327, #9401: manual, fix infix attribute examples
(Florian Angeletti, report by David Cadé, review by Gabriel Scherer) -
#9403: added a description for warning 67 and added a â.â at the end of
warnings for consistency.
(Muskan Garg, review by Gabriel Scherer and Florian Angeletti) -
#7708, #9580: Ensure Stdlib documentation index refers to Stdlib.
(Stephen Dolan, review by Florian Angeletti, report by Hannes Mehnert)
Compiler user-interface and warnings:
-
#9712: Update the version format to allow â~â.
The new format is âmajor.minor[.patchlevel][(+|~)additional-info]â,
for instance â4.12.0~beta1+flambdaâ.
This is a documentation-only change for the 4.11 branch, the new format
will be used starting with the 4.12 branch.
(Florian Angeletti, review by Damien Doligez and Xavier Leroy) -
#1664: make -output-complete-obj link the runtime native c libraries when
building shared libraries like-output-obj
.
(Florian Angeletti, review by NicolĂĄs Ojeda BĂ€r) -
#9349: Support [@inlined hint] attribute.
(Leo White, review by Stephen Dolan) -
#2141: generate .annot files from cmt data; deprecate -annot.
(NicolĂĄs Ojeda BĂ€r, review by Alain Frisch, Gabriel Scherer and Damien
Doligez)
- [breaking change] #7678, #8631: ocamlc -c and ocamlopt -c pass same switches to the C
compiler when compiling .c files (in particular, this means ocamlopt
passes -fPIC on systems requiring it for shared library support).
(David Allsopp, report by Daniel BĂŒnzli, review by SĂ©bastien Hinderer)
-
#9074: reworded error message for non-regular structural types
(Florian Angeletti, review by Jacques Garrigue and Leo White,
report by Chas Emerick) -
#8938: Extend ocamlopt option â-stop-afterâ to handle âschedulingâ argument.
(Greta Yorsh, review by Florian Angeletti and SĂ©bastien Hinderer) -
#8945, #9086: Fix toplevel show directive to work with constructors
(Simon Parry, review by Gabriel Scherer, Jeremy Yallop,
Alain Frisch, Florian Angeletti) -
#9107: improved error message for exceptions in module signature errors
(Gabriel Scherer, review by Florian Angeletti) -
#9208: -dno-locations option to hide source locations (and debug events)
from intermediate-representation dumps (-dfoo).
(Gabriel Scherer, review by Vincent Laviron) -
#9393: Improve recursive module usage warnings
(Leo White, review by Thomas Refis) -
#9486: Fix configuration for the Haiku operating system
(Sylvain Kerjean, review by David Allsopp and SĂ©bastien Hinderer)
Internal/compiler-libs changes:
-
#9021: expose compiler Longident.t parsers
(Florian Angeletti, review by Gabriel Scherer) -
#9452: Add locations to docstring attributes
(Leo White, review by Gabriel Scherer) -
#463: a new Misc.Magic_number module for user-friendly parsing
and validation of OCaml magic numbers.
(Gabriel Scherer, review by Gabriel Radanne and Damien Doligez) -
#1176: encourage better compatibility with older Microsoft C compilers by
using GCCâs -Wdeclaration-after-statement when available. Introduce
Caml_inline to stop abuse of the inline keyword on MSVC and to help ensure
that only static inline is used in the codebase (erroneous instance in
runtime/win32.c removed).
(David Allsopp, review by Oliver Andrieu and Xavier Leroy) -
#8934: Stop relying on location to track usage
(Thomas Refis, review by Gabriel Radanne) -
#8970: separate value patterns (matching on values) from computation patterns
(matching on the effects of a copmutation) in the typedtree.
(Gabriel Scherer, review by Jacques Garrigue and Alain Frisch) -
#9060: ensure that Misc.protect_refs preserves backtraces
(Gabriel Scherer, review by Guillaume Munch-Maccagnoni and David Allsopp) -
#9078: make all compilerlibs/ available to ocamltest.
(Gabriel Scherer, review by SĂ©bastien Hinderer) -
#9079: typecore/parmatch: refactor ppat_of_type and refine
the use of backtracking on wildcard patterns
(Florian Angeletti, Jacques Garrigue, Gabriel Scherer,
review by Thomas Refis) -
#9081: typedtree, make the pat_env field of pattern data immutable
(Gabriel Scherer, review by Jacques Garrigue, report by Alain Frisch) -
#9178, #9182, #9196: refactor label-disambiguation (Typecore.NameChoice)
(Gabriel Scherer, Thomas Refis, Florian Angeletti and Jacques Garrigue,
reviewing each other without self-loops) -
#9321, #9322, #9359, #9361, #9417, #9447: refactor the
pattern-matching compiler
(Thomas Refis and Gabriel Scherer, review by Florian Angeletti) -
#9211, #9215, #9222: fix Makefile dependencies in
compilerlibs, dynlink, ocamltest.
(Gabriel Scherer, review by Vincent Laviron and David Allsopp) -
#9305: Avoid polymorphic compare in Ident
(Leo White, review by Xavier Leroy and Gabriel Scherer) -
#7927: refactor val_env met_env par_env to class_env
(Muskan Garg, review by Gabriel Scherer and Florian Angeletti) -
#2324, #9613: Replace the caml_int_compare and caml_float_compare
(C functions) with primitives.
(Greta Yorsh, review by Stephen Dolan and Vincent Laviron) -
#9246: Avoid rechecking functor applications
(Leo White, review by Jacques Garrigue) -
#9402: Remove
sudo:false
from .travis.yml
(Hikaru Yoshimura)
- [breaking change] #9411: forbid optional arguments reordering with -nolabels
(Thomas Refis, review by Frédéric Bour and Jacques Garrigue)
- #9414: testsuite, ocamltest: keep test artifacts only on failure.
Use KEEP_TEST_DIR_ON_SUCCESS=1 to keep all artifacts.
(Gabriel Scherer, review by SĂ©bastien Hinderer)
Build system:
- #9250: Add --disable-ocamltest to configure and disable building for
non-development builds.
(David Allsopp, review by SĂ©bastien Hinderer)