caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] proposal of small changes to bytecode executables
@ 2015-08-17  9:13 Mr. Herr
  0 siblings, 0 replies; only message in thread
From: Mr. Herr @ 2015-08-17  9:13 UTC (permalink / raw)
  To: Caml List

[-- Attachment #1: Type: text/plain, Size: 1435 bytes --]

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.




[-- Attachment #2: Type: text/html, Size: 2243 bytes --]

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2015-08-17  9:15 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-17  9:13 [Caml-list] proposal of small changes to bytecode executables Mr. Herr

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).