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
cywgin stack overflow
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2007-06-13 (16:20)
From: Xavier Leroy <Xavier.Leroy@i...>
Subject: Re: [Caml-list] cywgin stack overflow
> Ouch.  Is there a place I can find information on how stacks are
> implemented in Ocaml without having to wade through source?
> Particularly, I imagine the options to increase stack size of the
> executable compiled with ocamlopt would not be the same as for gcc...

Actually, they are the same.  Let me try to clarify:

For bytecode executables produced by ocamlc or ocamlc.opt
(this includes ocamlc, ocamlopt, etc):
the executables do not not contain any limit on the stack size.  The
bytecode interpreter will resize its stack (allocated with malloc())
as needed, up to a limit that can be set using the 'l' parameter in
the OCAMLRUNPARAM environment variable.

For native-code executables produced by ocamlopt or ocamlopt.opt
(this includes ocamlc.opt, ocamlopt.opt, etc):
these are produced by calling the C compiler with a bunch of .o and .a
files, some generated from Caml via the assembler, others (the
run-time system) being compiled from C.  So, if your C compiler has
flags to set a stack limit in the generated executable, just give
these flags to ocamlopt in a -ccopt option.  (See Matthieu Wipliez's
reply on this list.)

Actually, it might be sufficient to build the Cygwin OCaml package
by configuring with
   ./configure -cc "gcc -Wl,--stack -Wl,10485760"
so that these options will be added automatically, both when building
ocamlrun and when ocamlopt calls gcc to produce native executables.

Hope this helps,

- Xavier Leroy