Adding a runtime variant for bare metal and gating most OS-dependent parts on not bare metal. It forces single domain, no threads or signals, has no-op mutexes and malloc-based memory mapping.
The runtime is meant to provide the minimum necessary surface with no-op stubs for the necessary but not relevant functions. At a minimum the user needs to provide:
- a
uint64_t caml_bare_metal_time_ns(void) - a platform which include:
readandwritefor fds 0-2, all the other fail withENOSYSmalloc,reallocandfreeabortandexit- a
libmand standard memory/string/stdio functions.
Testing:
- Compiled and linked a hello world minimal Ocaml and an
open! Core. ForCoresome extraENOSYSstubs were needed. Both ran successfully on the hardware with stdout and stderr over UART.
Potential problems:
- compiles the runtime with
-march=armv8-a -mtune=cortex-a72. Maybe this should be an external flag/target? Or make the runtime croscc compiled against aaarch64-none-elf-gcc--this would also remove the glibc/newlib conflicts. - the runtime is compiled for every build. Maybe this should be gated by target and make
--enable-runtime-baremetaldefaulting to off? getenvreturnsNULLwhich makes the runtime untunable for things like fiber/thread stack sizes. It currently defaults to 8Mb which might be unsuitable for small embedded devices.