[ANN] Dune 1.7.0

On behalf of the dune team, I’m pleased to announce the release of dune 1.7.0. This release is the biggest release since 1.0 and I’m excited to present it to you. The change log is quite long so I’ll summarize the most noteworthy changes:

  • The jbuilder binary and jbuild files are officially deprecated. But not to worry, we’ve created a $ dune upgrade command to do the hard work for you.

  • The virtual libraries feature has made it to 1.7.0. I’ve blogged about it before

  • There’s now a mode to disable transitive dependencies. This mode still has some caveats because it lacks proper compiler support. But we welcome user reports regarding its usability.

  • Dune now has a --trace-file to profile slow builds using shiny flame graphs in Chrome.

As usual, the (exceedingly long) change list is available for your convenience:

1.7.0 (12/02/2010)

  • Second step of the deprecation of jbuilder: the jbuilder binary
    now emits a warning on every startup and both jbuilder and dune
    emit warnings when encountering jbuild files (#1752, @jeremiedimino)

  • Change the layout of build artifacts inside _build. The new layout enables
    optimizations that depend on the presence of .cmx files of private modules
    (#1676, @bobot)

  • Fix merlin handling of private module visibility (#1653 @bobot)

  • unstable-fmt: use boxes to wrap some lists (#1608, fix #1153, @emillon,
    thanks to @rgrinberg)

  • skip directories when looking up programs in the PATH (#1628, fixes
    #1616, @jeremiedimino)

  • Use lsof on macOS to implement --stats (#1636, fixes #1634, @xclerc)

  • Generate dune-package files for every package. These files are installed and
    read instead of META files whenever they are available (#1329, @rgrinberg)

  • Fix preprocessing for libraries with (include_subdirs ..) (#1624, fix #1626,
    @nojb, @rgrinberg)

  • Do not generate targets for archive that don’t match the modes field.
    (#1632, fix #1617, @rgrinberg)

  • When executing actions, open files lazily and close them as soon as
    possible in order to reduce the maximum number of file descriptors
    opened by Dune (#1635, #1643, fixes #1633, @jonludlam, @rgrinberg,
    @jeremiedimino)

  • Reimplement the core of Dune using a new generic memoization system
    (#1489, @rudihorn, @jeremiedimino)

  • Replace the broken cycle detection algorithm by a state of the art
    one from this paper (#1489,
    @rudihorn)

  • Get the correct environment node for multi project workspaces (#1648,
    @rgrinberg)

  • Add dune compute to call internal memoized functions (#1528,
    @rudihorn, @jeremiedimino)

  • Add --trace-file option to trace dune internals (#1639, fix #1180, @emillon)

  • Add --no-print-directory (borrowed from GNU make) to suppress
    Entering directory messages. (#1668, @dra27)

  • Remove --stats and track fd usage in --trace-file (#1667, @emillon)

  • Add virtual libraries feature and enable it by default (#1430 fixes #921,
    @rgrinberg)

  • Fix handling of Control+C in watch mode (#1678, fixes #1671, @jeremiedimino)

  • Look for jsoo runtime in the same dir as the js_of_ocaml binary
    when the ocamlfind package is not available (#1467, @nojb)

  • Make the seq package available for OCaml >= 4.07 (#1714, @rgrinberg)

  • Add locations to error messages where a rule fails to generate targets and
    rules that require files outside the build/source directory. (#1708, fixes
    #848, @rgrinberg)

  • Let Configurator handle sizeof (in addition to negative numbers).
    (#1726, fixes #1723, @Chris00)

  • Fix an issue causing menhir generated parsers to fail to build in
    some cases. The fix is to systematically use -short-paths when
    calling ocamlc -i (#1743, fix #1504, @jeremiedimino)

  • Never raise when printing located errors. The code that would print the
    location excerpts was prone to raising. (#1744, fix #1736, @rgrinberg)

  • Add a dune upgrade command for upgrading jbuilder projects to Dune
    (#1749, @jeremiedimino)

  • When automatically creating a dune-project file, insert the
    detected name in it (#1749, @jeremiedimino)

  • Add (implicit_transitive_deps <bool>) mode to dune projects. When this mode
    is turned off, transitive dependencies are not accessible. Only listed
    dependencies are directly accessible. (#1734, #430, @rgrinberg, @hnrgrgr)

  • Add toplevel stanza. This stanza is used to define toplevels with libraries
    already preloaded. (#1713, @rgrinberg)

  • Generate .merlin files that account for normal preprocessors defined using a
    subset of the action language. (#1768, @rgrinberg)

  • Emit (orig_src_dir <path>) metadata in dune-package for dune packages
    built with --store-orig-source-dir command line flag (also controlled by
    DUNE_STORE_ORIG_SOURCE_DIR env variable). This is later used to generate
    .merlin with S-directives pointed to original source locations and thus
    allowing merlin to see those. (#1750, @andreypopp)

  • Improve the behavior of dune promote when the files to be promoted have been
    deleted. (#1775, fixes #1772, @jeremiedimino)

  • unstable-fmt: preserve comments (#1766, @emillon)

  • Pass flags correctly when using staged_pps (#1779, fixes #1774, @jeremiedimino)

  • Fix an issue with the use of (mode promote) in the menhir
    stanza. It was previously causing intermediate mock files to be
    promoted (#1783, fixes #1781, @jeremiedimino)

  • unstable-fmt: ignore files using OCaml syntax (#1784, @emillon)

  • Configurator: Add which function to replace the which command line utility
    in a cross platform way. (#1773, fixes #1705, @Chris00)

  • Make configurator append paths to $PKG_CONFIG_PATH on macOS. Previously it
    was prepending paths and thus $PKG_CONFIG_PATH set by users could have been
    overridden by homebrew installed libraries (#1785, @andreypopp)

  • Disallow c/cxx sources that share an object file in the same stubs archive.
    This means that foo.c and foo.cpp can no longer exist in the same library.
    (#1788, @rgrinberg)

  • Forbid use of %{targets} (or ${@} in jbuild files) inside
    preprocessing actions
    (#1812, fixes #1811, @jeremiedimino)

  • Add DUNE_PROFILE environment variable to easily set the profile. (#1806,
    @rgrinberg)

  • Deprecate the undocumented (no_keep_locs) field. It was only
    necessary until virtual libraries were supported (#1822, fix #1816,
    @jeremiedimino)

  • Rename unstable-fmt to format-dune-file and remove its --inplace option.
    (#1821, @emillon).

  • Autoformatting: (using fmt 1.1) will also format dune files (#1821, @emillon).

  • Autoformatting: record dependencies on .ocamlformat-ignore files (#1824,
    fixes #1793, @emillon)

21 Likes

Looks like a typo - 2010?

Indeed it was. Fixed it in the repository.

I’m just trying out virtual libraries and I’m getting an error:

Error: 'virtual_modules' is only available since version 1.7 of the dune language

dune --version is 1.7.1

The dune file is:

(library
  (name ojs_subtlecrypto)
  (public_name ojs-subtlecrypto)
  (virtual_modules js_dom)
  (modes byte)
  (libraries logs logs.fmt logs.browser fmt.tty win-error gen_js_api cstruct lwt)
  (preprocess (pps js_of_ocaml-ppx))
  (flags (:standard -w -7-26-27-32-33-53-55))
)

Not too sure what the error relates to?

Set version in dune-project file. Features are gated by that.

Whoopee :grinning: Thanks

I had some issues after the upgrade. In my project we’re building a shared library, and I had to adjust the rule that creates it from the targets (add ‘/native’ ) :

.alba_base.objs/bla.cmx => .alba_base.objs/native/bla.cmx

No biggie, but unexpected

Yh, we have been talking about adding %{cmx:...} to access these files. Their location is not specified and we moved them a few times to accommodate various features.

BTW, is it to build a .cmxs?

Yes. I’m building a .cmxs

Why do you need a custom rule? i.e. rather than using <libname>.cmxs

we’re building multiple .cmxs There’s no other way to explain that
for plugin x.cmxs we need files x0.cmx, x1.cmx, …xn.cmx
and
for plugin y we need files y0.cmx … yn.cmx

(some of the files are used in multiple plugins)

I see. I remember that we discussed a similar scenario with @nojb, i.e. having modules that are part of several libraries.