ZCaml My Caml: Everything Everywhere All at Once

Talk

SPEAKERS

Shreyas Mididoddi
Shreyas Mididoddi

ABSTRACT

Distributing native programs across multiple platforms can mean dealing with complex cross-toolchains, broken sysroots, bulky Docker setups, libc incompatibilities, and so on. All that just to get your program onto somebody else's machine.

Rust and Go make choosing a build target straightforward. We want that kind of workflow for OCaml.

Getting there with OCaml takes a bit more work. Its native compiler targets one platform per build. Target assumptions and C-toolchain configuration are baked in at build time. The OCaml compiler has to run on your host and generate code for your target. The runtime and libraries need to be built for that target too. Then you need the right C toolchain to put it all together.

Zig takes a lot of the pain away on the C side with its fantastic cross-compilation support: a C compiler, assembler, linker, and built-in libc support for many targets, without manually setting up a sysroot. ZCaml brings that power to OCaml. For each supported host–target pair, it ships an OCaml compiler configured to use zig cc, together with Zig itself. The OCaml compiler runs on your host and generates code for your target; Zig handles the C-toolchain side. No custom sysroots or Docker setups just to cross-compile for those targets.

In this talk, we'll dig into the shared cross-compilation headaches, OCaml's specific problems, and how ZCaml puts the pieces together. Then we'll build the same OCaml CLI on x86-64 Linux for both x86-64 and AArch64 Linux and run it on both. We'll also look at what works today, what still needs work, and how you can help. No prior Zig experience needed.