Generate IRs with dune?

I was writing on a tight loop in OCaml to control PWM on GPIO pins on the raspberry pi zero, where I could observe a little bit of noise in the signal.

I then remembered the post by OCamlpro on how to not allocate in OCaml. Here ocamlopt -c -dcmm test.ml is used to analyze the compiled code, but as I have library dependencies and I’m already using dune, I tried to lookup how to generate IRs with dune, but didn’t find anything. Is this possible?

Try something like

 ; dune file
(executable
 ...
 (ocamlopt_flags
  (:standard -O3 -dcmm)))
1 Like

Nice, thanks (: didn’t expect dune to cleanly dump the IR to stderr

Note that you can also ask the compiler to redirect all debugging output to a specific directory with -dump-dir path.

1 Like