binary-size.rst
changeset 1894 2e3bc2435d68
parent 279 061995ef35d2
child 1905 fba288d59662
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/binary-size.rst	Sat Feb 20 23:13:00 2016 +0200
@@ -0,0 +1,50 @@
+.. -*- coding: utf-8; -*-
+.. include:: HEADER.rst
+
+===========================
+ Reducing binary code size
+===========================
+.. contents::
+
+Common receipt
+==============
+
+Configure build with disabling unused features e.g.::
+
+  $ ./configure --without-png
+
+Link dynamically instead statically (on your platform shared library may be
+already present).
+
+Avoid debug build. Make release/final build instead debug.
+
+Use packers. Packer compress binary so binary smaller. When program load
+decompress itself, so startup time increase.
+
+Binary packers::
+
+  http://upx.sourceforge.net
+    Home page.
+
+GCC
+======
+
+Use ``-Os`` when produces ``*.o`` files.
+
+Use ``-s`` when produces executable. And ``--remove-section=.comment`` and
+``--remove-section=.note"``.
+
+Use::
+
+  $ strip --strip-all <executable>
+
+and::
+
+  $ gcc -ffunction-sections -fdata-sections -c -o my.o my.c
+  $ gcc -Wl,--gc-sections -o my my.o
+
+MSVC
+====
+
+Use ``/Os`` when produces ``*.obj`` files.
+