Compile Ocaml from scratch

i download the first version of ocaml souce code ocaml-csl-1.06 from github. Then i configured and compile it. and i got the following message:

Makefile:39: recipe for target 'pervasives.cmi' failed
make[1]: *** [pervasives.cmi] Segmentation fault (core dumped)
make[1]: Leaving directory '/home/kiukotsu/Projects/ocaml-csl-1.06/stdlib'
Makefile:111: recipe for target 'coldstart' failed
make: *** [coldstart] Error 2

How can i compile it sucessfully?

the additional message:

Linux CRONUS 4.15.0-38-generic #41~16.04.1-Ubuntu SMP Wed Oct 10 20:16:04 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
gcc (Ubuntu 5.4.0-6ubuntu1~16.04.10) 5.4.0 20160609

the makefile.config setting:











RANLIB=ar -rs






You are trying to compile on a x86_64 system a version of OCaml published eight years before the first AMD64 processor appeared; some compilation trouble is expected. Do you have any particular reason to be trying to compile a version of OCaml as ancient as Caml Special Light - 1.06 ?

i just want to know how ocaml builds code. and i want to go deep into ocaml buinding system. what i want to learn is how to generate ocamlc, how does the ocamllex and ocamlyacc work, how does byterun work, and how the stdlib are constructed. Maybe i should try it on i368 machine.

By the way, thanks for your reply!

Why not start with the trunk(i.e. dev) version of OCaml in this case? None of your objectives seem to really require going back to Caml Special Light 1.06. Contrarily, by using the dev version of OCaml, there would be more people able to help you, less compilation trouble and less french comments.

In fact, i am a newbie and i am afraid of reading source code. so i choose to read the first version of ocaml source code which has the least lines of code. LOL!:joy: But i think it is time to change. i am gonna to read the trunk version of OCaml code. Thanks for you help! maybe i need to challenge myself.

1 Like

Then I’d suggest you to start from reading a book which would disambiguate the core concepts underlying the OCaml. [1] [2] and [3] are good enough. You’d also better to learn from some toy ML implementations like these ones [4] instead of a full featured production-grade compiler.






Thanks a lot! That helps me much!!!:+1:

One resource I like is the online manuscript/book

Using, Understanding, and Unraveling the OCaml language – from practice to theory and vice versa

This book is about the language design, more than compilation. It describes the language features layer by layer, very precisely (introducing and using the notations that programming language researchers use to formalize languages), with a series of exercises to implement an interpreter and a type system along the way.