In my (linux-based) CI/CD pipeline i'm currently doing (basically):
- Build Release (cmake out-of-source-build)
- Test/(Custom-)Fuzz the build
- Build Instrumentation-focused = gcov + ASan (again: cmake)
- Test/(Custom-)Fuzz the build
- Process Coverage (gcovr)
This is based on GCC 10 right now.
While thinking about adding Sonarqube-based analysis (which means using a build-wrapper which hopefully is as non-intrusive as described -> i even considered a 3rd build due to being somewhat scared!), i wondered about the original approach i have taken:
Is it safe / correct / a good idea to fuse the code-coverage and memory-sanitization instrumentation into a single build?
Is there any chance that i lose something (e.g. power of ASan-reasoning, coverage count accuracy, non-linear slowdowns) compared to independent builds (which sadly increases the time needed as we need to run the tests twice)?
Edit:
For what it's worth, a few more details on what it means using gcov/asan for me (yes: it's not as clean as it could be in regards to other parts of the cmake-def):
# Code Coverage Analysis
option(ENABLE_CODE_COVERAGE_ANALYSIS "Enable instrumentalization-based code-coverage" OFF)
if (${ENABLE_CODE_COVERAGE_ANALYSIS})
message(STATUS "Instrumentalize for code-coverage analysis.")
add_definitions(--coverage)
set(COV_LINKING gcov)
endif()
# ASAN Memory Sanitization
option(ENABLE_ASAN "Enable ASAN" OFF)
if (${ENABLE_ASAN})
message(STATUS "Instrumentalize for ASAN")
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")
# suppress GRPC ASAN stuff
# https://github.com/grpc/grpc/pull/22325/files
add_definitions("-DGRPC_ASAN_SUPPRESSED")
endif()