[C++-sig] Reducing size of binary
s_sourceforge at nedprod.com
Fri Jun 16 21:34:18 CEST 2006
On 16 Jun 2006 at 9:29, Will Lee wrote:
> I'm currently using Boost Python in a fairly large project using Linux and
> g++. The combined .so code that I tried to wrap is around 9MB (-O with no
> symbol). I got to a point where the python wrapper binary gets pretty big
> (sometimes the wrapper debug .so with symbols can get to 350 MB and the -O
> version without symobls would be around 18 MB). Compile time can get up to
> 15-20 minutes. As far as I see, I'm not doing anything too extraordinary.
> I am using a lot of add_property and def methods in the wrapper code.
> Does anyone have hints on reducing the size of the wrapper binary?
That's nothing. I'm regularly generating 25Mb release build bindings
on Linux. They take several hours to compile.
If you're using gcc 4.x, use -fvisibility=hidden. Also optimise for
smallest possible size at expense of speed. Use 3.4 or later rather
than 3.3 or earlier.
Ultimately though, ELF is a fat binary format and how GCC stores
typeinfo is space expensive. Mach-O on Apple and PE on Windows are
far far smaller for the same source.
More information about the Cplusplus-sig