File tree Expand file tree Collapse file tree 3 files changed +33
-21
lines changed
Expand file tree Collapse file tree 3 files changed +33
-21
lines changed Original file line number Diff line number Diff line change @@ -37,22 +37,12 @@ jobs:
3737 sudo apt install -y help2man libboost-dev libboost-filesystem-dev \
3838 libboost-program-options-dev libboost-python-dev libboost-regex-dev
3939
40- - name : ' [Jammy] Add sanitizers to CXXFLAGS'
41- if : matrix.version >= 22.04
42- run : |
43- # Use ASAN and UBSAN
44- CXXFLAGS="$CXXFLAGS -fsanitize=address,undefined"
45- # Recommended for better error traces
46- CXXFLAGS="$CXXFLAGS -fno-omit-frame-pointer"
47- # Make UBSAN reports fatal
48- CXXFLAGS="$CXXFLAGS -fno-sanitize-recover=all"
49-
50- # Make UBSAN print whole stack traces
51- UBSAN_OPTIONS="print_stacktrace=1"
52-
53- # Store the env variables
54- echo "CXXFLAGS=$CXXFLAGS" >> "$GITHUB_ENV"
55- echo "UBSAN_OPTIONS=$UBSAN_OPTIONS" >> "$GITHUB_ENV"
56-
5740 - name : Build and check
58- run : make distcheck
41+ run : |
42+ if [[ "${{ matrix.version }}" == 22.04 ]]; then
43+ # Make UBSAN print whole stack traces
44+ export UBSAN_OPTIONS="print_stacktrace=1"
45+ make distcheck-sanitizers
46+ else
47+ make distcheck
48+ fi
Original file line number Diff line number Diff line change 1- # Copyright (C) 2011 - 2020 Red Hat, Inc.
1+ # Copyright (C) 2011 - 2022 Red Hat, Inc.
22#
33# This file is part of csdiff.
44#
@@ -20,13 +20,18 @@ NUM_CPU ?= $(shell getconf _NPROCESSORS_ONLN 2>/dev/null || echo 1)
2020CMAKE ?= cmake
2121CTEST ?= ctest -j$(NUM_CPU ) --progress
2222
23+ SANITIZERS ?= OFF
24+
2325CMAKE_BUILD_TYPE ?= RelWithDebInfo
2426
25- .PHONY : all check clean distclean distcheck fast install version.cc src/version.cc
27+ .PHONY : all check clean sanitizers distclean distcheck distcheck-sanitizers \
28+ fast install version.cc src/version.cc
2629
2730all : version.cc
2831 mkdir -p csdiff_build
29- cd csdiff_build && $(CMAKE ) -D ' CMAKE_BUILD_TYPE=$(CMAKE_BUILD_TYPE)' ..
32+ cd csdiff_build && $(CMAKE ) \
33+ -D ' CMAKE_BUILD_TYPE=$(CMAKE_BUILD_TYPE)' \
34+ -D SANITIZERS=' $(SANITIZERS)' ..
3035 $(MAKE ) -sC csdiff_build -j$(NUM_CPU )
3136
3237fast : version.cc
@@ -38,13 +43,19 @@ check: all
3843clean :
3944 if test -e csdiff_build/Makefile; then $( MAKE) clean -C csdiff_build; fi
4045
46+ sanitizers :
47+ $(MAKE ) -s all SANITIZERS=ON
48+
4149distclean :
4250 if test -e .git; then rm -f src/version.cc; fi
4351 rm -rf csdiff_build
4452
4553distcheck : distclean
4654 $(MAKE ) -s check
4755
56+ distcheck-sanitizers :
57+ $(MAKE ) -s distcheck SANITIZERS=ON
58+
4859install : all
4960 $(MAKE ) -C csdiff_build install
5061
Original file line number Diff line number Diff line change @@ -23,6 +23,17 @@ set(CMAKE_CXX_EXTENSIONS OFF)
2323set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -pedantic" )
2424set (CMAKE_POSITION_INDEPENDENT_CODE ON )
2525
26+ # enable sanitizers
27+ option (SANITIZERS "Compile with ASan and UBSan" OFF )
28+ if (SANITIZERS)
29+ # enable ASan and UBSan
30+ set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address,undefined" )
31+ # recommended for better error traces
32+ set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-omit-frame-pointer" )
33+ # make UBSan reports fatal
34+ set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-sanitize-recover=all" )
35+ endif ()
36+
2637# find Boost
2738find_package (Boost REQUIRED
2839 COMPONENTS filesystem
You can’t perform that action at this time.
0 commit comments