Repository navigation
0.3.0
-
OCaml 5.0 to 5.3: the
ocamlrecipe builds their runtime. They commit
the minor heap withmmap(MAP_FIXED), which emscripten lacks ("Failed
to create main domain"):patches/5.0/andpatches/5.1/commit it
withmprotectas 5.2 and later do (patches/5.4+/becomes
patches/5.2+/). 5.0 callspthread_getaffinity_np, which its
configure only compiles (patches/5.0/), and names the otherlibs stub
archives without thebytsuffix. -
OCaml 5:
-pthreadis kept out of the runtime by giving
PTHREAD_CFLAGS=-D_REENTRANTto configure, instead of editing
Makefile.config(5.0 put it inOC_CFLAGS, which the edit missed: "no
domain lock held"). -
The C compiler of the wasm context drops
CPATH,C_INCLUDE_PATH,
CPLUS_INCLUDE_PATHandLIBRARY_PATH: their host headers came before
those of the sysroot (ctypes-foreign's stubs were compiled with the
host'sffi.h: "Unexpected type 0" at the first call). -
ctypes on wasm32, OCaml 5.2 and later: a library compiled against the
host's ctypes (ctypes-foreign, once zstd had rebuilt ctypes) is rebuilt
for wasm32 again. ocamlc quotes the files of "make inconsistent
assumptions", which hid them. -
A stub library of the sysroot built from an opam package (with dune, or
blindly) for another version than the installed one, after anopam upgrade, is built again: the old one was linked (digestif 1.4's blake3
primitives undefined). -
A library of the compiler missing from the runtime of the sysroot
(libthreads.a, built since) has the runtime built again, instead of
failing ("libthreads.a (wasm) not found"). -
ctypes on wasm32: ctypes and the packages of the program depending on it
are rebuilt for wasm32 (driver.sh shadow) into the sysroot's findlib
directory, which the toolchain searches first, andbuildbuilds the
bytecode against them: struct layouts,sizeofand arrays now have the
sizes of wasm32, for the structs laid out at run time and for the type
descriptions generated when the package is built (yaml now works on
wasm32).linkanddoctorwarn when a bytecode was compiled against
the host's builds, or uses a package that could not be rebuilt (packages
without dune). -
dune's
(ctypes)stanza (a project's, or a package's): dune links its
generators natively only (ocaml/dune#13650), which the wasm context
cannot. A project or package using it is built by a dune patched to link
them as custom bytecode withoutocamlopt
(share/tools/dune/ctypes-linkage.patch), built once per version from
the sources of the switch's dune: its structs have the layouts of the
target. Thebuildof a project with the stanza used to fail, and the
stubs of such packages came from their native build. -
The C compiler of the wasm context makes node scripts of the executables
it links (-sEXECUTABLE), for build rules to run, with the node of
emscripten's configuration (memory64 for wasm64). -
The
ocamlcwrapper of the toolchains no longer writes placeholder
dllX.sofiles in the host's switch, next to its installed libraries.
On OCaml 4.x, those ofunixandstrinlib/ocaml(inld.conf)
hid the real ones: the host'socaml unix.cmaandocamlc unix.cma
failed (The external function unix_waitpid is not available). A
switch wherebuildran before keeps them: delete the emptydll*.so
oflib/outside thestublibsdirectories. -
--wasi(link,build):OUT.wasmis a WASI module, importing only
WASI functions, for wasmtime, node's WASI and other WASI hosts (wasm32).
emscripten's standalone libc fails to open orstata file and imports
the rest of the file system from JavaScript:share/runtime/wasi.c
implements these system calls with WASI (preopened directories, a
current directory), sleeping,selectandgetrusagewith
poll_oneoffand the WASI clocks,dup/dup2of an opened file by
opening it again, file locks and owners as no-ops. Linked with
-sPURE_WASI, the module is translated to the standard exception
handling instructions (exnref) that WASI hosts implement.
tests/run.sh --wasiruns the suite this way (wasmtime or node's WASI),
and CI does on 4.14 and 5.5. -
A standalone
OUT.wasm(with or without--wasi) has its bytecode as C
arrays started bycaml_startup_code, instead of a file of emscripten's
JavaScript file system, which it does not have.linklists the imports
that are not WASI. -
The functions of
share/runtime/*.c(compat.c,dlsym.c,wasi.c)
that the program's libraries define as well are left out: the program's
are linked. -
ocamlrecipe: on wasm32, the integer literals beyond 31 bits are
wrapped bycaml_startup_codeas well; the debug events of a program
started bycaml_startup_codecan come from memory (backtraces of
standalone modules have their locations). A runtime built before needs
ocaml-emcc setup --force(linksays so). -
Recipes change the sources they build with patches (
patches/next to
recipe.sh) instead ofsedandperl: ocaml, libffi, liblmdb, lmdb,
lwt, mirage-crypto, cryptokit, secp256k1-internal. Theocamlones apply
to the sources of every version from 4.08 to 5.5 (on 5.0 to 5.3, the
wasm32 build used to stop on the DATA literals). A recipe's checksum
covers its patches: the "recipe changed" note shows when they change.