Default flags for the project



I have two questions regarding dune build flags.

  1. what are the default (standard) flags for ocamlopt, ocamlc, js_of_ocaml


  1. how to set default flags for the entire project (i.e. one containing many libs and exes)

As far as I understand I need a dune file in the root with the env stanza, something like

  (ocamlopt_flags (:standard -O3 -unbox-closures))))

How to add js_of_ocaml flags to it?


The default depend on the build profile and are hard-coded in dune. You can find out the set of active flags for a given directory by running dune printenv. If you have no special configuration, this will give you the set of default flags:

$ dune printenv .
 (ocamlc_flags (-g))
 (ocamlopt_flags (-g))
$ dune printenv --profile release .
 (flags (-w -40))
 (ocamlc_flags (-g))
 (ocamlopt_flags (-g))

To set the flags globally, you should indeed write an env stanza as you mentioned.

jsoo flags are currently not covered by this mechanism, but they indeed should. Do you mind opening an issue on the dune github project to track this feature?


I think it’s reported already, is it the same issue?


Indeed, it is the same