Skip to content
This repository has been archived by the owner on Jun 23, 2022. It is now read-only.

build: add sanitizer support #359

Merged
merged 15 commits into from
Dec 18, 2019
Prev Previous commit
Next Next commit
test tag
  • Loading branch information
foreverneverer committed Dec 17, 2019
commit 060cf97a98ca083953bdb8b114c9560978ca315c
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -29,3 +29,4 @@ thirdparty/src
thirdparty/output

packages/
config-test.ini
13 changes: 7 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -33,12 +33,13 @@ if(ENABLE_GCOV)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lgcov")
endif()

if(${SANITIZER})
if(NOT "${COMPILER_FAMILY}" STREQUAL "gcc" AND "${COMPILER_VERSION}" VERSION_GREATER "4.8")
message(SEND_ERROR "Cannot use sanitizer without gcc >= 4.8")
endif()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O1 -g -fsanitize=${SANITIZER} -fno-omit-frame-pointer")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O1 -g -fsanitize=${SANITIZER} -fno-omit-frame-pointer")
if(DEFINED SANITIZER)
if(NOT ("${COMPILER_FAMILY}" STREQUAL "gcc" AND "${COMPILER_VERSION}" VERSION_GREATER "4.8"))
message(SEND_ERROR "Cannot use sanitizer without gcc >= 4.8")
endif()
message("running cmake with sanitizer=${SANITIZER}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O1 -g -fsanitize=${SANITIZER} -fno-omit-frame-pointer")
foreverneverer marked this conversation as resolved.
Show resolved Hide resolved
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O1 -g -fsanitize=${SANITIZER} -fno-omit-frame-pointer")
endif()


9 changes: 5 additions & 4 deletions run.sh
Original file line number Diff line number Diff line change
@@ -139,11 +139,12 @@ function run_build()
--sanitizer)
if echo "${SANITIZERS[@]}" | grep -w "$2" &>/dev/null; then
SANITIZER="$2"
shift
else
echo "ERROR: unknown sanitizer type \"$2\""
usage_build
exit 1
fi
echo "ERROR: unknown sanitize type \"$2\""
usage_build
exit 1
shift
;;
-m|--test_module)
if [ "$ONLY_BUILD" == "YES" ]; then