aarch64 clang cross compilation
cover aarch64 clang cross compilation
Use clang/LLVM toolchain with gcc stdlib to cross compile aarch64 target.
Juraj Linkeš (2):
ci: add aarch64 clang cross-compilation builds
doc: add clang to aarch64 cross build guide
.ci/linux-build.sh | 9 +- .travis.yml | 22 ++- .../linux_gsg/cross_build_dpdk_for_arm64.rst | 183 +++++++++++++----- 3 files changed, 159 insertions(+), 55 deletions(-)
Signature · 1 line
2.20.1
PATCH 1/2 ci: add aarch64 clang cross-compilation builds
Mirror the existing gcc jobs - build static and shared libs. Use arm64_armv8_linux_clang meson cross file.
--- .ci/linux-build.sh | 9 +++++++-- .travis.yml | 22 ++++++++++++++++++++-- 2 files changed, 27 insertions(+), 4 deletions(-)
.ci/linux-build.sh +7 -2
@@ -28,11 +28,16 @@ install_libabigail() { rm ${version}.tar.gz } -if [ "$AARCH64" = "1" ]; then +if [ "$AARCH64_GCC" = "1" ]; then # convert the arch specifier OPTS="$OPTS --cross-file config/arm/arm64_armv8_linux_gcc" fi +if [ "$AARCH64_CLANG" = "1" ]; then + # convert the arch specifier + OPTS="$OPTS --cross-file config/arm/arm64_armv8_linux_clang" +fi + if [ "$BUILD_DOCS" = "1" ]; then OPTS="$OPTS -Denable_docs=true" fi
@@ -53,7 +58,7 @@ OPTS="$OPTS --buildtype=debugoptimized" meson build --werror $OPTS ninja -C build -if [ "$AARCH64" != "1" ]; then +if [ "$AARCH64_GCC" != "1" ] && [ "$AARCH64_CLANG" != 1 ]; then devtools/test-null.sh fi
.travis.yml +20 -2
@@ -18,6 +18,10 @@ _aarch64_packages: &aarch64_packages - *required_packages - [gcc-aarch64-linux-gnu, libc6-dev-arm64-cross, pkg-config-aarch64-linux-gnu] +_aarch64_clang_packages: &aarch64_clang_packages + - *required_packages + - [libgcc-8-dev-arm64-cross, libatomic1-arm64-cross, libc6-dev-arm64-cross, pkg-config-aarch64-linux-gnu] + _build_32b_packages: &build_32b_packages - *required_packages - [gcc-multilib]
@@ -69,20 +73,34 @@ jobs: packages: - *build_32b_packages # x86_64 cross-compiling aarch64 jobs - - env: DEF_LIB="static" AARCH64=1 + - env: DEF_LIB="static" AARCH64_GCC=1 arch: amd64 compiler: gcc addons: apt: packages: - *aarch64_packages - - env: DEF_LIB="shared" AARCH64=1 + - env: DEF_LIB="shared" AARCH64_GCC=1 arch: amd64 compiler: gcc addons: apt: packages: - *aarch64_packages + - env: DEF_LIB="static" AARCH64_CLANG=1 + arch: amd64 + compiler: clang + addons: + apt: + packages: + - *aarch64_clang_packages + - env: DEF_LIB="shared" AARCH64_CLANG=1 + arch: amd64 + compiler: clang + addons: + apt: + packages: + - *aarch64_clang_packages # aarch64 gcc jobs - env: DEF_LIB="static" arch: arm64
Signature · 1 line
2.20.1
PATCH 2/2 doc: add clang to aarch64 cross build guide
In reply to Juraj LinkešReorganize and update the aarch64 cross guide with clang cross compilation. Update the GNU toolchain version which clang also uses. Reorganize into common part, GNU part and clang part.
--- .../linux_gsg/cross_build_dpdk_for_arm64.rst | 183 +++++++++++++----- 1 file changed, 132 insertions(+), 51 deletions(-)
doc/guides/linux_gsg/cross_build_dpdk_for_arm64.rst +132 -51
@@ -1,101 +1,182 @@ .. SPDX-License-Identifier: BSD-3-Clause - Copyright(c) 2018 ARM Corporation. + Copyright(c) 2020 ARM Corporation. -Cross compile DPDK for ARM64 -============================ +Cross compiling DPDK for ARM64 +============================== This chapter describes how to cross compile DPDK for ARM64 from x86 build hosts. .. note:: Whilst it is recommended to natively build DPDK on ARM64 (just - like with x86), it is also possible to cross-build DPDK for ARM64. An - ARM64 cross compile GNU toolchain is used for this. + like with x86), it is also possible to cross compile DPDK for ARM64. + An ARM64 cross compiler GNU toolchain or an LLVM/clang toolchain + may be used for cross-compilation. -Obtain the cross tool chain ---------------------------- -The latest cross compile tool chain can be downloaded from: + +Prerequisites +------------- + +NUMA library +~~~~~~~~~~~~ + +NUMA is required by most modern machines, not needed for non-NUMA architectures. + +.. note:: + + For compiling the NUMA lib, run libtool --version to ensure the libtool version >= 2.2, + otherwise the compilation will fail with errors. + +.. code-block:: console + + git clone https://github.com/numactl/numactl.git + cd numactl + git checkout v2.0.13 -b v2.0.13 + ./autogen.sh + autoconf -i + ./configure --host=aarch64-linux-gnu CC=<compiler> --prefix=<numa install dir> + make install + +.. note:: + + The compiler above can be either aarch64-linux-gnu-gcc or clang. + See below for information on how to get the compiler of your choice. + +The numa header files and lib file is generated in the include and lib folder respectively under <numa install dir>. + +Meson prerequisites +~~~~~~~~~~~~~~~~~~~ + +Meson depends on pkgconfig to find the dependencies. +The package ``pkg-config-aarch64-linux-gnu`` is required for aarch64. +To install it in Ubuntu:: + + sudo apt install pkg-config-aarch64-linux-gnu + + +GNU toolchain +------------- + +.. _obtain_GNU_toolchain: + +Obtain the cross toolchain +~~~~~~~~~~~~~~~~~~~~~~~~~~ +The latest GNU cross compiler toolchain can be downloaded from: https://developer.arm.com/open-source/gnu-toolchain/gnu-a/downloads. It is always recommended to check and get the latest compiler tool from the page and use -it to generate better code. As of this writing 8.3-2019.03 is the newest, the following +it to generate better code. As of this writing 9.2-2019.12 is the newest, the following description is an example of this version. .. code-block:: console - wget https://developer.arm.com/-/media/Files/downloads/gnu-a/8.3-2019.03/binrel/gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu.tar.xz + 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 Unzip and add into the PATH ---------------------------- +~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. code-block:: console - tar -xvf gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu.tar.xz - export PATH=$PATH:<cross_install_dir>/gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu/bin + tar -xvf gcc-arm-9.2-2019.12-x86_64-aarch64-none-linux-gnu.tar.xz + export PATH=$PATH:<cross_install_dir>/gcc-arm-9.2-2019.12-x86_64-aarch64-none-linux-gnu/bin .. note:: For the host requirements and other info, refer to the release note section: https://releases.linaro.org/components/toolchain/binaries/ -.. _arm_cross_build_getting_the_prerequisite_library: +.. _augment_the_gnu_toolchain_with_numa_support: -Getting the prerequisite library --------------------------------- - -NUMA is required by most modern machines, not needed for non-NUMA architectures. +Augment the GNU toolchain with NUMA support +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. note:: - For compiling the NUMA lib, run libtool --version to ensure the libtool version >= 2.2, - otherwise the compilation will fail with errors. + This way is optional, an alternative is to use extra CFLAGS and LDFLAGS. + +Copy the NUMA header files and lib to the cross compiler's directories: .. code-block:: console - git clone https://github.com/numactl/numactl.git - cd numactl - git checkout v2.0.13 -b v2.0.13 - ./autogen.sh - autoconf -i - ./configure --host=aarch64-linux-gnu CC=aarch64-linux-gnu-gcc --prefix=<numa install dir> - make install + 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/ + 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/ + 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/ -The numa header files and lib file is generated in the include and lib folder respectively under <numa install dir>. +Cross Compiling DPDK with GNU toolchain using Meson +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +To cross-compile DPDK on a desired target machine we can use the following +command:: + + meson cross-build --cross-file <target_machine_configuration> + ninja -C cross-build + +For example if the target machine is aarch64 we can use the following +command:: -.. _augment_the_cross_toolchain_with_numa_support: + meson aarch64-build-gcc --cross-file config/arm/arm64_armv8_linux_gcc + ninja -C aarch64-build-gcc -Augment the cross toolchain with NUMA support ---------------------------------------------- + +LLVM/Clang toolchain +-------------------- + +Obtain the cross tool chain +~~~~~~~~~~~~~~~~~~~~~~~~~~~ +The latest LLVM/Clang cross compiler toolchain can be downloaded from: +https://developer.arm.com/tools-and-software/open-source-software/developer-tools/llvm-toolchain. + +.. code-block:: console + + # Ubuntu binaries + 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 + +The LLVM/Clang toolchain does not implement the standard c library. The GNU toolchain +ships an implementation we can use. Refer to obtain_GNU_toolchain_ to get the +GNU toolchain. + +Unzip and add into the PATH +~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. code-block:: console + + tar -xvf clang+llvm-10.0.0-x86_64-linux-gnu-ubuntu-18.04.tar.xz + export PATH=$PATH:<cross_install_dir>/clang+llvm-10.0.0-x86_64-linux-gnu-ubuntu-18.04/bin + +Cross Compiling DPDK with LLVM/Clang toolchain using Meson +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. note:: - This way is optional, an alternative is to use extra CFLAGS and LDFLAGS. + To use the NUMA library follow the same steps as for + augment_the_gnu_toolchain_with_numa_support_. -Copy the NUMA header files and lib to the cross compiler's directories: +The paths to GNU stdlib must be specified in a cross file. Augmenting the default +cross-file's c_args and c_link_args config/arm/arm64_armv8_linux_clang_ubuntu18.04 would look like this: .. code-block:: console - cp <numa_install_dir>/include/numa*.h <cross_install_dir>/gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu/aarch64-linux-gnu/libc/usr/include/ - cp <numa_install_dir>/lib/libnuma.a <cross_install_dir>/gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu/lib/gcc/aarch64-linux-gnu/8.3.0/ - cp <numa_install_dir>/lib/libnuma.so <cross_install_dir>/gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu/lib/gcc/aarch64-linux-gnu/8.3.0/ + ... + 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', '--gcc-toolchain=<cross_install_dir>/gcc-arm-9.2-2019.12-x86_64-aarch64-none-linux-gnu'] + c_link_args = ['-target', 'aarch64-linux-gnu', '-fuse-ld=lld', '<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'] -.. _configure_and_cross_compile_dpdk_build: +Assuming the file with augmented c_args and c_link_args is named arm64_armv8_linux_clang, +use the following command to cross-compile DPDK for your target machine:: -Cross Compiling DPDK --------------------- + meson aarch64-build-clang --cross-file config/arm/arm64_armv8_linux_clang + ninja -C aarch64-build-clang -Meson depends on pkgconfig to find the dependencies. -The package ``pkg-config-aarch64-linux-gnu`` is required for aarch64. -To install it in Ubuntu:: +Cross Compiling DPDK with LLVM/Clang toolchain using Meson on Ubuntu18.04 +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - sudo apt-get install pkg-config-aarch64-linux-gnu +On most popular Linux distribution it's not necessary to download +the toolchains, but rather use the packages provided by said distributions. +On Ubuntu18.04, you'll need these packages: -To cross-compile DPDK on a desired target machine we can use the following -command:: +.. code-block:: console - meson cross-build --cross-file <target_machine_configuration> - ninja -C cross-build + sudo apt-get install pkg-config-aarch64-linux-gnu clang llvm llvm-dev lld + libc6-dev-arm64-cross libatomic1-arm64-cross libgcc-8-dev-arm64-cross -For example if the target machine is arm64 we can use the following -command:: +Use the following command to cross-compile DPDK for your target machine:: - meson arm64-build --cross-file config/arm/arm64_armv8_linux_gcc - ninja -C arm64-build + meson aarch64-build-clang --cross-file config/arm/arm64_armv8_linux_clang_ubuntu18.04 + ninja -C aarch64-build-clang
Signature · 1 line
2.20.1
v2 cover aarch64 clang cross compilation
In reply to Juraj LinkešUse clang/LLVM toolchain with gcc stdlib to cross compile aarch64 target.
Juraj Linkeš (3):
build: add aarch64 clang to meson cross-compile
ci: add aarch64 clang cross-compilation builds
doc: add clang to aarch64 cross build guide
.ci/linux-build.sh | 9 +- .travis.yml | 22 ++- config/arm/arm64_armv8_linux_clang_ubuntu1804 | 20 ++ .../linux_gsg/cross_build_dpdk_for_arm64.rst | 183 +++++++++++++----- 4 files changed, 179 insertions(+), 55 deletions(-) create mode 100644 config/arm/arm64_armv8_linux_clang_ubuntu1804
Signature · 1 line
2.20.1
PATCH v2 1/3 build: add aarch64 clang to meson cross-compile
Create meson cross file arm64_armv8_linux_clang_ubuntu1804. Use clang/LLVM toolchain with sysroot pointing to gcc cross stdlib.
--- config/arm/arm64_armv8_linux_clang_ubuntu1804 | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 config/arm/arm64_armv8_linux_clang_ubuntu1804
config/arm/arm64_armv8_linux_clang_ubuntu1804 new file +20 -0
@@ -0,0 +1,20 @@ +[binaries] +c = 'clang' +cpp = 'clang++' +ar = 'llvm-ar' +strip = 'llvm-strip' +llvm-config = 'llvm-config' +pcap-config = 'llvm-config' +pkgconfig = 'aarch64-linux-gnu-pkg-config' + +[host_machine] +system = 'linux' +cpu_family = 'aarch64' +cpu = 'armv8-a' +endian = 'little' + +[properties] +implementor_id = 'generic' +implementor_pn = 'default' +c_args = ['-target', 'aarch64-linux-gnu', '--sysroot', '/usr/aarch64-linux-gnu', '--gcc-toolchain=/usr'] +c_link_args = ['-target', 'aarch64-linux-gnu', '-fuse-ld=lld']
Signature · 1 line
2.20.1
Re: [dpdk-dev] [PATCH v2 1/3] build: add aarch64 clang to meson cross-compile
Quoted 7 lines · Juraj Linkeš
Create meson cross file
arm64_armv8_linux_clang_ubuntu1804. Use clang/LLVM toolchain with sysroot pointing to gcc cross stdlib.Signed-off-by Juraj Linkeš <[email protected]>--- config/arm/arm64_armv8_linux_clang_ubuntu1804 | 20 +++++++++++++++++++
IMO, if we are adding a specific OS distribution-specific configuration then it won't scale.
Why not have just arm64_armv8_linux_clang ?
Re: [dpdk-dev] [PATCH v2 1/3] build: add aarch64 clang to meson cross-compile
Quoted 18 lines
-----Original Message-----
From: Jerin Jacob <[email protected]>
Sent: Sunday, October 4, 2020 10:30 AM
To: Juraj Linkeš <[email protected]>
Cc: Thomas Monjalon <[email protected]>; David Marchand <[email protected]>; Aaron Conole <[email protected]>; Michael Santana <[email protected]>; dpdk-dev <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v2 1/3] build: add aarch64 clang to meson cross- compileQuoted 4 lines · Juraj Linkeš
Create meson cross file
arm64_armv8_linux_clang_ubuntu1804. Use clang/LLVM toolchain with sysroot pointing to gcc cross stdlib.
Quoted 8 lines
Quoted 4 lines
Signed-off-by Juraj Linkeš <[email protected]>--- config/arm/arm64_armv8_linux_clang_ubuntu1804 | 20+++++++++++++++++++
IMO, if we are adding a specific OS distribution-specific configuration then it won't scale.
Why not have justarm64_armv8_linux_clang?
CFLAGS, LDFLAGS, c_args and c_link_args don't work when cross-compiling (at least they didn't work when I tested it) and that means we have to put the paths to stdlib (which llvm/clang doesn't implement) into a cross file. The arm64_armv8_linux_clang_ubuntu1804 contains paths that work with ubuntu clang/gcc packages (and would thus be used in CI). We can't have a generic cross file for clang because of this path limitation.
Re: [dpdk-dev] [PATCH v2 1/3] build: add aarch64 clang to meson cross-compile
Quoted 24 lines · Juraj Linkeš
Quoted 24 lines
-----Original Message-----
From: Jerin Jacob <[email protected]>
Sent: Sunday, October 4, 2020 10:30 AM
To: Juraj Linkeš <[email protected]>
Cc: Thomas Monjalon <[email protected]>; David Marchand <[email protected]>; Aaron Conole <[email protected]>; Michael Santana <[email protected]>; dpdk-dev <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v2 1/3] build: add aarch64 clang to meson cross- compileQuoted 8 lines · Juraj Linkeš
Create meson cross file
arm64_armv8_linux_clang_ubuntu1804. Use clang/LLVM toolchain with sysroot pointing to gcc cross stdlib.Signed-off-by Juraj Linkeš <[email protected]>--- config/arm/arm64_armv8_linux_clang_ubuntu1804 | 20+++++++++++++++++++
Quoted 5 lines
Quoted 3 lines
IMO, if we are adding a specific OS distribution-specific configuration then it won't scale.
Why not have justarm64_armv8_linux_clang?CFLAGS, LDFLAGS,
c_argsandc_link_argsdon't work when cross-compiling (at least they didn't work when I tested it) and that means we have to put the paths to stdlib (which llvm/clang doesn't implement) into a cross file
I am using cross-build, following syntax is working CFLAGS='-g -ggdb3' meson build
Quoted 1 line
The
arm64_armv8_linux_clang_ubuntu1804contains paths that work with ubuntu clang/gcc packages (and would thus be used in CI). We can't have a generic cross file for clang because of this path limitation.
If ubuntu 18.04 needs some fix up like adding the stuff to PATH etc, we could do a different stage in Travis ci. right?
Re: [dpdk-dev] [PATCH v2 1/3] build: add aarch64 clang to meson cross-compile
Quoted 51 lines
-----Original Message-----
From: Jerin Jacob <[email protected]>
Sent: Monday, October 5, 2020 4:26 PM
To: Juraj Linkeš <[email protected]>
Cc: Thomas Monjalon <[email protected]>; David Marchand <[email protected]>; Aaron Conole <[email protected]>; Michael Santana <[email protected]>; dpdk-dev <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v2 1/3] build: add aarch64 clang to meson cross- compileQuoted 25 lines · Juraj Linkeš
Quoted 25 lines
-----Original Message-----
From: Jerin Jacob <[email protected]>
Sent: Sunday, October 4, 2020 10:30 AM
To: Juraj Linkeš <[email protected]>
Cc: Thomas Monjalon <[email protected]>; David Marchand <[email protected]>; Aaron Conole <[email protected]>; Michael Santana <[email protected]>; dpdk-dev <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v2 1/3] build: add aarch64 clang to meson cross- compileQuoted 8 lines · Juraj Linkeš
Create meson cross file
arm64_armv8_linux_clang_ubuntu1804. Use clang/LLVM toolchain with sysroot pointing to gcc cross stdlib.Signed-off-by Juraj Linkeš <[email protected]>--- config/arm/arm64_armv8_linux_clang_ubuntu1804 | 20+++++++++++++++++++
Quoted 8 lines
Quoted 3 lines
IMO, if we are adding a specific OS distribution-specific configuration then it won't scale.
Why not have justarm64_armv8_linux_clang?CFLAGS, LDFLAGS,
c_argsandc_link_argsdon't work when cross-compiling (at least they didn't work when I tested it) and that means we have to put the paths to stdlib (which llvm/clang doesn't implement) into a cross fileI am using cross-build, following syntax is working CFLAGS='-g -ggdb3' meson build
Quoted 6 lines
Quoted 1 line
The
arm64_armv8_linux_clang_ubuntu1804contains paths that work withubuntu clang/gcc packages (and would thus be used in CI). We can't have a generic cross file for clang because of this path limitation.
If ubuntu 18.04 needs some fix up like adding the stuff to PATH etc, we could do a different stage in Travis ci. right?
Sorry for the long delay, I was swamped with other stuff.
What do you mean by "following syntax is working CFLAGS='-g -ggdb3' meson build" in cross-builds? I tried the same thing with the flags I've put into the arm64_armv8_linux_clang_ubuntu1804 file and it doesn't work at all for cross builds - CFLAGS get only used for native compiler and not the cross compiler.
Here's what I mean:
CFLAGS='--sysroot /usr/aarch64-linux-gnu --gcc-toolchain=/usr' meson clang-build-aarch64 --werror -Dexamples=all --default-library static --cross-file config/arm/arm64_armv8_linux_clang # the cross file doesn't contain the paths Results in meson not being able to properly figure out size of "void *":
-----------------------
Running compile:
Working directory: /tmp/tmpf_n3b9c7 Command line: clang /tmp/tmpf_n3b9c7/testfile.c -pipe -D_FILE_OFFSET_BITS=64 -c -o /tmp/tmpf_n3b9c7/output.obj -target aarch64-linux-gnu -O0
Code:
#include <stdio.h>
int main(int argc, char **argv) {
void * something;
}Compiler stdout:
Compiler stderr:
In file included from /tmp/tmpf_n3b9c7/testfile.c:1:/usr/include/stdio.h:27:10: fatal error: 'bits/libc-header-start.h' file not found
#include <bits/libc-header-start.h>
^~~~~~~~~~~~~~~~~~~~~~~~~~1 error generated.
Checking for size of "void *": -1
-----------------------
However, when I put the paths into the cross file and run without CFLAGS, it works fine:
meson clang-build-aarch64 --werror -Dexamples=all --default-library static --cross-file config/arm/arm64_armv8_linux_clang_ubuntu1804 # the cross file contains the paths Results in:
-----------------------
Running compile:
Working directory: /tmp/tmpikoi3353 Command line: clang /tmp/tmpikoi3353/testfile.c -pipe -D_FILE_OFFSET_BITS=64 -c -o /tmp/tmpikoi3353/output.obj -target aarch64-linux-gnu --sysroot /usr/aarch64-linux-gnu --gcc-toolchain=/usr -O0
Code:
#include <stdio.h>
int main(int argc, char **argv) {
void * something;
}Compiler stdout:
Compiler stderr:
-----------------------
From what I was able to google, meson devs only want to allow specifying cross-specific option in cross files and are purposefully ignoring env variables for cross builds.
What we could do is just modify the cross file in Travis before running the build. But then we would have a useless clang cross file in the repo since we have to have the paths in it for clang cross compilition.
I hope I'm wrong, but I don't see a way around this.
What do you think?
PATCH v2 2/3 ci: add aarch64 clang cross-compilation builds
In reply to Juraj LinkešMirror the existing gcc jobs - build static and shared libs. Use arm64_armv8_linux_clang_ubuntu1804 meson cross file.
--- .ci/linux-build.sh | 9 +++++++-- .travis.yml | 22 ++++++++++++++++++++-- 2 files changed, 27 insertions(+), 4 deletions(-)
.ci/linux-build.sh +7 -2
@@ -28,11 +28,16 @@ install_libabigail() { rm ${version}.tar.gz } -if [ "$AARCH64" = "1" ]; then +if [ "$AARCH64_GCC" = "1" ]; then # convert the arch specifier OPTS="$OPTS --cross-file config/arm/arm64_armv8_linux_gcc" fi +if [ "$AARCH64_CLANG" = "1" ]; then + # convert the arch specifier + OPTS="$OPTS --cross-file config/arm/arm64_armv8_linux_clang_ubuntu1804" +fi + if [ "$BUILD_DOCS" = "1" ]; then OPTS="$OPTS -Denable_docs=true" fi
@@ -53,7 +58,7 @@ OPTS="$OPTS --buildtype=debugoptimized" meson build --werror $OPTS ninja -C build -if [ "$AARCH64" != "1" ]; then +if [ "$AARCH64_GCC" != "1" ] && [ "$AARCH64_CLANG" != 1 ]; then devtools/test-null.sh fi
.travis.yml +20 -2
@@ -18,6 +18,10 @@ _aarch64_packages: &aarch64_packages - *required_packages - [gcc-aarch64-linux-gnu, libc6-dev-arm64-cross, pkg-config-aarch64-linux-gnu] +_aarch64_clang_packages: &aarch64_clang_packages + - *required_packages + - [libgcc-8-dev-arm64-cross, libatomic1-arm64-cross, libc6-dev-arm64-cross, pkg-config-aarch64-linux-gnu] + _build_32b_packages: &build_32b_packages - *required_packages - [gcc-multilib]
@@ -69,20 +73,34 @@ jobs: packages: - *build_32b_packages # x86_64 cross-compiling aarch64 jobs - - env: DEF_LIB="static" AARCH64=1 + - env: DEF_LIB="static" AARCH64_GCC=1 arch: amd64 compiler: gcc addons: apt: packages: - *aarch64_packages - - env: DEF_LIB="shared" AARCH64=1 + - env: DEF_LIB="shared" AARCH64_GCC=1 arch: amd64 compiler: gcc addons: apt: packages: - *aarch64_packages + - env: DEF_LIB="static" AARCH64_CLANG=1 + arch: amd64 + compiler: clang + addons: + apt: + packages: + - *aarch64_clang_packages + - env: DEF_LIB="shared" AARCH64_CLANG=1 + arch: amd64 + compiler: clang + addons: + apt: + packages: + - *aarch64_clang_packages # aarch64 gcc jobs - env: DEF_LIB="static" arch: arm64
Signature · 1 line
2.20.1
Re: [dpdk-dev] [PATCH v2 2/3] ci: add aarch64 clang cross-compilation builds
Quoted 14 lines · Juraj Linkeš
Mirror the existing gcc jobs - build static and shared libs. Use
arm64_armv8_linux_clang_ubuntu1804meson cross file.Signed-off-by Juraj Linkeš <[email protected]>--- .ci/linux-build.sh | 9 +++++++-- .travis.yml | 22 ++++++++++++++++++++-- 2 files changed, 27 insertions(+), 4 deletions(-).ci/linux-build.sh +0
-0
.ci/linux-build.sh install_libabigail() { · line 31
Quoted 5 lines
.ci/linux-build.sh +1
-1@@ -28,11 +28,16 @@ install_libabigail() { rm ${version}.tar.gz } -if [ "$AARCH64" = "1" ]; then +if [ "$AARCH64_GCC" = "1" ]; then
Why do we need to do this?
CC_FOR_BUILD and CC should be either 'gcc' or 'clang' - so we could just key off of those instead of having to do this new set of variables, yes?
Quoted 73 lines
.ci/linux-build.sh +6
-1# convert the arch specifier OPTS="$OPTS --cross-file config/arm/arm64_armv8_linux_gcc" fi +if [ "$AARCH64_CLANG" = "1" ]; then + # convert the arch specifier + OPTS="$OPTS --cross-file config/arm/arm64_armv8_linux_clang_ubuntu1804" +fi + if [ "$BUILD_DOCS" = "1" ]; then OPTS="$OPTS -Denable_docs=true" fi@@ -53,7 +58,7 @@ OPTS="$OPTS --buildtype=debugoptimized" meson build --werror $OPTS ninja -C build -if [ "$AARCH64" != "1" ]; then +if [ "$AARCH64_GCC" != "1" ] && [ "$AARCH64_CLANG" != 1 ]; then devtools/test-null.sh fi.travis.yml +20
-2@@ -18,6 +18,10 @@ _aarch64_packages: &aarch64_packages - *required_packages - [gcc-aarch64-linux-gnu, libc6-dev-arm64-cross, pkg-config-aarch64-linux-gnu] +_aarch64_clang_packages: &aarch64_clang_packages + - *required_packages + - [libgcc-8-dev-arm64-cross, libatomic1-arm64-cross, libc6-dev-arm64-cross, pkg-config-aarch64-linux-gnu] + _build_32b_packages: &build_32b_packages - *required_packages - [gcc-multilib]@@ -69,20 +73,34 @@ jobs: packages: - *build_32b_packages # x86_64 cross-compiling aarch64 jobs - - env: DEF_LIB="static" AARCH64=1 + - env: DEF_LIB="static" AARCH64_GCC=1 arch: amd64 compiler: gcc addons: apt: packages: - *aarch64_packages - - env: DEF_LIB="shared" AARCH64=1 + - env: DEF_LIB="shared" AARCH64_GCC=1 arch: amd64 compiler: gcc addons: apt: packages: - *aarch64_packages + - env: DEF_LIB="static" AARCH64_CLANG=1 + arch: amd64 + compiler: clang + addons: + apt: + packages: + - *aarch64_clang_packages + - env: DEF_LIB="shared" AARCH64_CLANG=1 + arch: amd64 + compiler: clang + addons: + apt: + packages: + - *aarch64_clang_packages # aarch64 gcc jobs - env: DEF_LIB="static" arch: arm64
Re: [dpdk-dev] [PATCH v2 2/3] ci: add aarch64 clang cross-compilation builds
Quoted 29 lines
-----Original Message-----
From: Aaron Conole <[email protected]>
Sent: Thursday, October 1, 2020 3:32 PM
To: Juraj Linkeš <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v2 2/3] ci: add aarch64 clang cross-compilation buildsQuoted 17 lines · Juraj Linkeš
Mirror the existing gcc jobs - build static and shared libs. Use
arm64_armv8_linux_clang_ubuntu1804meson cross file.Signed-off-by Juraj Linkeš <[email protected]>--- .ci/linux-build.sh | 9 +++++++-- .travis.yml | 22 ++++++++++++++++++++-- 2 files changed, 27 insertions(+), 4 deletions(-).ci/linux-build.sh index renamed from .ci/linux-build.sh +0
-0
d079801d7..137f51e91100755.ci/linux-build.sh +0
-0@@ -28,11 +28,16 @@ install_libabigail() { rm ${version}.tar.gz }
Quoted 8 lines
.ci/linux-build.sh install_libabigail() { · line 31
Quoted 2 lines
.ci/linux-build.sh +1
-1-if [ "$AARCH64" = "1" ]; then +if [ "$AARCH64_GCC" = "1" ]; thenWhy do we need to do this?
CC_FOR_BUILDand CC should be either 'gcc' or 'clang' - so we could just key off of those instead of having to do this new set of variables, yes?
I didn't think of these variables. I'll make use of them, that's better, thanks.
Quoted 77 lines
.ci/linux-build.sh install_libabigail() {
Quoted 7 lines
.ci/linux-build.sh +3
-0# convert the arch specifier OPTS="$OPTS --cross-file config/arm/arm64_armv8_linux_gcc" fi +if [ "$AARCH64_CLANG" = "1" ]; then + # convert the arch specifier + OPTS="$OPTS --cross-fileconfig/arm/arm64_armv8_linux_clang_ubuntu1804"
Quoted 68 lines
.ci/linux-build.sh +3
-1+fi + if [ "$BUILD_DOCS" = "1" ]; then OPTS="$OPTS -Denable_docs=true" fi@@ -53,7 +58,7 @@ OPTS="$OPTS --buildtype=debugoptimized" meson build --werror $OPTS ninja -C build -if [ "$AARCH64" != "1" ]; then +if [ "$AARCH64_GCC" != "1" ] && [ "$AARCH64_CLANG" != 1 ]; then devtools/test-null.sh fi.travis.yml index d6eeab371..1f769d823 renamed from .travis.yml +0
-0100644
.travis.yml +0
-0@@ -18,6 +18,10 @@ _aarch64_packages: &aarch64_packages - *required_packages - [gcc-aarch64-linux-gnu, libc6-dev-arm64-cross,pkg-config-aarch64-linux-gnu]
.travis.yml +21
-2+_aarch64_clang_packages: &aarch64_clang_packages + - *required_packages + - [libgcc-8-dev-arm64-cross, libatomic1-arm64-cross, +libc6-dev-arm64-cross, pkg-config-aarch64-linux-gnu] + _build_32b_packages: &build_32b_packages - *required_packages - [gcc-multilib]@@ -69,20 +73,34 @@ jobs: packages: - *build_32b_packages # x86_64 cross-compiling aarch64 jobs - - env: DEF_LIB="static" AARCH64=1 + - env: DEF_LIB="static" AARCH64_GCC=1 arch: amd64 compiler: gcc addons: apt: packages: - *aarch64_packages - - env: DEF_LIB="shared" AARCH64=1 + - env: DEF_LIB="shared" AARCH64_GCC=1 arch: amd64 compiler: gcc addons: apt: packages: - *aarch64_packages + - env: DEF_LIB="static" AARCH64_CLANG=1 + arch: amd64 + compiler: clang + addons: + apt: + packages: + - *aarch64_clang_packages + - env: DEF_LIB="shared" AARCH64_CLANG=1 + arch: amd64 + compiler: clang + addons: + apt: + packages: + - *aarch64_clang_packages # aarch64 gcc jobs - env: DEF_LIB="static" arch: arm64
PATCH v2 3/3 doc: add clang to aarch64 cross build guide
In reply to Juraj LinkešReorganize and update the aarch64 cross guide with clang cross compilation. Update the GNU toolchain version which clang also uses. Reorganize into common part, GNU part and clang part.
--- .../linux_gsg/cross_build_dpdk_for_arm64.rst | 183 +++++++++++++----- 1 file changed, 132 insertions(+), 51 deletions(-)
doc/guides/linux_gsg/cross_build_dpdk_for_arm64.rst +132 -51
@@ -1,101 +1,182 @@ .. SPDX-License-Identifier: BSD-3-Clause - Copyright(c) 2018 ARM Corporation. + Copyright(c) 2020 ARM Corporation. -Cross compile DPDK for ARM64 -============================ +Cross compiling DPDK for ARM64 +============================== This chapter describes how to cross compile DPDK for ARM64 from x86 build hosts. .. note:: Whilst it is recommended to natively build DPDK on ARM64 (just - like with x86), it is also possible to cross-build DPDK for ARM64. An - ARM64 cross compile GNU toolchain is used for this. + like with x86), it is also possible to cross compile DPDK for ARM64. + An ARM64 cross compiler GNU toolchain or an LLVM/clang toolchain + may be used for cross-compilation. -Obtain the cross tool chain ---------------------------- -The latest cross compile tool chain can be downloaded from: + +Prerequisites +------------- + +NUMA library +~~~~~~~~~~~~ + +NUMA is required by most modern machines, not needed for non-NUMA architectures. + +.. note:: + + For compiling the NUMA lib, run libtool --version to ensure the libtool version >= 2.2, + otherwise the compilation will fail with errors. + +.. code-block:: console + + git clone https://github.com/numactl/numactl.git + cd numactl + git checkout v2.0.13 -b v2.0.13 + ./autogen.sh + autoconf -i + ./configure --host=aarch64-linux-gnu CC=<compiler> --prefix=<numa install dir> + make install + +.. note:: + + The compiler above can be either aarch64-linux-gnu-gcc or clang. + See below for information on how to get the compiler of your choice. + +The numa header files and lib file is generated in the include and lib folder respectively under <numa install dir>. + +Meson prerequisites +~~~~~~~~~~~~~~~~~~~ + +Meson depends on pkgconfig to find the dependencies. +The package ``pkg-config-aarch64-linux-gnu`` is required for aarch64. +To install it in Ubuntu:: + + sudo apt install pkg-config-aarch64-linux-gnu + + +GNU toolchain +------------- + +.. _obtain_GNU_toolchain: + +Obtain the cross toolchain +~~~~~~~~~~~~~~~~~~~~~~~~~~ +The latest GNU cross compiler toolchain can be downloaded from: https://developer.arm.com/open-source/gnu-toolchain/gnu-a/downloads. It is always recommended to check and get the latest compiler tool from the page and use -it to generate better code. As of this writing 8.3-2019.03 is the newest, the following +it to generate better code. As of this writing 9.2-2019.12 is the newest, the following description is an example of this version. .. code-block:: console - wget https://developer.arm.com/-/media/Files/downloads/gnu-a/8.3-2019.03/binrel/gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu.tar.xz + 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 Unzip and add into the PATH ---------------------------- +~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. code-block:: console - tar -xvf gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu.tar.xz - export PATH=$PATH:<cross_install_dir>/gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu/bin + tar -xvf gcc-arm-9.2-2019.12-x86_64-aarch64-none-linux-gnu.tar.xz + export PATH=$PATH:<cross_install_dir>/gcc-arm-9.2-2019.12-x86_64-aarch64-none-linux-gnu/bin .. note:: For the host requirements and other info, refer to the release note section: https://releases.linaro.org/components/toolchain/binaries/ -.. _arm_cross_build_getting_the_prerequisite_library: +.. _augment_the_gnu_toolchain_with_numa_support: -Getting the prerequisite library --------------------------------- - -NUMA is required by most modern machines, not needed for non-NUMA architectures. +Augment the GNU toolchain with NUMA support +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. note:: - For compiling the NUMA lib, run libtool --version to ensure the libtool version >= 2.2, - otherwise the compilation will fail with errors. + This way is optional, an alternative is to use extra CFLAGS and LDFLAGS. + +Copy the NUMA header files and lib to the cross compiler's directories: .. code-block:: console - git clone https://github.com/numactl/numactl.git - cd numactl - git checkout v2.0.13 -b v2.0.13 - ./autogen.sh - autoconf -i - ./configure --host=aarch64-linux-gnu CC=aarch64-linux-gnu-gcc --prefix=<numa install dir> - make install + 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/ + 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/ + 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/ -The numa header files and lib file is generated in the include and lib folder respectively under <numa install dir>. +Cross Compiling DPDK with GNU toolchain using Meson +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +To cross-compile DPDK on a desired target machine we can use the following +command:: + + meson cross-build --cross-file <target_machine_configuration> + ninja -C cross-build + +For example if the target machine is aarch64 we can use the following +command:: -.. _augment_the_cross_toolchain_with_numa_support: + meson aarch64-build-gcc --cross-file config/arm/arm64_armv8_linux_gcc + ninja -C aarch64-build-gcc -Augment the cross toolchain with NUMA support ---------------------------------------------- + +LLVM/Clang toolchain +-------------------- + +Obtain the cross tool chain +~~~~~~~~~~~~~~~~~~~~~~~~~~~ +The latest LLVM/Clang cross compiler toolchain can be downloaded from: +https://developer.arm.com/tools-and-software/open-source-software/developer-tools/llvm-toolchain. + +.. code-block:: console + + # Ubuntu binaries + 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 + +The LLVM/Clang toolchain does not implement the standard c library. The GNU toolchain +ships an implementation we can use. Refer to obtain_GNU_toolchain_ to get the +GNU toolchain. + +Unzip and add into the PATH +~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. code-block:: console + + tar -xvf clang+llvm-10.0.0-x86_64-linux-gnu-ubuntu-18.04.tar.xz + export PATH=$PATH:<cross_install_dir>/clang+llvm-10.0.0-x86_64-linux-gnu-ubuntu-18.04/bin + +Cross Compiling DPDK with LLVM/Clang toolchain using Meson +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. note:: - This way is optional, an alternative is to use extra CFLAGS and LDFLAGS. + To use the NUMA library follow the same steps as for + augment_the_gnu_toolchain_with_numa_support_. -Copy the NUMA header files and lib to the cross compiler's directories: +The paths to GNU stdlib must be specified in a cross file. Augmenting the default +cross-file's c_args and c_link_args config/arm/arm64_armv8_linux_clang_ubuntu1804 would look like this: .. code-block:: console - cp <numa_install_dir>/include/numa*.h <cross_install_dir>/gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu/aarch64-linux-gnu/libc/usr/include/ - cp <numa_install_dir>/lib/libnuma.a <cross_install_dir>/gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu/lib/gcc/aarch64-linux-gnu/8.3.0/ - cp <numa_install_dir>/lib/libnuma.so <cross_install_dir>/gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu/lib/gcc/aarch64-linux-gnu/8.3.0/ + ... + 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', '--gcc-toolchain=<cross_install_dir>/gcc-arm-9.2-2019.12-x86_64-aarch64-none-linux-gnu'] + c_link_args = ['-target', 'aarch64-linux-gnu', '-fuse-ld=lld', '<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'] -.. _configure_and_cross_compile_dpdk_build: +Assuming the file with augmented c_args and c_link_args is named arm64_armv8_linux_clang, +use the following command to cross-compile DPDK for your target machine:: -Cross Compiling DPDK --------------------- + meson aarch64-build-clang --cross-file config/arm/arm64_armv8_linux_clang + ninja -C aarch64-build-clang -Meson depends on pkgconfig to find the dependencies. -The package ``pkg-config-aarch64-linux-gnu`` is required for aarch64. -To install it in Ubuntu:: +Cross Compiling DPDK with LLVM/Clang toolchain using Meson on Ubuntu 18.04 +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - sudo apt-get install pkg-config-aarch64-linux-gnu +On most popular Linux distribution it's not necessary to download +the toolchains, but rather use the packages provided by said distributions. +On Ubuntu 18.04, you'll need these packages: -To cross-compile DPDK on a desired target machine we can use the following -command:: +.. code-block:: console - meson cross-build --cross-file <target_machine_configuration> - ninja -C cross-build + sudo apt-get install pkg-config-aarch64-linux-gnu clang llvm llvm-dev lld + libc6-dev-arm64-cross libatomic1-arm64-cross libgcc-8-dev-arm64-cross -For example if the target machine is arm64 we can use the following -command:: +Use the following command to cross-compile DPDK for your target machine:: - meson arm64-build --cross-file config/arm/arm64_armv8_linux_gcc - ninja -C arm64-build + meson aarch64-build-clang --cross-file config/arm/arm64_armv8_linux_clang_ubuntu1804 + ninja -C aarch64-build-clang
Signature · 1 line
2.20.1
v3 cover aarch64 clang cross compilation
In reply to Juraj LinkešUse clang/LLVM toolchain with gcc stdlib to cross compile aarch64 target.
v3:
Removed AARCH_GCC and AARCH_CLANG variables in favor of CC_FOR_BUILD.
Juraj Linkeš (3):
build: add aarch64 clang to meson cross-compile
ci: add aarch64 clang cross-compilation builds
doc: add clang to aarch64 cross build guide
.ci/linux-build.sh | 6 +- .travis.yml | 18 ++ config/arm/arm64_armv8_linux_clang_ubuntu1804 | 20 ++ .../linux_gsg/cross_build_dpdk_for_arm64.rst | 183 +++++++++++++----- 4 files changed, 175 insertions(+), 52 deletions(-) create mode 100644 config/arm/arm64_armv8_linux_clang_ubuntu1804
Signature · 1 line
2.20.1
PATCH v3 1/3 build: add aarch64 clang to meson cross-compile
Create meson cross file arm64_armv8_linux_clang_ubuntu1804. Use clang/LLVM toolchain with sysroot pointing to gcc cross stdlib.
--- config/arm/arm64_armv8_linux_clang_ubuntu1804 | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 config/arm/arm64_armv8_linux_clang_ubuntu1804
config/arm/arm64_armv8_linux_clang_ubuntu1804 new file +20 -0
@@ -0,0 +1,20 @@ +[binaries] +c = 'clang' +cpp = 'clang++' +ar = 'llvm-ar' +strip = 'llvm-strip' +llvm-config = 'llvm-config' +pcap-config = 'llvm-config' +pkgconfig = 'aarch64-linux-gnu-pkg-config' + +[host_machine] +system = 'linux' +cpu_family = 'aarch64' +cpu = 'armv8-a' +endian = 'little' + +[properties] +implementor_id = 'generic' +implementor_pn = 'default' +c_args = ['-target', 'aarch64-linux-gnu', '--sysroot', '/usr/aarch64-linux-gnu', '--gcc-toolchain=/usr'] +c_link_args = ['-target', 'aarch64-linux-gnu', '-fuse-ld=lld']
Signature · 1 line
2.20.1
Re: [dpdk-dev] [PATCH v3 1/3] build: add aarch64 clang to meson cross-compile
Quoted 49 lines
-----Original Message-----
From: dev <[email protected]> On Behalf Of Juraj Linke?
Sent: Friday, October 2, 2020 5:38 PM
To: [email protected]; [email protected]; [email protected]; [email protected]
Cc: [email protected]; Juraj Linkeš <[email protected]>
Subject: [dpdk-dev] [PATCH v3 1/3] build: add aarch64 clang to meson cross- compileCreate meson cross file
arm64_armv8_linux_clang_ubuntu1804. Use clang/LLVM toolchain with sysroot pointing to gcc cross stdlib.Signed-off-by Juraj Linkeš <[email protected]>--- config/arm/arm64_armv8_linux_clang_ubuntu1804 | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 config/arm/arm64_armv8_linux_clang_ubuntu1804config/arm/arm64_armv8_linux_clang_ubuntu1804 new file +21
-1@@ -0,0 +1,20 @@ +[binaries] +c = 'clang' +cpp = 'clang++' +ar = 'llvm-ar' +strip = 'llvm-strip' +llvm-config = 'llvm-config' +pcap-config = 'llvm-config' +pkgconfig = 'aarch64-linux-gnu-pkg-config' + +[host_machine] +system = 'linux' +cpu_family = 'aarch64' +cpu = 'armv8-a' +endian = 'little' + +[properties] +implementor_id = 'generic' +implementor_pn = 'default' +c_args = ['-target', 'aarch64-linux-gnu', '--sysroot', +'/usr/aarch64-linux-gnu', '--gcc-toolchain=/usr'] c_link_args = +['-target', 'aarch64-linux-gnu', '-fuse-ld=lld'] --
Quoted 1 line
2.20.1
I understand specific flags are needed by clang to do cross compiling. Path to gnu libc which is required could be different on some other systems. The cross file works on Ubuntu, and could be referred to by other systems.
PATCH v3 2/3 ci: add aarch64 clang cross-compilation builds
In reply to Juraj LinkešMirror the existing gcc jobs - build static and shared libs. Use arm64_armv8_linux_clang_ubuntu1804 meson cross file.
--- .ci/linux-build.sh | 6 +++++- .travis.yml | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-)
.ci/linux-build.sh +5 -1
@@ -30,7 +30,11 @@ install_libabigail() { if [ "$AARCH64" = "1" ]; then # convert the arch specifier - OPTS="$OPTS --cross-file config/arm/arm64_armv8_linux_gcc" + if [ "$CC_FOR_BUILD" = "gcc" ]; then + OPTS="$OPTS --cross-file config/arm/arm64_armv8_linux_gcc" + elif [ "$CC_FOR_BUILD" = "clang" ]; then + OPTS="$OPTS --cross-file config/arm/arm64_armv8_linux_clang_ubuntu1804" + fi fi if [ "$BUILD_DOCS" = "1" ]; then
.travis.yml +18 -0
@@ -18,6 +18,10 @@ _aarch64_packages: &aarch64_packages - *required_packages - [gcc-aarch64-linux-gnu, libc6-dev-arm64-cross, pkg-config-aarch64-linux-gnu] +_aarch64_clang_packages: &aarch64_clang_packages + - *required_packages + - [libgcc-8-dev-arm64-cross, libatomic1-arm64-cross, libc6-dev-arm64-cross, pkg-config-aarch64-linux-gnu] + _build_32b_packages: &build_32b_packages - *required_packages - [gcc-multilib]
@@ -83,6 +87,20 @@ jobs: apt: packages: - *aarch64_packages + - env: DEF_LIB="static" AARCH64=1 + arch: amd64 + compiler: clang + addons: + apt: + packages: + - *aarch64_clang_packages + - env: DEF_LIB="shared" AARCH64=1 + arch: amd64 + compiler: clang + addons: + apt: + packages: + - *aarch64_clang_packages # aarch64 gcc jobs - env: DEF_LIB="static" arch: arm64
Signature · 1 line
2.20.1
PATCH v3 3/3 doc: add clang to aarch64 cross build guide
In reply to Juraj LinkešReorganize and update the aarch64 cross guide with clang cross compilation. Update the GNU toolchain version which clang also uses. Reorganize into common part, GNU part and clang part.
--- .../linux_gsg/cross_build_dpdk_for_arm64.rst | 183 +++++++++++++----- 1 file changed, 132 insertions(+), 51 deletions(-)
doc/guides/linux_gsg/cross_build_dpdk_for_arm64.rst +132 -51
@@ -1,101 +1,182 @@ .. SPDX-License-Identifier: BSD-3-Clause - Copyright(c) 2018 ARM Corporation. + Copyright(c) 2020 ARM Corporation. -Cross compile DPDK for ARM64 -============================ +Cross compiling DPDK for ARM64 +============================== This chapter describes how to cross compile DPDK for ARM64 from x86 build hosts. .. note:: Whilst it is recommended to natively build DPDK on ARM64 (just - like with x86), it is also possible to cross-build DPDK for ARM64. An - ARM64 cross compile GNU toolchain is used for this. + like with x86), it is also possible to cross compile DPDK for ARM64. + An ARM64 cross compiler GNU toolchain or an LLVM/clang toolchain + may be used for cross-compilation. -Obtain the cross tool chain ---------------------------- -The latest cross compile tool chain can be downloaded from: + +Prerequisites +------------- + +NUMA library +~~~~~~~~~~~~ + +NUMA is required by most modern machines, not needed for non-NUMA architectures. + +.. note:: + + For compiling the NUMA lib, run libtool --version to ensure the libtool version >= 2.2, + otherwise the compilation will fail with errors. + +.. code-block:: console + + git clone https://github.com/numactl/numactl.git + cd numactl + git checkout v2.0.13 -b v2.0.13 + ./autogen.sh + autoconf -i + ./configure --host=aarch64-linux-gnu CC=<compiler> --prefix=<numa install dir> + make install + +.. note:: + + The compiler above can be either aarch64-linux-gnu-gcc or clang. + See below for information on how to get the compiler of your choice. + +The numa header files and lib file is generated in the include and lib folder respectively under <numa install dir>. + +Meson prerequisites +~~~~~~~~~~~~~~~~~~~ + +Meson depends on pkgconfig to find the dependencies. +The package ``pkg-config-aarch64-linux-gnu`` is required for aarch64. +To install it in Ubuntu:: + + sudo apt install pkg-config-aarch64-linux-gnu + + +GNU toolchain +------------- + +.. _obtain_GNU_toolchain: + +Obtain the cross toolchain +~~~~~~~~~~~~~~~~~~~~~~~~~~ +The latest GNU cross compiler toolchain can be downloaded from: https://developer.arm.com/open-source/gnu-toolchain/gnu-a/downloads. It is always recommended to check and get the latest compiler tool from the page and use -it to generate better code. As of this writing 8.3-2019.03 is the newest, the following +it to generate better code. As of this writing 9.2-2019.12 is the newest, the following description is an example of this version. .. code-block:: console - wget https://developer.arm.com/-/media/Files/downloads/gnu-a/8.3-2019.03/binrel/gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu.tar.xz + 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 Unzip and add into the PATH ---------------------------- +~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. code-block:: console - tar -xvf gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu.tar.xz - export PATH=$PATH:<cross_install_dir>/gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu/bin + tar -xvf gcc-arm-9.2-2019.12-x86_64-aarch64-none-linux-gnu.tar.xz + export PATH=$PATH:<cross_install_dir>/gcc-arm-9.2-2019.12-x86_64-aarch64-none-linux-gnu/bin .. note:: For the host requirements and other info, refer to the release note section: https://releases.linaro.org/components/toolchain/binaries/ -.. _arm_cross_build_getting_the_prerequisite_library: +.. _augment_the_gnu_toolchain_with_numa_support: -Getting the prerequisite library --------------------------------- - -NUMA is required by most modern machines, not needed for non-NUMA architectures. +Augment the GNU toolchain with NUMA support +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. note:: - For compiling the NUMA lib, run libtool --version to ensure the libtool version >= 2.2, - otherwise the compilation will fail with errors. + This way is optional, an alternative is to use extra CFLAGS and LDFLAGS. + +Copy the NUMA header files and lib to the cross compiler's directories: .. code-block:: console - git clone https://github.com/numactl/numactl.git - cd numactl - git checkout v2.0.13 -b v2.0.13 - ./autogen.sh - autoconf -i - ./configure --host=aarch64-linux-gnu CC=aarch64-linux-gnu-gcc --prefix=<numa install dir> - make install + 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/ + 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/ + 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/ -The numa header files and lib file is generated in the include and lib folder respectively under <numa install dir>. +Cross Compiling DPDK with GNU toolchain using Meson +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +To cross-compile DPDK on a desired target machine we can use the following +command:: + + meson cross-build --cross-file <target_machine_configuration> + ninja -C cross-build + +For example if the target machine is aarch64 we can use the following +command:: -.. _augment_the_cross_toolchain_with_numa_support: + meson aarch64-build-gcc --cross-file config/arm/arm64_armv8_linux_gcc + ninja -C aarch64-build-gcc -Augment the cross toolchain with NUMA support ---------------------------------------------- + +LLVM/Clang toolchain +-------------------- + +Obtain the cross tool chain +~~~~~~~~~~~~~~~~~~~~~~~~~~~ +The latest LLVM/Clang cross compiler toolchain can be downloaded from: +https://developer.arm.com/tools-and-software/open-source-software/developer-tools/llvm-toolchain. + +.. code-block:: console + + # Ubuntu binaries + 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 + +The LLVM/Clang toolchain does not implement the standard c library. The GNU toolchain +ships an implementation we can use. Refer to obtain_GNU_toolchain_ to get the +GNU toolchain. + +Unzip and add into the PATH +~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. code-block:: console + + tar -xvf clang+llvm-10.0.0-x86_64-linux-gnu-ubuntu-18.04.tar.xz + export PATH=$PATH:<cross_install_dir>/clang+llvm-10.0.0-x86_64-linux-gnu-ubuntu-18.04/bin + +Cross Compiling DPDK with LLVM/Clang toolchain using Meson +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. note:: - This way is optional, an alternative is to use extra CFLAGS and LDFLAGS. + To use the NUMA library follow the same steps as for + augment_the_gnu_toolchain_with_numa_support_. -Copy the NUMA header files and lib to the cross compiler's directories: +The paths to GNU stdlib must be specified in a cross file. Augmenting the default +cross-file's c_args and c_link_args config/arm/arm64_armv8_linux_clang_ubuntu1804 would look like this: .. code-block:: console - cp <numa_install_dir>/include/numa*.h <cross_install_dir>/gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu/aarch64-linux-gnu/libc/usr/include/ - cp <numa_install_dir>/lib/libnuma.a <cross_install_dir>/gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu/lib/gcc/aarch64-linux-gnu/8.3.0/ - cp <numa_install_dir>/lib/libnuma.so <cross_install_dir>/gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu/lib/gcc/aarch64-linux-gnu/8.3.0/ + ... + 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', '--gcc-toolchain=<cross_install_dir>/gcc-arm-9.2-2019.12-x86_64-aarch64-none-linux-gnu'] + c_link_args = ['-target', 'aarch64-linux-gnu', '-fuse-ld=lld', '<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'] -.. _configure_and_cross_compile_dpdk_build: +Assuming the file with augmented c_args and c_link_args is named arm64_armv8_linux_clang, +use the following command to cross-compile DPDK for your target machine:: -Cross Compiling DPDK --------------------- + meson aarch64-build-clang --cross-file config/arm/arm64_armv8_linux_clang + ninja -C aarch64-build-clang -Meson depends on pkgconfig to find the dependencies. -The package ``pkg-config-aarch64-linux-gnu`` is required for aarch64. -To install it in Ubuntu:: +Cross Compiling DPDK with LLVM/Clang toolchain using Meson on Ubuntu 18.04 +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - sudo apt-get install pkg-config-aarch64-linux-gnu +On most popular Linux distribution it's not necessary to download +the toolchains, but rather use the packages provided by said distributions. +On Ubuntu 18.04, you'll need these packages: -To cross-compile DPDK on a desired target machine we can use the following -command:: +.. code-block:: console - meson cross-build --cross-file <target_machine_configuration> - ninja -C cross-build + sudo apt-get install pkg-config-aarch64-linux-gnu clang llvm llvm-dev lld + libc6-dev-arm64-cross libatomic1-arm64-cross libgcc-8-dev-arm64-cross -For example if the target machine is arm64 we can use the following -command:: +Use the following command to cross-compile DPDK for your target machine:: - meson arm64-build --cross-file config/arm/arm64_armv8_linux_gcc - ninja -C arm64-build + meson aarch64-build-clang --cross-file config/arm/arm64_armv8_linux_clang_ubuntu1804 + ninja -C aarch64-build-clang
Signature · 1 line
2.20.1
Re: [dpdk-dev] [PATCH v3 3/3] doc: add clang to aarch64 cross build guide
Quoted 10 lines
-----Original Message-----
From: dev <[email protected]> On Behalf Of Juraj Linke?
Sent: Friday, October 2, 2020 5:38 PM
To: [email protected]; [email protected]; [email protected]; [email protected]
Cc: [email protected]; Juraj Linkeš <[email protected]>
Subject: [dpdk-dev] [PATCH v3 3/3] doc: add clang to aarch64 cross build guide
Quoted 9 lines
Reorganize and update the aarch64 cross guide with clang cross compilation. Update the GNU toolchain version which clang also uses. Reorganize into common part, GNU part and clang part.
Signed-off-by Juraj Linkeš <[email protected]>--- .../linux_gsg/cross_build_dpdk_for_arm64.rst | 183 +++++++++++++----- 1 file changed, 132 insertions(+), 51 deletions(-)
v4 cover aarch64 clang cross compilation
In reply to Juraj LinkešUse clang/LLVM toolchain with gcc stdlib to cross compile aarch64 target.
v3:
Removed AARCH_GCC and AARCH_CLANG variables in favor of CC_FOR_BUILD.
v4:
Rebased.
Updated commit msg in build: add aarch64 clang to meson cross-compile.
Juraj Linkeš (3):
build: add aarch64 clang to meson cross-compile
ci: add aarch64 clang cross-compilation builds
doc: add clang to aarch64 cross build guide
.ci/linux-build.sh | 6 +- .travis.yml | 18 ++ config/arm/arm64_armv8_linux_clang_ubuntu1804 | 20 ++ .../linux_gsg/cross_build_dpdk_for_arm64.rst | 183 +++++++++++++----- 4 files changed, 175 insertions(+), 52 deletions(-) create mode 100644 config/arm/arm64_armv8_linux_clang_ubuntu1804
Signature · 1 line
2.20.1
PATCH v4 1/3 build: add aarch64 clang to meson cross-compile
Create meson cross-file arm64_armv8_linux_clang_ubuntu1804. Use clang/LLVM toolchain with sysroot pointing to gcc cross stdlib.
The sysroot path must be in the cross-file so that Clang can find the proper headers:
* setting CFLAGS, LDFLAGS or -Dc_args, -Dc_link_args doesn't affect cross builds (only native builds). Support added in 0.51.0.
* setting pkg-config vars only affects lib searching, not includes
* splitting the cross-file into two (one with clang info, one with paths) doesn't work. Support added in 0.52.0.
--- config/arm/arm64_armv8_linux_clang_ubuntu1804 | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 config/arm/arm64_armv8_linux_clang_ubuntu1804
config/arm/arm64_armv8_linux_clang_ubuntu1804 new file +20 -0
@@ -0,0 +1,20 @@ +[binaries] +c = 'clang' +cpp = 'clang++' +ar = 'llvm-ar' +strip = 'llvm-strip' +llvm-config = 'llvm-config' +pcap-config = 'llvm-config' +pkgconfig = 'aarch64-linux-gnu-pkg-config' + +[host_machine] +system = 'linux' +cpu_family = 'aarch64' +cpu = 'armv8-a' +endian = 'little' + +[properties] +implementor_id = 'generic' +implementor_pn = 'default' +c_args = ['-target', 'aarch64-linux-gnu', '--sysroot', '/usr/aarch64-linux-gnu'] +c_link_args = ['-target', 'aarch64-linux-gnu', '-fuse-ld=lld', '--gcc-toolchain=/usr']
Signature · 1 line
2.20.1
Re: [dpdk-dev] [PATCH v4 1/3] build: add aarch64 clang to meson cross-compile
19/01/2021 09:33, Juraj Linkeš:
Quoted 1 line
Create meson cross-file
arm64_armv8_linux_clang_ubuntu1804.
Why is it specific to Ubuntu 18.04?
I don't want to add specifc cross files per distributions.
Quoted 9 lines
Use clang/LLVM toolchain with sysroot pointing to gcc cross stdlib.
The sysroot path must be in the cross-file so that Clang can find the proper headers:
* setting CFLAGS, LDFLAGS or -Dc_args, -Dc_link_args doesn't affect cross builds (only native builds). Support added in 0.51.0.
* setting pkg-config vars only affects lib searching, not includes
* splitting the cross-file into two (one with clang info, one with paths) doesn't work. Support added in 0.52.0.
I don't understand the explanations above. Please explain what is the bug and how it is fixed.
[...]
Quoted 2 lines
config/arm/arm64_armv8_linux_clang_ubuntu1804 new file +2
-0+c_args = ['-target', 'aarch64-linux-gnu', '--sysroot', '/usr/aarch64-linux-gnu'] +c_link_args = ['-target', 'aarch64-linux-gnu', '-fuse-ld=lld', '--gcc-toolchain=/usr']
Re: [dpdk-dev] [PATCH v4 1/3] build: add aarch64 clang to meson cross-compile
Quoted 28 lines
-----Original Message-----
From: Thomas Monjalon <[email protected]>
Sent: Tuesday, January 19, 2021 5:08 PM
To: Juraj Linkeš <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [dpdk-dev] [PATCH v4 1/3] build: add aarch64 clang to meson cross- compile19/01/2021 09:33, Juraj Linkeš:
Quoted 1 line
Create meson cross-file
arm64_armv8_linux_clang_ubuntu1804.Why is it specific to Ubuntu 18.04?
I don't want to add specifc cross files per distributions.Quoted 9 lines
Use clang/LLVM toolchain with sysroot pointing to gcc cross stdlib.
The sysroot path must be in the cross-file so that Clang can find the proper headers:
* setting CFLAGS, LDFLAGS or -Dc_args, -Dc_link_args doesn't affect cross builds (only native builds). Support added in 0.51.0.
* setting pkg-config vars only affects lib searching, not includes
* splitting the cross-file into two (one with clang info, one with paths) doesn't work. Support added in 0.52.0.
Quoted 3 lines
I don't understand the explanations above. Please explain what is the bug and how it is fixed.
I guess the missing piece is that the sysroot path is the ubuntu specific part. The explanations illustrate why we can't have a generic cross file with the current meson version - there's no way to pass the paths to cross builds. Now that I think about it, the commit message needs a rewrite - I should've mentioned that clang/llvm doesn't provide it's own standard c lib, so that has to come from elsewhere (such as gcc) and thus we have to provide the paths.
Quoted 7 lines
[...]
Quoted 3 lines
+c_args = ['-target', 'aarch64-linux-gnu', '--sysroot', +'/usr/aarch64-linux-gnu']
c_link_args= ['-target', +'aarch64-linux-gnu', '-fuse-ld=lld', '--gcc-toolchain=/usr']
Re: [dpdk-dev] [PATCH v4 1/3] build: add aarch64 clang to meson cross-compile
20/01/2021 09:24, Juraj Linkeš:
Quoted 17 lines
From: Thomas Monjalon <[email protected]>
Quoted 16 lines
19/01/2021 09:33, Juraj Linkeš:
Quoted 1 line
Create meson cross-file
arm64_armv8_linux_clang_ubuntu1804.Why is it specific to Ubuntu 18.04?
I don't want to add specifc cross files per distributions.Quoted 9 lines
Use clang/LLVM toolchain with sysroot pointing to gcc cross stdlib.
The sysroot path must be in the cross-file so that Clang can find the proper headers:
* setting CFLAGS, LDFLAGS or -Dc_args, -Dc_link_args doesn't affect cross builds (only native builds). Support added in 0.51.0.
* setting pkg-config vars only affects lib searching, not includes
* splitting the cross-file into two (one with clang info, one with paths) doesn't work. Support added in 0.52.0.
Quoted 5 lines
Quoted 3 lines
I don't understand the explanations above. Please explain what is the bug and how it is fixed.
I guess the missing piece is that the sysroot path is the ubuntu specific part. The explanations illustrate why we can't have a generic cross file with the current meson version - there's no way to pass the paths to cross builds. Now that I think about it, the commit message needs a rewrite - I should've mentioned that clang/llvm doesn't provide it's own standard c lib, so that has to come from elsewhere (such as gcc) and thus we have to provide the paths.
Can it be done with the option -Dc_args?
Quoted 4 lines
Quoted 4 lines
[...]
Quoted 3 lines
+c_args = ['-target', 'aarch64-linux-gnu', '--sysroot', +'/usr/aarch64-linux-gnu']
c_link_args= ['-target', +'aarch64-linux-gnu', '-fuse-ld=lld', '--gcc-toolchain=/usr']
Re: [dpdk-dev] [PATCH v4 1/3] build: add aarch64 clang to meson cross-compile
Quoted 34 lines
-----Original Message-----
From: Thomas Monjalon <[email protected]>
Sent: Wednesday, January 20, 2021 11:22 AM
To: Juraj Linkeš <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [dpdk-dev] [PATCH v4 1/3] build: add aarch64 clang to meson cross- compile20/01/2021 09:24, Juraj Linkeš:
Quoted 21 lines
From: Thomas Monjalon <[email protected]>
Quoted 19 lines
19/01/2021 09:33, Juraj Linkeš:
Quoted 1 line
Create meson cross-file
arm64_armv8_linux_clang_ubuntu1804.Why is it specific to Ubuntu 18.04?
I don't want to add specifc cross files per distributions.Quoted 9 lines
Use clang/LLVM toolchain with sysroot pointing to gcc cross stdlib.
The sysroot path must be in the cross-file so that Clang can find the proper headers:
* setting CFLAGS, LDFLAGS or -Dc_args, -Dc_link_args doesn't affect cross builds (only native builds). Support added in 0.51.0.
* setting pkg-config vars only affects lib searching, not includes
* splitting the cross-file into two (one with clang info, one with paths) doesn't work. Support added in 0.52.0.I don't understand the explanations above. Please explain what is the bug and how it is fixed.
Quoted 9 lines
Quoted 1 line
I guess the missing piece is that the sysroot path is the ubuntu specific part.
The explanations illustrate why we can't have a generic cross file with the current meson version - there's no way to pass the paths to cross builds. Now that I think about it, the commit message needs a rewrite - I should've mentioned that clang/llvm doesn't provide it's own standard c lib, so that has to come from elsewhere (such as gcc) and thus we have to provide the paths.
Can it be done with the option -Dc_args?
Not in Meson 0.47.1, it's explained in the commit msg:
* setting CFLAGS, LDFLAGS or -Dc_args, -Dc_link_args doesn't affect cross builds (only native builds). Support added in 0.51.0.
Quoted 8 lines
Quoted 5 lines
Quoted 5 lines
[...]
Quoted 3 lines
+c_args = ['-target', 'aarch64-linux-gnu', '--sysroot', +'/usr/aarch64-linux-gnu']
c_link_args= ['-target', +'aarch64-linux-gnu', '-fuse-ld=lld', '--gcc-toolchain=/usr']
Re: [dpdk-dev] [PATCH v4 1/3] build: add aarch64 clang to meson cross-compile
20/01/2021 11:30, Juraj Linkeš:
Quoted 30 lines
From: Thomas Monjalon <[email protected]>
Quoted 29 lines
20/01/2021 09:24, Juraj Linkeš:
Quoted 17 lines
From: Thomas Monjalon <[email protected]>
Quoted 16 lines
19/01/2021 09:33, Juraj Linkeš:
Quoted 1 line
Create meson cross-file
arm64_armv8_linux_clang_ubuntu1804.Why is it specific to Ubuntu 18.04?
I don't want to add specifc cross files per distributions.Quoted 9 lines
Use clang/LLVM toolchain with sysroot pointing to gcc cross stdlib.
The sysroot path must be in the cross-file so that Clang can find the proper headers:
* setting CFLAGS, LDFLAGS or -Dc_args, -Dc_link_args doesn't affect cross builds (only native builds). Support added in 0.51.0.
* setting pkg-config vars only affects lib searching, not includes
* splitting the cross-file into two (one with clang info, one with paths) doesn't work. Support added in 0.52.0.Quoted 5 lines
Quoted 3 lines
I don't understand the explanations above. Please explain what is the bug and how it is fixed.
I guess the missing piece is that the sysroot path is the ubuntu specific part.
The explanations illustrate why we can't have a generic cross file with the current meson version - there's no way to pass the paths to cross builds. Now that I think about it, the commit message needs a rewrite - I should've mentioned that clang/llvm doesn't provide it's own standard c lib, so that has to come from elsewhere (such as gcc) and thus we have to provide the paths.
Quoted 6 lines
Quoted 2 lines
Can it be done with the option -Dc_args?
Not in Meson 0.47.1, it's explained in the commit msg:
* setting CFLAGS, LDFLAGS or -Dc_args, -Dc_link_args doesn't affect cross builds (only native builds). Support added in 0.51.0.
So I suggest to make it clearer :)
One proposal:
* setting CFLAGS/LDFLAGS variables or using -Dc_args/-Dc_link_args options do not work on cross builds until Meson 0.51.0.
Quoted 9 lines
Quoted 7 lines
Quoted 4 lines
Quoted 4 lines
[...]
Quoted 3 lines
+c_args = ['-target', 'aarch64-linux-gnu', '--sysroot', +'/usr/aarch64-linux-gnu']
c_link_args= ['-target', +'aarch64-linux-gnu', '-fuse-ld=lld', '--gcc-toolchain=/usr']
Re: [dpdk-dev] [PATCH v4 1/3] build: add aarch64 clang to meson cross-compile
Quoted 53 lines
-----Original Message-----
From: Thomas Monjalon <[email protected]>
Sent: Wednesday, January 20, 2021 11:35 AM
To: Juraj Linkeš <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [dpdk-dev] [PATCH v4 1/3] build: add aarch64 clang to meson cross- compile20/01/2021 11:30, Juraj Linkeš:
Quoted 31 lines
From: Thomas Monjalon <[email protected]>
Quoted 30 lines
20/01/2021 09:24, Juraj Linkeš:
Quoted 19 lines
From: Thomas Monjalon <[email protected]>
Quoted 18 lines
19/01/2021 09:33, Juraj Linkeš:
Quoted 1 line
Create meson cross-file
arm64_armv8_linux_clang_ubuntu1804.Why is it specific to Ubuntu 18.04?
I don't want to add specifc cross files per distributions.Quoted 11 lines
Use clang/LLVM toolchain with sysroot pointing to gcc cross stdlib.
The sysroot path must be in the cross-file so that Clang can find the proper headers:
* setting CFLAGS, LDFLAGS or -Dc_args, -Dc_link_args doesn't affect cross builds (only native builds). Support added in 0.51.0.
* setting pkg-config vars only affects lib searching, not includes
* splitting the cross-file into two (one with clang info, one with
paths) doesn't work. Support added in 0.52.0.Quoted 5 lines
Quoted 3 lines
I don't understand the explanations above. Please explain what is the bug and how it is fixed.
I guess the missing piece is that the sysroot path is the ubuntu specific part.
The explanations illustrate why we can't have a generic cross file with the current meson version - there's no way to pass the paths to cross builds. Now that I think about it, the commit message needs a rewrite - I should've mentioned that clang/llvm doesn't provide it's own standard c lib, so that has to come from elsewhere (such as gcc) and
thus we have to provide the paths.
Quoted 7 lines
Quoted 3 lines
Can it be done with the option -Dc_args?
Not in Meson 0.47.1, it's explained in the commit msg:
* setting CFLAGS, LDFLAGS or -Dc_args, -Dc_link_args doesn't affect cross builds (only native builds). Support added in 0.51.0.
Quoted 6 lines
So I suggest to make it clearer :)
One proposal:* setting CFLAGS/LDFLAGS variables or using -Dc_args/-Dc_link_args options do not work on cross builds until Meson 0.51.0.
Ok, I'll reword the commit message to make it more clearer based on your feedback.
Quoted 14 lines
Quoted 9 lines
Quoted 7 lines
Quoted 4 lines
Quoted 4 lines
[...]
Quoted 3 lines
+c_args = ['-target', 'aarch64-linux-gnu', '--sysroot', +'/usr/aarch64-linux-gnu']
c_link_args= ['-target', +'aarch64-linux-gnu', '-fuse-ld=lld', '--gcc-toolchain=/usr']
PATCH v4 2/3 ci: add aarch64 clang cross-compilation builds
In reply to Juraj LinkešMirror the existing gcc jobs - build static and shared libs. Use arm64_armv8_linux_clang_ubuntu1804 meson cross file.
--- .ci/linux-build.sh | 6 +++++- .travis.yml | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-)
.ci/linux-build.sh +5 -1
@@ -32,7 +32,11 @@ install_libabigail() { if [ "$AARCH64" = "true" ]; then # convert the arch specifier - OPTS="$OPTS --cross-file config/arm/arm64_armv8_linux_gcc" + if [ "$CC_FOR_BUILD" = "gcc" ]; then + OPTS="$OPTS --cross-file config/arm/arm64_armv8_linux_gcc" + elif [ "$CC_FOR_BUILD" = "clang" ]; then + OPTS="$OPTS --cross-file config/arm/arm64_armv8_linux_clang_ubuntu1804" + fi fi if [ "$BUILD_DOCS" = "true" ]; then
.travis.yml +18 -0
@@ -21,6 +21,10 @@ _aarch64_packages: &aarch64_packages - *required_packages - [gcc-aarch64-linux-gnu, libc6-dev-arm64-cross, pkg-config-aarch64-linux-gnu] +_aarch64_clang_packages: &aarch64_clang_packages + - *required_packages + - [libgcc-7-dev-arm64-cross, libatomic1-arm64-cross, libc6-dev-arm64-cross, pkg-config-aarch64-linux-gnu] + _libabigail_build_packages: &libabigail_build_packages - [autoconf, automake, libtool, pkg-config, libxml2-dev, libdw-dev]
@@ -102,6 +106,20 @@ jobs: apt: packages: - *aarch64_packages + - env: DEF_LIB="static" AARCH64=true + arch: amd64 + compiler: clang + addons: + apt: + packages: + - *aarch64_clang_packages + - env: DEF_LIB="shared" AARCH64=true + arch: amd64 + compiler: clang + addons: + apt: + packages: + - *aarch64_clang_packages # aarch64 gcc jobs - env: DEF_LIB="static" arch: arm64
Signature · 1 line
2.20.1
PATCH v4 3/3 doc: add clang to aarch64 cross build guide
In reply to Juraj LinkešReorganize and update the aarch64 cross guide with clang cross compilation. Update the GNU toolchain version which clang also uses. Reorganize into common part, GNU part and clang part.
--- .../linux_gsg/cross_build_dpdk_for_arm64.rst | 183 +++++++++++++----- 1 file changed, 132 insertions(+), 51 deletions(-)
doc/guides/linux_gsg/cross_build_dpdk_for_arm64.rst +132 -51
@@ -1,101 +1,182 @@ .. SPDX-License-Identifier: BSD-3-Clause - Copyright(c) 2018 ARM Corporation. + Copyright(c) 2020 ARM Corporation. -Cross compile DPDK for ARM64 -============================ +Cross compiling DPDK for ARM64 +============================== This chapter describes how to cross compile DPDK for ARM64 from x86 build hosts. .. note:: Whilst it is recommended to natively build DPDK on ARM64 (just - like with x86), it is also possible to cross-build DPDK for ARM64. An - ARM64 cross compile GNU toolchain is used for this. + like with x86), it is also possible to cross compile DPDK for ARM64. + An ARM64 cross compiler GNU toolchain or an LLVM/clang toolchain + may be used for cross-compilation. -Obtain the cross tool chain ---------------------------- -The latest cross compile tool chain can be downloaded from: + +Prerequisites +------------- + +NUMA library +~~~~~~~~~~~~ + +NUMA is required by most modern machines, not needed for non-NUMA architectures. + +.. note:: + + For compiling the NUMA lib, run libtool --version to ensure the libtool version >= 2.2, + otherwise the compilation will fail with errors. + +.. code-block:: console + + git clone https://github.com/numactl/numactl.git + cd numactl + git checkout v2.0.13 -b v2.0.13 + ./autogen.sh + autoconf -i + ./configure --host=aarch64-linux-gnu CC=<compiler> --prefix=<numa install dir> + make install + +.. note:: + + The compiler above can be either aarch64-linux-gnu-gcc or clang. + See below for information on how to get the compiler of your choice. + +The numa header files and lib file is generated in the include and lib folder respectively under <numa install dir>. + +Meson prerequisites +~~~~~~~~~~~~~~~~~~~ + +Meson depends on pkgconfig to find the dependencies. +The package ``pkg-config-aarch64-linux-gnu`` is required for aarch64. +To install it in Ubuntu:: + + sudo apt install pkg-config-aarch64-linux-gnu + + +GNU toolchain +------------- + +.. _obtain_GNU_toolchain: + +Obtain the cross toolchain +~~~~~~~~~~~~~~~~~~~~~~~~~~ +The latest GNU cross compiler toolchain can be downloaded from: https://developer.arm.com/open-source/gnu-toolchain/gnu-a/downloads. It is always recommended to check and get the latest compiler tool from the page and use -it to generate better code. As of this writing 8.3-2019.03 is the newest, the following +it to generate better code. As of this writing 9.2-2019.12 is the newest, the following description is an example of this version. .. code-block:: console - wget https://developer.arm.com/-/media/Files/downloads/gnu-a/8.3-2019.03/binrel/gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu.tar.xz + 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 Unzip and add into the PATH ---------------------------- +~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. code-block:: console - tar -xvf gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu.tar.xz - export PATH=$PATH:<cross_install_dir>/gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu/bin + tar -xvf gcc-arm-9.2-2019.12-x86_64-aarch64-none-linux-gnu.tar.xz + export PATH=$PATH:<cross_install_dir>/gcc-arm-9.2-2019.12-x86_64-aarch64-none-linux-gnu/bin .. note:: For the host requirements and other info, refer to the release note section: https://releases.linaro.org/components/toolchain/binaries/ -.. _arm_cross_build_getting_the_prerequisite_library: +.. _augment_the_gnu_toolchain_with_numa_support: -Getting the prerequisite library --------------------------------- - -NUMA is required by most modern machines, not needed for non-NUMA architectures. +Augment the GNU toolchain with NUMA support +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. note:: - For compiling the NUMA lib, run libtool --version to ensure the libtool version >= 2.2, - otherwise the compilation will fail with errors. + This way is optional, an alternative is to use extra CFLAGS and LDFLAGS. + +Copy the NUMA header files and lib to the cross compiler's directories: .. code-block:: console - git clone https://github.com/numactl/numactl.git - cd numactl - git checkout v2.0.13 -b v2.0.13 - ./autogen.sh - autoconf -i - ./configure --host=aarch64-linux-gnu CC=aarch64-linux-gnu-gcc --prefix=<numa install dir> - make install + 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/ + 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/ + 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/ -The numa header files and lib file is generated in the include and lib folder respectively under <numa install dir>. +Cross Compiling DPDK with GNU toolchain using Meson +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +To cross-compile DPDK on a desired target machine we can use the following +command:: + + meson cross-build --cross-file <target_machine_configuration> + ninja -C cross-build + +For example if the target machine is aarch64 we can use the following +command:: -.. _augment_the_cross_toolchain_with_numa_support: + meson aarch64-build-gcc --cross-file config/arm/arm64_armv8_linux_gcc + ninja -C aarch64-build-gcc -Augment the cross toolchain with NUMA support ---------------------------------------------- + +LLVM/Clang toolchain +-------------------- + +Obtain the cross tool chain +~~~~~~~~~~~~~~~~~~~~~~~~~~~ +The latest LLVM/Clang cross compiler toolchain can be downloaded from: +https://developer.arm.com/tools-and-software/open-source-software/developer-tools/llvm-toolchain. + +.. code-block:: console + + # Ubuntu binaries + 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 + +The LLVM/Clang toolchain does not implement the standard c library. The GNU toolchain +ships an implementation we can use. Refer to obtain_GNU_toolchain_ to get the +GNU toolchain. + +Unzip and add into the PATH +~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. code-block:: console + + tar -xvf clang+llvm-10.0.0-x86_64-linux-gnu-ubuntu-18.04.tar.xz + export PATH=$PATH:<cross_install_dir>/clang+llvm-10.0.0-x86_64-linux-gnu-ubuntu-18.04/bin + +Cross Compiling DPDK with LLVM/Clang toolchain using Meson +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. note:: - This way is optional, an alternative is to use extra CFLAGS and LDFLAGS. + To use the NUMA library follow the same steps as for + augment_the_gnu_toolchain_with_numa_support_. -Copy the NUMA header files and lib to the cross compiler's directories: +The paths to GNU stdlib must be specified in a cross file. Augmenting the default +cross-file's c_args and c_link_args config/arm/arm64_armv8_linux_clang_ubuntu1804 would look like this: .. code-block:: console - cp <numa_install_dir>/include/numa*.h <cross_install_dir>/gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu/aarch64-linux-gnu/libc/usr/include/ - cp <numa_install_dir>/lib/libnuma.a <cross_install_dir>/gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu/lib/gcc/aarch64-linux-gnu/8.3.0/ - cp <numa_install_dir>/lib/libnuma.so <cross_install_dir>/gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu/lib/gcc/aarch64-linux-gnu/8.3.0/ + ... + 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'] + 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'] -.. _configure_and_cross_compile_dpdk_build: +Assuming the file with augmented c_args and c_link_args is named arm64_armv8_linux_clang, +use the following command to cross-compile DPDK for your target machine:: -Cross Compiling DPDK --------------------- + meson aarch64-build-clang --cross-file config/arm/arm64_armv8_linux_clang + ninja -C aarch64-build-clang -Meson depends on pkgconfig to find the dependencies. -The package ``pkg-config-aarch64-linux-gnu`` is required for aarch64. -To install it in Ubuntu:: +Cross Compiling DPDK with LLVM/Clang toolchain using Meson on Ubuntu 18.04 +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - sudo apt-get install pkg-config-aarch64-linux-gnu +On most popular Linux distribution it's not necessary to download +the toolchains, but rather use the packages provided by said distributions. +On Ubuntu 18.04, you'll need these packages: -To cross-compile DPDK on a desired target machine we can use the following -command:: +.. code-block:: console - meson cross-build --cross-file <target_machine_configuration> - ninja -C cross-build + sudo apt-get install pkg-config-aarch64-linux-gnu clang llvm llvm-dev lld + libc6-dev-arm64-cross libatomic1-arm64-cross libgcc-8-dev-arm64-cross -For example if the target machine is arm64 we can use the following -command:: +Use the following command to cross-compile DPDK for your target machine:: - meson arm64-build --cross-file config/arm/arm64_armv8_linux_gcc - ninja -C arm64-build + meson aarch64-build-clang --cross-file config/arm/arm64_armv8_linux_clang_ubuntu1804 + ninja -C aarch64-build-clang
Signature · 1 line
2.20.1
v5 cover aarch64 clang cross compilation
In reply to Juraj LinkešUse clang/LLVM toolchain with gcc stdlib to cross compile aarch64 target.
v3:
Removed AARCH_GCC and AARCH_CLANG variables in favor of CC_FOR_BUILD.
v4:
Rebased.
Updated commit msg in build: add aarch64 clang to meson cross-compile.
v5:
Rebased.
Reworded commit msg in build: add aarch64 clang to meson cross-compile.
Juraj Linkeš (3):
build: add aarch64 clang to meson cross-compile
ci: add aarch64 clang cross-compilation builds
doc: add clang to aarch64 cross build guide
.ci/linux-build.sh | 6 +- .travis.yml | 18 ++ config/arm/arm64_armv8_linux_clang_ubuntu1804 | 20 ++ .../linux_gsg/cross_build_dpdk_for_arm64.rst | 183 +++++++++++++----- 4 files changed, 175 insertions(+), 52 deletions(-) create mode 100644 config/arm/arm64_armv8_linux_clang_ubuntu1804
Signature · 1 line
2.20.1
PATCH v5 1/3 build: add aarch64 clang to meson cross-compile
Create distribution specific meson cross-file arm64_armv8_linux_clang_ubuntu1804. The file is distribution specific because it contains paths to headers and libs specific to the distribution. The clang/LLVM toolchain does not provide its own c stdlib so the paths must be supplied in some manner.
In the current version of meson, v0.47.1, the only place where the paths can be specified is the cross-file. Other possibilities do not work:
* setting CFLAGS, LDFLAGS only sets these for non-cross builds.
* setting -Dc_args, -Dc_link_args on the command line also only sets these for non-cross builds. Support for specifying these for cross builds was added in v0.51.0 [0].
* the cross-file can't be split into generic clang cross config and distribution specific config. Support added in v0.52.0 [1].
[0] https://mesonbuild.com/Builtin-options.html#specifying-options-per-machine
[1] https://mesonbuild.com/Machine-files.html#loading-multiple-machine-files
--- config/arm/arm64_armv8_linux_clang_ubuntu1804 | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 config/arm/arm64_armv8_linux_clang_ubuntu1804
config/arm/arm64_armv8_linux_clang_ubuntu1804 new file +20 -0
@@ -0,0 +1,20 @@ +[binaries] +c = 'clang' +cpp = 'clang++' +ar = 'llvm-ar' +strip = 'llvm-strip' +llvm-config = 'llvm-config' +pcap-config = 'llvm-config' +pkgconfig = 'aarch64-linux-gnu-pkg-config' + +[host_machine] +system = 'linux' +cpu_family = 'aarch64' +cpu = 'armv8-a' +endian = 'little' + +[properties] +implementor_id = 'generic' +implementor_pn = 'default' +c_args = ['-target', 'aarch64-linux-gnu', '--sysroot', '/usr/aarch64-linux-gnu'] +c_link_args = ['-target', 'aarch64-linux-gnu', '-fuse-ld=lld', '--gcc-toolchain=/usr']
Signature · 1 line
2.20.1
PATCH v5 2/3 ci: add aarch64 clang cross-compilation builds
In reply to Juraj LinkešMirror the existing gcc jobs - build static and shared libs. Use arm64_armv8_linux_clang_ubuntu1804 meson cross file.
--- .ci/linux-build.sh | 6 +++++- .travis.yml | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-)
.ci/linux-build.sh +5 -1
@@ -32,7 +32,11 @@ install_libabigail() { if [ "$AARCH64" = "true" ]; then # convert the arch specifier - OPTS="$OPTS --cross-file config/arm/arm64_armv8_linux_gcc" + if [ "$CC_FOR_BUILD" = "gcc" ]; then + OPTS="$OPTS --cross-file config/arm/arm64_armv8_linux_gcc" + elif [ "$CC_FOR_BUILD" = "clang" ]; then + OPTS="$OPTS --cross-file config/arm/arm64_armv8_linux_clang_ubuntu1804" + fi fi if [ "$BUILD_DOCS" = "true" ]; then
.travis.yml +18 -0
@@ -21,6 +21,10 @@ _aarch64_packages: &aarch64_packages - *required_packages - [gcc-aarch64-linux-gnu, libc6-dev-arm64-cross, pkg-config-aarch64-linux-gnu] +_aarch64_clang_packages: &aarch64_clang_packages + - *required_packages + - [libgcc-7-dev-arm64-cross, libatomic1-arm64-cross, libc6-dev-arm64-cross, pkg-config-aarch64-linux-gnu] + _libabigail_build_packages: &libabigail_build_packages - [autoconf, automake, libtool, pkg-config, libxml2-dev, libdw-dev]
@@ -102,6 +106,20 @@ jobs: apt: packages: - *aarch64_packages + - env: DEF_LIB="static" AARCH64=true + arch: amd64 + compiler: clang + addons: + apt: + packages: + - *aarch64_clang_packages + - env: DEF_LIB="shared" AARCH64=true + arch: amd64 + compiler: clang + addons: + apt: + packages: + - *aarch64_clang_packages # aarch64 gcc jobs - env: DEF_LIB="static" arch: arm64
Signature · 1 line
2.20.1
PATCH v5 3/3 doc: add clang to aarch64 cross build guide
In reply to Juraj LinkešReorganize and update the aarch64 cross guide with clang cross compilation. Update the GNU toolchain version which clang also uses. Reorganize into common part, GNU part and clang part.
--- .../linux_gsg/cross_build_dpdk_for_arm64.rst | 183 +++++++++++++----- 1 file changed, 132 insertions(+), 51 deletions(-)
doc/guides/linux_gsg/cross_build_dpdk_for_arm64.rst +132 -51
@@ -1,104 +1,185 @@ .. SPDX-License-Identifier: BSD-3-Clause - Copyright(c) 2018 ARM Corporation. + Copyright(c) 2020 ARM Corporation. -Cross compile DPDK for ARM64 -============================ +Cross compiling DPDK for ARM64 +============================== This chapter describes how to cross compile DPDK for ARM64 from x86 build hosts. .. note:: Whilst it is recommended to natively build DPDK on ARM64 (just - like with x86), it is also possible to cross-build DPDK for ARM64. An - ARM64 cross compile GNU toolchain is used for this. + like with x86), it is also possible to cross compile DPDK for ARM64. + An ARM64 cross compiler GNU toolchain or an LLVM/clang toolchain + may be used for cross-compilation. -Obtain the cross tool chain ---------------------------- -The latest cross compile tool chain can be downloaded from: + +Prerequisites +------------- + +NUMA library +~~~~~~~~~~~~ + +NUMA is required by most modern machines, not needed for non-NUMA architectures. + +.. note:: + + For compiling the NUMA lib, run libtool --version to ensure the libtool version >= 2.2, + otherwise the compilation will fail with errors. + +.. code-block:: console + + git clone https://github.com/numactl/numactl.git + cd numactl + git checkout v2.0.13 -b v2.0.13 + ./autogen.sh + autoconf -i + ./configure --host=aarch64-linux-gnu CC=<compiler> --prefix=<numa install dir> + make install + +.. note:: + + The compiler above can be either aarch64-linux-gnu-gcc or clang. + See below for information on how to get the compiler of your choice. + +The numa header files and lib file is generated in the include and lib folder respectively under <numa install dir>. + +Meson prerequisites +~~~~~~~~~~~~~~~~~~~ + +Meson depends on pkgconfig to find the dependencies. +The package ``pkg-config-aarch64-linux-gnu`` is required for aarch64. +To install it in Ubuntu:: + + sudo apt install pkg-config-aarch64-linux-gnu + + +GNU toolchain +------------- + +.. _obtain_GNU_toolchain: + +Obtain the cross toolchain +~~~~~~~~~~~~~~~~~~~~~~~~~~ +The latest GNU cross compiler toolchain can be downloaded from: https://developer.arm.com/open-source/gnu-toolchain/gnu-a/downloads. It is always recommended to check and get the latest compiler tool from the page and use -it to generate better code. As of this writing 8.3-2019.03 is the newest, the following +it to generate better code. As of this writing 9.2-2019.12 is the newest, the following description is an example of this version. .. code-block:: console - wget https://developer.arm.com/-/media/Files/downloads/gnu-a/8.3-2019.03/binrel/gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu.tar.xz + 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 Unzip and add into the PATH ---------------------------- +~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. code-block:: console - tar -xvf gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu.tar.xz - export PATH=$PATH:<cross_install_dir>/gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu/bin + tar -xvf gcc-arm-9.2-2019.12-x86_64-aarch64-none-linux-gnu.tar.xz + export PATH=$PATH:<cross_install_dir>/gcc-arm-9.2-2019.12-x86_64-aarch64-none-linux-gnu/bin .. note:: For the host requirements and other info, refer to the release note section: https://releases.linaro.org/components/toolchain/binaries/ -.. _arm_cross_build_getting_the_prerequisite_library: +.. _augment_the_gnu_toolchain_with_numa_support: -Getting the prerequisite library --------------------------------- - -NUMA is required by most modern machines, not needed for non-NUMA architectures. +Augment the GNU toolchain with NUMA support +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. note:: - For compiling the NUMA lib, run libtool --version to ensure the libtool version >= 2.2, - otherwise the compilation will fail with errors. + This way is optional, an alternative is to use extra CFLAGS and LDFLAGS. + +Copy the NUMA header files and lib to the cross compiler's directories: .. code-block:: console - git clone https://github.com/numactl/numactl.git - cd numactl - git checkout v2.0.13 -b v2.0.13 - ./autogen.sh - autoconf -i - ./configure --host=aarch64-linux-gnu CC=aarch64-linux-gnu-gcc --prefix=<numa install dir> - make install + 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/ + 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/ + 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/ -The numa header files and lib file is generated in the include and lib folder respectively under <numa install dir>. +Cross Compiling DPDK with GNU toolchain using Meson +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +To cross-compile DPDK on a desired target machine we can use the following +command:: + + meson cross-build --cross-file <target_machine_configuration> + ninja -C cross-build + +For example if the target machine is aarch64 we can use the following +command:: -.. _augment_the_cross_toolchain_with_numa_support: + meson aarch64-build-gcc --cross-file config/arm/arm64_armv8_linux_gcc + ninja -C aarch64-build-gcc -Augment the cross toolchain with NUMA support ---------------------------------------------- + +LLVM/Clang toolchain +-------------------- + +Obtain the cross tool chain +~~~~~~~~~~~~~~~~~~~~~~~~~~~ +The latest LLVM/Clang cross compiler toolchain can be downloaded from: +https://developer.arm.com/tools-and-software/open-source-software/developer-tools/llvm-toolchain. + +.. code-block:: console + + # Ubuntu binaries + 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 + +The LLVM/Clang toolchain does not implement the standard c library. The GNU toolchain +ships an implementation we can use. Refer to obtain_GNU_toolchain_ to get the +GNU toolchain. + +Unzip and add into the PATH +~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. code-block:: console + + tar -xvf clang+llvm-10.0.0-x86_64-linux-gnu-ubuntu-18.04.tar.xz + export PATH=$PATH:<cross_install_dir>/clang+llvm-10.0.0-x86_64-linux-gnu-ubuntu-18.04/bin + +Cross Compiling DPDK with LLVM/Clang toolchain using Meson +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. note:: - This way is optional, an alternative is to use extra CFLAGS and LDFLAGS. + To use the NUMA library follow the same steps as for + augment_the_gnu_toolchain_with_numa_support_. -Copy the NUMA header files and lib to the cross compiler's directories: +The paths to GNU stdlib must be specified in a cross file. Augmenting the default +cross-file's c_args and c_link_args config/arm/arm64_armv8_linux_clang_ubuntu1804 would look like this: .. code-block:: console - cp <numa_install_dir>/include/numa*.h <cross_install_dir>/gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu/aarch64-linux-gnu/libc/usr/include/ - cp <numa_install_dir>/lib/libnuma.a <cross_install_dir>/gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu/lib/gcc/aarch64-linux-gnu/8.3.0/ - cp <numa_install_dir>/lib/libnuma.so <cross_install_dir>/gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu/lib/gcc/aarch64-linux-gnu/8.3.0/ + ... + 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'] + 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'] -.. _configure_and_cross_compile_dpdk_build: +Assuming the file with augmented c_args and c_link_args is named arm64_armv8_linux_clang, +use the following command to cross-compile DPDK for your target machine:: -Cross Compiling DPDK --------------------- + meson aarch64-build-clang --cross-file config/arm/arm64_armv8_linux_clang + ninja -C aarch64-build-clang -Meson depends on pkgconfig to find the dependencies. -The package ``pkg-config-aarch64-linux-gnu`` is required for aarch64. -To install it in Ubuntu:: +Cross Compiling DPDK with LLVM/Clang toolchain using Meson on Ubuntu 18.04 +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - sudo apt-get install pkg-config-aarch64-linux-gnu +On most popular Linux distribution it's not necessary to download +the toolchains, but rather use the packages provided by said distributions. +On Ubuntu 18.04, you'll need these packages: -To cross-compile DPDK on a desired target machine we can use the following -command:: +.. code-block:: console - meson cross-build --cross-file <target_machine_configuration> - ninja -C cross-build + sudo apt-get install pkg-config-aarch64-linux-gnu clang llvm llvm-dev lld + libc6-dev-arm64-cross libatomic1-arm64-cross libgcc-8-dev-arm64-cross -For example if the target machine is arm64 we can use the following -command:: +Use the following command to cross-compile DPDK for your target machine:: - meson arm64-build --cross-file config/arm/arm64_armv8_linux_gcc - ninja -C arm64-build + meson aarch64-build-clang --cross-file config/arm/arm64_armv8_linux_clang_ubuntu1804 + ninja -C aarch64-build-clang Supported cross-compilation targets -----------------------------------
Signature · 1 line
2.20.1
Re: [dpdk-dev] [PATCH v5 3/3] doc: add clang to aarch64 cross build guide
21/01/2021 16:51, Juraj Linkeš:
Quoted 6 lines
Reorganize and update the aarch64 cross guide with clang cross compilation. Update the GNU toolchain version which clang also uses. Reorganize into common part, GNU part and clang part.
Signed-off-by Juraj Linkeš <[email protected]>Acked-by Ruifeng Wang <[email protected]>
I fix some spacing, quoting and avoid "you" form, while applying.
Quoted 4 lines
Juraj Linkeš (3):
build: add aarch64 clang to meson cross-compile
ci: add aarch64 clang cross-compilation builds
doc: add clang to aarch64 cross build guide
Applied with doc fixups, thanks