Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modules cannot depend on eachother inside of a pack. #142

Open
jordwalke opened this issue Aug 2, 2015 · 11 comments
Open

Modules cannot depend on eachother inside of a pack. #142

jordwalke opened this issue Aug 2, 2015 · 11 comments
Labels

Comments

@jordwalke
Copy link

Inside of autopack/src/b/c.ml, place the following line:

let test = A.foo

And observe the error when compiling:

[1 of 7] Compiling B.A
[2 of 7] Compiling B.C

File "src/b/C.ml", line 2, characters 11-16:
Error: Unbound module A

Then build a second time, and it works!

Then inside of autopack/src/b/a.ml, place the following line, and see that it compiles.

let test = C.foo

There's clearly something going on here, where two builds are required for one direction of the dependency and one build is required for the other direction. I'm guessing it's because the correct ordering isn't determined by something like ocamldep for the files wihin a pack. Is this correct?

@jordwalke
Copy link
Author

What's confusing is that in the case where two builds are required, it looks like the correct build ordering:

[1 of 7] Compiling B.A
[2 of 7] Compiling B.C

@jordwalke
Copy link
Author

And it's so strange because sometimes I receive different errors after cleaning/rebuilding:

../../../dist/build/obuild/obuild build
[1 of 7] Compiling B.A
[2 of 7] Compiling B.C
[3 of 7] Packing B

File "dist/build/autopack/B.cmx", line 1:
Error: File dist/build/autopack/b/C.cmx was compiled without access
       to the .cmx file for module A,
       which was produced by `ocamlopt -for-pack'.
       Please recompile dist/build/autopack/b/C.cmx
       with the correct `-I' option so that A.cmx is found.

@jordwalke
Copy link
Author

Here's another error I've seen, doing the same clean/configure/build cycle - I change literally nothing, yet the errors are different - I suspect some parallelism is determining the subtle way in which this fails:

../../../dist/build/obuild/obuild build
[1 of 7] Compiling B.A
[2 of 7] Compiling B.C

File "src/b/C.ml", line 1:
Error: Corrupted compiled interface
dist/build/autopack/b/a.cmi

@jordwalke
Copy link
Author

And sure enough, when I build with -j 1 (for only one parallel job), the issue goes away.

@jordwalke
Copy link
Author

Bisecting progress: Seems to begin failing at this rev:

Author: Jerome Maloberti <[email protected]>
Date:   Sun Jul 26 09:10:29 2015 +0100

    Add atdgen, major rework of the file access/checking methods.

@UnixJunkie
Copy link

Can you create a minimal project that allows to reproduce the bug?

@jordwalke
Copy link
Author

A pull request to permanently commit? Sure, I'll try to send one later today. In the mean time, you can just add this line to autopack/src/b/c.ml

let test = A.foo

@jeromemaloberti
Copy link
Contributor

No need for a pull request, I have enough information to investigate the bug, thank you. I will fix it as soon as I come back from holiday.

@KasperJanssens
Copy link

KasperJanssens commented Aug 22, 2016

@jeromemaloberti : Did this get fixed then eventually, because the issue is still open and I seem to run into it in the 4.03 compiler. As the issues was mentioned to be fixed about a year ago, I thought I'd ask.

Edit: Nevermind, I think what I ran into was really a correct usage of the remark concerning the directories.

@UnixJunkie
Copy link

diff --git a/tests/full/autopack/src/b/a.ml b/tests/full/autopack/src/b/a.ml
index 70f7a64..98ae82f 100644
--- a/tests/full/autopack/src/b/a.ml
+++ b/tests/full/autopack/src/b/a.ml
@@ -1 +1,2 @@
 let foo = "B.A.foo"
+let test = "A.foo"

$ cd tests/full/autopack
$ obuild clean
$ obuild build -j 1
[1 of 7] Compiling B.A                           
[2 of 7] Compiling B.C                           
[3 of 7] Compiling A                             
[4 of 7] Packing B                             
File "dist/build/autopack/b.cmx", line 1:
Error: Forward reference to A in file dist/build/autopack/b/c.cmx
$ obuild clean
$ obuild build
[1 of 7] Compiling B.A                           
[2 of 7] Compiling B.C                           
File "src/b/c.ml", line 2, characters 11-16:
Error: Unbound module A

Funny that -j 1 has a different behaviour than without it. I thought -j 1 is the default.

@jeromemaloberti
Copy link
Contributor

jeromemaloberti commented Aug 23, 2016

Ok. The main problem here is the name collision between src/a.ml and src/b/a.ml. If you rename either of them it will work. When I refactored the code to make the build more parallel it introduced indeterminism that broke this test (but the test is wrong anyway).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants