xref: /dpdk/doc/guides/prog_guide/lto.rst (revision 10b71caecbe1cddcbb65c050ca775fba575e88db)
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
29When using make based build, link time optimization can be enabled for
30the whole DPDK by setting:
31
32.. code-block:: console
33
34    CONFIG_RTE_ENABLE_LTO=y
35
36in config file.
37
38For the meson based build it can be enabled by setting meson built-in
39'b_lto' option:
40
41.. code-block:: console
42
43    meson build -Db_lto=true
44