Hi,
to produce executable files we currently have two general
options: compile to native code, or compile to byte code.
For byte code as executable files, ocamlc can produce two sorts
of output: with (option -custom) or without embedded runtime.
Let's look at byte code without embedded runtime.
The bytecode VM "ocamlrun" is tied to the compiler version, and
so is the ocamlc produced output.
To make sure that byte code and ocamlrun versions match, the
runtime reads a magic byte at the end of the byte code and
refuses to execute non matching input. Additionally ocamlc puts
an absolute hash bang path at
the beginning of the executable, pointing to the correct
ocamlrun binary executable at the time of compilation.
Perceived
shortcoming:
opam has become very good at managing compilers, yet it is not
recommended to run opam as root.
This leads to an absolute ocamlrun path pointing to the hidden
.opam directory in the programmer's home directory (opam
default),
limiting use of non-custom ocamlc builds to the programmer.
Solution: build the ocamlrun executable with the version in the
name: ocamlrun_xyz, change the hash bang path to "#!/usr/bin/env
ocamlrun_xyz",
this would give the sysadmin the basics to easily manage byte
code executables without embedded runtime.
Complexity of change: very small. The only question is what
exotic *nix systems do not have /usr/bin/env?
What do you think?
/Str.