reasonml-old / rebel

122 stars 16 forks source link

Infamous "inconsistent assumptions" error. #79

Closed jordwalke closed 7 years ago

jordwalke commented 7 years ago

I changed one file, then tried to rebuild, and I got the following:

build/ocamlfind/lib/core_bench/core_bench.cmxa _build/src/Src.cmx _build/src/Src__LayoutTypes.cmx _build/src/Src__LayoutSupport.cmx _build/src/Src__LayoutPrint.cmx _build/src/Src__ReJsPrelude.cmx _build/src/Src__Layout.cmx _build/src/Src__LayoutTestUtils.cmx _build/src/Src__LayoutTest.cmx
File "_none_", line 1:
Error: Files _build/src/Src__LayoutTest.cmx
       and _build/src/Src__LayoutTestUtils.cmx
       make inconsistent assumptions over implementation Src__LayoutTestUtils
ocamlopt.opt returned with exit code 2

I think this happens when an interface file is automatically generated for files that don't have actual interface files (and it produces a .cmi artifact which is untracked by the build system). I think the solution may be to have the build system explicitly create the interface file as an artifact for any implementation file that does not already include an interface file. Then the build system knows to compile everything against that interface, although we understand it is automatically generated.

jordwalke commented 7 years ago

ocamlbuild is notorious for having this issue as well. We can solve it in rebel!

vramana commented 7 years ago

@jordwalke I have solved this just recently. master doesn't have this bug.

jordwalke commented 7 years ago

:D Excellent. What was the solution?

vramana commented 7 years ago

We apply this nifty optimization for ocamlc where if the cmi doesn't change we don't recompile entire the file. But that doesn't apply in the case of ocamlopt due to some inter module optimizations. So , in the case of ocamlopt we just trigger the recompile of file and everything works.

Reference: http://stackoverflow.com/questions/9843378/ocaml-module-types-and-separate-compilation/9844542#9844542

jordwalke commented 7 years ago

Great!

jordwalke commented 7 years ago

Actually, I recall there's a new flag for ocamlopt (maybe only in 4.03?) that allows the same behavior for ocamlopt. We should look into that.