4
在Ubuntu 14.04,32位:ocaml的4.01.0→4.02.1,二進制大小變大
➥ 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
可執行文件的大小變得越來越大:158569→171122→171196.
在一個更復雜的應用程序,我得到了更大的文件大小的增加。
任何想法如何解決?
更新#1:
嘗試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
它繼續增長:117368→127580→127612
更新#2:
嘗試選項-compact
,沒有工作:
➥ 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
試過選項-inline
,沒有工作過:
➥ 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
有趣的是,你試過剝離? – ivg 2014-10-30 12:20:38
在帖子中增加了關於strip的信息。 – shorrty 2014-10-30 12:31:56
後一版本增加了更積極的內聯,這可以解釋它。 – PatJ 2014-10-30 14:12:05