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