binary-size.rst
author Oleksandr Gavenko <gavenkoa@gmail.com>
Mon, 22 Feb 2016 12:46:36 +0200
changeset 1905 fba288d59662
parent 1894 2e3bc2435d68
child 1912 8b81a8f0f692
permissions -rw-r--r--
Include only local subsections into TOC. This prevent duplication of TOC when build single page HTML document. Also this make unnecessary CSS hack to hide document title as top level section.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1894
2e3bc2435d68 Convert all files from TXT to RST.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 279
diff changeset
     1
.. -*- coding: utf-8; -*-
2e3bc2435d68 Convert all files from TXT to RST.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 279
diff changeset
     2
.. include:: HEADER.rst
279
061995ef35d2 How reduce biraries size.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     3
1894
2e3bc2435d68 Convert all files from TXT to RST.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 279
diff changeset
     4
===========================
2e3bc2435d68 Convert all files from TXT to RST.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 279
diff changeset
     5
 Reducing binary code size
2e3bc2435d68 Convert all files from TXT to RST.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 279
diff changeset
     6
===========================
2e3bc2435d68 Convert all files from TXT to RST.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 279
diff changeset
     7
.. contents::
1905
fba288d59662 Include only local subsections into TOC. This prevent duplication of
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1894
diff changeset
     8
   :local:
279
061995ef35d2 How reduce biraries size.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     9
1894
2e3bc2435d68 Convert all files from TXT to RST.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 279
diff changeset
    10
Common receipt
2e3bc2435d68 Convert all files from TXT to RST.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 279
diff changeset
    11
==============
2e3bc2435d68 Convert all files from TXT to RST.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 279
diff changeset
    12
2e3bc2435d68 Convert all files from TXT to RST.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 279
diff changeset
    13
Configure build with disabling unused features e.g.::
279
061995ef35d2 How reduce biraries size.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    14
061995ef35d2 How reduce biraries size.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    15
  $ ./configure --without-png
061995ef35d2 How reduce biraries size.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    16
061995ef35d2 How reduce biraries size.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    17
Link dynamically instead statically (on your platform shared library may be
061995ef35d2 How reduce biraries size.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    18
already present).
061995ef35d2 How reduce biraries size.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    19
1894
2e3bc2435d68 Convert all files from TXT to RST.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 279
diff changeset
    20
Avoid debug build. Make release/final build instead debug.
279
061995ef35d2 How reduce biraries size.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    21
061995ef35d2 How reduce biraries size.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    22
Use packers. Packer compress binary so binary smaller. When program load
061995ef35d2 How reduce biraries size.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    23
decompress itself, so startup time increase.
061995ef35d2 How reduce biraries size.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    24
1894
2e3bc2435d68 Convert all files from TXT to RST.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 279
diff changeset
    25
Binary packers::
2e3bc2435d68 Convert all files from TXT to RST.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 279
diff changeset
    26
279
061995ef35d2 How reduce biraries size.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    27
  http://upx.sourceforge.net
1894
2e3bc2435d68 Convert all files from TXT to RST.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 279
diff changeset
    28
    Home page.
279
061995ef35d2 How reduce biraries size.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    29
1894
2e3bc2435d68 Convert all files from TXT to RST.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 279
diff changeset
    30
GCC
2e3bc2435d68 Convert all files from TXT to RST.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 279
diff changeset
    31
======
2e3bc2435d68 Convert all files from TXT to RST.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 279
diff changeset
    32
2e3bc2435d68 Convert all files from TXT to RST.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 279
diff changeset
    33
Use ``-Os`` when produces ``*.o`` files.
279
061995ef35d2 How reduce biraries size.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    34
1894
2e3bc2435d68 Convert all files from TXT to RST.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 279
diff changeset
    35
Use ``-s`` when produces executable. And ``--remove-section=.comment`` and
2e3bc2435d68 Convert all files from TXT to RST.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 279
diff changeset
    36
``--remove-section=.note"``.
279
061995ef35d2 How reduce biraries size.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    37
1894
2e3bc2435d68 Convert all files from TXT to RST.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 279
diff changeset
    38
Use::
279
061995ef35d2 How reduce biraries size.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    39
061995ef35d2 How reduce biraries size.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    40
  $ strip --strip-all <executable>
061995ef35d2 How reduce biraries size.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    41
1894
2e3bc2435d68 Convert all files from TXT to RST.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 279
diff changeset
    42
and::
279
061995ef35d2 How reduce biraries size.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    43
061995ef35d2 How reduce biraries size.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    44
  $ gcc -ffunction-sections -fdata-sections -c -o my.o my.c
061995ef35d2 How reduce biraries size.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    45
  $ gcc -Wl,--gc-sections -o my my.o
061995ef35d2 How reduce biraries size.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    46
1894
2e3bc2435d68 Convert all files from TXT to RST.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 279
diff changeset
    47
MSVC
2e3bc2435d68 Convert all files from TXT to RST.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 279
diff changeset
    48
====
279
061995ef35d2 How reduce biraries size.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    49
1894
2e3bc2435d68 Convert all files from TXT to RST.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 279
diff changeset
    50
Use ``/Os`` when produces ``*.obj`` files.
279
061995ef35d2 How reduce biraries size.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    51