Commit d5e0d6a
committed
fix: keep [Stdlib]-provider lib in [kept_libs] under narrowing
Every OCaml/Melange compile implicitly opens [Stdlib] before reading
its source. The implicit open is not visible in [ocamldep -modules]
output (ocamldep reports only modules named in source), so it never
appears in the BFS frontier and the lib that provides [Stdlib] is
dropped from [kept_libs] under L6's filtered-include-flags path.
For OCaml-mode compiles this is typically invisible: [Stdlib] lives on
the compiler's built-in include path (via [+stdlib]); no dune-managed
lib provides a module named [Stdlib], so the [Lib_index] lookup for
[Stdlib] is empty and no narrowing decision depends on it.
For Melange-mode compiles (post-L10), [Stdlib] lives in the
[melange]/[stdlib] dune library, and dropping its [-I] from a
consumer's compile rule causes [Error: Unbound module Stdlib] at the
[-open] resolution step the moment that consumer's source references
any [Stdlib] type ([int], [float], etc.) without syntactically naming
a [Stdlib.X] member.
Force [Stdlib] onto the initial BFS frontier in [lib_deps_for_module]
alongside [all_raw] and [open_modules]. The injection is mode-agnostic
— the [Lib_index] lookup decides what (if anything) to include:
- Typical OCaml project: no dune lib named [Stdlib], lookup is empty,
zero effect.
- Melange project: pulls in the [melange]/[stdlib] lib via the normal
classification path. Fixes the Stdlib-resolution bug.
- Unwrapped OCaml lib that exports a [Stdlib] module (rare): the
lookup hits and that lib's [-I] + [Stdlib.cmi] are kept in every
consumer's compile rule. Matches the broad-dep path's behavior
pre-narrowing — slight precision loss (extra dep) but soundness
preserved.
- Wrapped lib with a [Stdlib.ml] sibling: index records only the
wrapper name, lookup is empty, no effect.
Reproduced and fixed against:
- belt unit lib (melange 6.0.1-54): rebuild from scratch under L10
dune now produces all [belt__Belt_*.cmi]/[cmj] artefacts (was
failing with [Error: Unbound module Stdlib] on every [.pp.mli]
whose source did not syntactically name [Stdlib.X]).
- ocaml#14732 CI: macOS opam [Install deps] step failed
compiling melange.6.0.1-54 with hundreds of identical errors, same
root cause.
Signed-off-by: Robin Bate Boerop <me@robinbb.com>1 parent 6cf56fa commit d5e0d6a
1 file changed
Lines changed: 16 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
180 | 180 | | |
181 | 181 | | |
182 | 182 | | |
183 | | - | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
184 | 199 | | |
185 | 200 | | |
186 | 201 | | |
| |||
0 commit comments