Skip to content

Commit

Permalink
reenable msan sanitizer workflow (#1589)
Browse files Browse the repository at this point in the history
  • Loading branch information
dmah42 authored May 3, 2023
1 parent b177433 commit fba5dd1
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 40 deletions.
43 changes: 21 additions & 22 deletions .github/libcxx-setup.sh
Original file line number Diff line number Diff line change
@@ -1,27 +1,26 @@
#!/usr/bin/env bash

set -e

# Checkout LLVM sources
#git clone --depth=1 https://github.com/llvm/llvm-project.git llvm-project
#
git clone --depth=1 https://github.com/llvm/llvm-project.git llvm-project

## Setup libc++ options
#if [ -z "$BUILD_32_BITS" ]; then
# export BUILD_32_BITS=OFF && echo disabling 32 bit build
#fi
#
## Build and install libc++ (Use unstable ABI for better sanitizer coverage)
#cd ./llvm-project
#cmake -DCMAKE_C_COMPILER=${CC} \
# -DCMAKE_CXX_COMPILER=${CXX} \
# -DCMAKE_BUILD_TYPE=RelWithDebInfo \
# -DCMAKE_INSTALL_PREFIX=/usr \
# -DLIBCXX_ABI_UNSTABLE=OFF \
# -DLLVM_USE_SANITIZER=${LIBCXX_SANITIZER} \
# -DLLVM_BUILD_32_BITS=${BUILD_32_BITS} \
# -DLLVM_ENABLE_RUNTIMES='libcxx;libcxxabi' \
# -S llvm -B llvm-build -G "Unix Makefiles"
#make -C llvm-build -j3 cxx cxxabi
#sudo make -C llvm-build install-cxx install-cxxabi
#cd ..
if [ -z "$BUILD_32_BITS" ]; then
export BUILD_32_BITS=OFF && echo disabling 32 bit build
fi

sudo apt update
sudo apt -y install libc++-dev libc++abi-dev
## Build and install libc++ (Use unstable ABI for better sanitizer coverage)
mkdir llvm-build && cd llvm-build
cmake -DCMAKE_C_COMPILER=${CC} \
-DCMAKE_CXX_COMPILER=${CXX} \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DCMAKE_INSTALL_PREFIX=/usr \
-DLIBCXX_ABI_UNSTABLE=OFF \
-DLLVM_USE_SANITIZER=${LIBCXX_SANITIZER} \
-DLLVM_BUILD_32_BITS=${BUILD_32_BITS} \
-DLLVM_ENABLE_RUNTIMES='libcxx;libcxxabi;libunwind' \
-G "Unix Makefiles" \
../llvm-project/runtimes/
make -j cxx cxxabi unwind
cd ..
26 changes: 8 additions & 18 deletions .github/workflows/sanitizer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,14 @@ env:

jobs:
job:
name: ${{ matrix.sanitizer }}.${{ matrix.build_type }}.${{ matrix.compiler }}
name: ${{ matrix.sanitizer }}.${{ matrix.build_type }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
build_type: ['Debug', 'RelWithDebInfo']
sanitizer: ['asan', 'ubsan', 'tsan']
compiler: ['clang', 'gcc']
# TODO: add 'msan' above. currently failing and needs investigation.
sanitizer: ['asan', 'ubsan', 'tsan', 'msan']

steps:
- uses: actions/checkout@v3

Expand Down Expand Up @@ -46,36 +45,27 @@ jobs:
echo "LIBCXX_SANITIZER=Thread" >> $GITHUB_ENV
- name: fine-tune asan options
# in clang+asan we get an error from std::regex. ignore it.
if: matrix.sanitizer == 'asan' && matrix.compiler == 'clang'
# in asan we get an error from std::regex. ignore it.
if: matrix.sanitizer == 'asan'
run: |
echo "ASAN_OPTIONS=alloc_dealloc_mismatch=0" >> $GITHUB_ENV
- name: setup clang
if: matrix.compiler == 'clang'
uses: egor-tensin/setup-clang@v1
with:
version: latest
platform: x64

- name: configure clang
if: matrix.compiler == 'clang'
run: |
echo "CC=cc" >> $GITHUB_ENV
echo "CXX=c++" >> $GITHUB_ENV
- name: configure gcc
if: matrix.compiler == 'gcc'
run: |
sudo apt update && sudo apt -y install gcc-10 g++-10
echo "CC=gcc-10" >> $GITHUB_ENV
echo "CXX=g++-10" >> $GITHUB_ENV
- name: install llvm stuff
if: matrix.compiler == 'clang'
- name: build libc++ (non-asan)
if: matrix.sanitizer != 'asan'
run: |
"${GITHUB_WORKSPACE}/.github/libcxx-setup.sh"
echo "EXTRA_CXX_FLAGS=\"-stdlib=libc++\"" >> $GITHUB_ENV
echo "EXTRA_CXX_FLAGS=-stdlib=libc++ -L ${GITHUB_WORKSPACE}/llvm-build/lib -lc++abi -Isystem${GITHUB_WORKSPACE}/llvm-build/include -Isystem${GITHUB_WORKSPACE}/llvm-build/include/c++/v1 -Wl,-rpath,${GITHUB_WORKSPACE}/llvm-build/lib" >> $GITHUB_ENV
- name: create build environment
run: cmake -E make_directory ${{ runner.workspace }}/_build
Expand Down

0 comments on commit fba5dd1

Please sign in to comment.