Profiling with Landmarks - setup question

I’m trying to set up a dune project for profiling with Landmarks. Ideally I can compile the project with and without profiling. Landmarks documents a lot of ways to set it up and I struggle to make it work. So far I have:

==> dune-workspace <==
(lang dune 3.21)
(context default)
(context (default (name profiling) (instrument_with landmarks)))

==> bin/dune <==
(executable
 (name main)
 (public_name vmax)
 (instrumentation (backend landmarks))
 (libraries vmax server cmdliner))


==> lib/dune <==
(library
 (name vmax)
 (instrumentation (backend landmarks))
 (libraries ptime mustache fit utils expr yojson))


A dune build now builds

./_build/default/bin/main.exe
./_build/profiling/bin/main.exe

Observations so far:

  • Running the profiling binary does not create a profiling log, no matter if OCAML_LANDMARKS=output=landmarks.txt,time,allocation is set or not. This suggests the setup above is missing something or the build step requires something that I am missing.
  • ./_build/installcontains both binaries - but which one gets installed when doing a dune install?

I had Landmarks working when I used

(preprocess
   (pps landmarks-ppx --auto))

but this makes it difficult to switch between profiling and no profiling.

(lang dune 3.21)
(context default)
(context
  (default
    (name profiling)
    (instrument_with landmarks)
    (env
      (_ (env-vars ("OCAML_LANDMARKS" "auto")))
    )
  )
)

The environment variable must be set during compilation and execution.