Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save xandkar/3c1872ca078010f512cf to your computer and use it in GitHub Desktop.

Select an option

Save xandkar/3c1872ca078010f512cf to your computer and use it in GitHub Desktop.
How to tweak compiler warnings when configuring build with Oasis?

How to tweak compiler warnings when configuring build with Oasis?

When using bare ocamlbuild, it is simple-enough - just add -cflags -w <warnings> to the ocamlbuild command line options. But when using Oasis to configure the build - it is less straight forward. Your options are:

  • A) use _tags file, which is simple, but incomplete in functionality and documentation
  • B) use myocamlbuild.ml, which is not documented at all

I first tried using option (A), but found that it only allows you to add one of the letter options and does not allow disabling individual, numbered, warnings:

https://github.com/ocaml/ocaml/blob/a18bc7950b385ba1668d5efe7b277591b8638802/ocamlbuild/ocaml_specific.ml#L716-L730

Looking at how the above is implemented and a bit more grepping, I found:

val flag : Tags.elt list -> Command.spec -> unit

Which can be used to set arbitrary compiler flags.

This is what I ended-up appending to the end of myocamlbuild.ml, to enable all compiler warnings but 33 (Unused open statement) and 44 (Open statement shadows an already defined identifier):

flag ["ocaml"; "compile"] (S [ A "-w"; A "A-33-44"])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment