Skip to content

0.3.0

Choose a tag to compare

@rboudrouss rboudrouss released this 25 Oct 08:04
· 424 commits to main since this release
  • OCaml 5.0 to 5.3: the ocaml recipe builds their runtime. They commit
    the minor heap with mmap(MAP_FIXED), which emscripten lacks ("Failed
    to create main domain"): patches/5.0/ and patches/5.1/ commit it
    with mprotect as 5.2 and later do (patches/5.4+/ becomes
    patches/5.2+/). 5.0 calls pthread_getaffinity_np, which its
    configure only compiles (patches/5.0/), and names the otherlibs stub
    archives without the byt suffix.

  • OCaml 5: -pthread is kept out of the runtime by giving
    PTHREAD_CFLAGS=-D_REENTRANT to configure, instead of editing
    Makefile.config (5.0 put it in OC_CFLAGS, which the edit missed: "no
    domain lock held").

  • The C compiler of the wasm context drops CPATH, C_INCLUDE_PATH,
    CPLUS_INCLUDE_PATH and LIBRARY_PATH: their host headers came before
    those of the sysroot (ctypes-foreign's stubs were compiled with the
    host's ffi.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 an opam 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, and build builds the
    bytecode against them: struct layouts, sizeof and 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). link and doctor warn 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 without ocamlopt
    (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. The build of 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 ocamlc wrapper of the toolchains no longer writes placeholder
    dllX.so files in the host's switch, next to its installed libraries.
    On OCaml 4.x, those of unix and str in lib/ocaml (in ld.conf)
    hid the real ones: the host's ocaml unix.cma and ocamlc unix.cma
    failed (The external function unix_waitpid is not available). A
    switch where build ran before keeps them: delete the empty dll*.so
    of lib/ outside the stublibs directories.

  • --wasi (link, build): OUT.wasm is a WASI module, importing only
    WASI functions, for wasmtime, node's WASI and other WASI hosts (wasm32).
    emscripten's standalone libc fails to open or stat a 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, select and getrusage with
    poll_oneoff and the WASI clocks, dup/dup2 of 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 --wasi runs 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 by caml_startup_code, instead of a file of emscripten's
    JavaScript file system, which it does not have. link lists 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.

  • ocaml recipe: on wasm32, the integer literals beyond 31 bits are
    wrapped by caml_startup_code as well; the debug events of a program
    started by caml_startup_code can come from memory (backtraces of
    standalone modules have their locations). A runtime built before needs
    ocaml-emcc setup --force (link says so).

  • Recipes change the sources they build with patches (patches/ next to
    recipe.sh) instead of sed and perl: ocaml, libffi, liblmdb, lmdb,
    lwt, mirage-crypto, cryptokit, secp256k1-internal. The ocaml ones 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.