Skip to content

fix(menhir): preserve compiler stdlib in inference sandbox - #15679

Closed
Alizter wants to merge 2 commits into
ocaml:mainfrom
Alizter:issue-15642-macos-relocatable-compiler
Closed

Alizter wants to merge 2 commits into
ocaml:mainfrom
Alizter:issue-15642-macos-relocatable-compiler

Conversation

@Alizter

@Alizter Alizter commented Aug 4, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Declare the configured compiler standard-library directory as a hidden
dependency of the ocamlc -i invocation used for Menhir type inference. This
materializes the standard library at its executable-relative location when a
package-managed compiler is invoked through a sandbox symlink on macOS, without
adding it to the compiler load path. As a result, -nostdlib and replacement
standard libraries remain respected.

Add a macOS-only regression test with a native compiler wrapper that reproduces
the platform-specific executable-path behavior.

Related Issue and Motivation

Fixes #15642.

Testing

  • The macOS regression-test commit fails with Unbound module Stdlib before the
    fix.
  • The targeted cram test was invoked locally and skipped on the non-macOS host.
  • CI is running against the updated revision.

@Alizter
Alizter force-pushed the issue-15642-macos-relocatable-compiler branch from 94ef90a to 65d688b Compare August 5, 2026 15:38
@Alizter Alizter changed the title fix(menhir): include compiler stdlib during inference fix(menhir): preserve compiler stdlib in inference sandbox Aug 5, 2026
@shonfeder shonfeder self-assigned this Sep 2, 2026
@shonfeder

Copy link
Copy Markdown
Member

I built on this in #16374, which also fixes the additional problem that is causing the macos CI test to fail here. Thanks!

@shonfeder shonfeder closed this Sep 12, 2026
shonfeder added a commit that referenced this pull request Sep 25, 2026
…enhir with package management (#16374)

## Description

The relocatable ocaml compiler relies on platform-specific heuristics to
find the compiler executable, which it then uses to locate the Stdlib.
When the relocatable ocaml compiler is managed as a regular package by
dune package management, we had been (unintentionally) relying on
behavior that is only guaranteed on Linux to make up for a rule that did
not specify its dependency on the Stdlib. This allowed
#15642 to surface on macOS.

To fix this error across all platforms, two fixes are required:

1. The stdlib must be added as an explicit dependency for the rule that
generates interfaces.
2. In case the the path to the stdlib is located inside the `_build`
directory (as it is when using dune package management with the
relocatable compiler), we need to reclassify the path as `Local`, to
ensure the stdlib will get linked into the sandbox where it is needed.

## Related Issue and Motivation

Fixes #15642

Builds on and supersedes #15679
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.

Build fails with Unbound module Stdlib when a project uses menhir with package management

2 participants