Correct way to use ocamlopt_flags for flambda in jbuild file

I just want to make sure that I’m using ocamlopt_flags correctly in my jbuild files using OCaml 4.05.0+flambda. I think I am, but … In all of the jbuild files I include the same sexp: (ocamlopt_flags (:standard -O2)) [or I change I change all of the -O2's to -O3's.]

In my project I have to package directories and one executable directory. The jbuild files in the package directories are the same except for module names etc. Here’s one of them:

(jbuild_version 1)

(library 
 ((name        utils)
  (public_name utils)
  (modules (prob genl))
  (libraries (batteries core owl))
  (ocamlopt_flags (:standard -O2))
  ))

The jbuild file for the executables that use the two packages is similar:

(jbuild_version 1)

(executables
 ((names (wrightfisherPDFs setchainPDFs))
	(public_names (wrightfisherPDFs setchainPDFs))
  (package models)
  (libraries (core models utils))
  (modes (native))
  (ocamlopt_flags (:standard -O2))
 ))

Is this the right place for the ocamlopt_flags expression? Does it make sense to include it in all of the jbuild files?

2 Likes