1.. SPDX-License-Identifier: BSD-3-Clause 2 Copyright(c) 2022 Loongson Technology Corporation Limited 3 4Cross compiling DPDK for LoongArch 5================================== 6 7This chapter describes how to cross compile DPDK for LoongArch from x86 build 8hosts. 9 10.. note:: 11 12 Due to some of the code under review, the current Linux 5.19 cannot boot 13 on LoongArch system. There are still some Linux distributions that have 14 supported LoongArch host, such as Anolis OS, Kylin, Loongnix and UOS. These 15 distributions base on Linux kernel 4.19 supported by Loongson Corporation. 16 Because LoongArch is such a new platform with many fundamental pieces of 17 software still under development, it is currently recommended to cross 18 compile DPDK on x86 for LoongArch. 19 20 21Prerequisites 22------------- 23 24Ensure that you have all pre-requisites for building DPDK natively as those 25will be required also for cross-compilation. 26 27Linux kernel 28~~~~~~~~~~~~ 29 30Make sure that LoongArch host is running Linux kernel 4.19 or newer supported 31by Loongson Corporation. The support for LoongArch in the current Linux 5.19 32is not complete because it still misses some patches to add for other 33subsystems. 34 35GNU toolchain 36------------- 37 38Obtain the cross toolchain 39~~~~~~~~~~~~~~~~~~~~~~~~~~ 40 41The build process was tested using a precompiled toolchain: 42 43* Latest `LoongArch GNU toolchain 44 <https://github.com/loongson/build-tools/releases/download/2022.08.11/loongarch64-clfs-5.1-cross-tools-gcc-glibc.tar.xz>`_ 45 on Debian 10.4 or CentOS 8. 46 47After downloading the archive, we need to unzip and add those executable 48binaries into the PATH as follows: 49 50.. code-block:: console 51 52 tar -xvf <download_dir>/loongarch64-clfs-5.1-cross-tools-gcc-glibc.tar.xz -C <cross_tool_install_dir> --strip-components 1 53 export PATH=$PATH:<cross_tool_install_dir>/bin 54 55Generate the cross toolchain from sources 56~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 57 58Alternatively the toolchain may be built straight from upstream sources. 59You can refer to this thread `Introduce support for LoongArch architecture 60<https://inbox.dpdk.org/dev/53b50799-cb29-7ee6-be89-4fe21566e127@loongson.cn/T/#m1da99578f85894a4ddcd8e39d8239869e6a501d1>`_. 61 62Before you start running the script, you may need to install some dependencies. 63For instance, if you want to run this script in a RHEL 8 system, you can use 64the following command to install these dependencies: 65 66.. code-block:: console 67 68 subscription-manager repos --enable codeready-builder-for-rhel-8-x86_64-rpms 69 dnf install bison diffutils file flex gcc gcc-c++ git gmp-devel libtool make python3 rsync texinfo wget xz zlib-devel ccache 70 71Once generated, the location of the executable binaries must be added to PATH: 72 73.. code-block:: console 74 75 export PATH=$PATH:<cross_tool_install_dir>/bin 76 77Cross Compiling DPDK with GNU toolchain using Meson 78~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 79 80To cross-compile DPDK for generic LoongArch we can use the following command: 81 82.. code-block:: console 83 84 meson setup cross-build --cross-file config/loongarch/loongarch_loongarch64_linux_gcc 85 ninja -C cross-build 86 87Supported cross-compilation targets 88----------------------------------- 89 90Currently the following target is supported: 91 92* Generic LoongArch64 ISA: ``config/loongarch/loongarch_loongarch64_linux_gcc`` 93 94To add a new target support, a corresponding cross-file has to be added to 95``config/loongarch`` directory. 96