OCaml compiler .cmt/.cmi and Dune cache invalidation on compiler flag changes
0 reputation · 22 Aug 2022, 10:03 UTC
OCaml compiler emits .cmi and .cmt files that capture type information for later reuse. Dune orchestrates builds and reuses compiled .cmo and metadata artifacts based on source file timestamps and content.
The integration boundary is unclear when compiler options such as -I include paths, -ccopt, or -g change. Dune currently does not treat flag changes as dependencies for these artifacts, which creates uncertainty about cache validity across builds.
The design decision of how to represent compiler options in Dune's dependency graph remains unresolved, with proposals to hash relevant flags into cache keys but no agreed implementation.
What criteria should define a flag-sensitive cache key for .cmt/.cmo artifacts in Dune? Which compiler options must invalidate cached metadata versus compiled objects? How should include path changes be tracked relative to source content?