Skip to content
This repository has been archived by the owner on Feb 2, 2023. It is now read-only.

Getting started hacking the compiler

Gabriel Scherer edited this page Jun 8, 2017 · 2 revisions

Prerequisites

  • A unix-like system (Linux, MacOSX, etc.)
  • gcc and GNU Make.
  • git

Where to find the OCaml sources

Just clone the official Github repository to get a local copy of the sources:

   $ git clone https://github.com/ocaml/ocaml.git

For significant chunks of work, forking the repository on GitHub will make it easier to share patches, merge changes, etc.

There are several people around who are familiar with git and happy to help, so don't be shy about asking for guidance if you're not sure what to do.

Quickstart

The INSTALL in the OCaml distribution contains full instructions. For the impatient, the following will build the compiler:

  $ ./configure
  $ make world.opt

See the HACKING.adoc file for more information on the source tree.

Use Merlin when hacking compiler

  1. First, install Gabriel Scherer's opam-compiler-conf script

  2. Do the following to compile and install your experimental compiler. Switch to new compiler environment accordingly

      $ opam compiler-conf configure
      $ make -j world.opt
      $ opam compiler-conf install 
    

    Optionally, verify you are indeed using experimental compiler by checking ocaml -version.

  3. Now, we install Merlin. Use opam info merlin to make sure available version of Merlin is at least version 2.3. Otherwise, run opam update

      $  opam install merlin
    
  4. Try use Merlin to type compiler source code. If that does not work out, try restart your editor.

  5. When you are happy with your compiler and want to try it out, do

      $ make -j world.opt
      $ opam compiler-conf reinstall
    

    The last command will also compile Merlin (and all packages) again using new compiler.

What to work on

See the Things to work on page, which has a section dedicated to the language implementation.

Submitting patches upstream

Patches can be submitted as github pull requests.