From ba46a47e07bb1982736136665f6f527466fdbf4d Mon Sep 17 00:00:00 2001 From: Alexey Samsonov Date: Thu, 30 Jul 2015 00:50:40 +0000 Subject: [PATCH] [Sanitizer] Replace diagnostic string literal to workaround CMake 2.8 bug. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Let me tell you a story. Suppose you want to build your project (e.g. LLVM) with CMake 2.8, Clang and AddressSanitizer. You also want to ensure that Clang is fresh enough and check that CMAKE_CXX_COMPILER_VERSION is 3.1+. This check would fail - CMake would fail to correctly calculate compiler version if you pass CMAKE_CXX_FLAGS=-fsanitize=address. The problem is funky compiler version calculation in CMakeDetermineCompilerId.cmake module: it compiles the sample source file with provided compiler and compile flags, runs "strings" and greps for "INFO:" ASCII strings contained on the executable to fetch "INFO:compiler", "INFO:compiler_version" etc. It limits the output of grep to just 4 lines. Unfortunately, if your executable was built with ASan, it would also contain an ASCII string INFO: %s ignores mlock/mlockall/munlock/munlockall and INFO:compiler_version string would never be parsed. All of the above actually happened after r243574 when we tried to configure libcxx with just-built Clang with TSan/MSan, and the version check mentioned above failed in HandleLLVMOptions.cmake (╯°□°)╯.~.┻━┻ llvm-svn: 243599 --- .../lib/sanitizer_common/sanitizer_common_interceptors.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc index f0de440c2d5f..b14dce62a9ee 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc +++ b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc @@ -4957,7 +4957,7 @@ static void MlockIsUnsupported() { static atomic_uint8_t printed; if (atomic_exchange(&printed, 1, memory_order_relaxed)) return; - VPrintf(1, "INFO: %s ignores mlock/mlockall/munlock/munlockall\n", + VPrintf(1, "%s ignores mlock/mlockall/munlock/munlockall\n", SanitizerToolName); }