Skip to content

Commit

Permalink
Add memory sanitizer CI
Browse files Browse the repository at this point in the history
  • Loading branch information
vrabaud committed Dec 10, 2024
1 parent 37cb0bf commit 6e3ed83
Showing 1 changed file with 36 additions and 6 deletions.
42 changes: 36 additions & 6 deletions .github/workflows/ci-unix-static-sanitized.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
sanitizer: [address, thread, undefined] # TODO(yguyon): Add memory
os: [ubuntu-24.04, macos-latest]
sanitizer: [address, memory, thread, undefined]
exclude:
- os: macos-latest
sanitizer: memory

env:
CC: clang
Expand All @@ -44,7 +47,29 @@ jobs:
- id: cache-hit
run: echo "hit=${{ (runner.os == 'Linux' && steps.setup_linux.outputs.ext-cache-hit == 'true') || (runner.os == 'macOS' && steps.setup_macos.outputs.ext-cache-hit == 'true') }}" >> "$GITHUB_OUTPUT"

- name: Set FLAGS for sanitizers
- name: Build cxx and cxxabi
if: ${{ matrix.sanitizer == 'memory' }}
run: |
# clone LLVM
git clone --depth=1 --branch llvmorg-18.1.8 https://github.com/llvm/llvm-project
# configure cmake
cmake -G Ninja -S llvm-project/runtimes -B llvm-project/msan_out \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi;libunwind" \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++ \
-DLLVM_USE_SANITIZER=MemoryWithOrigins
# build the libraries
cmake --build llvm-project/msan_out -- cxx cxxabi unwind
- name: Set FLAGS for memory sanitizer
if: ${{ matrix.sanitizer == 'memory' }}
run: |
echo "CI_CFLAGS=-fsanitize=memory -L${{ github.workspace }}/llvm-project/msan_out/lib -I${{ github.workspace }}/llvm-project/msan_out/include" >> $GITHUB_ENV
echo "CI_CXXFLAGS=-fsanitize=memory -stdlib=libc++ -L${{ github.workspace }}/llvm-project/msan_out/lib -I${{ github.workspace }}/llvm-project/msan_out/include -I${{ github.workspace }}/llvm-project/msan_out/include/c++/v1" >> $GITHUB_ENV
echo "CI_LDFLAGS=-fsanitize=memory -L${{ github.workspace }}/llvm-project/msan_out/lib -lc++abi" >> $GITHUB_ENV
echo "CI_LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${{ github.workspace }}/llvm-project/msan_out/lib" >> $GITHUB_ENV
- name: Set FLAGS for other sanitizers
if: ${{ matrix.sanitizer != 'memory' }}
run: |
echo "CI_CFLAGS=-fsanitize=${{ matrix.sanitizer }}" >> $GITHUB_ENV
echo "CI_CXXFLAGS=-fsanitize=${{ matrix.sanitizer }}" >> $GITHUB_ENV
Expand All @@ -61,10 +86,15 @@ jobs:
CFLAGS: ${{ env.CI_CFLAGS }}
CXXFLAGS: ${{ env.CI_CXXFLAGS }}
LDFLAGS: ${{ env.CI_LDFLAGS }}
- name: Prepare dav1d
if: ${{ steps.cache-hit.outputs.hit == 'false' }}
- name: Prepare dav1d for msan
if: ${{ (steps.cache-hit.outputs.hit == 'false') && (matrix.sanitizer == 'memory') }}
working-directory: ./ext
run:
run: |
sed -i -e 's/meson setup \(.*\) \.\./meson setup \1 -Db_sanitize=memory -Db_lundef=false -Denable_asm=false ../g' dav1d.cmd
- name: Prepare dav1d for other sanitizers
if: ${{ (steps.cache-hit.outputs.hit == 'false') && (matrix.sanitizer != 'memory') }}
working-directory: ./ext
run: |
sed -i -e 's/meson setup \(.*\) \.\./meson setup \1 -Db_sanitize=${{ matrix.sanitizer }} -Db_lundef=false ../g' dav1d.cmd
- name: Build dav1d
if: ${{ steps.cache-hit.outputs.hit == 'false' }}
Expand Down

0 comments on commit 6e3ed83

Please sign in to comment.