diff options
author | 2010-03-04 16:18:23 +0000 | |
---|---|---|
committer | 2010-03-04 16:18:23 +0000 | |
commit | 252aa149a8c1e8df04c02d1b8be1501f122526ad (patch) | |
tree | 1e337c2a80bf57fe2cb4cc5058116d8593aeb4a5 | |
parent | 2a0b8d89809fdfd48274359c15ba16d98df95a00 (diff) |
Makefile: try to avoid rare make failures related with make -j + ocamlopt + .cmi
As said now in a comment of Makefile.build:
NB: for the moment ocamlopt erases and recreates .cmi if there's no .mli around.
This can lead to nasty things with make -j (e.g. another process accessing a
partial .cmi). To avoid that:
1) We make .cmx always depend on .cmi
2) This .cmi will be created from the .mli, or trigger the compilation of the
.cmo if there's no .mli (see rule below about MLWITHOUTMLI)
3) We tell ocamlopt to output to temporary names, remove the temp .cmi
(since the actual .cmi should already be there and up-to-date) and move
the temp .cmx and .o back in place
Ok, this is quite a hack. I'll make a proper bug report to ocaml asap...
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/coq/trunk@12837 85f007b7-540e-0410-9357-904b9bb8a0f7
-rw-r--r-- | Makefile.build | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/Makefile.build b/Makefile.build index 130435f77..eb1ab45be 100644 --- a/Makefile.build +++ b/Makefile.build @@ -748,9 +748,23 @@ COND_OPTFLAGS= \ $(SHOW)'OCAMLC $<' $(HIDE)$(OCAMLC) $(COND_BYTEFLAGS) -c $< +## NB: for the moment ocamlopt erases and recreates .cmi if there's no .mli around. +## This can lead to nasty things with make -j. To avoid that: +## 1) We make .cmx always depend on .cmi +## 2) This .cmi will be created from the .mli, or trigger the compilation of the +## .cmo if there's no .mli (see rule below about MLWITHOUTMLI) +## 3) We tell ocamlopt to output to temporary names, remove the temp .cmi +## (since the actual .cmi should already be there and up-to-date) and move +## the temp .cmx and .o back in place + +$(MLFILES:.ml=.cmx): %.cmx: %.cmi + +$(MLWITHOUTMLI:.ml=.cmi): %.cmi: %.cmo + %.cmx: %.ml | %.ml.d $(SHOW)'OCAMLOPT $<' - $(HIDE)$(OCAMLOPT) $(COND_OPTFLAGS) -c $< + $(HIDE)$(OCAMLOPT) $(COND_OPTFLAGS) -c -o $*.tmp.cmx $< && \ + rm -f $*.tmp.cmi && mv -f $*.tmp.o $*.o && mv -f $*.tmp.cmx $*.cmx %.cmxs: %.cmxa $(SHOW)'OCAMLOPT -shared -o $@' |