diff --git a/.circleci/config.yml b/.circleci/config.yml index 2bb2c7f..6d1e489 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -12,6 +12,22 @@ jobs: command: | make lint + sanitize: + docker: + - image: redislabsmodules/llvm-toolset:latest + steps: + - checkout + - run: + name: Install CMAKE + command: 'apt install -y cmake' + - run: + name: Pull Submodules + command: git submodule update --init --recursive + - run: + name: Build & Test with sanitizers + command: | + make sanitize + static-analysis-infer: docker: - image: redisbench/infer-linux64:1.0.0 @@ -64,6 +80,7 @@ workflows: jobs: - lint - build + - sanitize nightly: triggers: - schedule: diff --git a/CMakeLists.txt b/CMakeLists.txt index a69413a..2c24767 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,6 +28,16 @@ IF(NOT CMAKE_BUILD_TYPE) "Debug" "Release" "MinSizeRel" "RelWithDebInfo") ENDIF() + +if(ENABLE_SANITIZERS) + message(STATUS "Forcing build type to Debug to run coverage.") + set(CMAKE_BUILD_TYPE "Debug" CACHE + STRING "Choose the type of build." FORCE) + set (CMAKE_C_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address") + set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address") + set (CMAKE_LINKER_FLAGS_DEBUG "${CMAKE_LINKER_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address") +ENDIF() + if(ENABLE_CODECOVERAGE) message(STATUS "Forcing build type to Debug to run coverage.") set(CMAKE_BUILD_TYPE "Debug" CACHE diff --git a/Makefile b/Makefile index 0f06c34..db8f06a 100644 --- a/Makefile +++ b/Makefile @@ -61,6 +61,18 @@ ifndef CMAKE_PROFILE_OPTIONS endif +ifndef CMAKE_SANITIZE_OPTIONS + CMAKE_SANITIZE_OPTIONS=\ + -DBUILD_SHARED=ON \ + -DBUILD_STATIC=OFF \ + -DENABLE_CODECOVERAGE=OFF \ + -DBUILD_TESTS=ON \ + -DBUILD_BENCHMARK=OFF \ + -DBUILD_EXAMPLES=OFF \ + -DENABLE_PROFILE=OFF \ + -DENABLE_SANITIZERS=ON +endif + ifndef CMAKE_TEST_OPTIONS CMAKE_TEST_OPTIONS=\ -DBUILD_SHARED=ON \ @@ -124,6 +136,10 @@ clean: distclean distclean: rm -rf build/* +sanitize: clean + ( mkdir -p build; cd build ; cmake $(CMAKE_SANITIZE_OPTIONS) .. ; $(MAKE) VERBOSE=1 ) + $(SHOW) build/tests/td_test + profile: clean ( mkdir -p build; cd build ; cmake $(CMAKE_PROFILE_OPTIONS) .. ; $(MAKE) VERBOSE=1 2> $(basename $@).compiler_stedrr_output.txt )