Skip to content

Commit bdd6c44

Browse files
authored
Enable various sanitizer builds in github actions (google#1167)
* Enable various sanitizer builds in github actions * try with off the shelf versions * nope * specific version? * rats * oops * remove msan for now * reorder so env is set before building libc++
1 parent fbc3140 commit bdd6c44

File tree

3 files changed

+85
-2
lines changed

3 files changed

+85
-2
lines changed

.github/workflows/sanitizer.yml

+83
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: sanitizer
2+
3+
on:
4+
push: {}
5+
pull_request: {}
6+
7+
env:
8+
CC: clang-3.8
9+
CXX: clang++-3.8
10+
EXTRA_CXX_FLAGS: "-stdlib=libc++"
11+
UBSAN_OPTIONS: "print_stacktrace=1"
12+
13+
jobs:
14+
job:
15+
name: ${{ matrix.sanitizer }}.${{ matrix.build_type }}
16+
runs-on: ubuntu-16.04
17+
strategy:
18+
fail-fast: false
19+
matrix:
20+
build_type: ['Debug', 'RelWithDebInfo']
21+
sanitizer: ['asan', 'ubsan', 'tsan']
22+
# TODO: add 'msan' above. currently failing and needs investigation.
23+
steps:
24+
- uses: actions/checkout@v2
25+
26+
- name: configure msan env
27+
if: matrix.sanitizer == 'msan'
28+
run: |
29+
echo "EXTRA_FLAGS=-g -O2 -fno-omit-frame-pointer -fsanitize=memory -fsanitize-memory-track-origins" >> $GITHUB_ENV
30+
echo "LIBCXX_SANITIZER=MemoryWithOrigins" >> $GITHUB_ENV
31+
32+
- name: configure ubsan env
33+
if: matrix.sanitizer == 'ubsan'
34+
run: |
35+
echo "EXTRA_FLAGS=-g -O2 -fno-omit-frame-pointer -fsanitize=undefined -fno-sanitize-recover=all" >> $GITHUB_ENV
36+
echo "LIBCXX_SANITIZER=Undefined" >> $GITHUB_ENV
37+
38+
- name: configure asan env
39+
if: matrix.sanitizer == 'asan'
40+
run: |
41+
echo "EXTRA_FLAGS=-g -O2 -fno-omit-frame-pointer -fsanitize=address -fno-sanitize-recover=all" >> $GITHUB_ENV
42+
echo "LIBCXX_SANITIZER=Address" >> $GITHUB_ENV
43+
44+
- name: configure tsan env
45+
if: matrix.sanitizer == 'tsan'
46+
run: |
47+
echo "EXTRA_FLAGS=-g -O2 -fno-omit-frame-pointer -fsanitize=thread -fno-sanitize-recover=all" >> $GITHUB_ENV
48+
echo "LIBCXX_SANITIZER=Thread" >> $GITHUB_ENV
49+
50+
- name: install clang-3.8
51+
run: |
52+
sudo apt update
53+
sudo apt -y install clang-3.8
54+
55+
- name: install libc++
56+
run: "${GITHUB_WORKSPACE}/.libcxx-setup.sh"
57+
58+
- name: create build environment
59+
run: cmake -E make_directory ${{ runner.workspace }}/_build
60+
61+
- name: configure cmake
62+
shell: bash
63+
working-directory: ${{ runner.workspace }}/_build
64+
run: >
65+
cmake $GITHUB_WORKSPACE
66+
-DBENCHMARK_ENABLE_ASSEMBLY_TESTS=OFF
67+
-DBENCHMARK_ENABLE_LIBPFM=OFF
68+
-DBENCHMARK_DOWNLOAD_DEPENDENCIES=ON
69+
-DCMAKE_C_COMPILER=${{ env.CC }}
70+
-DCMAKE_CXX_COMPILER=${{ env.CXX }}
71+
-DCMAKE_C_FLAGS="${{ env.EXTRA_FLAGS }}"
72+
-DCMAKE_CXX_FLAGS="${{ env.EXTRA_FLAGS }} ${{ env.EXTRA_CXX_FLAGS }}"
73+
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
74+
75+
- name: build
76+
shell: bash
77+
working-directory: ${{ runner.workspace }}/_build
78+
run: cmake --build . --config ${{ matrix.build_type }}
79+
80+
- name: test
81+
shell: bash
82+
working-directory: ${{ runner.workspace }}/_build
83+
run: ctest -C ${{ matrix.build_type }} -VV

.travis-libcxx-setup.sh .libcxx-setup.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ fi
1919
mkdir llvm-build && cd llvm-build
2020
cmake -DCMAKE_C_COMPILER=${C_COMPILER} -DCMAKE_CXX_COMPILER=${COMPILER} \
2121
-DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX=/usr \
22-
-DLIBCXX_ABI_UNSTABLE=ON \
22+
-DLIBCXX_ABI_UNSTABLE=OFF \
2323
-DLLVM_USE_SANITIZER=${LIBCXX_SANITIZER} \
2424
-DLLVM_BUILD_32_BITS=${BUILD_32_BITS} \
2525
../llvm-source

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ matrix:
149149

150150
before_script:
151151
- if [ -n "${LIBCXX_BUILD}" ]; then
152-
source .travis-libcxx-setup.sh;
152+
source .libcxx-setup.sh;
153153
fi
154154
- if [ -n "${ENABLE_SANITIZER}" ]; then
155155
export EXTRA_OPTIONS="-DBENCHMARK_ENABLE_ASSEMBLY_TESTS=OFF";

0 commit comments

Comments
 (0)