Optimizing a build for size

    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.

    See also

    You can use the online to generate a file containing SCons options. You can then save this file and place it at the root of your Godot source directory.

    Disabling 3D

    For 2D games, having the whole 3D engine available usually makes no sense. Because of this, there is a build flag to disable it:

    Tools must be disabled in order to use this flag, as the editor is not designed to operate without 3D support. Without it, the binary size can be reduced by about 15%.

      Disabling unwanted modules

      A lot of Godot’s functions are offered as modules. You can see a list of modules with the following command:

      The list of modules that can be disabled will appear, together with all build options. If you are working on a simple 2D game, you could disable a lot of them:

      If this proves not to work for your use case, you should review the list of modules and see which ones you actually still need for your game (e.g. you might want to keep networking-related modules, regex support, or theora/webm to play videos).

      Alternatively, you can supply a list of disabled modules by creating custom.py at the root of the source, with the contents similar to the following:

      See also

      Godot 3.1 onwards allows compiling using size optimizations (instead of speed). To enable this, set the flag to size:

      Some platforms such as WebAssembly already use this mode by default.

      Compiling with link-time optimization

      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:

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

      If you build from source, remember to strip debug symbols from binaries:

      1. strip godot.64