Skip to content

Commit

Permalink
chore: enable ubsan and asan in debug build script
Browse files Browse the repository at this point in the history
  • Loading branch information
sadderchris committed Feb 11, 2022
1 parent a33386e commit b782e77
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 9 deletions.
20 changes: 15 additions & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,18 @@ jobs:
matrix:
container-image: ['amazonlinux:1', 'amazonlinux:2']
compiler:
- { cc: 'gcc', cxx: 'g++'}
- { cc: 'clang', cxx: 'clang++' }
- { cc: 'gcc', cxx: 'g++', debug_cflags: '', debug_cxxflags: '', debug_ldflags: '' }
- { cc: 'clang', cxx: 'clang++', debug_cflags: '', debug_cxxflags: '', debug_ldflags: '' }
runs-on: ubuntu-latest
container: ${{ format('docker://{0}', matrix.container-image) }}
env:
CC: ${{ matrix.compiler.cc }}
CXX: ${{ matrix.compiler.cxx }}
DEBUG_CFLAGS: ${{ matrix.compiler.debug_cflags }}
DEBUG_CXXFLAGS: ${{ matrix.compiler.debug_cxxflags }}
DEBUG_LDFLAGS: ${{ matrix.compiler.debug_ldflags }}
UBSAN_OPTIONS: "print_stacktrace=1"
ASAN_OPTIONS: "halt_on_error=0"
steps:
- name: Install `which`
run: yum install which -y
Expand Down Expand Up @@ -63,19 +68,24 @@ jobs:
matrix:
os: ['macos-latest', 'ubuntu-latest']
compiler:
- { cc: 'gcc', cxx: 'g++'}
- { cc: 'clang', cxx: 'clang++' }
- { cc: 'gcc', cxx: 'g++', debug_cflags: '-fsanitize=address,undefined -fsanitize-recover=address -fno-omit-frame-pointer -fno-optimize-sibling-calls', debug_cxxflags: '-fsanitize=address,undefined -fsanitize-recover=address -fno-omit-frame-pointer -fno-optimize-sibling-calls', debug_ldflags: '-fsanitize=address,undefined' }
- { cc: 'clang', cxx: 'clang++', debug_cflags: '-fsanitize=address,undefined -fsanitize-recover=address -fno-omit-frame-pointer -fno-optimize-sibling-calls', debug_cxxflags: '-fsanitize=address,undefined -fsanitize-recover=address -fno-omit-frame-pointer -fno-optimize-sibling-calls', debug_ldflags: '' }
# gcc just redirects to clang on the macos vm; replace with a specific gcc alias
exclude:
- os: 'macos-latest'
compiler: { cc: 'gcc', cxx: 'g++'}
include:
- os: 'macos-latest'
compiler: { cc: 'gcc-11', cxx: 'g++-11'}
compiler: { cc: 'gcc-11', cxx: 'g++-11', debug_cflags: '-fsanitize=address,undefined -fsanitize-recover=address -fno-omit-frame-pointer -fno-optimize-sibling-calls', debug_cxxflags: '-fsanitize=address,undefined -fsanitize-recover=address -fno-omit-frame-pointer -fno-optimize-sibling-calls', debug_ldflags: '-fsanitize=address,undefined' }
runs-on: ${{ matrix.os }}
env:
CC: ${{ matrix.compiler.cc }}
CXX: ${{ matrix.compiler.cxx }}
DEBUG_CFLAGS: ${{ matrix.compiler.debug_cflags }}
DEBUG_CXXFLAGS: ${{ matrix.compiler.debug_cxxflags }}
DEBUG_LDFLAGS: ${{ matrix.compiler.debug_ldflags }}
UBSAN_OPTIONS: "print_stacktrace=1"
ASAN_OPTIONS: "halt_on_error=0"
steps:
- name: Checkout Code
uses: actions/checkout@v2
Expand Down
19 changes: 15 additions & 4 deletions build-debug.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
#!/bin/sh --

mkdir -p build/debug
cd build/debug
cmake -DCMAKE_BUILD_TYPE=Debug ../..
make clean && make
set -x

DEFAULT_CFLAGS="-fsanitize=address,undefined -fsanitize-recover=address -fno-omit-frame-pointer -fno-optimize-sibling-calls"
DEFAULT_CXXFLAGS="${DEFAULT_CFLAGS}"
DEFAULT_LDFLAGS="-fsanitize=address,undefined"

export LD="$CXX"

mkdir -p build/debug && cd build/debug
cmake \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_C_FLAGS_DEBUG="${DEBUG_CFLAGS-${DEFAULT_CFLAGS}}" \
-DCMAKE_CXX_FLAGS_DEBUG="${DEBUG_CXXFLAGS-${DEFAULT_CXXFLAGS}}" \
../..
make clean && make LDFLAGS="${DEBUG_LDFLAGS-${DEFAULT_LDFLAGS}}" -j"$(nproc || sysctl -n hw.ncpu)"

0 comments on commit b782e77

Please sign in to comment.