Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OCaml: how to solve findlib warnings of multiple `cmi`s

Now I try to write a compiler using ocamlfind and some packages, especially ppx_sexp_conv with opam.
Somehow dependencies of ppx_sexp_conv require compiler-libs so the compilation option -I ~/.opam/VERSION/lib/compiler-libs is added when compiling files by ocamlfind ocamlc -package ppx_sexp_conv.

The problem is, compiler-libs includes very common name files like parsing.cmi, main.cmi, lexing.cmi.
This make conflicts of .cmi files and make many noisy warnings as follows:

$ ocamlfind ocamlc  -package ppx_sexp_conv -c parser.mli
findlib: [WARNING] Interface main.cmi occurs in several directories: ., /home/nomaddo/.opam/4.02.3/lib/ocaml/compiler-libs
findlib: [WARNING] Interface lexer.cmi occurs in several directories: ., /home/nomaddo/.opam/4.02.3/lib/ocaml/compiler-libs
findlib: [WARNING] Interface topdirs.cmi occurs in several directories: /home/nomaddo/.opam/4.02.3/lib/ocaml/compiler-libs, /home/nomaddo/.opam/4.02.3/lib/ocaml
findlib: [WARNING] Interface parser.cmi occurs in several directories: ., /home/nomaddo/.opam/4.02.3/lib/ocaml/compiler-libs

```

Note that main.cmi, parsing.cmi, lexing.cmi and main.cmi exist in the same directory.

I believe that such file names are common and everybody want to use.
My question is, how to quiet such noisy warnings.
Thanks to them, it is hard to find more important warnings and errors immediately...

My environment: ocaml 4.02.3 with opam 1.2.2.

like image 303
nomaddo Avatar asked Jul 10 '16 16:07

nomaddo


1 Answers

One way to suppress those warnings is to set findlib environment variable OCAMLFIND_IGNORE_DUPS_IN to /home/nomaddo/.opam/4.03.0/lib/ocaml/compiler-libs.

Here is an example with OCaml 4.03.0 and ppx_sexp_conv version 113.33.01+4.03.

parser.mli:

type t = int [@@deriving sexp]

In shell, do the following

export OCAMLFIND_IGNORE_DUPS_IN=/home/nomaddo/.opam/4.03.0/lib/ocaml/compiler-libs

ocamlfind ocamlc  -package ppx_sexp_conv -dsource -c parser.mli

You can see the .mli is preprocessed and no extra warning is emitted.

Reference:

  • findlib man page
  • Mantis 6754
like image 131
objmagic Avatar answered Oct 29 '22 03:10

objmagic