binary-size.rst
changeset 1894 2e3bc2435d68
parent 279 061995ef35d2
child 1905 fba288d59662
equal deleted inserted replaced
1893:da0024f4f068 1894:2e3bc2435d68
       
     1 .. -*- coding: utf-8; -*-
       
     2 .. include:: HEADER.rst
       
     3 
       
     4 ===========================
       
     5  Reducing binary code size
       
     6 ===========================
       
     7 .. contents::
       
     8 
       
     9 Common receipt
       
    10 ==============
       
    11 
       
    12 Configure build with disabling unused features e.g.::
       
    13 
       
    14   $ ./configure --without-png
       
    15 
       
    16 Link dynamically instead statically (on your platform shared library may be
       
    17 already present).
       
    18 
       
    19 Avoid debug build. Make release/final build instead debug.
       
    20 
       
    21 Use packers. Packer compress binary so binary smaller. When program load
       
    22 decompress itself, so startup time increase.
       
    23 
       
    24 Binary packers::
       
    25 
       
    26   http://upx.sourceforge.net
       
    27     Home page.
       
    28 
       
    29 GCC
       
    30 ======
       
    31 
       
    32 Use ``-Os`` when produces ``*.o`` files.
       
    33 
       
    34 Use ``-s`` when produces executable. And ``--remove-section=.comment`` and
       
    35 ``--remove-section=.note"``.
       
    36 
       
    37 Use::
       
    38 
       
    39   $ strip --strip-all <executable>
       
    40 
       
    41 and::
       
    42 
       
    43   $ gcc -ffunction-sections -fdata-sections -c -o my.o my.c
       
    44   $ gcc -Wl,--gc-sections -o my my.o
       
    45 
       
    46 MSVC
       
    47 ====
       
    48 
       
    49 Use ``/Os`` when produces ``*.obj`` files.
       
    50