What compilation flags does Dune use by default?

Heya!

I’m trying to understand what compilation flags dune runs with by default. I know we can set up envs like this

(env
 (dev
  (flags (:standard -w +42)))
 (release
  (ocamlopt_flags (:standard -O3))))

and then run dune build --profile release for it to run optimized. I wonder though, if I just run dune build without adding any env or flags, does it do any optimization whatsover then?

A good way to figure this kind of things is the --verbose flag. When passed to dune, every command executed by dune will be printed on stdout.

When running dune build, Dune uses the default profile, which is dev by deafult (but can be changed using the (profile <name>) stanza in dune-workspace). The difference between dev and release is that 1) warnings are not hard errors in the release profile, and 2) dev disables inlining across modules by passing -opaque, which speeds up recompilation.

Those are the defaults. One can then add/change flags as you did above to customize each profile to your liking.

Cheers,
Nicolas

That makes sense, thank you so much for the clarification!