On Ubuntu 14.04, 32 bit:
➥ cat test.ml
let () = print_endline "hello";
➥ opam switch list | grep " C "
4.01.0 C 4.01.0 Official 4.01.0 release
➥ ocamlopt test.ml
➥ ls -l a.out
-rwxrwxr-x 1 shorrty shorrty 158569 Oct. 30 13:29 a.out
➥ opam switch 4.02.0
➥ eval `opam config env`
➥ ocamlopt test.ml
➥ ls -l a.out
-rwxrwxr-x 1 shorrty shorrty 171122 Oct. 30 13:30 a.out
➥ opam switch 4.02.1
➥ eval `opam config env`
➥ ocamlopt test.ml
➥ ls -l a.out
-rwxrwxr-x 1 shorrty shorrty 171196 Oct. 30 14:08 a.out
Executable size became bigger and bigger: 158569 → 171122 → 171196.
In a more complex applications I get an even greater increase in the size of the file.
Any ideas how to fix?
Update #1:
Tried strip
:
➥ strip -V | head -n 1
GNU strip (GNU Binutils for Ubuntu) 2.24
➥ ls -l
-rwxrwxr-x 1 shorrty shorrty 158569 Oct. 30 15:22 a.4.01.0.out
-rwxrwxr-x 1 shorrty shorrty 117368 Oct. 30 15:26 a.4.01.0.out.stripped
-rwxrwxr-x 1 shorrty shorrty 171122 Oct. 30 15:03 a.4.02.0.out
-rwxrwxr-x 1 shorrty shorrty 127580 Oct. 30 15:26 a.4.02.0.out.stripped
-rwxrwxr-x 1 shorrty shorrty 171196 Oct. 30 15:21 a.4.02.1.out
-rwxrwxr-x 1 shorrty shorrty 127612 Oct. 30 15:26 a.4.02.1.out.stripped
-rwxrwxr-x 1 shorrty shorrty 158569 Oct. 30 15:21 a.out
It continues to grow: 117368 → 127580 → 127612
Update #2:
Tried option -compact
, didn't work:
➥ opam switch 4.01.0 && eval `opam config env`
➥ ocamlopt test.ml && ls -l a.out
-rwxrwxr-x 1 shorrty shorrty 158569 Oct. 30 22:02 a.out
➥ ocamlopt -compact test.ml && ls -l a.out
-rwxrwxr-x 1 shorrty shorrty 158569 Oct. 30 22:03 a.out
➥ opam switch 4.02.1 && eval `opam config env`
➥ ocamlopt test.ml && ls -l a.out
-rwxrwxr-x 1 shorrty shorrty 171196 Oct. 30 22:05 a.out
➥ ocamlopt -compact test.ml && ls -l a.out
-rwxrwxr-x 1 shorrty shorrty 171196 Oct. 30 22:05 a.out
Tried option -inline
, didn't work too:
➥ opam switch 4.01.0 && eval `opam config env`
➥ ocamlopt -inline 0 test.ml && ls -l a.out
-rwxrwxr-x 1 shorrty shorrty 158569 Oct. 30 22:07 a.out
➥ ocamlopt -inline 1 test.ml && ls -l a.out
-rwxrwxr-x 1 shorrty shorrty 158569 Oct. 30 22:07 a.out
➥ opam switch 4.02.1 && eval `opam config env`
➥ ocamlopt -inline 0 test.ml && ls -l a.out
-rwxrwxr-x 1 shorrty shorrty 171196 Oct. 30 22:08 a.out
➥ ocamlopt -inline 1 test.ml && ls -l a.out
-rwxrwxr-x 1 shorrty shorrty 171196 Oct. 30 22:09 a.out
Your code didn't change, but it calls the pervasives module which changed between 4.01 and 4.02.
Notably, the part about formats was changed to use GADT-based formats instead of strings. This notably made to_string, of_string and concatenation (quite) heavier.
See this discussion for more details.