A container for cross-compiling the llvm-test-suite arm64.
1.4K
Often when making changes to LLVM's AArch64 backend, inorder to get a LGTM to land changes you must build and run llvm's test suite on device. This guide will show how to build clang, llvm, lld, and the aarch64-linux compiler-rt and libc++ runtimes inorder to do this. This guide will standardize on Ubuntu 20.04 LTS (Update: we are using Swift focal-nightly based on Ubuntu 20.04 as a way to easily bundle swift) for both the cross-building docker environment as well as the device deployment environment (On to the Raspberry Pi 4).
The following step by step guide will show how to cross-build the llvm-test-suite for the Raspberry Pi 4. For step on how to setup the Raspberry Pi 4 itself for on-device runs of the llvm-test-suite, please seem README-RPI4.md.
Now that you've installed Docker pull the image from Docker Hub:
docker pull plotfi/llvm-pi
Alternatively you can build the Docker image yourself:
git clone https://github.com/plotfi/llvm-pi.git
cd llvm-pi
docker build -t plotfi/llvm-pi:latest .
Now that you have your Docker image, run an instance of the image:
mkdir share
docker run --privileged --interactive --tty --name llvm-pi \
--mount type=bind,source=`pwd`/share,target=/mnt/share \
plotfi/llvm-pi:latest /bin/bash
Note that the share directory will be shared between the docker instance (at /mnt/share) and your host machine.
Update the llvm-project checkout and build the toolchain (the Dockerfile setup has already cloned and configured it for you):
cd
git -C ./llvm-project fetch --all
git -C ./llvm-project reset --hard origin/master
ninja -C./llvm-project-build
DESTDIR=`pwd`/toolchain ninja -C./llvm-project-build install
We now have an llvm toolchain capable of building the llvm-test-suite for the AArch64 Linux.
Clone the latest llvm-test-suite, configure it, and build it using the newly built toolchain:
cd
git clone http://github.com/llvm/llvm-test-suite
cmake -B./llvm-test-suite-build -DLLVM_INSTALL_ROOT=`pwd`/toolchain/ \
-DCMAKE_SYSROOT=`pwd`/sysroots/aarch64-linux-gnu \
-DCMAKE_C_FLAGS="-save-temps" \
-C./llvm-pi/llvm-test-suite-rpi4.cmake \
-C./llvm-test-suite/cmake/caches/O3.cmake \
./llvm-test-suite
make -j8 -C./llvm-test-suite-build VERBOSE=1
mypatch.diff. We can post this diff to seashells.io by doing the following:$ cat mypatch.diff | nc seashells.io 1337
serving at https://seashells.io/v/PNHBFVpj
cd
curl https://seashells.io/p/some_hash | patch -d./llvm-project -p1
DESTDIR=`pwd`/toolchain-prime ninja -C./llvm-project-build install
git -C ./llvm-project clean -fdx
git -C ./llvm-project reset --hard origin/master
Now /root/toolchain-prime should be populated with a toolchain that has your changes.
Proceed to rebuild the llvm-test-suite with your new changes to the compiler, linker, and/or runtimes by doing the following (make sure you add any new flags required to the CMAKE_C_FLAGS, these flags are inherited by the CMAKE_CXX_FLAGS as well):
cd
mkdir llvm-test-suite-build-prime
cmake -B./llvm-test-suite-build-prime -DLLVM_INSTALL_ROOT=`pwd`/toolchain-prime/ \
-DCMAKE_SYSROOT=`pwd`/sysroots/aarch64-linux-gnu \
-DCMAKE_C_FLAGS="-save-temps <additional_flags_for_your_changes>" \
-C./llvm-pi/llvm-test-suite-rpi4.cmake \
-C./llvm-test-suite/cmake/caches/O3.cmake \
./llvm-test-suite
make -j16 -C./llvm-test-suite-build-prime VERBOSE=1
rsync -av llvm-test-suite-build /mnt/share
rsync -av llvm-test-suite-build-prime /mnt/share
share directory on your host system. You can analyze them or run them on a Raspberry Pi 4 or other AArch64 Linux device for perf deltas.Content type
Image
Digest
Size
3.1 GB
Last updated
almost 6 years ago
docker pull plotfi/llvm-pi