Sometimes, it is desired to optimize a build for size rather than speed.
This means not compiling unused functions from the engine, as well as using
specific compiler flags to aid on decreasing build size.
Common situations include creating builds for mobile and Web platforms.

This tutorial aims to give an overview on different methods to create
a smaller binary. Before continuing, it is recommended to read the previous tutorials
on compiling Godot for each platform.

Enabling link-time optimization produces more efficient binaries, both in
terms of performance and file size. It works by eliminating duplicate
template functions and unused code. It can currently be used with the GCC
and MSVC compilers:

scons p=windows target=release tools=no use_lto=yes

Linking becomes much slower with this option, so it should be used only for
release builds.

If you are targeting desktop platforms, the
UPX compressor can be used.
This can reduce binary size considerably.

However, keep in mind that some antivirus programs may detect UPX-packed
binaries as a virus. Therefore, if you are releasing a commercial game,
make sure to sign your binaries or use a platform that will distribute them.