Skip to content

Allow overriding the output path for compile and compile-impl#1462

Open
jonludlam wants to merge 8 commits into
ocaml:masterfrom
jonludlam:driver-fixes-plus-output-override
Open

Allow overriding the output path for compile and compile-impl#1462
jonludlam wants to merge 8 commits into
ocaml:masterfrom
jonludlam:driver-fixes-plus-output-override

Conversation

@jonludlam

Copy link
Copy Markdown
Member

Before this commit, we were very strict about where the output of odoc compile and odoc compile-impl went, as it's very important to ensure that we can specify paths correctly for -L. However, with the idea of putting the odoc files into the switch, we can relax this somewhat, on the basis that if the output files go alongside the cmis, then we're inheriting exactly the same path-based resolution that the compiler has, and if it's good enough for the compiler, it should be good enough for us!

This is on top of the driver changes commits.

jonludlam and others added 8 commits July 17, 2026 17:59
read_libraries_from_pkg_defs only looked up the archive under the
[byte]/[native] predicates. ppx derivers such as ppxlib.traverse and
ppxlib.metaquot declare their archive only under the ppx_driver
predicate, so they were dropped here and later re-discovered by the
no-META fallback, which names a library after its .cma file (e.g.
ppxlib_traverse instead of ppxlib.traverse).

Also try the [byte; ppx_driver] and [native; ppx_driver] predicates,
mirroring Ocamlfind.archives which the non-voodoo driver already uses.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Previously the include set passed to `odoc compile`/`compile-impl` was
derived from the compiled library's whole dependency set (every library
it requires). That implies doing the transitive closure over all
libraries' dependencies. In voodoo mode, we only have the META files
for the package being documented, so this isn't possible.

Instead, derive the include set from the unit's actual per-module
dependencies. Each dependency carries the interface hash of the module
it refers to; look that hash up among the units being compiled plus the
partials of already-compiled dependencies, and take the directory of the
providing unit. This is more precise (far fewer `-I` flags) and doesn't
depend on META completeness.

Applies to both interfaces and implementations; `impl_extra` now carries
the implementation's dependency list. In the non-voodoo driver, where
the library-level set was already complete, source-link output is
byte-for-byte identical.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Compute the link phase's -I search path per library -- the union of its
units' dependency cones, the same directories the compiler used -- rather
than a package-wide set. -L and -P remain package-wide and unvarying (the
reference scope). Because a library's -I holds only its own cone, alternative
implementations of a virtual library never share a search path, so no
sibling-exclusion special-case is needed.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Document, in driver.mld and the author-facing odoc_for_authors.mld, the
reference-scope convention for opam-installed packages: the per-package
-P/-L reference scope, the per-unit -I include path, and the
odoc-config.sexp stanzas. Also capture the broader driver guidance learned
from building the odd driver -- the compile/link include model,
virtual-library handling, and what a driver should compile.
Previously 'odoc compile' silently ignored -o when --parent-id was
passed, and --output-dir was mandatory alongside --parent-id. Now -o
takes precedence over the path computed from --parent-id and
--output-dir, and --output-dir may be omitted when -o is given. The
identifier is still derived from --parent-id and the output basename.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Mirrors the same change to 'odoc compile': -o now takes precedence over
the path computed from --parent-id and --output-dir (which becomes
optional), so drivers can place impl .odoc files freely, e.g. next to the
interface .odoc in an object directory.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant