From a939ba0c4c3f4924e441ce06d1310274b6ac34db Mon Sep 17 00:00:00 2001 From: Michael Platings Date: Tue, 12 Mar 2024 10:35:40 +0000 Subject: [PATCH] Enable running ci.sh on an x86 machine --- .gitlab-ci.yml | 2 +- docker/Dockerfile | 25 +++++++++++++++++++++++++ scripts/ci.sh | 28 +++++++++++++++++----------- 3 files changed, 43 insertions(+), 12 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e67964ac0..5d86dd6b3 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -2,7 +2,7 @@ # # SPDX-License-Identifier: Apache-2.0 -image: registry.gitlab.arm.com/intrinsiccv/intrinsiccv:4 +image: registry.gitlab.arm.com/intrinsiccv/intrinsiccv:5 # Only run CI for main branch & merge requests workflow: diff --git a/docker/Dockerfile b/docker/Dockerfile index 9227aa203..61ec1571a 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -42,6 +42,31 @@ RUN wget -q https://apt.llvm.org/llvm-snapshot.gpg.key -O /etc/apt/trusted.gpg.d libclang-rt-${LLVM_VERSION}-dev \ llvm-${LLVM_VERSION} +# Install libclang-rt-dev on an x86 host. +# Hacks are needed to make this work: +# 1. Once we add the arm64 architecture then apt update will fail so +# ignore the error. +# 2. libclang-rt-dev declares a dependency on libc & libc++ which isn't +# needed to build, so edit the package to remove all dependencies. +RUN if [ $(dpkg --print-architecture) = amd64 ]; then \ + dpkg --add-architecture arm64 \ + && (apt-get -y update || true) \ + && cd /tmp \ + && apt-get -y download libclang-rt-${LLVM_VERSION}-dev:arm64 \ + && dpkg-deb -x libclang-rt*.deb libclang-rt \ + && dpkg-deb --control libclang-rt*.deb libclang-rt/DEBIAN \ + && sed -i '/Depends:/d' libclang-rt/DEBIAN/control \ + && dpkg -b libclang-rt libclang-rt.deb \ + && apt-get -y install ./libclang-rt.deb \ + && rm -rf libclang-rt* \ + ; fi + +# Hacks required to run tests on an x86 host. +RUN if [ $(dpkg --print-architecture) = amd64 ]; then \ + ln -sf /usr/aarch64-linux-gnu/lib/ld-linux-aarch64.so.1 /lib \ + ; fi +ENV LD_LIBRARY_PATH=/usr/aarch64-linux-gnu/lib + RUN pipx install cpplint==1.6.1 RUN pipx install gcovr==6.0 RUN pipx install reuse==3.0.0 diff --git a/scripts/ci.sh b/scripts/ci.sh index a6785d478..fe873d28d 100755 --- a/scripts/ci.sh +++ b/scripts/ci.sh @@ -31,7 +31,7 @@ doxygen # Build cmake -S . -B build -G Ninja \ -DCMAKE_CXX_CLANG_TIDY=clang-tidy \ - -DCMAKE_CXX_FLAGS="--coverage" \ + -DCMAKE_CXX_FLAGS="--target=aarch64-linux-gnu --coverage" \ -DINTRINSICCV_ENABLE_SVE2=ON \ -DINTRINSICCV_ENABLE_SVE2_SELECTIVELY=OFF \ -DINTRINSICCV_CHECK_BANNED_FUNCTIONS=ON @@ -42,7 +42,7 @@ echo '{"Checks": "-*,cppcoreguidelines-avoid-goto"}'>build/.clang-tidy ninja -C build # Build with GCC -CC=gcc CXX=g++ cmake -S . -B build/gcc -G Ninja +CC=aarch64-linux-gnu-gcc CXX=aarch64-linux-gnu-g++ cmake -S . -B build/gcc -G Ninja ninja -C build/gcc # Run tests @@ -67,14 +67,20 @@ scripts/prefix_testsuite_names.py build/test-results/gcc-neon/intrinsiccv-api-te # Generate test coverage report LLVM_COV=llvm-cov scripts/generate_coverage_report.py -# Clang address & undefined behaviour sanitizers -cmake -S . -B build/sanitize -G Ninja \ - -DINTRINSICCV_ENABLE_SME2=OFF \ - -DCMAKE_CXX_FLAGS="-fsanitize=address,undefined -fno-sanitize-recover=all -Wno-pass-failed" -ninja -C build/sanitize intrinsiccv-api-test -build/sanitize/test/api/intrinsiccv-api-test - -# Check OpenCV-IntrinsicCV integration -scripts/ci-opencv.sh +# Sanitizers don't work when run through qemu so must be run natively. +if [[ $(dpkg --print-architecture) = arm64 ]]; then + # Clang address & undefined behaviour sanitizers + cmake -S . -B build/sanitize -G Ninja \ + -DINTRINSICCV_ENABLE_SME2=OFF \ + -DCMAKE_CXX_FLAGS="-fsanitize=address,undefined -fno-sanitize-recover=all -Wno-pass-failed" + ninja -C build/sanitize intrinsiccv-api-test + build/sanitize/test/api/intrinsiccv-api-test +fi + +# TODO: Cross-build OpenCV +if [[ $(dpkg --print-architecture) = arm64 ]]; then + # Check OpenCV-IntrinsicCV integration + scripts/ci-opencv.sh +fi exit $TESTRESULT -- GitLab