I have a very simple one-ocaml-file → one-executable project
(jbuild_version 1)
(executable
((name vidimetro)
(libraries (lablgl.glut nonstd sosa cmdliner misuja))))
(install ((section bin) (files ((vidimetro.exe as vidimetro)))))
I've noticed that some small but functional changes to vidimetro.ml do not trigger relinking of the executable:
$ jbuilder --version
1.0+beta12
$ jbuilder build --dev @install
ocamldep vidimetro.depends.ocamldep-output
ocamlc vidimetro.{cmi,cmo,cmt}
ocamlopt vidimetro.{cmx,o}
it does not rebuild vidimetro.exe.
If I clean I get the right .exe:
$ jbuilder clean
$ jbuilder build --dev @install
ocamldep vidimetro.depends.ocamldep-output
ocamlc vidimetro.{cmi,cmo,cmt}
ocamlopt vidimetro.{cmx,o}
ocamlopt vidimetro.exe
(I doubt that it is a file time-stamps problem, I'm on a standard ext4 file-system)
(the code is in this branch: https://gitlab.com/smondet/vidimetro/commits/packaging-improvements)
PS: maybe (?) we had similar issues in solvuu-build, need to depend on .cmx and .o files
https://github.com/solvuu/solvuu-build/issues/65
I have not had time to construct a small reproduction case, but FWIW I have experienced this same issue with beta12, beta11 is ok.
Note that this is unrelated to timestamps as the staleness mechanism uses checksums in beta12. I'll investigate but we'll likely need @diml here.
It is in fact related to timestamps, but subtly. An executable only depends on the .cmx files, which was fine when we used timestamps but is not fine now that we compare contents, because there are many changes which do not affect .cmx files.
This should be fixed in #238 - @smondet, I've tested it with the repo here, @jberdine - if you're able to test it (opam pin add jbuilder https://github.com/dra27/jbuilder.git#fix-exe-compilation), that'd also be handy, thanks!
@dra27 I just tried opam pin add jbuilder https://github.com/dra27/jbuilder.git#fix-exe-compilation, it works :+1:
About the question in #238, yes I think cmxa and cmxs files should also depend on the .o (better safe than sorry after all :) ).
@smondet - actually, I was meaning whether executables should depend on the .a file in addition to the .cmxa (I think, looking at the OCaml sources, that the same thing can happen - .cmxa identical, but .a file changed) but you are also right that the compilation of the libraries themselves should do the same thing!
Only a quick test so far, but it looks to be fixed. Thanks, that was fast!
In case someone runs into the same issue as I did: ppx_expect failures of the kind File … changed, you need rebuild inline_test_runner to be able to run expect tests are also fixed by this.
I've just run into this bug when editing a constant in a file, it can be reproduced with this testcase: https://gist.github.com/edwintorok/a5d0492467f80fcbb226635f1f63da3c.
I confirm that the fix from @dra27 works.
@dra27 @rgrinberg was the issue also fixed in the case of the .cmxas and .as?
@smondet - within a jbuilder project, it's not necessary for .cmxa to depend on .a, since the .cmxa will have been rebuilt if any of the modules in it were rebuilt (the .cmxa does now depend on the .o files). So the executable will always be relinked if the underlying the .a file changed because we can guarantee that so did the .cmxa.
I haven't convinced myself that it's impossible for packages coming from findlib (i.e. opam) to hit this, though.
Most helpful comment
I have not had time to construct a small reproduction case, but FWIW I have experienced this same issue with beta12, beta11 is ok.