Skip to content

fix: odoc driver linking to stdlib in $prefix/lib64 - #1474

Open
katrinafyi wants to merge 7 commits into
ocaml:masterfrom
rsc-s:katrinafyi-patch-2
Open

fix: odoc driver linking to stdlib in $prefix/lib64#1474
katrinafyi wants to merge 7 commits into
ocaml:masterfrom
rsc-s:katrinafyi-patch-2

Conversation

@katrinafyi

@katrinafyi katrinafyi commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

This does two related changes to fix #1477:

  • Use Findlib's own logic for inferring stdlib directory
  • Adjust odoc_driver's classify_libs logic to also accept lib64/ and also accept files appearing outside of a package subdirectory, as the ocaml stdlib files do.

I can test that it works with dune exec odoc_driver -- fmt.


Removing the explicitly provided arguments to findlib will be more reliable than hardcoding a subpath of the opam prefix.

As of about 2 years ago, ocamlfind is able to automatically infer the config path from opam environment variables: https://github.com/ocaml/ocamlfind/blob/be2335f14cc45b5551dea4278affdfb2718eb72e/src/findlib/findlib_config.mlp#L71-L77

Also, hardcoding the env_camllib can be risky because it's not portable or overridable. On openSUSE Tumbleweed, my stdlib was actually in {prefix}/lib64 rather than the lib/ocaml which was hardcoded.

Findlib also has logic to let the user override the paths using environment variables, if needed: https://github.com/ocaml/ocamlfind/blob/be2335f14cc45b5551dea4278affdfb2718eb72e/src/findlib/findlib.ml#L281-L289

As of about 2 years ago, ocamlfind is able to automatically infer the config path from opam environment variables: https://github.com/ocaml/ocamlfind/blob/be2335f14cc45b5551dea4278affdfb2718eb72e/src/findlib/findlib_config.mlp#L71-L77

This removes the explicitly provided arguments and will be more reliable than hardcoding a subpath of the opam prefix.

Also, hardcoding the `env_camllib` can be risky because it's not portable. On openSUSE Tumbleweed, my stdlib was actually in `{prefix}/lib64` rather than the `lib/ocaml` which was hardcoded.
@jonludlam jonludlam added the no changelog This pull request does not need a changelog entry label Aug 7, 2026
@jonludlam

Copy link
Copy Markdown
Member

Thanks! I just put 'no changelog required' on this PR, but thinking about it, it's fixing a real bug that you found and that others might too - in which case it'd be useful to create an issue then have a changelog referencing it. Could you do that please?

@jonludlam jonludlam removed the no changelog This pull request does not need a changelog entry label Aug 7, 2026
@Leonidas-from-XIV

Copy link
Copy Markdown
Member

Looking at the commit that added it the code is only available in ocamlfind >= 1.9.8, so I think it requires some updates to the lower bounds in odoc.

@katrinafyi

Copy link
Copy Markdown
Contributor Author

Thanks! Added and updated the changelog, let me know if that looks okay.

I do also still intend to file the issue, as Jon suggested. I just wanted to double-check some things first and I'm away from the relevant computer right now.

@katrinafyi katrinafyi changed the title driver: Use Findlib's own logic for inferring directories fix: odoc driver linking to stdlib in $prefix/lib64 Aug 14, 2026
- Fix odoc_driver's detection of `stdlib` when it is in `$prefix/lib64`, requires ocamlfind >= 1.9.8
@katrinafyi

Copy link
Copy Markdown
Contributor Author

@jonludlam I've filed the issue and incorporated another small change which was needed to fully fix the issue :) Let me know how it looks.

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.

odoc driver cannot link to stdlib in $prefix/lib64

3 participants