From 500fed496c4fe6ea0b652812c4a22bddf02807c7 Mon Sep 17 00:00:00 2001 From: Leonid Yuriev Date: Fri, 3 Jul 2020 01:55:42 +0300 Subject: [PATCH] mdbx-cmake: add ENABLE_UBSAN option. Change-Id: Ic4333f28aa6494be24c7be1f396bd069dcb9bb5d --- cmake/compiler.cmake | 4 ++++ cmake/profile.cmake | 3 +++ 2 files changed, 7 insertions(+) diff --git a/cmake/compiler.cmake b/cmake/compiler.cmake index fca9886f..e13225d6 100644 --- a/cmake/compiler.cmake +++ b/cmake/compiler.cmake @@ -651,6 +651,10 @@ macro(setup_compile_flags) add_compile_flags("C;CXX" -fsanitize=address) endif() + if(ENABLE_UBSAN) + add_compile_flags("C;CXX" -fsanitize=undefined) + endif() + if(ENABLE_GCOV) if(NOT HAVE_GCOV) message(FATAL_ERROR diff --git a/cmake/profile.cmake b/cmake/profile.cmake index c1c4f78e..cf285653 100644 --- a/cmake/profile.cmake +++ b/cmake/profile.cmake @@ -42,4 +42,7 @@ endif() option(ENABLE_ASAN "Enable AddressSanitizer, a fast memory error detector based on compiler instrumentation" OFF) +option(ENABLE_UBSAN + "Enable UndefinedBehaviorSanitizer, a fast undefined behavior detector based on compiler instrumentation" OFF) + cmake_policy(POP)