Version française
Home     About     Download     Resources     Contact us    
Browse thread
No unused code linking?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Dmitry Bely <dbely@m...>
Subject: No unused code linking?
I am thinking of reducing the size of ocamlopt-generated executables that
easily grows to 1Mb and above. The problem as I see it is that any module is
linked as a single whole (as all its functions are placed into the single
object file), no matter what is actually used. So almost all
stdlib/otherlibs become quickly linked into even not very complex project.

In C world there is a solution that lets the linker to do its job smartly
for monolitic object files: place each function into the separate section
(gcc's "-ffunction-sections" or msvc's "-Gy" options) and then ask linker
to eliminate unused sections during the link stage. Can anything similar be
done with Ocamlopt compiler?

Of course, placing each function into the separate section is not a problem -
modifications of the code generator would be minimal. The real problem are
the frame tables - the single table references all functions in the
module. Maybe they can be split and linked separately? What Ocaml
developers think of that?

- Dmitry Bely