I'd like to pass the -S
flag to ocamlopt when building with the ocamlbuild and corebuild commands.
I understand doing ocamlbuild -cflag -S ...
won't work since -S
flag does only exist for ocamlopt and not ocamlc.
How can I do this using _tags files?
Here's one way to do it using myocamlbuild.ml and _tags.
In myocamlbuild.ml, add a
flag
instruction to let ocamlbuild recognize a new tag - here keep_asm - which will enable-S
for selected files when compiling to native:Without the
"native"
string in the list passed toflag
, the flag would be enabled for any compilation stage using ocaml (as indicated by the strings"ocaml"
and"compile"
), and would trigger when ocamlc is invoked, which you don't want.So, for a complete stand alone myocamlbuild.ml doing only the above, this would turn out as:
Once, you've got that new tag defined, you may use it in your _tags file as with any other tag, for instance: