Go to main content

man pages section 1: User Commands

Exit Print View

Updated: Wednesday, February 10, 2021

ocamlrun (1)


ocamlrun - The Objective Caml bytecode interpreter


ocamlrun [ options ] filename argument ...


OCAMLRUN(1)                 General Commands Manual                OCAMLRUN(1)

       ocamlrun - The Objective Caml bytecode interpreter

       ocamlrun [ options ] filename argument ...

       The ocamlrun(1) command executes bytecode files produced by the linking
       phase of the ocamlc(1) command.

       The first non-option argument is taken to be the name of the file  con-
       taining  the  executable  bytecode.  (That file is searched in the exe-
       cutable path as well as in the current directory.) The remaining  argu-
       ments  are  passed  to  the Objective Caml program, in the string array
       Sys.argv.  Element 0 of this array is the name  of  the  bytecode  exe-
       cutable file; elements 1 to n are the remaining arguments.

       In  most cases, the bytecode executable files produced by the ocamlc(1)
       command are self-executable, and manage to launch the ocamlrun(1)  com-
       mand on themselves automatically.

       The following command-line options are recognized by ocamlrun(1).

       -b     When  the  program  aborts due to an uncaught exception, print a
              detailed "back trace" of the execution, showing where the excep-
              tion  was  raised  and  which function calls were outstanding at
              this point.  The back trace is printed only if the bytecode exe-
              cutable  contains  debugging  information, i.e. was compiled and
              linked with the -g option to  ocamlc(1)  set.   This  option  is
              equivalent  to  setting the b flag in the OCAMLRUNPARAM environ-
              ment variable (see below).

       -I dir Search the directory dir for  dynamically-loaded  libraries,  in
              addition to the standard search path.  -p Print the names of the
              primitives known to this version of ocamlrun(1) and exit.

       -v     Direct the memory manager to print verbose messages on  standard
              error.   This is equivalent to setting v=63 in the OCAMLRUNPARAM
              environment variable (see below).

              Print version and exit.

       The following environment variable are also consulted:

              Additional  directories   to   search   for   dynamically-loaded

              The  directory  containing  the Objective Caml standard library.
              (If OCAMLLIB is not set, CAMLLIB will be used instead.) Used  to
              locate  the  ld.conf configuration file for dynamic loading.  If
              not set, default to the library directory specified when compil-
              ing Objective Caml.

              Set  the  runtime  system options and garbage collection parame-
              ters.  (If OCAMLRUNPARAM is not set, CAMLRUNPARAM will  be  used
              instead.)   This variable must be a sequence of parameter speci-
              fications.  A parameter specification is an option  letter  fol-
              lowed  by  an  = sign, a decimal number (or a hexadecimal number
              prefixed by 0x), and an optional  multiplier.   There  are  nine
              options,  six  of  which correspond to the fields of the control
              record documented in The Objective Caml user's  manual,  chapter
              "Standard Library", section "Gc".

       b      Trigger  the  printing  of  a  stack  backtrace when an uncaught
              exception aborts the program.  This option takes no argument.

       p      Turn on debugging support for ocamlyacc-generated parsers.  When
              this  option  is  on,  the  pushdown automaton that executes the
              parsers prints a trace of its actions.   This  option  takes  no

       a (allocation_policy)
              The policy used for allocating in the OCaml heap.  Possible val-
              ues are 0 for the next-fit policy, and 1 for the first-fit  pol-
              icy.   Next-fit  is somewhat faster, but first-fit is better for
              avoiding fragmentation and the associated heap compactions.

       s (minor_heap_size)
              The size of the minor heap (in words).

       i (major_heap_increment)
              The default size increment for the major heap (in words).

       o (space_overhead)
              The major GC speed setting.

       O (max_overhead)
              The heap compaction trigger setting.

       l (stack_limit)
              The limit (in words) of the stack size.

       h      The initial size of the major heap (in words).

       v (verbose)
              What GC messages to print to stderr.  This is a  sum  of  values
              selected from the following:

              0x001 Start of major GC cycle.

              0x002 Minor collection and major GC slice.

              0x004 Growing and shrinking of the heap.

              0x008 Resizing of stacks and memory manager tables.

              0x010 Heap compaction.

              0x020 Change of GC parameters.

              0x040 Computation of major GC slice size.

              0x080 Calling of finalisation functions.

              0x100  Startup  messages  (loading the bytecode executable file,
              resolving shared libraries).

              The multiplier is k, M or G, for multiplication by  2^10,  2^20,
              and  2^30  respectively.  For example, on a 32-bit machine under
              bash, the command export OCAMLRUNPARAM='s=256k,v=1' tells a sub-
              sequent  ocamlrun  to  set  its  initial  minor  heap  size to 1
              megabyte and to print a message at the start of  each  major  GC

              If  OCAMLRUNPARAM is not found in the environment, then CAMLRUN-
              PARAM will be used instead.  If CAMLRUNPARAM is not found,  then
              the default values will be used.

       PATH   List  of  directories  searched  to find the bytecode executable

       See attributes(7) for descriptions of the following attributes:

       |Availability   | runtime/ocaml    |
       |Stability      | Volatile         |
       The Objective Caml user's manual, chapter "Runtime system".

       This    software    was    built    from    source     available     at
       https://github.com/oracle/solaris-userland.    The  original  community
       source     was     downloaded      from       http://caml.inria.fr/dis-

       Further information about this software can be found on the open source
       community website at http://www.ocaml.org.