Using `day10` to build an OxCaml project
Mark Elvers
~1 min read

Categories

  • ocaml,day10,oxcaml

Tags

  • tunbury.org

Today, looking at my OxCaml inference engine, I wanted to see whether day10 build . could build an OxCaml project.

As I already had oxcaml/opam-repository, clone locally, along with ocaml/opam-repository. day10 supports multiple repositories on the command line and in .day10, so it should work.

The project had no .opam file, so I wrote a minimal one based on dune-project:

opam-version: "2.0"
synopsis: "Tessera ONNX inference engine in OxCaml with AVX2 SIMD"
maintainer: "mark@tarides.com"
authors: "Mark Elvers"
license: "ISC"
depends: [
  "ocaml-variants" {= "5.2.0+ox"}
  "dune" {>= "3.21"}
  "ocaml-protoc"
  "pbrt"
  "ocaml_simd"
  "base_bigstring"
]
build: [
  ["dune" "build" "-p" name "-j" jobs]
]

The OxCaml compiler is ocaml-variants.5.2.0+ox, and day10 parses OCAML_VERSION straight through OpamPackage.of_string, so the literal name has to match the package as it appears in the repository.

A .day10 in the project root pins the compiler and lists the two repositories. The order matters: the overlay comes first, so its +ox forks shadow the upstream versions:

OCAML_VERSION=ocaml-variants.5.2.0+ox
OPAM_REPOSITORY=/home/mtelvers/opam-repository-oxcaml
OPAM_REPOSITORY=/home/mtelvers/opam-repository

day10 build . solved the constraints, built the dependency layers, and produced a working _build/default/bin/main.exe.

The project code is available at mtelvers/day10 and the inference engine is at mtelvers/oxcaml-infer.