@@ -193,20 +193,22 @@ $(LOCAL_SRC)/%.cmx: $(LOCAL_SRC)/%.ml
193193
194194# Rules for building the [Dynlink_compilerlibs] bytecode and native packs
195195# from their components.
196-
196+ # The dynlink_compilerlibs.cmi file is unfortunately written by both the ocamlc
197+ # and ocamlopt invocations. The resulting files are different, probably because
198+ # of sharing differences. Writing an .mli file would be problematic. Instead
199+ # we allow the compiler to generate the inferred .cmi upon the ocamlc
200+ # invocation, then trick it (by touching dynlink_compilerlibs.cmi) upon the
201+ # ocamlopt invocation, which causes it to use the ocamlc-generated .cmi.
197202dynlink_compilerlibs.cmi : $(COMPILERLIBS_CMO )
203+ rm -f dynlink_compilerlibs.mli
198204 $(OCAMLC ) $(COMPFLAGS ) -pack -o dynlink_compilerlibs.cmo $(COMPILERLIBS_CMO )
199205
200206dynlink_compilerlibs.cmo : dynlink_compilerlibs.cmi
201207
202- dynlink_compilerlibs.cmx : $(COMPILERLIBS_CMX )
208+ dynlink_compilerlibs.cmx : $(COMPILERLIBS_CMX ) dynlink_compilerlibs.cmi
209+ touch dynlink_compilerlibs.mli
203210 $(OCAMLOPT ) $(COMPFLAGS ) $(OPTCOMPFLAGS ) -pack -o $@ $(COMPILERLIBS_CMX )
204211
205- # Rules for building the interface of the [Dynlink_compilerlibs] packs.
206- # To avoid falling foul of the problem described below, the .cmo and .cmx
207- # files for the dynlink-specific compilerlibs packs generated here---and in
208- # particular the corresponding .cmi files -- are kept in separate directories.
209-
210212# The main dynlink rules start here.
211213
212214extract_crc := extract_crc$(EXE )
0 commit comments