InnocentZero's Treasure Chest

HomeFeedAbout Me

19 Feb 2025

OCaml Compiler Meetings

OCaml Compiler Meetings

12-02-2025

  • /boot directory: has the bytecode compiler. ocamlc is already committed there.
  • There is ocamlrun in runtime which is only in C, and hence can be built without OCaml.

Workflow looks like this:

  • use ocamlrun to run pre-commited ocamlc to get a bytecode compiler. This will compile code into bytecode.
  • Then we get an ocamlopt that will give you the compilers compiled in native code.
  • Using that, we can get ocamlc.opt and ocamlopt.opt. They perform the same functions but they are native executables.

There is also a test suite that allows you to test code. Go to testsuite/.

Name mangling scheme

camlStdlib__print_endline_366

before double underscores, it's module name, then it's function name, then

AST Parsing stages

  • lambda
  • clambda
  • cmm
  • linear

Register arguments

asmcomp has the registers and their meaning for all the calling conventions.

Meta

The allocation routines are present in

  • asmcomp/<arch>/emit.mlp
  • runtime/<arch>.s
  • runtime/caml/alloc.h

There's also caml_alloc_1 , caml_alloc_2, and other caml_alloc_N function calls in emit.mlp.


Other posts
Creative Commons License
This website by Md Isfarul Haque is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.