From 122e1427264ed995071418054314e4b5293598fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Tue, 24 Oct 2023 21:53:58 +0200 Subject: [PATCH] fixed #12113 - made CMake build work with UBSAN and GCC (#5590) GCC does not support `-fsanitize=nullability` --- cmake/dynamic_analyzer_options.cmake | 10 ++++++++-- releasenotes.txt | 1 + 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/cmake/dynamic_analyzer_options.cmake b/cmake/dynamic_analyzer_options.cmake index b5dc5077b..a1f96f133 100644 --- a/cmake/dynamic_analyzer_options.cmake +++ b/cmake/dynamic_analyzer_options.cmake @@ -19,11 +19,17 @@ endif() if(ANALYZE_UNDEFINED) # TODO: enable signed-integer-overflow - add_compile_options(-fsanitize=undefined -fsanitize=nullability -fno-sanitize=signed-integer-overflow) + add_compile_options(-fsanitize=undefined -fno-sanitize=signed-integer-overflow) + if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") + add_compile_options(-fsanitize=nullability) + endif() add_compile_options(-fno-sanitize-recover=all) add_compile_options(-fno-omit-frame-pointer) - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=undefined -fsanitize=nullability -fno-sanitize=signed-integer-overflow") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=undefined -fno-sanitize=signed-integer-overflow") + if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=nullability") + endif() endif() if(ANALYZE_DATAFLOW) diff --git a/releasenotes.txt b/releasenotes.txt index 5a1631f01..99fa49afd 100644 --- a/releasenotes.txt +++ b/releasenotes.txt @@ -28,3 +28,4 @@ Other: - You can suppress warnings in a block of code using "-begin" and "-end". - You can suppress warnings in current file using "-file". - You can suppress all warnings where macro is used using "-macro" +- fixed CMake build with UBSAN and GCC