mirror of
https://github.com/gabime/spdlog.git
synced 2024-12-25 01:51:38 +08:00
Move tsan/asan flag management to cmake
Add sudo: required to fix asan builds
This commit is contained in:
parent
7e32ccbd8f
commit
49d663f6c8
13
.travis.yml
13
.travis.yml
@ -2,6 +2,7 @@
|
||||
# - Louis Dionne's Hana: https://github.com/ldionne/hana
|
||||
# - Paul Fultz II's FIT: https://github.com/pfultz2/Fit
|
||||
# - Eric Niebler's range-v3: https://github.com/ericniebler/range-v3
|
||||
sudo: required
|
||||
language: cpp
|
||||
|
||||
addons: &gcc48
|
||||
@ -96,14 +97,20 @@ before_install:
|
||||
- valgrind --version
|
||||
|
||||
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}
|
||||
- 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
|
||||
|
||||
script:
|
||||
- export TSAN_OPTIONS=verbosity=1
|
||||
- if [ "$ASAN" != "On" ] && [ "$TSAN" != "On" ]; then CTEST_FLAGS="-DExperimentalMemCheck"; fi
|
||||
- ctest -j2 -VV $CTEST_FLAGS
|
||||
|
||||
|
@ -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}")
|
||||
endif()
|
||||
|
||||
include(cmake/sanitizers.cmake)
|
||||
|
||||
#---------------------------------------------------------------------------------------
|
||||
# spdlog target
|
||||
#---------------------------------------------------------------------------------------
|
||||
|
21
cmake/sanitizers.cmake
Normal file
21
cmake/sanitizers.cmake
Normal file
@ -0,0 +1,21 @@
|
||||
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()
|
Loading…
Reference in New Issue
Block a user