implement llvm-cov #2
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and collect test coverage | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
types: [assigned, opened, synchronize, reopened] | |
workflow_dispatch: | |
defaults: | |
run: | |
# This is already the default, except when running inside another Docker | |
# image, which is the case here. So set it up globally to avoid | |
# repeating elsewhere. | |
shell: bash | |
env: | |
# Run apt package manager in the CI in non-interactive mode. | |
# Otherwise, on Ubuntu 20.04 the installation of tzdata asking question | |
DEBIAN_FRONTEND: noninteractive | |
jobs: | |
build-repo: | |
name: Build and Code Coverage | |
# By latest GitHub means actually latest LTS only | |
runs-on: ubuntu-latest | |
strategy: | |
# Run all the test even if there are some which fail | |
fail-fast: false | |
# Run the tests on the Cartesian product of the following | |
matrix: | |
ubuntu_version: [ 22.04 ] | |
steps: | |
# Clone the repo and its submodules. Do shallow clone to save clone | |
# time. | |
- 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 | |
# Install cmake here to get the latest version to compile | |
# LLVM. The Ubuntu 20.04 cmake version is only 3.16.3 | |
run: | | |
pip install cmake numpy psutil pybind11 rich | |
- name: Install Ninja | |
# Can not use the following since it wants to use `sudo` not | |
# available in the case of Docker execution | |
# https://github.com/llvm/actions/tree/main/install-ninja | |
# uses: llvm/actions/install-ninja@6a57890d0e3f9f35dfc72e7e48bc5e1e527cdd6c | |
# So just use the specific implementation instead: | |
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 | |
# Get the LLVM commit hash to be used in the ccache database key to | |
# avoid mixing different binaries compiled by different LLVM versions | |
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: | |
# Since there are now several compilation jobs running in parallel, | |
# use a different key per job to avoid a ccache writing race condition | |
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=../llvm/install/lib/cmake/mlir \ | |
-DLLVM_DIR=../llvm/install/lib/cmake/llvm \ | |
-DLLVM_USE_LINKER=lld \ | |
-DLLVM_EXTERNAL_LIT=`pwd`/../llvm/build/bin/llvm-lit | |
ninja && ninja generate-aie-coverage-report |