]> granicus.if.org Git - llvm/commitdiff
[CMake] Fix USE_LLVM_SANITIZER configuration for out-of-tree builds.
authorEric Fiselier <eric@efcs.ca>
Tue, 7 Feb 2017 22:48:20 +0000 (22:48 +0000)
committerEric Fiselier <eric@efcs.ca>
Tue, 7 Feb 2017 22:48:20 +0000 (22:48 +0000)
Summary:
r291918 changed `HandleLLVMOptions.cmake` to add `-fsanitize-blacklist=<llvm-file>` 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

cmake/modules/HandleLLVMOptions.cmake

index fd6969ff6f1474910f5948b5bf83cf59d008b1e9..50a8541206b971fa4d87b19b1447295c65cf9943 100644 (file)
@@ -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)