Honor OCAML* environment variables in configure#173
Open
samoht wants to merge 2 commits into
Open
Conversation
Default ocaml, ocamlc, ocamlopt, ocamlmklib, ocamldep and ocamldoc to their environment variables when set, and use $ocamlc (not a bare ocamlc) to query -where and -version, so a cross build is configured entirely against the toolchain it was given: the C stub compiles against the target's caml headers and the target's compiler, not the build machine's. Native builds are unchanged, each variable defaulting to the bare tool name.
This was referenced Jun 18, 2026
Building the native plugin needs shared libraries; a cross target without them (a freestanding or static backend) still ships dynlink.cmxa, so the old `checkcmxalib dynlink.cmxa` test wrongly enabled it and the link failed against an empty shared GMP. Gate on `ocamlopt -config`'s supports_shared_libraries.
samoht
added a commit
to samoht/ocaml-solo5
that referenced
this pull request
Jun 21, 2026
End-to-end macOS check: build the aarch64 cross-compiler and cross-build zarith (C stubs + GMP) with it. Pins the not-yet-released forks (Solo5/solo5#641, mirage/ocaml-gmp#29, ocaml/Zarith#173); drop this commit, or at least the pins and fork clones, once they are in opam.
samoht
added a commit
to samoht/ocaml-solo5
that referenced
this pull request
Jun 21, 2026
Pin the not-yet-released forks (Solo5/solo5#641, mirage/ocaml-gmp#29, ocaml/Zarith#173) and build the cross-compiler plus zarith through opam. Drop this commit (or at least the pins) once they are in opam.
samoht
added a commit
to samoht/ocaml-solo5
that referenced
this pull request
Jun 21, 2026
Build the aarch64 cross-compiler (pinning Solo5/solo5#641) and cross-build zarith with it: point OCAMLC/OCAMLOPT/... at `ocamlfind -toolchain solo5` so zarith's configure (ocaml/Zarith#173) compiles caml_z.c with the cross cc. Pins the not-yet-released forks (also mirage/ocaml-gmp#29); drop this commit, or at least the pins, once they are in opam.
samoht
added a commit
to samoht/ocaml-solo5
that referenced
this pull request
Jun 21, 2026
Build the aarch64 cross-compiler (pinning Solo5/solo5#641) and cross-build zarith with it: install ocaml-gmp (mirage/ocaml-gmp#29) for its relocatable gmp.pc, then point OCAMLC/OCAMLOPT/... at `ocamlfind -toolchain solo5` and PKG_CONFIG_PATH at that gmp.pc so zarith's configure (ocaml/Zarith#173) compiles caml_z.c with the cross cc against ocaml-gmp. Drop this commit, or the pins, once the forks are in opam.
samoht
added a commit
to samoht/ocaml-solo5
that referenced
this pull request
Jun 21, 2026
Build the aarch64 cross-compiler (pinning Solo5/solo5#641) and cross-build zarith with it: install ocaml-gmp (mirage/ocaml-gmp#29) for its relocatable gmp.pc, then point OCAMLC/OCAMLOPT/... at `ocamlfind -toolchain solo5` and PKG_CONFIG_PATH at that gmp.pc so zarith's configure (ocaml/Zarith#173) compiles caml_z.c with the cross cc against ocaml-gmp. Drop this commit, or the pins, once the forks are in opam.
samoht
added a commit
to samoht/ocaml-solo5
that referenced
this pull request
Jun 22, 2026
Build the aarch64 cross-compiler (pinning Solo5/solo5#641) and cross-build zarith with it: install ocaml-gmp (mirage/ocaml-gmp#29) for its relocatable gmp.pc, then point OCAMLC/OCAMLOPT/... at `ocamlfind -toolchain solo5` and PKG_CONFIG_PATH at that gmp.pc so zarith's configure (ocaml/Zarith#173) compiles caml_z.c with the cross cc against ocaml-gmp. Drop this commit, or the pins, once the forks are in opam.
samoht
added a commit
to samoht/ocaml-solo5
that referenced
this pull request
Jun 23, 2026
Build the aarch64 cross-compiler (pinning Solo5/solo5#641) and cross-build zarith with it: install ocaml-gmp (mirage/ocaml-gmp#29) for its relocatable gmp.pc, then point OCAMLC/OCAMLOPT/... at `ocamlfind -toolchain solo5` and PKG_CONFIG_PATH at that gmp.pc so zarith's configure (ocaml/Zarith#173) compiles caml_z.c with the cross cc against ocaml-gmp. Drop this commit, or the pins, once the forks are in opam.
samoht
added a commit
to samoht/ocaml-solo5
that referenced
this pull request
Jun 23, 2026
Build the aarch64 cross-compiler (pinning Solo5/solo5#641) and cross-build zarith with it: install ocaml-gmp (mirage/ocaml-gmp#29) for its relocatable gmp.pc, then point OCAMLC/OCAMLOPT/... at `ocamlfind -toolchain solo5` and PKG_CONFIG_PATH at that gmp.pc so zarith's configure (ocaml/Zarith#173) compiles caml_z.c with the cross cc against ocaml-gmp. Drop this commit, or the pins, once the forks are in opam.
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.
configurehardcodes the OCaml tools to bare names (ocamlc,ocamlopt, ...), so it can't be pointed at a cross toolchain: cross-compiling buildscaml_z.cagainst the host compiler and headers, not the target's.This PR makes each tool honor an environment variable (
OCAML,OCAMLC,OCAMLOPT,OCAMLMKLIB,OCAMLDEP,OCAMLDOC), falling back to the bare name when unset so native builds are unchanged. SettingOCAMLC="ocamlfind -toolchain <target> ocamlc"(etc.) then builds for that target.Came up cross-building MirageOS unikernels on macOS:
gmp.pclibgmp.awith the crossar/ranlib