xref: /dpdk/doc/guides/prog_guide/lto.rst (revision e24b8ad46b2124d09a97d2f9e911ba197b4f83d1)
1098cc0feSAndrzej Ostruszka..  SPDX-License-Identifier: BSD-3-Clause
2098cc0feSAndrzej Ostruszka    Copyright(c) 2019 Marvell International Ltd.
3098cc0feSAndrzej Ostruszka
4098cc0feSAndrzej OstruszkaLink Time Optimization
5098cc0feSAndrzej Ostruszka======================
6098cc0feSAndrzej Ostruszka
7098cc0feSAndrzej OstruszkaThe DPDK supports compilation with link time optimization turned on.
8098cc0feSAndrzej OstruszkaThis depends obviously on the ability of the compiler to do "whole
9098cc0feSAndrzej Ostruszkaprogram" optimization at link time and is available only for compilers
10098cc0feSAndrzej Ostruszkathat support that feature.
11098cc0feSAndrzej OstruszkaTo be more specific, compiler (in addition to performing LTO) have to
12098cc0feSAndrzej Ostruszkasupport creation of ELF objects containing both normal code and internal
13098cc0feSAndrzej Ostruszkarepresentation (called fat-lto-objects in gcc and icc).
14098cc0feSAndrzej OstruszkaThis is required since during build some code is generated by parsing
15098cc0feSAndrzej Ostruszkaproduced ELF objects (pmdinfogen).
16098cc0feSAndrzej Ostruszka
17098cc0feSAndrzej OstruszkaThe amount of performance gain that one can get from LTO depends on the
18098cc0feSAndrzej Ostruszkacompiler and the code that is being compiled.
19098cc0feSAndrzej OstruszkaHowever LTO is also useful for additional code analysis done by the
20098cc0feSAndrzej Ostruszkacompiler.
21098cc0feSAndrzej OstruszkaIn particular due to interprocedural analysis compiler can produce
22098cc0feSAndrzej Ostruszkaadditional warnings about variables that might be used uninitialized.
23098cc0feSAndrzej OstruszkaSome of these warnings might be "false positives" though and you might
24098cc0feSAndrzej Ostruszkaneed to explicitly initialize variable in order to silence the compiler.
25098cc0feSAndrzej Ostruszka
26098cc0feSAndrzej OstruszkaPlease note that turning LTO on causes considerable extension of
27098cc0feSAndrzej Ostruszkabuild time.
28098cc0feSAndrzej Ostruszka
2989c67ae2SCiara PowerLink time optimization can be enabled by setting meson built-in 'b_lto' option:
30098cc0feSAndrzej Ostruszka
31098cc0feSAndrzej Ostruszka.. code-block:: console
32098cc0feSAndrzej Ostruszka
33*e24b8ad4SStephen Hemminger    meson setup build -Db_lto=true
34