Why Kaleidoscope tutorial in OCaml is removed?

The official doc (LLVM Tutorial: Table of Contents — LLVM 13 documentation) has the tutorial in C++ and I can only find the tutorial in OCaml at LLVM Tutorial: Table of Contents — LLVM 12 documentation.

I found the git commit moving it to llvm-archive.

Is the OCaml tutorial outdated in the new release?

Hi @arbipher,
It was me who removed it.

I was trying OCaml tutorial. It was not building from chapter 4. I ask on discord forum about it. But it seems we (llvm community) don’t have any maintainer for ocaml binding.

So I send the patch here - ⚙ D96299 [examples] Move llvm/examples/OCaml-Kaleidoscope/ to llvm-archive and ask previous maintainer about it and they allowed to remove it.

Another llvm ocaml user also ask about it here - Move LLVM OCaml-Kaleidoscope tutorial to llvm-archive by xgupta · Pull Request #1 · llvm/llvm-archive · GitHub

I did tell reason there -

Don’t have build system. autoconf removed but cmake was added.
Don’t have any testcase.

If you want to support it, I can revert that patch.

My thinking was having tutorials is good thing but if they are unmaintained they will more frustate newcomers.

Is the OCaml tutorial outdated in the new release?

The errors I found were related to JIT. And I also found the same question on stack overflow(which is still unanswered from 2016-17). So my assumption was Ocaml tutorial is outdated from 2016-17.


Hi @Shivam ,
Thanks for your explanation.

I am learning to use the LLVM OCaml binding recently. It’s still working and updating. And I updated it to LLVM 12.0.1 in opam (ocaml package manager).

I understood the problem: the outdated build system etc.

I found one OCaml tutorial implementation for Kaleidoscope on GitHub. The good is it works (with LLVM 12 and the latest OCaml). The bad is it lacks for the chapters 8,9,10 and the code/folder structure is not identical to the C++ one. Another point is in OCaml, using a parser generator (e.g. menhir) is usually much popular than a manual lexer/parser. I guess it’s true even for OCaml LLVM users.

I am working on extending it to cover the material in chapters 8,9,10 on my own. It’s almost done and it works.

I agree with your thinking on unmaintained tutorials. Let me finish my code first and have another post to discuss on the tutorial.

It seems the DIBuilder is not in the LLVM OCaml API so my work is now paused at section 9.4.
(I found it in llvm repo. The doc I used is also outdated)

The code before that section works fine.

This is my working repo arbipher/llvm-ocaml-tutorial. I forked from llvm-ocaml-tutorial, patched it to make it work and updated it for the chapter 8 and 9.

Let me refactor the code a bit to make it more aligned with the C++ version, for a better comparison. I am thinking maybe I could make a new PR to llvm when it’s done.