The Dune team has started planning the next major release and we would like to share and discuss the current plan with the community. We expect to release Dune 3 in August 2021.
Better support for warnings sounds intriguing, but I’m wondering how that will actually work in practice. Is there a sketch for what functionality you’d aim to provide?
One thing I could imagine is for warnings to show up as Merlin squiggles, but not to otherwise show up in build feedback.
Could you provide some more details on this please?
Calling ocamlfind at runtime. When running Dune outside of an opam environment, Dune invokes ocamlfind if it is present to figure out where to look for installed libraries. This is bad for reproducibility and doesn’t feel useful anymore, so we plan to stop doing that. Dune will however continue to use the OCAMLPATH variable, as well as the search paths hard-coded at build time by the optional ./configure script.
What does it mean for people running Dune outside of an opam environment? Does it mean that running Dune without opam will no longer be supported? Or is it still supported, but limited, by requiring that search paths be known at the time of building the Dune executable from source?
The current implementation of scoping has wrong semantics for nested vendored projects: a public library in the inner vendored project escapes its scope and is globally visible. This loophole caused problems for users, and we are going to remove it.
There seem to be two conflicting uses of vendoring in dune. One is to make a library private, and the other (which I tend to use) is an alternative to opam pins during development. When using vendoring-as-pinning, the library should still be considered public. It would be good if there were a way to specify which kind of vendoring you wanted.
We have a few ideas, but no concrete proposal yet. In a nutshell, we’d like the presence of warnings to mark the overall build as failed but not make it fail immediately. Also, during incremental compilation warnings should be displayed until they are fixed. Right now, when warnings are not treated as errors they are displayed during the first compilation and not subsequent ones.
Could you provide some more details on this please?
Sure. When looking for a library that is not defined locally, Dune 2.x looks for in the following directories:
first it looks in directories specified in the OCAMLPATH environment variable
if it doesn’t find it there, it checks if a set of directories was hard-coded at configure time
if yes, it looks in these directories
if no, it checks if OPAM_SWITCH_PREFIX is defined
if yes, it looks for it in $OPAM_SWITCH_PREFIX/lib
if no, it checks if ocamlfind is present in the PATH
if yes, it calls ocamlfind printconf path (unsetting OCAMLPATH) and looks for it in the directories reported by ocamlfind
if no, it looks for the library in $(which ocamlc)/../../lib
This means that when running outside of an opam environment, the behaviour of Dune depends on whether ocamlfind is installed or not. This is flaky given that there is no dependency between the two packages. So Dune 3.x will skip this step.
Concretely, ocamlfind printconf path uses the following source of informations:
the OCAMLPATH variable
the findlib.conf file, whose path is hard-coded at configfure time (or can be passed via OCAMLFIND_CONF)
a set of directories hard-coded at ocamlfind’s configure time
So, if your tooling/package manager is:
setting OCAMLPATH, there is nothing to do to adapt to Dune 3.x
hardcoding a set of directories in ocamlfind, then it should do the same for Dune (we checked and Debian does that for instance)
doing neither of the above and relying on the findlib configuration file, then we should probably discuss
What does it mean for people running Dune outside of an opam environment? Does it mean that running Dune without opam will no longer be supported? Or is it still supported, but limited, by requiring that search paths be known at the time of building the Dune executable from source?
This is a good time for us to learn about these use cases. In which environment do you use Dune?
I had a similar concern, since I use Nix to set up my OCaml development environment. Sounds like $OCAMLPATH is being used, though, so I think this doesn’t affect my use case.
Just to confirm, Dune will still be able to read and generate META files, correct? Internally we have packages built by both Dune and other build systems. We rely on META files for interop between them.
do you guys have plans for a generic release-mode?
I’m mostly interested in optimized & stripped executables when I invoke dune install without having to write custom rules.
Yes, dune will still read and generate META files.
We think we should be fine with removing the dependency on the ocamlfind executable being available, because we do set an OCAMLPATH where the relevant META files exist.
By “stripped”, do you mean executables compiled without -g? I’m afraid we don’t have any plans to add something specific here, but we do let users customize flags. Is that not enough?
Well, the compiler doesn’t have a flag corresponding to gcc’s -s. So my usual workflow involves specifying ocamlopt flags without -g and like so: -ffunction-sections -compact -ccopt -Os -ccopt -s -ccopt -flto -ccopt -Wl,--gc-sections (ocaml >= 4.10) followed by a custom rule that runs strip -s on the resulting executable just to be extra sure.
The shrink in size vs a default dune install is around 30~50% and reaches ~75% for smaller executables.
For the warnings, a first task is just to look at how people customize warnings, and if the documentation is clear on those points. We could have specific ways to specify those compiler flags. Perhaps using the new named warnings from the compiler.
The second is indeed as you propose to see if we can show the warnings at different times. Warnings specific to the editor is a good idea. Another possibility is for some warnings such as unused value to delay them to runtest or a runcheck, which would print the warnings delayed (e.g logged separately) and fail if it is not empty. But one design question is what is the set of compiled file considered.
The third is to clarify what we do for new compilers with new warnings.
I was just thinking about a release mode since it’s a common thing among build tools. Many distros packaging software (and I can imagine they’re not the only use case) opt for turning on extra optimizations, minimizing executable size, and stripping executables in favour of separate debug symbols.