Commit 49d663f6 authored by Daniel Chabrowski's avatar Daniel Chabrowski

Move tsan/asan flag management to cmake

Add sudo: required to fix asan builds
parent 7e32ccbd
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
# - Louis Dionne's Hana: https://github.com/ldionne/hana # - Louis Dionne's Hana: https://github.com/ldionne/hana
# - Paul Fultz II's FIT: https://github.com/pfultz2/Fit # - Paul Fultz II's FIT: https://github.com/pfultz2/Fit
# - Eric Niebler's range-v3: https://github.com/ericniebler/range-v3 # - Eric Niebler's range-v3: https://github.com/ericniebler/range-v3
sudo: required
language: cpp language: cpp
addons: &gcc48 addons: &gcc48
...@@ -96,14 +97,20 @@ before_install: ...@@ -96,14 +97,20 @@ before_install:
- valgrind --version - valgrind --version
install: install:
- if [ "$ASAN" == "On" ]; then export CXX_FLAGS="${CXX_FLAGS} -fsanitize=address,undefined -fno-omit-frame-pointer -fno-sanitize=signed-integer-overflow -fuse-ld=gold"; fi
- if [ "$TSAN" == "On" ]; then export CXX_FLAGS="${CXX_FLAGS} -fsanitize=thread -fno-omit-frame-pointer -fuse-ld=gold"; fi
- cd ${TRAVIS_BUILD_DIR} - cd ${TRAVIS_BUILD_DIR}
- mkdir -p build && cd build - mkdir -p build && cd build
- cmake .. -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_CXX_STANDARD=$CPP -DCMAKE_CXX_FLAGS="${CXX_FLAGS}" -DSPDLOG_BUILD_EXAMPLES=ON --warn-uninitialized - |
cmake .. \
--warn-uninitialized \
-DCMAKE_BUILD_TYPE=$BUILD_TYPE \
-DCMAKE_CXX_STANDARD=$CPP \
-DSPDLOG_BUILD_EXAMPLES=ON \
-DSPDLOG_SANITIZE_THREAD=$TSAN \
-DSPDLOG_SANITIZE_ADDRESS=$ASAN
- VERBOSE=1 make -j2 - VERBOSE=1 make -j2
script: script:
- export TSAN_OPTIONS=verbosity=1
- if [ "$ASAN" != "On" ] && [ "$TSAN" != "On" ]; then CTEST_FLAGS="-DExperimentalMemCheck"; fi - if [ "$ASAN" != "On" ] && [ "$TSAN" != "On" ]; then CTEST_FLAGS="-DExperimentalMemCheck"; fi
- ctest -j2 -VV $CTEST_FLAGS - ctest -j2 -VV $CTEST_FLAGS
......
...@@ -20,6 +20,8 @@ if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" MATCH ...@@ -20,6 +20,8 @@ if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" MATCH
set(CMAKE_CXX_FLAGS "-Wall -O3 ${CMAKE_CXX_FLAGS}") set(CMAKE_CXX_FLAGS "-Wall -O3 ${CMAKE_CXX_FLAGS}")
endif() endif()
include(cmake/sanitizers.cmake)
#--------------------------------------------------------------------------------------- #---------------------------------------------------------------------------------------
# spdlog target # spdlog target
#--------------------------------------------------------------------------------------- #---------------------------------------------------------------------------------------
......
if(SPDLOG_SANITIZE_THREAD AND SPDLOG_SANITIZE_ADDRESS)
message(FATAL_ERROR "AddressSanitizer is not compatible with ThreadSanitizer.")
endif()
if(SPDLOG_SANITIZE_ADDRESS)
message(STATUS "AddressSanitizer enabled")
set(SANITIZER_FLAGS "-fsanitize=address,undefined")
add_compile_options("-fno-sanitize=signed-integer-overflow")
endif()
if(SPDLOG_SANITIZE_THREAD)
message(STATUS "ThreadSanitizer enabled")
set(SANITIZER_FLAGS "-fsanitize=thread")
endif()
if(SPDLOG_SANITIZE_THREAD OR SPDLOG_SANITIZE_ADDRESS)
add_compile_options(${SANITIZER_FLAGS})
add_compile_options("-fno-sanitize-recover=all")
add_compile_options("-fno-omit-frame-pointer")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${SANITIZER_FLAGS} -fuse-ld=gold")
endif()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment