diff --git a/.github/workflows/ci-unix-static-sanitized.yml b/.github/workflows/ci-unix-static-sanitized.yml index e9ffef7d5c..e86c3f85ed 100644 --- a/.github/workflows/ci-unix-static-sanitized.yml +++ b/.github/workflows/ci-unix-static-sanitized.yml @@ -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 @@ -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 @@ -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' }}