I have a library that takes a very long time to compile, and sometimes causes the compiler to stack-overflow depending on the system where it’s being built (yes, it’s autogenerated code ).
I was wondering if it might be possible to distribute this library using the .cma file generated by dune. My ideal setup is that I would be able to build the library from scratch if I have an environment variable set, and otherwise dune would just copy an archive that I had previously promoted to the source directory over to the lib folder.
I’ve tried using various rules and installs but can’t seem to find a way to achieve this where dune is happy.
How does the stack trace look like when the compiler crashes? I’ve experienced crashes in register allocator (also generated code), and, if I remember correctly, in this case it might help to use -linscan to change the register allocation strategy.
If that doesn’t work, another approach is to use bytecode-compiled version of the native code compiler to compile your file using a custom dune rule. I’m not sure if it is available on all systems, but it is called ocamlopt.byte. You can set an OCAMLRUNPARAM parameter called l to increase the stack size, but it only affects byte-code–compiled ocamlopt.byte. However, it will produce native code.