Skip to content

Commit

Permalink
Fix a make -j bug, by ensuring Lazy depends on CamlinternalLazy.
Browse files Browse the repository at this point in the history
Without this patch, make -j often fails to build the stdlib with
a message along the lines of:

    no cmx file was found in path for module CamlinternalLazy

The issue is that stdlib files that use `lazy` actually depend on
camlinternalLazy.cmi because matching.ml expands lazy pattern
matches to code that refers to CamlinternalLazy. However, since
this dependency does not appear in the source code, there is no
way for ocamldep to discover it. This means that when building
the stdlib, there is no constraint ensuring that CamlinternalLazy
is built before stdlib modules using Lazy.

This causes issues with parallel make, but the issue can be
reproduced using a sequential make invocation:

    cd stdlib
    make clean
    make stdlib_stream.cmo

This patch adds a module alias to CamlinternalLazy into lazy.mli.
This alias is not used, but its presence makes ocamldep see that
all files that use Lazy depend on camlinternallazy.cmi.
  • Loading branch information
stedolan committed Nov 14, 2018
1 parent 4fadd45 commit 44224ee
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion stdlib/.depend
Expand Up @@ -104,7 +104,7 @@ stdlib__int64.cmx : stdlib.cmx stdlib__int64.cmi
stdlib__int64.cmi :
stdlib__lazy.cmo : stdlib__obj.cmi camlinternalLazy.cmi stdlib__lazy.cmi
stdlib__lazy.cmx : stdlib__obj.cmx camlinternalLazy.cmx stdlib__lazy.cmi
stdlib__lazy.cmi :
stdlib__lazy.cmi : camlinternalLazy.cmi
stdlib__lexing.cmo : stdlib__sys.cmi stdlib__string.cmi stdlib__bytes.cmi stdlib__array.cmi stdlib__lexing.cmi
stdlib__lexing.cmx : stdlib__sys.cmx stdlib__string.cmx stdlib__bytes.cmx stdlib__array.cmx stdlib__lexing.cmi
stdlib__lexing.cmi :
Expand Down
2 changes: 2 additions & 0 deletions stdlib/lazy.ml
Expand Up @@ -81,3 +81,5 @@ let lazy_from_fun = from_fun
let lazy_from_val = from_val

let lazy_is_val = is_val

module Internal = CamlinternalLazy
4 changes: 4 additions & 0 deletions stdlib/lazy.mli
Expand Up @@ -93,3 +93,7 @@ val lazy_from_val : 'a -> 'a t
val lazy_is_val : 'a t -> bool
[@@ocaml.deprecated "Use Lazy.is_val instead."]
(** @deprecated synonym for [is_val]. *)

(* For internal use. Makes explicit the dependency on
CamlinternalLazy, introduced implicitly by matching.ml *)
module Internal = CamlinternalLazy

0 comments on commit 44224ee

Please sign in to comment.