Skip to content

implement llvm-cov

implement llvm-cov #9

name: Build and collect test coverage
on:
push:
branches:
- main
pull_request:
types: [assigned, opened, synchronize, reopened]
workflow_dispatch:
defaults:
run:
shell: bash
env:
DEBIAN_FRONTEND: noninteractive
jobs:
build-repo:
name: Build and Code Coverage
runs-on: ubuntu-latest
steps:
- name: Get the project repository
uses: actions/checkout@v3
with:
fetch-depth: 2
submodules: "true"
- uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install Python and other packages
run: |
pip install cmake numpy psutil pybind11 rich
- name: Install Ninja
run: sudo apt-get install -y ninja-build
- name: Install llvm-cov
run: sudo apt-get install -y clang lld llvm
- name: Get LLVM
id: clone-llvm
run: utils/clone-llvm.sh
- name: Get LLVM commit hash
id: get-llvm-commit-hash
run: echo "hash=$(cd llvm ; git log -1 --format='%H')" >> $GITHUB_OUTPUT
- name: Ccache for C++ compilation
# https://github.com/hendrikmuhs/ccache-action/releases/tag/v1.2.9
uses: hendrikmuhs/ccache-action@ca3acd2731eef11f1572ccb126356c2f9298d35e
with:
key: ${{ runner.os }}-${{ matrix.ubuntu_version }}-${{ steps.get-llvm-commit-hash.outputs.hash }}
max-size: 1G
- name: Build and install LLVM
run: LLVM_ENABLE_RTTI=ON utils/build-llvm.sh
- name: Install our python reqs
run: pip install -r python/requirements.txt
- name: Build and generate coverage (Release)
run: |
mkdir build_release
cd build_release
cmake .. \
-GNinja \
-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ \
-DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DCMAKE_EXE_LINKER_FLAGS_INIT="-fuse-ld=lld" -DCMAKE_MODULE_LINKER_FLAGS_INIT="-fuse-ld=lld" -DCMAKE_SHARED_LINKER_FLAGS_INIT="-fuse-ld=lld" \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_PLATFORM_NO_VERSIONED_SONAME=ON \
-DCMAKE_VISIBILITY_INLINES_HIDDEN=ON \
-DCMAKE_C_VISIBILITY_PRESET=hidden \
-DCMAKE_CXX_VISIBILITY_PRESET=hidden \
-DAIE_COMPILER=NONE \
-DAIE_LINKER=NONE \
-DHOST_COMPILER=NONE \
-DBUILD_INSTRUMENTED_COVERAGE=ON \
-DLLVM_ENABLE_ASSERTIONS=OFF \
-DLLVM_ENABLE_RTTI=ON \
-DCMAKE_MODULE_PATH=`pwd`/../cmake/modulesXilinx \
-DMLIR_DIR=/home/runner/work/mlir-aie/mlir-aie/llvm/install/lib/cmake/mlir \
-DLLVM_DIR=/home/runner/work/mlir-aie/mlir-aie/llvm/install/lib/cmake/llvm \
-DLLVM_USE_LINKER=lld \
-DLLVM_EXTERNAL_LIT=`pwd`/../llvm/build/bin/llvm-lit
ninja && ninja generate-aie-coverage-report
cat report/summary.txt