Repository navigation
fix: support building dune with ocamlfind-secondary on older OCaml switches - #14443
Merged
Merged
Conversation
shonfeder
requested changes
May 8, 2026
shonfeder
left a comment
Member
There was a problem hiding this comment.
I tested this on my machine and it worked! Just one fix I think needed in the constraints.
…itches
The secondary compiler fallback in bootstrap.ml was broken in two ways:
1. It invoked [ocamlfind -toolchain secondary ocaml], but ocamlfind does
not support the [ocaml] toplevel as a subcommand — only compiler tools
like [ocamlc] and [ocamlopt]. We now query [ocamlfind -toolchain
secondary query ocaml -format "%d"] to locate the secondary compiler's
bin directory and invoke [ocaml] and [ocamllex] from there directly.
2. The secondary [ocaml] toplevel would pick up the primary switch's
[unix.cma] and [dllunix.so], which are ABI-incompatible. We now pass
[-I] for the secondary compiler's lib directory and set
[CAML_LD_LIBRARY_PATH] to its stublibs directory.
The opam constraint is restored to the historical pattern, allowing dune
to be installed on switches with OCaml >= 4.02 via ocamlfind-secondary:
("ocaml" {>= "4.14"} | ("ocaml" {>= "4.02" & < "4.14~~"} & "ocamlfind-secondary"))
Tested on OCaml 4.02.3 and 4.13.1 switches with ocaml-secondary-compiler
4.14.2.
Signed-off-by: Ali Caglayan <[email protected]>
Collaborator
Author
|
@kit-ty-kate Would you mind taking a look? |
shonfeder
approved these changes
May 8, 2026
Alizter
added a commit
that referenced
this pull request
May 11, 2026
shonfeder
added a commit
that referenced
this pull request
May 14, 2026
Required for the patch release since it announces a user-facing fix. Since this missed landing in main initially, it's not important to but it there, because it will just be deleted and moved into the `CHANGELOG.md` when the release is cut anyhow. --------- Signed-off-by: Shon Feder <[email protected]> Co-authored-by: Ali Caglayan <[email protected]>
This was referenced May 14, 2026
shonfeder
added a commit
to ocaml/opam-repository
that referenced
this pull request
May 19, 2026
CHANGES:
### Fixed
- Fix the `menhir` opam dependency injection introduced in 3.23. Dune
now only fills in the lower bound `{>= "20180523"}` on an existing
user-declared `menhir` dependency; it no longer adds `menhir` as a
new dependency to packages that did not declare it themselves.
(ocaml/dune#14434, fixes ocaml/dune#14428, @robinbb)
- Gate the `dune` version-bound deduplication in generated opam files
(introduced in 3.23) on `(lang dune 3.23)`. Projects at earlier lang
versions get the prior `And [...]` shape — e.g.
`{>= "3.17" & >= "3.20"}` — restoring 3.22 behaviour and avoiding a
silent change to opam output on dune-binary upgrade. (ocaml/dune#14436,
@robinbb)
- Preserve library order when building a shared jsoo standalone runtime.
(ocaml/dune#14438, @vouillon)
- Fix the fallback to the secondary compiler, allowing recovering of support for
packages with upper bounds on OCaml less than 4.14. Packages depending on dune
3.23.1 or later and with an upper bound on the OCaml compiler that is less
than 4.14, will now be able to use the latest dune, but dune will be built
with the secondary compiler at version 4.14. (ocaml/dune#14443, @Alizter)
- Fix the bootstrap on NetBSD by including `<sys/wait.h>` in `lev_stubs.c`,
matching the existing FreeBSD/OpenBSD guard.
(ocaml/dune#14512, fixes ocaml/dune#14484, @0-wiz-0)
pull Bot
pushed a commit
to metanivek/dune
that referenced
this pull request
May 19, 2026
…itches (ocaml#14443) The secondary compiler fallback in bootstrap.ml was broken in two ways: 1. It invoked `ocamlfind -toolchain secondary ocaml`, but `ocamlfind` does not support the `ocaml` toplevel as a subcommand. Only compiler tools like `ocamlc` and `ocamlopt`. We now query `ocamlfind -toolchain secondary query ocaml -format "%d"` to locate the secondary compiler's bin directory and invoke `ocaml` and `ocamllex` from there directly. 2. The secondary `ocaml` toplevel would pick up the primary switch's `unix.cma` and `dllunix.so`, which are ABI-incompatible. We now pass `-I` for the secondary compiler's lib directory and set `CAML_LD_LIBRARY_PATH` to its stublibs directory. The opam constraint is restored to the historical pattern, allowing dune to be installed on switches with OCaml >= 4.02 via ocamlfind-secondary: ``` ("ocaml" {>= "4.14"} | ("ocaml" {>= "4.02" & < "4.14~~"} & "ocamlfind-secondary")) ``` Tested on OCaml 4.02.3 and 4.13.1 switches with ocaml-secondary-compiler 4.14.2. - Fixes ocaml#13908 (cherry picked from commit 9e65007) Signed-off-by: Shon Feder <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The secondary compiler fallback in bootstrap.ml was broken in two ways:
It invoked
ocamlfind -toolchain secondary ocaml, butocamlfinddoes not support theocamltoplevel as a subcommand. Only compiler tools likeocamlcandocamlopt. We now queryocamlfind -toolchain secondary query ocaml -format "%d"to locate the secondary compiler's bin directory and invokeocamlandocamllexfrom there directly.The secondary
ocamltoplevel would pick up the primary switch'sunix.cmaanddllunix.so, which are ABI-incompatible. We now pass-Ifor the secondary compiler's lib directory and setCAML_LD_LIBRARY_PATHto its stublibs directory.The opam constraint is restored to the historical pattern, allowing dune to be installed on switches with OCaml >= 4.02 via ocamlfind-secondary:
Tested on OCaml 4.02.3 and 4.13.1 switches with ocaml-secondary-compiler 4.14.2.