Hello!
Please see this terminal session demonstrating a simple project setup:
I adapted my dune file according to the dune documentation here.
I don’t see any difference in the final output executable. Mainly, debug_info
still remains + the output size does not change when applying the release profile, which looks wrong.
Essentially, I understand that dune
delegates to ocamlopt
, but it’s unclear to me what the best practices are related to building a binary for production usage.
I did manage to remove the debug info + reduce the overall size by applying strip
manually, like such:
$ ocamlopt -O3 ./main.ml -o main && strip ./main && file ./main && du -sh ./main
./main: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=1d8adb88a132aace87d4f6ca0091e4f198c4ac60, for GNU/Linux 3.2.0, stripped
356K ./main
Is this advisable? How do you build your binaries for production? Can I make it a one-step process via dune?