From: Eric Fiselier Date: Tue, 7 Feb 2017 22:48:20 +0000 (+0000) Subject: [CMake] Fix USE_LLVM_SANITIZER configuration for out-of-tree builds. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9652e72de3d26151cf31c1efa169b2a55ca3c502;p=llvm [CMake] Fix USE_LLVM_SANITIZER configuration for out-of-tree builds. Summary: r291918 changed `HandleLLVMOptions.cmake` to add `-fsanitize-blacklist=` when `LLVM_USE_SANITIZER=Undefined` is specified. This breaks out-of-tree users of `LLVM_USE_SANITIZER` since that file is not present. This patch fixes the issue by checking if the file exists first. Reviewers: mgorny, bogner, vitalybuka, krasin Reviewed By: krasin Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D29686 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@294367 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/cmake/modules/HandleLLVMOptions.cmake b/cmake/modules/HandleLLVMOptions.cmake index fd6969ff6f1..50a8541206b 100644 --- a/cmake/modules/HandleLLVMOptions.cmake +++ b/cmake/modules/HandleLLVMOptions.cmake @@ -589,8 +589,11 @@ if(LLVM_USE_SANITIZER) append_common_sanitizer_flags() append("-fsanitize=undefined -fno-sanitize=vptr,function -fno-sanitize-recover=all" CMAKE_C_FLAGS CMAKE_CXX_FLAGS) - append("-fsanitize-blacklist=${CMAKE_SOURCE_DIR}/utils/sanitizers/ubsan_blacklist.txt" - CMAKE_C_FLAGS CMAKE_CXX_FLAGS) + set(BLACKLIST_FILE "${CMAKE_SOURCE_DIR}/utils/sanitizers/ubsan_blacklist.txt") + if (EXISTS "${BLACKLIST_FILE}") + append("-fsanitize-blacklist=${BLACKLIST_FILE}" + CMAKE_C_FLAGS CMAKE_CXX_FLAGS) + endif() elseif (LLVM_USE_SANITIZER STREQUAL "Thread") append_common_sanitizer_flags() append("-fsanitize=thread" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)