diff options
author | Pierre Letouzey <pierre.letouzey@inria.fr> | 2017-06-15 15:24:03 +0200 |
---|---|---|
committer | Pierre Letouzey <pierre.letouzey@inria.fr> | 2017-06-15 15:35:03 +0200 |
commit | d1d068bcc7ed43d375b1f69a3cc796fb12333519 (patch) | |
tree | 15a2e1c82036d185880d124e5f93681b0b9d0a51 /Makefile.build | |
parent | 28c732ea340f5ac571a77a8ac26de600c29165b2 (diff) |
Makefile.build : restore (temporarily?) the anti-cmi-corruption hacks
Due to the recent conversion of many .mli-only files into .ml files
(hugely debatable impact of the API introduction), parallel make may
fail badly again (always the same race between ocamlc and ocamlopt for .cmi).
Still working on a proper fix, but meanwhile let's reintroduce the
old hacks against these corruptions.
Diffstat (limited to 'Makefile.build')
-rw-r--r-- | Makefile.build | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/Makefile.build b/Makefile.build index 484673e17..0dafde997 100644 --- a/Makefile.build +++ b/Makefile.build @@ -516,6 +516,27 @@ 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 use the .cmi as the interface source file. With this +## hack, everything goes as if there is a .mli, and the .cmi is preserved +## and the .cmx is checked with respect to this .cmi + +HACKMLI = $(if $(wildcard $<i),,-intf-suffix .cmi) + +define diff + $(strip $(foreach f, $(1), $(if $(filter $(f),$(2)),,$f))) +endef + +MLWITHOUTMLI := $(call diff, $(MLFILES), $(MLIFILES:.mli=.ml)) + +$(MLWITHOUTMLI:.ml=.cmx): %.cmx: %.cmi # for .ml with .mli this is already the case + +$(MLWITHOUTMLI:.ml=.cmi): %.cmi: %.cmo + # NB: the *_FORPACK variables are generated in *.mlpack.d by ocamllibdep # The only exceptions are the sources of the csdpcert binary. # To avoid warnings, we set them manually here: @@ -526,11 +547,11 @@ plugins/micromega/csdpcert_FORPACK:= plugins/%.cmx: plugins/%.ml $(SHOW)'OCAMLOPT $<' - $(HIDE)$(OCAMLOPT) $(COND_OPTFLAGS) $($(@:.cmx=_FORPACK)) -c $< + $(HIDE)$(OCAMLOPT) $(COND_OPTFLAGS) $(HACKMLI) $($(@:.cmx=_FORPACK)) -c $< %.cmx: %.ml $(SHOW)'OCAMLOPT $<' - $(HIDE)$(OCAMLOPT) $(COND_OPTFLAGS) -c $< + $(HIDE)$(OCAMLOPT) $(COND_OPTFLAGS) $(HACKMLI) -c $< %.cmxs: %.cmx $(SHOW)'OCAMLOPT -shared -o $@' |