Added checks to avoid bad sanitizer combinations.

Some sanitizers are not compatible with other sanitizers. Added some checks to
avoid these combinations at configuration time.
This commit is contained in:
Alexander Haase 2016-04-12 21:04:21 +02:00
parent 6975d64d6b
commit f566e2b9ec
4 changed files with 21 additions and 22 deletions

View File

@ -33,9 +33,18 @@ set(FLAG_CANDIDATES
)
if (SANITIZE_ADDRESS AND (SANITIZE_THREAD OR SANITIZE_MEMORY))
message(FATAL_ERROR "AddressSanitizer is not compatible with "
"ThreadSanitizer or MemorySanitizer.")
endif ()
include(sanitize-helpers)
sanitizer_check_compiler_flags("${FLAG_CANDIDATES}" "AddressSanitizer" "ASan")
if (SANITIZE_ADDRESS)
sanitizer_check_compiler_flags("${FLAG_CANDIDATES}" "AddressSanitizer"
"ASan")
endif ()
function (add_sanitize_address TARGET)
if (NOT SANITIZE_ADDRESS)

View File

@ -22,25 +22,6 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
# The following options will enable the desired sanitizers.
option(SANITIZE "Enable all available sanitizers for sanitized targets." OFF)
# If option SANITIZE is enabled, enable all available sanitizers.
if (SANITIZE)
set(SANITIZE_ADDRESS ON CACHE BOOL
"Enable AddressSanitizer for sanitized targets." FORCE)
set(SANITIZE_THREAD ON CACHE BOOL
"Enable ThreadSanitizer for sanitized targets." FORCE)
set(SANITIZE_MEMORY ON CACHE BOOL
"Enable MemorySanitizer for sanitized targets." FORCE)
set(SANITIZE_UNDEFINED ON CACHE BOOL
"Enable UndefinedBehaviorSanitizer for sanitized targets." FORCE)
endif (SANITIZE)
set(FIND_QUIETLY_FLAG "")
if (DEFINED Sanitizers_FIND_QUIETLY)
set(FIND_QUIETLY_FLAG "QUIET")

View File

@ -29,6 +29,13 @@ set(FLAG_CANDIDATES
)
# ThreadSanitizer is not compatible with MemorySanitizer.
if (SANITIZE_THREAD AND SANITIZE_MEMORY)
message(FATAL_ERROR "ThreadSanitizer is not compatible with "
"MemorySanitizer.")
endif ()
include(sanitize-helpers)
if (SANITIZE_THREAD)

View File

@ -32,8 +32,10 @@ set(FLAG_CANDIDATES
include(sanitize-helpers)
sanitizer_check_compiler_flags("${FLAG_CANDIDATES}" "UndefinedBehaviorSanitizer"
"UBSan")
if (SANITIZE_UNDEFINED)
sanitizer_check_compiler_flags("${FLAG_CANDIDATES}"
"UndefinedBehaviorSanitizer" "UBSan")
endif ()
function (add_sanitize_undefined TARGET)
if (NOT SANITIZE_UNDEFINED)