dune icon indicating copy to clipboard operation
dune copied to clipboard

When building with portable lockdirs the ocaml compiler is built with `--disable-native-compiler`

Open gridbugs opened this issue 8 months ago • 1 comments

Expected Behavior

Dune should build the ocaml compiler without the --disable-native-compiler flag on linux x86_64 and macos aarch64 (among other platforms).

Actual Behavior

When portable lockdirs is enabled, package solutions include the package ocaml-option-bytecode-only which causes the compiler to be built with the --disable-native-compiler flag.

Reproduction

I can repro this with https://github.com/gridbugs/llama/. Solve the project with a portable lockdir and then build the project with --verbose to learn the path to the compiler toolchain. Inspect the bin directory and confirm that ocamlopt is missing. Confirm that the solution includes the package ocaml-option-bytecode-only.

gridbugs avatar Jun 17 '25 14:06 gridbugs

This happens because the ocaml-compiler.5.3.0 package has this dependency:

             "ocaml-option-bytecode-only"
               {arch != "arm64" & arch != "x86_64" & arch != "s390x" & arch != "riscv64" &
                arch != "ppc64"}

By default dune solves with an unset sentinel value for arch in the hopes that that would make the solution more general. But if arch is set to a value other than the architectures in the above condition then ocaml will be built with --disable-native-compiler.

The fix is to change the default solver environments to include architectures arm64 and x86_64 as these are by far the most common.

gridbugs avatar Jun 18 '25 00:06 gridbugs