Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
the typer fails reading unnecessary cmis with -no-alias-deps and -w -49 #6998
Original bug ID: 6998
As you can see in the script below, when aliasing a compilation unit, the compiler tries to read the cmi for that compilation unit.
If the cmi doesn't exit, a 'try with Not_found' in Env.lookup_module makes the typer succeed. If the cmi can be read, but it is not consistency with the other cmis, the typer succeeds because the consistency checked is skipped. There are other potentially errors caught in Env.read_pers_struct that are bypassed. But if the existing cmi on disk is for a different version of ocaml, or is partially written out by a concurrent call to the compiler, or generally speaking can't be read (no read permission for instance), then the typing fails.
I think this is wrong and no error should ever be given: there is no dependency between a.cmi and b.cmi in the example, so the behavior of the typer when building a.cmi should not depend on b.cmi. In the current state of the typer, I think we can't build a tree at the current version of ocaml and then at the next version of ocaml without cleaning the tree (assuming the cmi format changed) because of this.
I suppose two fixes are possible:
Steps to reproduce
a.ml builds if b.cmi is not present
but if some old garbage b.cmi is present
File "a.ml", line 1:
Error: Corrupted compiled interface
Comment author: @sliquister
So I confirm that cleaning between compiler changes is necessary because of this bug. I tried the attached patch, which solves the problem (but other than that, I haven't really tested it). I went with my second proposal, I think there are only the following slight behavior changes: