How common are 31b ints in modern Ocaml

Viewed 48

I'm trying to do some language interop stuff and would appreciate guidance on how important 31b deployments are to the OCaml developer community.

Specifically, whether Sys.int_size is almost always 63 (or at least ≥ 32 per the JS backend) for most deployments of OCaml or if 31b is still commonly seen in the wild.

I don't have a machine handy where sizeof (void*) == 4 so I can't just test what opam does by default there.

I looked into opam's ocaml-option-32bit.

Am I right that ocamlopt will use 31b ints if that's requested or if the architecture has 32b words?

That option seems to conflict with ocaml-vanilla-options which is required by ocaml-base-compiler but I don't know if that means it's no longer usable when ocamlopt is installed via opam.

1 Answers

You are right that the native compiler (and the bytecode) one will use 31 bits integer if either the architecture has 32bit mode or if the ocaml-option-32bit configuration flag is used.

Variants of the ocaml compiler are available from the ocaml-variants*+options opam package. It is thus possible to use the ocaml-option-32bit configuration option with opam.

It is hard to tell how much the option is used however. One possible data point is that when OCaml 5.0 announced that this specific version will not support 32bit architectures (to focus on getting a version of OCaml 5 out of the door soon enough), some people mentioned that ARM32 support was important to them.

Nevertheless, it seems relatively safe to start with supporting only 64bit mode and js_of_ocaml and to only add 32bit support if there is some demand for it.

Related