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:
flag ["ocaml";"compile";"native";"keep_asm"] (S [A "-S"]);
Without the "native"
string in the list passed to flag
, 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:
open Ocamlbuild_plugin;;
open Command;;
dispatch begin function
| Before_rules ->
begin
end
| After_rules ->
begin
flag ["ocaml";"compile";"native";"keep_asm"] (S [ A "-S"]);
end
| _ -> ()
end
Once, you've got that new tag defined, you may use it in your _tags file as with any other tag, for instance:
<myfile.ml>: use_bigarray, keep_asm