xref: /dpdk/doc/guides/linux_gsg/build_dpdk.rst (revision 218c4e68c1d9bd4a9281bc1dc4d0ab89859083bf)
15630257fSFerruh Yigit..  SPDX-License-Identifier: BSD-3-Clause
25630257fSFerruh Yigit    Copyright(c) 2010-2015 Intel Corporation.
31ab07743SBernard Iremonger
43b60ce8cSJohn McNamara.. _linux_gsg_compiling_dpdk:
53b60ce8cSJohn McNamara
62e486e26SSiobhan ButlerCompiling the DPDK Target from Source
72e486e26SSiobhan Butler=====================================
81ab07743SBernard Iremonger
91ab07743SBernard Iremonger.. note::
101ab07743SBernard Iremonger
1129c67340SJohn McNamara    Parts of this process can also be done using the setup script described in
1229c67340SJohn McNamara    the :ref:`linux_setup_script` section of this document.
131ab07743SBernard Iremonger
142e486e26SSiobhan ButlerInstall the DPDK and Browse Sources
152e486e26SSiobhan Butler-----------------------------------
161ab07743SBernard Iremonger
172e486e26SSiobhan ButlerFirst, uncompress the archive and move to the uncompressed DPDK source directory:
181ab07743SBernard Iremonger
191ab07743SBernard Iremonger.. code-block:: console
201ab07743SBernard Iremonger
21d1c34b5bSBaruch Siach    tar xJf dpdk-<version>.tar.xz
22d1c34b5bSBaruch Siach    cd dpdk-<version>
2329c67340SJohn McNamara
242e486e26SSiobhan ButlerThe DPDK is composed of several directories:
251ab07743SBernard Iremonger
262e486e26SSiobhan Butler*   lib: Source code of DPDK libraries
271ab07743SBernard Iremonger
28980ed498SBruce Richardson*   drivers: Source code of DPDK poll-mode drivers
29980ed498SBruce Richardson
302e486e26SSiobhan Butler*   app: Source code of DPDK applications (automatic tests)
311ab07743SBernard Iremonger
322e486e26SSiobhan Butler*   examples: Source code of DPDK application examples
331ab07743SBernard Iremonger
34c6dab2a8SThomas Monjalon*   config, buildtools, mk: Framework-related makefiles, scripts and configuration
351ab07743SBernard Iremonger
362e486e26SSiobhan ButlerInstallation of DPDK Target Environments
372e486e26SSiobhan Butler----------------------------------------
381ab07743SBernard Iremonger
3929c67340SJohn McNamaraThe format of a DPDK target is::
401ab07743SBernard Iremonger
411ab07743SBernard Iremonger    ARCH-MACHINE-EXECENV-TOOLCHAIN
421ab07743SBernard Iremonger
431ab07743SBernard Iremongerwhere:
441ab07743SBernard Iremonger
45f8277965SBrian Brooks* ``ARCH`` can be:  ``i686``, ``x86_64``, ``ppc_64``, ``arm64``
461ab07743SBernard Iremonger
47f8277965SBrian Brooks* ``MACHINE`` can be:  ``native``, ``power8``, ``armv8a``
481ab07743SBernard Iremonger
49*218c4e68SBruce Richardson* ``EXECENV`` can be:  ``linux``,  ``freebsd``
501ab07743SBernard Iremonger
5129c67340SJohn McNamara* ``TOOLCHAIN`` can be:  ``gcc``,  ``icc``
521ab07743SBernard Iremonger
531ab07743SBernard IremongerThe targets to be installed depend on the 32-bit and/or 64-bit packages and compilers installed on the host.
541ab07743SBernard IremongerAvailable targets can be found in the DPDK/config directory.
551ab07743SBernard IremongerThe defconfig\_ prefix should not be used.
561ab07743SBernard Iremonger
571ab07743SBernard Iremonger.. note::
581ab07743SBernard Iremonger
5929c67340SJohn McNamara    Configuration files are provided with the ``RTE_MACHINE`` optimization level set.
6029c67340SJohn McNamara    Within the configuration files, the ``RTE_MACHINE`` configuration value is set to native,
611ab07743SBernard Iremonger    which means that the compiled software is tuned for the platform on which it is built.
622e486e26SSiobhan Butler    For more information on this setting, and its possible values, see the *DPDK Programmers Guide*.
631ab07743SBernard Iremonger
641ab07743SBernard IremongerWhen using the Intel® C++ Compiler (icc), one of the following commands should be invoked for 64-bit or 32-bit use respectively.
6529c67340SJohn McNamaraNotice that the shell scripts update the ``$PATH`` variable and therefore should not be performed in the same session.
661ab07743SBernard IremongerAlso, verify the compiler's installation directory since the path may be different:
671ab07743SBernard Iremonger
681ab07743SBernard Iremonger.. code-block:: console
691ab07743SBernard Iremonger
701ab07743SBernard Iremonger    source /opt/intel/bin/iccvars.sh intel64
711ab07743SBernard Iremonger    source /opt/intel/bin/iccvars.sh ia32
721ab07743SBernard Iremonger
7329c67340SJohn McNamaraTo install and make targets, use the ``make install T=<target>`` command in the top-level DPDK directory.
741ab07743SBernard Iremonger
751ab07743SBernard IremongerFor example, to compile a 64-bit target using icc, run:
761ab07743SBernard Iremonger
771ab07743SBernard Iremonger.. code-block:: console
781ab07743SBernard Iremonger
79*218c4e68SBruce Richardson    make install T=x86_64-native-linux-icc
801ab07743SBernard Iremonger
811ab07743SBernard IremongerTo compile a 32-bit build using gcc, the make command should be:
821ab07743SBernard Iremonger
831ab07743SBernard Iremonger.. code-block:: console
841ab07743SBernard Iremonger
85*218c4e68SBruce Richardson    make install T=i686-native-linux-gcc
861ab07743SBernard Iremonger
871ab07743SBernard IremongerTo prepare a target without building it, for example, if the configuration changes need to be made before compilation,
8829c67340SJohn McNamarause the ``make config T=<target>`` command:
891ab07743SBernard Iremonger
901ab07743SBernard Iremonger.. code-block:: console
911ab07743SBernard Iremonger
92*218c4e68SBruce Richardson    make config T=x86_64-native-linux-gcc
931ab07743SBernard Iremonger
941ab07743SBernard Iremonger.. warning::
951ab07743SBernard Iremonger
9629c67340SJohn McNamara    Any kernel modules to be used, e.g. ``igb_uio``, ``kni``, must be compiled with the
97974438fbSBruce Richardson    same kernel as the one running on the target.
982e486e26SSiobhan Butler    If the DPDK is not being built on the target machine,
9929c67340SJohn McNamara    the ``RTE_KERNELDIR`` environment variable should be used to point the compilation at a copy of the kernel version to be used on the target machine.
1001ab07743SBernard Iremonger
1011ab07743SBernard IremongerOnce the target environment is created, the user may move to the target environment directory and continue to make code changes and re-compile.
1022e486e26SSiobhan ButlerThe user may also make modifications to the compile-time DPDK configuration by editing the .config file in the build directory.
1031ab07743SBernard Iremonger(This is a build-local copy of the defconfig file from the top- level config directory).
1041ab07743SBernard Iremonger
1051ab07743SBernard Iremonger.. code-block:: console
1061ab07743SBernard Iremonger
107*218c4e68SBruce Richardson    cd x86_64-native-linux-gcc
1081ab07743SBernard Iremonger    vi .config
1091ab07743SBernard Iremonger    make
1101ab07743SBernard Iremonger
1111ab07743SBernard IremongerIn addition, the make clean command can be used to remove any existing compiled files for a subsequent full, clean rebuild of the code.
1121ab07743SBernard Iremonger
1132e486e26SSiobhan ButlerBrowsing the Installed DPDK Environment Target
1142e486e26SSiobhan Butler----------------------------------------------
1151ab07743SBernard Iremonger
116980ed498SBruce RichardsonOnce a target is created it contains all libraries, including poll-mode drivers, and header files for the DPDK environment that are required to build customer applications.
1171ab07743SBernard IremongerIn addition, the test and testpmd applications are built under the build/app directory, which may be used for testing.
118980ed498SBruce RichardsonA kmod  directory is also present that contains kernel modules which may be loaded if needed.
119