FS#74061 - [dune] 3.0.3-1 does not correctly auto-detect OCaml libdir

Attached to Project: Community Packages
Opened by Hans-Nikolai Viessmann (hv15) - Tuesday, 08 March 2022, 17:09 GMT
Last edited by Konstantin Gizdov (kgizdov) - Friday, 11 March 2022, 23:01 GMT
Task Type Bug Report
Category Packages
Status Closed
Assigned To Felix Yan (felixonmars)
Konstantin Gizdov (kgizdov)
Architecture All
Severity High
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 1
Private No

Details

Description:

I maintain the cppo package on AUR, and a user reported being unable to build the package using the latest version of dune (3.0.3-1). cppo depends on ocamlbuild, but dune was unable to find the system-installed version (a locally installed version via opam was being picked up).

Comparing the output of `ocamlfind list`and `dune installed-libraries` gives:
```
bigarray (version: [distributed with Ocaml])
bytes (version: [distributed with OCaml 4.02 or above])
compiler-libs (version: [distributed with Ocaml])
compiler-libs.bytecomp (version: [distributed with Ocaml])
compiler-libs.common (version: [distributed with Ocaml])
compiler-libs.optcomp (version: [distributed with Ocaml])
compiler-libs.toplevel (version: [distributed with Ocaml])
csexp (version: n/a)
dune (version: n/a)
dune-action-plugin (version: n/a)
dune-build-info (version: n/a)
dune-configurator (version: n/a)
dune-glob (version: n/a)
dune-private-libs (version: n/a)
dune-private-libs.dune-section (version: n/a)
dune-private-libs.dune_re (version: n/a)
dune-private-libs.meta_parser (version: n/a)
dune-private-libs.ocaml-config (version: n/a)
dune-site (version: n/a)
dune-site.plugins (version: n/a)
dune.configurator (version: n/a)
dyn (version: n/a)
dyn.pp (version: n/a)
dynlink (version: [distributed with Ocaml])
fiber (version: n/a)
findlib (version: 1.9.1)
findlib.dynload (version: 1.9.1)
findlib.internal (version: 1.9.1)
findlib.top (version: 1.9.1)
ocamlbuild (version: 0.14.0)
ocamldoc (version: [distributed with Ocaml])
ordering (version: n/a)
pp (version: n/a)
result (version: n/a)
stdlib (version: [distributed with Ocaml])
stdune (version: n/a)
stdune.csexp (version: n/a)
stdune.filesystem_stubs (version: n/a)
str (version: [distributed with Ocaml])
threads (version: [distributed with Ocaml])
threads.none (version: [internal])
threads.posix (version: [internal])
unix (version: [distributed with Ocaml])
xdg (version: n/a)
```

and for dune:
```
bigarray (version: [distributed with OCaml])
bytes (version: [distributed with OCaml])
compiler-libs (version: [distributed with OCaml])
compiler-libs.bytecomp (version: [distributed with OCaml])
compiler-libs.common (version: [distributed with OCaml])
compiler-libs.optcomp (version: [distributed with OCaml])
compiler-libs.toplevel (version: [distributed with OCaml])
dynlink (version: [distributed with OCaml])
ocamldoc (version: [distributed with OCaml])
stdlib (version: [distributed with OCaml])
str (version: [distributed with OCaml])
threads (version: [distributed with OCaml])
threads.posix (version: [distributed with OCaml])
unix (version: [distributed with OCaml])
```

In the latter output clearly dune just doesn't find ocamlbuild. I submitted an issue to cppo upstream (https://github.com/ocaml-community/cppo/issues/82) and it was pointed out to me that the ArchLinux dune package does not explicitly set the system libdir (as is done by Debian). I am unsure why this matters, I understood dune should be able to auto-detect this, and if we look at the verbose output of `dune installed-libraries` we get a list of envs such as `"DUNE_OCAML_STDLIB" : "/usr/lib/ocaml"` which to me at least means it know where to look for stdlib libraries.

At any rate, before submitting anything here I thought I would have a go at compiling dune *with* an explicit libdir at configure time (see attached PKGBUILD; based off of what debian packagers do: https://salsa.debian.org/ocaml-team/ocaml-dune/-/blob/master/debian/rules#L22). Upon building and installing, dune behaves as expected.

The output of `dune installed-libraries` is now:
```
bigarray (version: [distributed with OCaml])
bytes (version: [distributed with OCaml])
compiler-libs (version: [distributed with OCaml])
compiler-libs.bytecomp (version: [distributed with OCaml])
compiler-libs.common (version: [distributed with OCaml])
compiler-libs.optcomp (version: [distributed with OCaml])
compiler-libs.toplevel (version: [distributed with OCaml])
csexp (version: n/a)
dune-action-plugin (version: n/a)
dune-build-info (version: n/a)
dune-configurator (version: n/a)
dune-glob (version: n/a)
dune-private-libs.dune-section (version: n/a)
dune-private-libs.dune_re (version: n/a)
dune-private-libs.meta_parser (version: n/a)
dune-private-libs.ocaml-config (version: n/a)
dune-site (version: n/a)
dune-site.plugins (version: n/a)
dune.configurator (version: n/a)
dyn (version: n/a)
dyn.pp (version: n/a)
dynlink (version: [distributed with OCaml])
fiber (version: n/a)
findlib (version: 1.9.1)
findlib.dynload (version: 1.9.1)
findlib.internal (version: 1.9.1)
findlib.top (version: 1.9.1)
ocamlbuild (version: 0.14.0)
ocamldoc (version: [distributed with OCaml])
ordering (version: n/a)
pp (version: n/a)
result (version: n/a)
stdlib (version: [distributed with OCaml])
stdune (version: n/a)
stdune.csexp (version: n/a)
stdune.filesystem_stubs (version: n/a)
str (version: [distributed with OCaml])
threads (version: [distributed with OCaml])
threads.posix (version: [distributed with OCaml])
unix (version: [distributed with OCaml])
xdg (version: n/a)
```

Steps to reproduce:

```
git clone https://github.com/ocaml-community/cppo.git
cd cppo
dune build --profile release
```
This task depends upon

Closed by  Konstantin Gizdov (kgizdov)
Friday, 11 March 2022, 23:01 GMT
Reason for closing:  Fixed
Additional comments about closing:  dune 3.0.3-2

Loading...