Bug 1679319 [wpt PR 26648] - [LargestContentfulPaint] Fix invisible image tracking...
[gecko.git] / build / docs / unified-builds.rst
blob876ef9544cd4132a45c3b29b08f0d55bd0d821d7
1 .. _unified-builds:
3 ==============
4 Unified Builds
5 ==============
7 The Firefox build system uses the technique of "unified builds" (or elsewhere
8 called "`unity builds <https://en.wikipedia.org/wiki/Unity_build>`_") to
9 improve compilation performance. Rather than compiling source files individually,
10 groups of files in the same directory are concatenated together, then compiled once
11 in a single batch.
13 Unified builds can be configured using the ``UNIFIED_SOURCES`` variable in ``moz.build`` files.
15 .. _unified_build_compilation_failures:
17 Why are there unrelated compilation failures when I change files?
18 =================================================================
20 Since multiple files are concatenated together in a unified build, it's possible for a change
21 in one file to cause the compilation of a seemingly unrelated file to fail.
22 This is usually because source files become implicitly dependent on each other for:
24 * ``#include`` statements
25 * ``using namespace ...;`` statements
26 * Other symbol imports or definitions
28 One of the more common cases of unexpected failures are when source code files are added or
29 removed, and the "chunking" is changed. There's a limit on the number of files that are combined
30 together for a single compilation, so sometimes the addition of a new file will cause another one
31 to be bumped into a different chunk. If that other chunk doesn't meet the implicit requirements
32 of the bumped file, there will be a tough-to-debug compilation failure.
34 Other notes:
35 ============
37 * Some IDEs (such as VSCode with ``clangd``) build files in standalone mode, so they may show
38   more failures than a ``mach build``.
39 * The amount of files per chunk can be adjusted in ``moz.build`` files with the
40   ``FILES_PER_UNIFIED_FILE`` variable. Note that changing the chunk size can introduce
41   compilation failures as described :ref:`above<unified_build_compilation_failures>`.
42 * We are happy to accept patches that fix problematic unified build chunks (such as by adding
43   includes or namespace annotations).