xref: /dpdk/doc/guides/prog_guide/lto.rst (revision e24b8ad46b2124d09a97d2f9e911ba197b4f83d1)
1..  SPDX-License-Identifier: BSD-3-Clause
2    Copyright(c) 2019 Marvell International Ltd.
3
4Link Time Optimization
5======================
6
7The DPDK supports compilation with link time optimization turned on.
8This depends obviously on the ability of the compiler to do "whole
9program" optimization at link time and is available only for compilers
10that support that feature.
11To be more specific, compiler (in addition to performing LTO) have to
12support creation of ELF objects containing both normal code and internal
13representation (called fat-lto-objects in gcc and icc).
14This is required since during build some code is generated by parsing
15produced ELF objects (pmdinfogen).
16
17The amount of performance gain that one can get from LTO depends on the
18compiler and the code that is being compiled.
19However LTO is also useful for additional code analysis done by the
20compiler.
21In particular due to interprocedural analysis compiler can produce
22additional warnings about variables that might be used uninitialized.
23Some of these warnings might be "false positives" though and you might
24need to explicitly initialize variable in order to silence the compiler.
25
26Please note that turning LTO on causes considerable extension of
27build time.
28
29Link time optimization can be enabled by setting meson built-in 'b_lto' option:
30
31.. code-block:: console
32
33    meson setup build -Db_lto=true
34