Multi-file compilation units
In addition to applying different optimizations to different source files or even functions, you can also decide what a compilation unit consists of—one or several source code files.
By default, a compilation unit consists of one source file, but you can also use multi-file compilation to make several source files in a compilation unit. The advantage is that interprocedural optimizations such as inlining and cross jump have more source code to work on. Ideally, the whole application should be compiled as one compilation unit. However, for large applications this is not practical because of resource restrictions on the host computer. For more information, see ‑‑mfc.
Note
Only one object file is generated, and therefore all symbols will be part of that object file.
If the whole application is compiled as one compilation unit, it is useful to make the compiler also discard unused public functions and variables before the interprocedural optimizations are performed. Doing this limits the scope of the optimizations to functions and variables that are actually used. For more information, see ‑‑discard_unused_publics.