1 .. SPDX-License-Identifier: BSD-3-Clause
2 Copyright(c) 2020 ARM Corporation.
4 Cross compiling DPDK for ARM64
5 ==============================
6 This chapter describes how to cross compile DPDK for ARM64 from x86 build hosts.
10 Whilst it is recommended to natively build DPDK on ARM64 (just
11 like with x86), it is also possible to cross compile DPDK for ARM64.
12 An ARM64 cross compiler GNU toolchain or an LLVM/clang toolchain
13 may be used for cross-compilation.
22 NUMA is required by most modern machines, not needed for non-NUMA architectures.
26 For compiling the NUMA lib, run libtool --version to ensure the libtool version >= 2.2,
27 otherwise the compilation will fail with errors.
29 .. code-block:: console
31 git clone https://github.com/numactl/numactl.git
33 git checkout v2.0.13 -b v2.0.13
36 ./configure --host=aarch64-linux-gnu CC=<compiler> --prefix=<numa install dir>
41 The compiler above can be either aarch64-linux-gnu-gcc or clang.
42 See below for information on how to get specific compilers.
44 The numa header files and lib file is generated in the include and lib folder
45 respectively under ``<numa install dir>``.
50 Meson depends on pkgconfig to find the dependencies.
51 The package ``pkg-config-aarch64-linux-gnu`` is required for aarch64.
52 To install it in Ubuntu::
54 sudo apt install pkg-config-aarch64-linux-gnu
60 .. _obtain_GNU_toolchain:
62 Obtain the cross toolchain
63 ~~~~~~~~~~~~~~~~~~~~~~~~~~
65 The latest GNU cross compiler toolchain can be downloaded from:
66 https://developer.arm.com/open-source/gnu-toolchain/gnu-a/downloads.
68 It is always recommended to check and get the latest compiler tool
69 from the page and use it to generate better code.
70 As of this writing 9.2-2019.12 is the newest,
71 the following description is an example of this version.
73 .. code-block:: console
75 wget https://developer.arm.com/-/media/Files/downloads/gnu-a/9.2-2019.12/binrel/gcc-arm-9.2-2019.12-x86_64-aarch64-none-linux-gnu.tar.xz
77 Unzip and add into the PATH
78 ~~~~~~~~~~~~~~~~~~~~~~~~~~~
80 .. code-block:: console
82 tar -xvf gcc-arm-9.2-2019.12-x86_64-aarch64-none-linux-gnu.tar.xz
83 export PATH=$PATH:<cross_install_dir>/gcc-arm-9.2-2019.12-x86_64-aarch64-none-linux-gnu/bin
87 For the host requirements and other info, refer to the release note section: https://releases.linaro.org/components/toolchain/binaries/
89 .. _augment_the_gnu_toolchain_with_numa_support:
91 Augment the GNU toolchain with NUMA support
92 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
96 This way is optional, an alternative is to use extra CFLAGS and LDFLAGS.
98 Copy the NUMA header files and lib to the cross compiler's directories:
100 .. code-block:: console
102 cp <numa_install_dir>/include/numa*.h <cross_install_dir>/gcc-arm-9.2-2019.12-x86_64-aarch64-none-linux-gnu/aarch64-none-linux-gnu/libc/usr/include/
103 cp <numa_install_dir>/lib/libnuma.a <cross_install_dir>/gcc-arm-9.2-2019.12-x86_64-aarch64-none-linux-gnu/lib/gcc/aarch64-none-linux-gnu/9.2.1/
104 cp <numa_install_dir>/lib/libnuma.so <cross_install_dir>/gcc-arm-9.2-2019.12-x86_64-aarch64-none-linux-gnu/lib/gcc/aarch64-none-linux-gnu/9.2.1/
106 Cross Compiling DPDK with GNU toolchain using Meson
107 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
109 To cross-compile DPDK on a desired target machine we can use the following
112 meson cross-build --cross-file <target_machine_configuration>
115 For example if the target machine is aarch64 we can use the following
118 meson aarch64-build-gcc --cross-file config/arm/arm64_armv8_linux_gcc
119 ninja -C aarch64-build-gcc
125 Obtain the cross tool chain
126 ~~~~~~~~~~~~~~~~~~~~~~~~~~~
128 The latest LLVM/Clang cross compiler toolchain can be downloaded from:
129 https://developer.arm.com/tools-and-software/open-source-software/developer-tools/llvm-toolchain.
131 .. code-block:: console
134 wget https://github.com/llvm/llvm-project/releases/download/llvmorg-10.0.0/clang+llvm-10.0.0-x86_64-linux-gnu-ubuntu-18.04.tar.xz
136 The LLVM/Clang toolchain does not implement the standard c library.
137 The GNU toolchain ships an implementation we can use.
138 Refer to obtain_GNU_toolchain_ to get the GNU toolchain.
140 Unzip and add into the PATH
141 ~~~~~~~~~~~~~~~~~~~~~~~~~~~
143 .. code-block:: console
145 tar -xvf clang+llvm-10.0.0-x86_64-linux-gnu-ubuntu-18.04.tar.xz
146 export PATH=$PATH:<cross_install_dir>/clang+llvm-10.0.0-x86_64-linux-gnu-ubuntu-18.04/bin
148 Cross Compiling DPDK with LLVM/Clang toolchain using Meson
149 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
153 To use the NUMA library follow the same steps as for
154 augment_the_gnu_toolchain_with_numa_support_.
156 The paths to GNU stdlib must be specified in a cross file.
157 Augmenting the default cross-file's ``c_args`` and ``c_link_args``
158 ``config/arm/arm64_armv8_linux_clang_ubuntu1804`` would look like this:
160 .. code-block:: console
163 c_args = ['-target', 'aarch64-linux-gnu', '--sysroot', '<cross_install_dir>/gcc-arm-9.2-2019.12-x86_64-aarch64-none-linux-gnu/aarch64-none-linux-gnu/libc']
164 c_link_args = ['-target', 'aarch64-linux-gnu', '-fuse-ld=lld', '--sysroot', '<cross_install_dir>/gcc-arm-9.2-2019.12-x86_64-aarch64-none-linux-gnu/aarch64-none-linux-gnu/libc', '--gcc-toolchain=<cross_install_dir>/gcc-arm-9.2-2019.12-x86_64-aarch64-none-linux-gnu']
166 Assuming the file with augmented ``c_args`` and ``c_link_args``
167 is named ``arm64_armv8_linux_clang``,
168 use the following command to cross-compile DPDK for the target machine::
170 meson aarch64-build-clang --cross-file config/arm/arm64_armv8_linux_clang
171 ninja -C aarch64-build-clang
173 Cross Compiling DPDK with LLVM/Clang toolchain using Meson on Ubuntu 18.04
174 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
176 On most popular Linux distribution it is not necessary to download
177 the toolchains, but rather use the packages provided by said distributions.
178 On Ubuntu 18.04, these packages are needed:
180 .. code-block:: console
182 sudo apt-get install pkg-config-aarch64-linux-gnu clang llvm llvm-dev lld
183 libc6-dev-arm64-cross libatomic1-arm64-cross libgcc-8-dev-arm64-cross
185 Use the following command to cross-compile DPDK for the target machine::
187 meson aarch64-build-clang --cross-file config/arm/arm64_armv8_linux_clang_ubuntu1804
188 ninja -C aarch64-build-clang
190 Supported cross-compilation targets
191 -----------------------------------
193 If you wish to build for a target which is not among the current cross-files,
194 you may use various combinations of implementer/part number::
196 Supported implementers:
197 'generic': Generic armv8
200 '0x50': Ampere Computing
201 '0x56': Marvell ARMADA
204 Supported part_numbers for generic:
205 'generic': valid for all armv8-a architectures (unoptimized portable build)
207 Supported part_numbers for 0x41, 0x56, dpaa:
215 Supported part_numbers for 0x43:
222 Supported part_numbers for 0x50:
225 Other cross file options
226 ------------------------
228 There are other options you may specify in a cross file to tailor the build::
230 Supported extra configuration
231 max_numa_nodes = n # will set RTE_MAX_NUMA_NODES
232 max_lcores = n # will set RTE_MAX_LCORE
234 numa = false # set to false to force building for a non-NUMA system
235 # if not set or set to true, the build system will build for a NUMA
236 # system only if libnuma is installed