Skip to content

[libshortfin] Build debug/asan #2

[libshortfin] Build debug/asan

[libshortfin] Build debug/asan #2

# Copyright 2024 Advanced Micro Devices, Inc
#
# Licensed under the Apache License v2.0 with LLVM Exceptions.
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
name: CI - libshortfin - ASan
on:
workflow_dispatch:
pull_request:
push:
paths:
- '.github/workflows/ci_linux_x64_asan-libshortfin.yml'
- 'libshortfin/**'
permissions:
contents: read
env:
PYENV_DIR: ${{ github.workspace }}/pyenv
PYENV_REF: 9ecd803bffaffb949fbdd8c70cb086227f6a3202 # v2.4.10
PYTHON_VER: 3.12.3
CACHE_VER: 1
IREE_SOURCE_DIR: ${{ github.workspace }}/iree
LIBSHORTFIN_DIR: ${{ github.workspace }}/libshortfin/
jobs:
setup-python-asan:
name: Setup Python ASan
runs-on: ubuntu-24.04
steps:
- name: Cache Python ASan
id: cache-python-asan
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
with:
path: ${{ env.PYENV_DIR }}
key: ${{ runner.os }}-python-asan-${{ env.PYENV_REF }}-${{ env.PYTHON_VER }}-${{ env.CACHE_VER }}
lookup-only: 'true'
- name: Install dependencies
if: steps.cache-python-asan.outputs.cache-hit != 'true'
run: |
sudo apt update
sudo apt install clang lld cmake ninja-build
sudo apt install build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev curl git libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev
- name: Checkout pyenv
if: steps.cache-python-asan.outputs.cache-hit != 'true'
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
repository: pyenv/pyenv
ref: ${{ env.PYENV_REF }}
path: ${{ env.PYENV_DIR }}
- name: Install pyenv & Python
if: steps.cache-python-asan.outputs.cache-hit != 'true'
run: |
cd ${{ env.PYENV_DIR }}
src/configure && make -C src
export PYENV_ROOT=${{ env.PYENV_DIR }}
export PATH=${{ env.PYENV_DIR }}/bin:$PATH && eval "$(pyenv init -)"
CC=clang-18 CXX=clang++-18 LDFLAGS="-lstdc++" PYTHON_CONFIGURE_OPTS="--with-address-sanitizer" pyenv install -v -g ${{ env.PYTHON_VER }}
build-and-test:
name: Build and test libshortfin
needs: [setup-python-asan]
runs-on: ubuntu-24.04
steps:
- name: Install dependencies
run: |
sudo apt update
sudo apt install clang lld cmake ninja-build
- name: Checkout repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
submodules: false
- name: Checkout IREE repo
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
repository: iree-org/iree
path: ${{ env.IREE_SOURCE_DIR }}
submodules: false
- name: Initalize IREE submodules
run : |
cd ${{ env.IREE_SOURCE_DIR }}
git submodule update --init --depth 1 -- third_party/benchmark
git submodule update --init --depth 1 -- third_party/cpuinfo/
git submodule update --init --depth 1 -- third_party/flatcc
git submodule update --init --depth 1 -- third_party/googletest
git submodule update --init --depth 1 -- third_party/hip-build-deps/
- name: Setup python
id: cache-python-asan
uses: actions/cache/restore@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
with:
path: ${{ env.PYENV_DIR }}
key: ${{ runner.os }}-python-asan-${{ env.PYENV_REF }}-${{ env.PYTHON_VER }}-${{ env.CACHE_VER }}
- name: Install Python packages
# TODO: Switch to `pip install -r requirements.txt -e libshortfin/`.
run: |
export PYENV_ROOT=${{ env.PYENV_DIR }}
export PATH=${{ env.PYENV_DIR }}/bin:$PATH && eval "$(pyenv init -)"
pyenv versions
pyenv global ${{ env.PYTHON_VER }}-debug
pyenv local ${{ env.PYTHON_VER }}-debug
pyenv shell ${{ env.PYTHON_VER }}-debug
pip install nanobind
pip install -r ${{ env.LIBSHORTFIN_DIR }}/requirements-tests.txt
- name: Build libshortfin
run: |
export PYENV_ROOT=${{ env.PYENV_DIR }}
export PATH=${{ env.PYENV_DIR }}/bin:$PATH && eval "$(pyenv init -)"
pyenv global ${{ env.PYTHON_VER }}-debug
pyenv local ${{ env.PYTHON_VER }}-debug
pyenv shell ${{ env.PYTHON_VER }}-debug
mkdir ${{ env.LIBSHORTFIN_DIR }}/build
cd ${{ env.LIBSHORTFIN_DIR }}/build
cmake -GNinja \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_C_COMPILER=clang-18 \
-DCMAKE_CXX_COMPILER=clang++-18 \
-DCMAKE_LINKER_TYPE=LLD \
-DSHORTFIN_BUNDLE_DEPS=ON \
-DSHORTFIN_IREE_SOURCE_DIR=${{ env.IREE_SOURCE_DIR }} \
-DSHORTFIN_BUILD_PYTHON_BINDINGS=ON \
-DSHORTFIN_ENABLE_ASAN=ON \
..
cmake --build . --target all
pip install -v -e .
- name: Test libshortfin
run: |
export PYENV_ROOT=${{ env.PYENV_DIR }}
export PATH=${{ env.PYENV_DIR }}/bin:$PATH && eval "$(pyenv init -)"
pyenv global ${{ env.PYTHON_VER }}-debug
pyenv local ${{ env.PYTHON_VER }}-debug
pyenv shell ${{ env.PYTHON_VER }}-debug
cd ${{ env.LIBSHORTFIN_DIR }}/build
cmake --build . --target test
cd ${{ env.LIBSHORTFIN_DIR }}
pytest -m "not requires_amd_gpu"