OCaml interpeter on the nintendo 3DS

@Ventuaer I took a quick peek at the specs for 3DS (128MB RAM; ARMv6) and devkitARM (GCC-based cross toolchain with pacman-installable binaries and libs). That is very similar to the Android pre-NDK23 toolchain (typically 0.5-4GB RAM devices; ARMv7; GCC-based cross toolchain w/ prebuilt binaries and libs). It sounds quite doable; a good starting point is [ANN] Simplified Android cross-compiler with DkML. Then fork dkml-compiler and add your own variation of env/android-ndk-env-to-ocaml-configure-env.sh. A few pieces of caution:

  1. The ARMv7 OCaml assembly generation backend had a couple serious bugs; the patches are in the dkml-compiler project. You might need to patch ARMv6.
  2. devkitARM has no ability to do shared libraries. I don’t think that will be a major problem, but I don’t know. At minimum, you’ll need to comment out the parts of dkml-compiler that build shared libraries in your fork.
  3. 3DS has somewhat low memory (128MB). You should stay bytecode only (comment out the parts of dkml-compiler that build native code in your fork) and I suspect you may want to patch the memory constants in runtime/caml/config.h.
  4. Unclear why you need OCaml on 3DS, so you are really on your own for support, even if others could get this project completed. Run into SIGSEGV because of an ARMv6 asmgen bug? You attach gdb, find the culprit and modify the asmgen backend. Have a question about modding dkml-compiler or how ocaml’s ./configure works? You have to figure it out yourself. Etc.

All the best.

1 Like