Using dkml-base-compiler instead of ocaml-base-compiler
jonahbeckford opened this issue · 1 comments
dkml-base-compiler is a new compiler package in the Opam repository. Among other things, it builds a cross-compiler for macOS (x86_64 + ARM64) and unofficially can build cross-compilers for Android (ARM32, etc.).
I can't figure out the command line options so that dkml-base-compiler.4.12.1~v1.0.0
is used as the compiler during opam monorepo lock
rather than ocaml-base-compiler.VERSION
.
Context: For my own internal needs I have been using the dunified Opam repository but do not use the opam monorepo
tools; instead I use Opam build command configuration so that opam install .
uses dune -x darwin_arm64
to build every Opam package dependency. That style of cross-compilation may be too complicated for other people. So not only would I like others to use opam monorepo
with dkml-base-compiler
but I've got some "dkml-workflows" tooling I'll be releasing that will create "native" (including cross-compiled) artifacts on GitHub Actions.
If needed, I have a Makefile that can be used to see the problems doing opam monorepo lock
with dkml-base-compiler
:
$ git clone https://github.com/diskuv/dkml-workflows-monorepo-example.git
$ cd dkml-workflows-monorepo-example
$ git reset --hard 2afd44bb59d41cf38cb382ad679b03b16fbffc85
$ make monorepo-pull
opam switch create . dkml-base-compiler.4.12.1~v1.0.0 \
--yes \
--deps-only \
--repo default=https://opam.ocaml.org,dune-universe=git+https://github.com/dune-universe/opam-overlays.git
<><> Installing new switch packages <><><><><><><><><><><><><><><><><><><><> 🐫
Switch invariant: ["dkml-base-compiler" {= "4.12.1~v1.0.0"}]
The following actions will be performed:
∗ install dkml-base-compiler 4.12.1~v1.0.0
∗ install base-unix base
...
Done.
# Run eval $(opam env) to update the current shell environment
OPAMSWITCH="$PWD" && if [ -x /usr/bin/cygpath ]; then OPAMSWITCH=$(/usr/bin/cygpath -aw "$OPAMSWITCH"); fi && \
opam monorepo lock your_example --ocaml-version=4.12.1 --require-cross-compile -vv
opam-monorepo: [DEBUG] Detected local packages:
your_example:/private/var/folders/8z/_n2pwgb92fx3sbkgkzhb484m0000gn/T/dkml-workflows-monorepo-example/your_example.opam
==> Using 1 locally scanned package as the target.
opam-monorepo: [INFO] Target package: your_example.
opam-monorepo: [INFO] Solve using current opam switch: /private/var/folders/8z/_n2pwgb92fx3sbkgkzhb484m0000gn/T/dkml-workflows-monorepo-example
opam-monorepo: [DEBUG] Removed dkml-base-compiler from formula as it is opam-provided
opam-monorepo: [DEBUG] Removed dkml-base-compiler from formula as it is opam-provided
opam-monorepo: [DEBUG] Removed dkml-base-compiler from formula as it is opam-provided
opam-monorepo: [DEBUG] Removed conf-dkml-cross-toolchain from formula as it is opam-provided
opam-monorepo: [INFO] Selected packages from dune-only run of solver: astring.0.8.5+dune,
base.v0.15.0, base-bigarray.base, base-bytes.base,
base-threads.base, base-unix.base, bos.0.2.1+dune,
camlp-streams.5.0.1, camomile.1.0.2,
cmdliner.1.1.1+dune, cppo.1.6.9, csexp.1.5.1,
diskuvbox.0.1.0, dune.3.4.1, dune-build-info.3.4.1,
dune-configurator.3.4.1, either.1.0.0,
findlib.1.8.1+dune, fix.20220121, fmt.0.9.0+dune,
fpath.0.7.3+dune, headache.1.05, logs.0.7.0+dune2,
lwt.5.6.1, mdx.2.1.0, menhir.20220210,
menhirLib.20220210, menhirSdk.20220210, ocaml.4.12.1,
ocaml-base-compiler.4.12.1,
ocaml-compiler-libs.v0.12.4, ocaml-config.2,
ocaml-options-vanilla.1, ocaml-version.3.5.0,
ocamlfind.1.8.1+dune, ocamlformat.0.24.1,
ocp-indent.1.8.1, ocplib-endian.1.2, odoc-parser.2.0.0,
ppx_derivers.1.2.1, ppx_deriving.5.2.1, ppxlib.0.27.0,
re.1.10.4, result.1.5, rresult.0.7.0+dune,
seq.base+dune, sexplib0.v0.15.1, stdio.v0.15.0,
stdlib-shims.0.3.0, uchar.0.0.2+dune2,
uucp.14.0.0+dune, uuseg.14.0.0+dune, uutf.1.0.3+dune,
your_example.zdev
opam-monorepo: [ERROR] Solving opam-provided dependencies could not find a solution
opam-monorepo: [ERROR] Can't find all required versions.
Selected: conf-dkml-cross-toolchain.4.12.1 ocaml-base-compiler&your_example
ocaml-base-compiler ocaml-base-compiler ocaml ocaml-base-compiler
ocaml-system
- astring -> astring.0.8.5+dune
User requested = 0.8.5+dune
...
- dkml-base-compiler -> (problem)
Rejected candidates:
dkml-base-compiler.4.12.1~v1.0.0: In same conflict class (ocaml-core-compiler) as ocaml-base-compiler
...
- ocaml-options-vanilla -> ocaml-options-vanilla.1
User requested = 1
- ocaml-system -> (problem)
Rejected candidates:
ocaml-system.4.12.1: In same conflict class (ocaml-core-compiler) as ocaml-base-compiler
...
make: *** [your_example.opam.locked] Error 1
For now I'm hand editing the .locked
file.
Hi @jonahbeckford. I'm afraid that's currently not possible since the compiler names are hardcoded because for dependency resolution these have to be special-cased.
However, it should be possible to rework the code to e.g. allow overwriting the default name of the compiler and using the flags: compiler
field from OPAM to avoid having to hardcode ocaml-variants
and ocaml-base-compiler
in the base_packages
, which I think would be a solid improvement.