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:
		@@ -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)
 | 
			
		||||
 
 | 
			
		||||
@@ -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")
 | 
			
		||||
 
 | 
			
		||||
@@ -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)
 | 
			
		||||
 
 | 
			
		||||
@@ -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)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user