From 5c262993798ddde6e15468041989e4a9d7b6cfaa Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Mon, 18 Mar 2024 02:18:17 +0100 Subject: [PATCH] ci: Test shared library with sanitizers Since we run our tests through Python, this requires - to link with -shared-libasan - to LD_PRELOAD the ASan runtime - to disable LeakSanitizer beacuse of false positives from Python --- .github/workflows/ci.yml | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fb072048d..77ff8e272 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -67,21 +67,30 @@ jobs: runs-on: ubuntu-latest strategy: fail-fast: false + matrix: + include: + - cmake_opts: '-DBUILD_SHARED_LIBS=NO' + - cmake_opts: '-DBUILD_SHARED_LIBS=YES' + cflags: '-shared-libasan' + test_env: 'LD_PRELOAD=$(clang -print-file-name=libclang_rt.asan-x86_64.so)' + asan_options: 'detect_leaks=0' env: + CMAKE_OPTIONS: ${{ matrix.cmake_opts }} CC: 'clang' CXX: 'clang++' - CFLAGS: '-fsanitize=address,undefined -fno-sanitize-recover=all' - CXXFLAGS: '-fsanitize=address,undefined -fno-sanitize-recover=all' + CFLAGS: '-fsanitize=address,undefined -fno-sanitize-recover=all ${{ matrix.cflags }}' + CXXFLAGS: '-fsanitize=address,undefined -fno-sanitize-recover=all ${{ matrix.cflags }}' + ASAN_OPTIONS: ${{ matrix.asan_options }} steps: - uses: actions/checkout@v4 - name: Build and test run: | - cmake -DBUILD_SHARED_LIBS=NO -DCMAKE_BUILD_TYPE=Debug -S . -B build + cmake $CMAKE_OPTIONS -DCMAKE_BUILD_TYPE=Debug -S . -B build cmake --build build # https://github.com/actions/runner-images/issues/9491 sudo sysctl vm.mmap_rnd_bits=28 - ctest --test-dir build --output-on-failure + env ${{ matrix.test_env }} ctest --test-dir build --output-on-failure macos: