Skip to content

fix(lib_config): only localize stdlib if its in a context - #16563

Merged
shonfeder merged 1 commit into
mainfrom
shonfeder/oxcaml-trunk-localized-stdlib-fix
Oct 13, 2026
Merged

shonfeder merged 1 commit into
mainfrom
shonfeder/oxcaml-trunk-localized-stdlib-fix

Conversation

@shonfeder

@shonfeder shonfeder commented Oct 9, 2026 •

Copy link
Copy Markdown
Member

Description

This weaken the assumption governing when paths to the stdlib placed within the _build directory are localized: previously, they were localized whenever the path wish in the _build directory; we now only localize the path if it is within a registered context. See 659a32c for a more detailed account of the rationale.

Related Issue and Motivation

Fixes #16521

Followup to #16374

Checklist

@shonfeder

Copy link
Copy Markdown
Member Author

I still need to review the tests here, clean up LLM garbage descriptions, verify the logic is all sound in the repro, and confirm the oxcaml trunk build goes thru now (I'm getting a different, I think unrelated failure, trying to build it locally, but I'll need to debug with fresh eyes tomorrow).

@shonfeder

Copy link
Copy Markdown
Member Author

The CI failures here look to be on main, and I think Ali has diagnosed at #16561 (comment)

@shonfeder
shonfeder force-pushed the shonfeder/oxcaml-trunk-localized-stdlib-fix branch from 55fb8ad to 659a32c Compare October 9, 2026 20:33
;;

let create ocaml_config ~ocamlopt =
let create ocaml_config ~ocamlopt ~stdlib_dir =

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not crazy about adding this extra argument, but AFAIK the alternative is to make this pure computation become a t Memo.t, because we need to search in the registered contexts.

@shonfeder
shonfeder marked this pull request as ready for review October 9, 2026 21:13
@shonfeder
shonfeder requested review from Alizter and rgrinberg October 9, 2026 21:13
@shonfeder shonfeder mentioned this pull request Oct 9, 2026
3 tasks done
@Alizter

Alizter commented Oct 12, 2026

Copy link
Copy Markdown
Collaborator

@shonfeder Would you mind splitting the reproduction case into a separate PR? The test commit will likely fail, since locally it doesn't seem to be atomic. It will allow us to consider dropping the menhir dependency too which I suspect is not necessary.

@shonfeder

Copy link
Copy Markdown
Member Author

@shonfeder Would you mind splitting the reproduction case into a separate PR? The test commit will likely fail, since locally it doesn't seem to be atomic. It will allow us to consider dropping the menhir dependency too which I suspect is not necessary.

#16580

@shonfeder

shonfeder commented Oct 12, 2026 •

Copy link
Copy Markdown
Member Author

The test commit will likely fail, since locally it doesn't seem to be atomic.

Could you elaborate? I don't understand what you mean by "locally it doesn't seem to be atomic", because I don't know what "locally" means in this context.

edit: ah, just means local to the commit. Indeed, that commit is missing expected output in the cram test. Good catch, thanks.

@shonfeder
shonfeder force-pushed the shonfeder/oxcaml-trunk-localized-stdlib-fix branch from 659a32c to 3fb387c Compare October 13, 2026 00:19
@shonfeder shonfeder mentioned this pull request Oct 13, 2026
62 tasks done
shonfeder added a commit that referenced this pull request Oct 13, 2026
It is an established convention for artifacts to end up in _build that
are not tracked by dune's build engine, so long as they stay out of
dune's workspace contexts or its private directories. Dune itself does
this with its trace files, but we also see this with oxcaml, which puts
artifacts in a _build/_bootinstall (e.g., in
https://github.com/oxcaml/oxcaml/blob/main/Makefile.common-ox#L216-L228).
It is reasonable, and convenient for users, for dune to to allow this.

However, oxcaml happens to be locating a built compiler in that
location, which caused the fix in
#16374 to produce a regression when
building the oxcaml trunk for the following reason: the fix in #16374
ensured that the stdblib provided by portable compilers via dune package
management was made accessible in sandboxed builds cross all supported
platforms (as far as we know). To achieve this, it localizes the path to
the stdlib *if* the stdlib is in the build directory. This is reasonable
to do under the assumption that anything within the _build directory is
managed by dune's build. However, this invariant does not hold, as shown
by the the convention of putting stuff that is not part of dune's build
in the root of the _build directory. This fix weakens the assumption, so
that now only stdlibs located within a registered *context* within the
_build directory get localized. The required invariant should indeed
hold in that case, and we avoid the build failure on oxcaml (or any
other project doing similar things).

Signed-off-by: Shon Feder <[email protected]>
@shonfeder
shonfeder force-pushed the shonfeder/oxcaml-trunk-localized-stdlib-fix branch from 3fb387c to faa54cc Compare October 13, 2026 15:09
@shonfeder
shonfeder merged commit e59cd0f into main Oct 13, 2026
36 of 37 checks passed
@shonfeder
shonfeder deleted the shonfeder/oxcaml-trunk-localized-stdlib-fix branch October 13, 2026 16:29
@shonfeder shonfeder mentioned this pull request Oct 13, 2026
3 tasks done
shonfeder added a commit that referenced this pull request Oct 13, 2026
## Description

The oxcaml trunk builds started failing. I think this was due to
https://github.com/oxcaml/oxcaml/pull/6562/changes#diff-6cff31f46da42c5f179cda29f9fe7f8dbb6441dcb4d1bd5bfa0a2b9070d87325R107
which ends up leading to tests being built and run on C++, if it's
available (as per the target at
https://github.com/oxcaml/oxcaml/pull/6562/changes#diff-84be0d67b9397fd509a12b5fbc24ec217c1a8f3900388234f6a2a28d102211bbR1266).

The `NIX_CFLAGS_COMPILE` apparently get passed to both C++ and C
compilation, but `-std=gnu17` is not valid for C++, leading to the
error:

```
cc1plus: error: command-line option '-std=gnu17' is valid for C/ObjC but not for C++ [-Werror]
cc1plus: all warnings being treated as errors
```

As per NixOS/nixpkgs#79303, `CFLAGS` (resp.
`CXXFLAGS` should be preferred).

Applying that fix here allows us to get a clean build of the oxcaml
trunk with dune.

CI results:

- The motivating build failure:
https://github.com/ocaml/dune/actions/runs/37988037703/job/114014841515
- A job run against this fix:
https://github.com/ocaml/dune/actions/runs/37992567833/job/114030249421

Note that this is on top of #16563 and will need a rebase once that is
merged.


## Checklist

- [x] Tests added, if applicable.
- [x] [Change log entry
added](../CONTRIBUTING.md#updating-the-changelog) for any user-facing
changes.
- [x] Documentation added for any user-facing changes.
@Alizter Alizter added this to the 3.26.0 milestone Oct 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Trunk of oxcaml fails to build after new handling of sandboxed stdlib

2 participants