From 1aec96bffdce7e835aa33f01f44269594a955548 Mon Sep 17 00:00:00 2001 From: Andreas Buhr Date: Thu, 12 Nov 2020 17:01:38 +0100 Subject: [PATCH] update KDE-ECM CMake modules to include fuzzer sanitizer Updates one 3rdparty CMake file from https://github.com/KDE/extra-cmake-modules to include support for fuzzing. Task-number: QTBUG-88429 Change-Id: I19e7ed3c5602c34ba4b86e6b0df2ea3047c7c9e6 Reviewed-by: Robert Loehning Reviewed-by: Alexandru Croitor --- .../modules/ECMEnableSanitizers.cmake | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/cmake/3rdparty/extra-cmake-modules/modules/ECMEnableSanitizers.cmake b/cmake/3rdparty/extra-cmake-modules/modules/ECMEnableSanitizers.cmake index e7bffe15c1..4c43e99b6b 100644 --- a/cmake/3rdparty/extra-cmake-modules/modules/ECMEnableSanitizers.cmake +++ b/cmake/3rdparty/extra-cmake-modules/modules/ECMEnableSanitizers.cmake @@ -40,6 +40,8 @@ # - thread # - leak # - undefined +# - fuzzer-no-link +# - fuzzer # # The sanitizers "address", "memory" and "thread" are mutually exclusive. You # cannot enable two of them in the same build. @@ -140,6 +142,13 @@ macro (enable_sanitizer_flags sanitize_option) elseif (${sanitize_option} MATCHES "undefined") check_compiler_version("4.9" "3.1") set(XSAN_COMPILE_FLAGS "-fsanitize=undefined -fsanitize=float-divide-by-zero -fno-omit-frame-pointer -fno-optimize-sibling-calls") + elseif (${sanitize_option} MATCHES "fuzzer-no-link") + check_compiler_version("99.99" "6.0") + set(XSAN_COMPILE_FLAGS "-fsanitize=fuzzer-no-link") + set(XSAN_LINKER_FLAGS "-fsanitize=fuzzer-no-link") + elseif (${sanitize_option} MATCHES "fuzzer") + check_compiler_version("99.99" "6.0") + set(XSAN_COMPILE_FLAGS "-fsanitize=fuzzer") else () message(FATAL_ERROR "Compiler sanitizer option \"${sanitize_option}\" not supported.") endif () @@ -161,7 +170,7 @@ if (ECM_ENABLE_SANITIZERS) if(CMAKE_CXX_COMPILER_ID MATCHES "GNU") link_libraries(${XSAN_LINKER_FLAGS}) endif() - if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") string(REPLACE "-Wl,--no-undefined" "" CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}") string(REPLACE "-Wl,--no-undefined" "" CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS}") endif ()