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
ocaml not native.
[ 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: ocaml not native.
> ocamlopt builds successfully on my systems.  Is there a reason why
> the installation doesn't rebuild ocaml to be native code, when it can?
> Is there a good reason not to attempt this myself?

There is a good reason why it wouldn't work: ocaml is not an
interpreter, it's a bytecode compiler that generates bytecode on the
fly for each phrase.  So, ocaml needs the bytecode interpreter.

Compiling it with ocamlopt would require an emulation of the bytecode
interpreter that can be used with ocamlopt.  One such emulation exists
(written by Fabrice Le Fessant), but is not yet integrated with the
toplevel, and also runs slower than the bytecode interpreter itself.

However, there is a simpler solution to the double #! problem:
build a custom toplevel with no extensions:

        ocamlmktop -custom -o /usr/local/bin/ocaml2

This packages the (bytecode) toplevel system with the runtime system,
in such a way that, viewed from the kernel, /usr/local/bin/ocaml2 is a
native executable.  Then, you can write scripts with


Hope this helps,

- Xavier Leroy