Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] How to add primitives to the standard ones?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Xavier Leroy <Xavier.Leroy@i...>
Subject: Re: [Caml-list] How to add primitives to the standard ones?
> I tried to add a primitive to the standard primitives as follows.
> 1. I put my foo.c file in byterun/ and put the /* ML */ at the end 
> of the primitives.
> 2. In byterun/Makefile, I added foo.o to macro  OBJS and foo.c to PRIMS.
> 3. In stdlib/, I added the declaration for my primitive and 
>    in stdlib/pervasives.mli, I exported the primitives.

This is about right, but you need to be very careful about
bootstrapping issues.  What should work is:
- start with pristine OCaml sources
- do "make world"
- perform your changes
- do "make all"  (NOT "make world")
- do "make bootstrap" to make sure everything is OK.

This said, there is absolutely no need to change the system to get
access to new C primitives: the -custom mode or the -make-runtime and
-use-runtime options to ocamlc provide much simpler ways of doing it.

Indeed, I would advise against adding your stuff to Pervasives and the
standard runtime system: it's going to be much harder for you to track
OCaml changes and for others to use your code.

- Xavier Leroy
Bug reports:  FAQ:
To unsubscribe, mail  Archives: