Repository navigation
fix: .cmxs build racing native stubs archive - #14500
Merged
Merged
Conversation
Alizter
force-pushed
the
push-pmorwuzttmyp
branch
from
May 12, 2026 17:20
bda4572 to
09cd74f
Compare
For libraries with mode-dependent foreign stubs, the .cmxa links against -l<lib>_stubs_native via -cclib. The .cmxs link follows that -cclib and needs libfoo_stubs_native.a, but build_shared was declaring a dep on the byte stubs archive instead (Only Byte). The native stubs archive was undeclared, so parallel builds could race and fail with: ld: error: unable to find library -lcachet_stubs_native Switch the dep to Only Native. For non-mode-dependent stubs both branches return nothing, so behavior is unchanged there. Fixes ocaml#12964. Signed-off-by: Ali Caglayan <[email protected]>
Alizter
force-pushed
the
push-pmorwuzttmyp
branch
from
May 13, 2026 12:47
09cd74f to
b16a1b0
Compare
nojb
approved these changes
May 13, 2026
nojb
left a comment
Collaborator
There was a problem hiding this comment.
I am not familiar with the code enough to confirm 100% this is the right fix, but the explanation and the patch certainly looks reasonable. LGTM
This was referenced May 28, 2026
raphael-proust
pushed a commit
to ocaml/opam-repository
that referenced
this pull request
Jun 30, 2026
CHANGES: ### Fixed - Fix promotion failure when a target changes from a directory to a file between builds, causing "Is a directory" errors. (ocaml/dune#14371, fixes ocaml/dune#5647, fixes ocaml/dune#6575, @Alizter) - Make `dune build @doc` pick up an odoc installed via `dune tools install odoc` even without `DUNE_CONFIG__LOCK_DEV_TOOL=enabled`, mirroring how `dune fmt` consumes a locked ocamlformat (ocaml/dune#14426, fixes ocaml/dune#14235, @mt-caret) - Reject `(package ...)` inside a named dependency binding (`(deps (:name (package foo)))`). Previously this was silently accepted but `%{name}` would resolve to an empty path list. (ocaml/dune#14499, @Alizter) - Fix incorrect dependency in the `.cmxs` build for libraries with mode-dependent foreign stubs: the rule depended on the byte stubs archive instead of the native one, so parallel builds could fail to find `-l<lib>_stubs_native`. (ocaml/dune#14500, fixes ocaml/dune#12964, @Alizter) - Fix `dune build` failing with "No rule found" when `lock_dir` paths in `dune-workspace` contain a subdirectory (e.g. `(path sub/dune.lock)`). (ocaml/dune#14524, fixes ocaml/dune#14523, @Alizter) - Artifact substitution repairs executable bit if it's not set correctly in the workspace (ocaml/dune#14556, @rgrinberg) - Ignore `EINVAL` when accepting sockets on MacOS (ocaml/dune#14612, fixes ocaml/dune#12660, @rgrinberg) - Validate profile names. Profile names must be non-empty and can only contain letters, digits, `_` and `-`. The name `_` is reserved as a wildcard in `(env ...)` stanzas. (ocaml/dune#14657, fixes ocaml/dune#14630, @rlepigre) ### Added - Add `%{pkg:<package>:<section>:<path>}` pform for resolving package install files. Works with workspace packages, lock-file packages, and installed packages. (ocaml/dune#14200, fixes ocaml/dune#14193, fixes ocaml/dune#3378, @Alizter) - Enable the relocatable compiler by default for package management (ocaml/dune#14357, fixes ocaml/dune#14012, @Alizter) - Add changed source files to the `build-start` trace event for watch-mode restarts, showing the paths that triggered the rebuild (ocaml/dune#14396, @rgrinberg) - Add dune's rusage information in start/finish build trace events (ocaml/dune#14402, @rgrinberg) - Add a status message for RPC clients that manage to connect (ocaml/dune#14424, @rgrinberg) - Allow blang expressions in the `runtest_alias` field in the `cram` stanza (ocaml/dune#14425, @rgrinberg) - Extend the stat based cache to cache the contents of directories and not just source files (ocaml/dune#14469, @rgrinberg). - Show the number of connected RPC clients in the watch mode status line (ocaml/dune#14489, @rgrinberg) - Promote directory targets from experimental to generally available in 3.24 (ocaml/dune#14579, @rgrinberg) ### Changed - Use `/` as directory separator when appending local paths to external paths, making path construction consistent across platforms. (ocaml/dune#14278, @Alizter) - On Windows, normalise process paths to `\` before passing them to `CreateProcessW` so that programs which scan `argv[0]` (notably `cmd.exe`) do not misparse mixed separators. (ocaml/dune#14278, @Alizter) - `%{bin:NAME}` now resolves to the build artifact path rather than the install staging path. Rules with `%{bin:NAME}` deps additionally get a per-rule `.binaries` directory prepended to the action's `PATH`, containing correctly-named symlinks for each declared bin pform dep. (ocaml/dune#14432, fixes ocaml/dune#3324, @Alizter) - Replace the Rocq language field `(stdlib ...)` with the presence-only field `(no_corelib)` in Rocq language 0.14. (ocaml/dune#14452, fixes ocaml/dune#14358, @Durbatuluk1701) - Throttle sandbox creation to 250 concurrent sandboxes. (ocaml/dune#14464, @rgrinberg) - The package solver now uses cached revision store lookups for improved performance. (ocaml/dune#14494, fixes ocaml/dune#12637, @Alizter, @rgrinberg) - Remove the deprecated `(lang coq)` Coq Build Language. Use the Rocq Build Language (`(using rocq <version>)`) instead. Projects that still declare `(using coq <version>)` now get an error pointing them at Rocq. (ocaml/dune#14525, fixes ocaml/dune#12788, @Alizter)
craff
pushed a commit
to craff/opam-repository
that referenced
this pull request
Jul 25, 2026
CHANGES: ### Fixed - Fix promotion failure when a target changes from a directory to a file between builds, causing "Is a directory" errors. (ocaml/dune#14371, fixes ocaml/dune#5647, fixes ocaml/dune#6575, @Alizter) - Make `dune build @doc` pick up an odoc installed via `dune tools install odoc` even without `DUNE_CONFIG__LOCK_DEV_TOOL=enabled`, mirroring how `dune fmt` consumes a locked ocamlformat (ocaml/dune#14426, fixes ocaml/dune#14235, @mt-caret) - Reject `(package ...)` inside a named dependency binding (`(deps (:name (package foo)))`). Previously this was silently accepted but `%{name}` would resolve to an empty path list. (ocaml/dune#14499, @Alizter) - Fix incorrect dependency in the `.cmxs` build for libraries with mode-dependent foreign stubs: the rule depended on the byte stubs archive instead of the native one, so parallel builds could fail to find `-l<lib>_stubs_native`. (ocaml/dune#14500, fixes ocaml/dune#12964, @Alizter) - Fix `dune build` failing with "No rule found" when `lock_dir` paths in `dune-workspace` contain a subdirectory (e.g. `(path sub/dune.lock)`). (ocaml/dune#14524, fixes ocaml/dune#14523, @Alizter) - Artifact substitution repairs executable bit if it's not set correctly in the workspace (ocaml/dune#14556, @rgrinberg) - Ignore `EINVAL` when accepting sockets on MacOS (ocaml/dune#14612, fixes ocaml/dune#12660, @rgrinberg) - Validate profile names. Profile names must be non-empty and can only contain letters, digits, `_` and `-`. The name `_` is reserved as a wildcard in `(env ...)` stanzas. (ocaml/dune#14657, fixes ocaml/dune#14630, @rlepigre) ### Added - Add `%{pkg:<package>:<section>:<path>}` pform for resolving package install files. Works with workspace packages, lock-file packages, and installed packages. (ocaml/dune#14200, fixes ocaml/dune#14193, fixes ocaml/dune#3378, @Alizter) - Enable the relocatable compiler by default for package management (ocaml/dune#14357, fixes ocaml/dune#14012, @Alizter) - Add changed source files to the `build-start` trace event for watch-mode restarts, showing the paths that triggered the rebuild (ocaml/dune#14396, @rgrinberg) - Add dune's rusage information in start/finish build trace events (ocaml/dune#14402, @rgrinberg) - Add a status message for RPC clients that manage to connect (ocaml/dune#14424, @rgrinberg) - Allow blang expressions in the `runtest_alias` field in the `cram` stanza (ocaml/dune#14425, @rgrinberg) - Extend the stat based cache to cache the contents of directories and not just source files (ocaml/dune#14469, @rgrinberg). - Show the number of connected RPC clients in the watch mode status line (ocaml/dune#14489, @rgrinberg) - Promote directory targets from experimental to generally available in 3.24 (ocaml/dune#14579, @rgrinberg) ### Changed - Use `/` as directory separator when appending local paths to external paths, making path construction consistent across platforms. (ocaml/dune#14278, @Alizter) - On Windows, normalise process paths to `\` before passing them to `CreateProcessW` so that programs which scan `argv[0]` (notably `cmd.exe`) do not misparse mixed separators. (ocaml/dune#14278, @Alizter) - `%{bin:NAME}` now resolves to the build artifact path rather than the install staging path. Rules with `%{bin:NAME}` deps additionally get a per-rule `.binaries` directory prepended to the action's `PATH`, containing correctly-named symlinks for each declared bin pform dep. (ocaml/dune#14432, fixes ocaml/dune#3324, @Alizter) - Replace the Rocq language field `(stdlib ...)` with the presence-only field `(no_corelib)` in Rocq language 0.14. (ocaml/dune#14452, fixes ocaml/dune#14358, @Durbatuluk1701) - Throttle sandbox creation to 250 concurrent sandboxes. (ocaml/dune#14464, @rgrinberg) - The package solver now uses cached revision store lookups for improved performance. (ocaml/dune#14494, fixes ocaml/dune#12637, @Alizter, @rgrinberg) - Remove the deprecated `(lang coq)` Coq Build Language. Use the Rocq Build Language (`(using rocq <version>)`) instead. Projects that still declare `(using coq <version>)` now get an error pointing them at Rocq. (ocaml/dune#14525, fixes ocaml/dune#12788, @Alizter)
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.
Summary
For libraries with mode-dependent foreign stubs, the
.cmxalinks against-l<lib>_stubs_nativevia-cclib. The.cmxslink (ocamlopt -shared) follows that-ccliband statically resolveslibfoo_stubs_native.a, so the rule must depend on the native stubs archive.build_sharedwas instead declaring a dep on the byte stubs archive (viaLibrary.foreign_lib_files ~for_mode:(Only Byte)), which is never referenced anywhere in the cmxs link chain. The native stubs archive was undeclared, so under parallel builds the cmxs link could race the native stubs archive rule and fail with:This matches the symptom from the FreeBSD/Linux CI flakes reported in #12964.
The fix switches the dep to
Only Native. For non-mode-dependent stubs both branches return nothing fromforeign_lib_files, so behavior is unchanged there. For mode-dependent stubs, the cmxs now correctly depends onlibfoo_stubs_native.a.