The culprit seems to be non-tail recursion in the backend, in particular Compilenv.structured_constants, which uses List.map (and so could be easily fixed), and Comballoc.combine, which requires a bit more work.

In the meantime, you may be able to work around the issue with something like 'ulimit'. The following works for me:

I am marking this PR as "suspended" for the reasons given in 0005925, namely: making the native-code generator tail-recursive is a very invasive change, and supporting huge generated source files is a low priority.