Skip to content

Initial support for OCaml 5.6#2227

Draft
vouillon wants to merge 9 commits into
masterfrom
ocaml-5.6
Draft

Initial support for OCaml 5.6#2227
vouillon wants to merge 9 commits into
masterfrom
ocaml-5.6

Conversation

@vouillon
Copy link
Copy Markdown
Member

No description provided.

udesou added a commit to ocaml-bench/macro-benches that referenced this pull request May 6, 2026
The 6.2.0 release rejects OCaml >= 5.5 outright; the upstream
ocaml-5.6 branch (PR ocsigen/js_of_ocaml#2227) extends the bound to
< 5.7, which covers our 5.4.1 / d8bb46c (5.5-beta) / trunk matrix.
jsoo's command-line code uses Cmdliner.Arg.Completion, which was
added in Cmdliner 2.0, so we also vendor cmdliner v2.1.0 instead of
the lockfile's 1.3.0.

Workload is the runtime's own ocamlc.byte (~3.5 MB shipped in every
switch's bin/, version-matched by construction). jsoo translates it
to JavaScript — exercising bytecode parsing, SSA / IR pipeline,
optimisation passes, and JS code generation. Wall ~7-9s, lands in
the macrobench envelope.

Two run-time gotchas baked into the wrapper:
  - jsoo uses Findlib at run time to resolve `+stdlib/`. The default
    findlib.conf in opam switches uses *relative* paths
    (`destdir="."`, `path="./ocaml:."`) which findlib resolves
    against CWD, not against the conf file's dir — so running jsoo
    from anywhere except $SWITCH/lib fails with
    `No_such_package(stdlib)`. We write a sibling findlib-<TAG>.conf
    next to the wrapper with absolute paths and point
    OCAMLFIND_CONF at it.
  - At build time, dune's `ocaml-compiler-libs.read_cma` requires
    the runtime under test's ocamlc to compile (Cmo_format.compunit
    constructor visibility). running-ng's per-cell PATH setup
    handles this; manual invocations need
    PATH=$SWITCH/bin:$PATH or the build picks up the wrong ocamlc.

Setup-monorepo.sh now clones the jsoo ocaml-5.6 branch and cmdliner
v2.1.0 explicitly (both replace what opam-monorepo's lockfile would
provide). Same pattern as the merlin clone.

Smoke results (running-ng, 1 invocation, fp_flambda baselines):
  5.4.1   wall=7.22s gc%=33% RSS=340 MB minor=2260 major=28
  d8bb46c wall=8.33s gc%=38% RSS=273 MB minor=2348 major=33

Removes the stale `gen_workload.sh` + workload.{ml,byte,cmi,cmo}
artifacts that were used by the previous parked configuration.

Updates README counts, cross-table, file layout listing, patches
table; integrates with the (separately landed) dune_bootstrap
removal.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
vouillon added 9 commits May 8, 2026 14:58
OCaml 5.5 added Hashtbl.find_and_remove and find_and_replace, and the
SeededS module type now requires them. The vendored htbl.ml lagged,
so the HofM functor failed to satisfy SeededS. Pull in the updated
upstream test (adds the two methods and a new assertion block) and
bump the dune build_if gate to 5.5.
OCaml 5.6 stdlib's Hashtbl now reads the runtime's randomization flag
through two new primitives. Implement them in the JS and Wasm runtimes,
gated on Version >= 5.6.
OCaml 5.6 reshaped the effect-handler ABI (commit a0ab87686082):
RESUME/RESUMETERM/REPERFORMTERM no longer carry a tail/last_fiber
slot, the effc handler arity drops by one (last_fiber removed), and
the cont_last_fiber primitive is gone.

In parse_bytecode, stop reading the tail slot for >= 5.6 and emit a
placeholder Pc 0 so the IR shape (%resume 4-arg, %reperform 3-arg)
stays stable -- effects.ml and the rest of the pipeline are unchanged.

In the JS and Wasm runtimes (CPS and JSPI modes), fork the perform /
reperform paths by OCaml version: the >= 5.6 variants call the user
handler without last_fiber. Reperform reuses the tail we already
maintain at cont[2] on every (re)perform, so no chain-walk is needed.
OCaml 5.6 (commit 068ef65491, "Implement primitive aliases") moved
external declarations from value_description.pval_prim to a separate
primitive_description type, with a pprim_kind variant distinguishing
plain primitives (Pprim_decl) from aliases (Pprim_alias).

Use ppx_optcomp_light to fork between the two AST shapes: pre-5.6
hooks Ast_mapper.value_description to read pval_prim, 5.6+ hooks
primitive_description and reads the string list from Pprim_decl
(aliases are skipped, since they reference an OCaml value rather
than a C primitive).
The 5.4 toplevel_expect_test.ml works unchanged on 5.6.
It is used since OCaml 5.6 to implement Atomic.Array.
Export it as an alias on caml_make_vect, mirroring the JS runtime.
OCaml 5.6's ocamllex emits a missing-case warning when the rule has no
'| _' fallback. The calculator only accepts digits, whitespace, and a
fixed set of operators; an unexpected character was previously
implementation-defined and is now a parse failure.
OCaml 5.6 deprecated Gc.stat in favour of full_major () followed by
quick_stat (). The "stat" test deliberately exercises Gc.stat itself
to verify the record's layout, so suppress the alert at the call site
rather than substitute the recommended replacement.
@hhugo hhugo mentioned this pull request May 11, 2026
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant