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

1

5

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.

Rear answered 10/7, 2016 at 16:32 Comment(0)
D
10

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:

Disembroil answered 10/7, 2016 at 18:20 Comment(2)
Thanks for your quick response. I have solved this problem!Rear
To find this path in a script: OCAMLFIND_IGNORE_DUPS_IN=`ocamlc -where`/compiler-libsShanahan

© 2022 - 2024 — McMap. All rights reserved.