Default flags for the project

dune

#1

I have two questions regarding dune build flags.

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

and

  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

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

How to add js_of_ocaml flags to it?


#2

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 .
(
 (flags
  (-w
   @a-4-29-40-41-42-44-45-48-58-59-60-40
   -strict-sequence
   -strict-formats
   -short-paths
   -keep-locs))
 (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?


#3

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


#4

Indeed, it is the same