[cmake] Pass /manifest:no to the linker when asan is enabled
authorReid Kleckner <rnk@google.com>
Tue, 25 Aug 2015 16:06:40 +0000 (16:06 +0000)
committerReid Kleckner <rnk@google.com>
Tue, 25 Aug 2015 16:06:40 +0000 (16:06 +0000)
This is a workaround for PR24476.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@245945 91177308-0d34-0410-b5e6-96231b3b80d8

cmake/modules/HandleLLVMOptions.cmake

index 7a6f633..76b9c3f 100644 (file)
@@ -456,7 +456,7 @@ macro(append_common_sanitizer_flags)
     # stack traces.
     add_flag_if_supported("-fno-omit-frame-pointer" FNO_OMIT_FRAME_POINTER)
     if (NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG" AND
-       NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "RELWITHDEBINFO")
+        NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "RELWITHDEBINFO")
       add_flag_if_supported("-gline-tables-only" GLINE_TABLES_ONLY)
     endif()
     # Use -O1 even in debug mode, otherwise sanitizers slowdown is too large.
@@ -469,6 +469,10 @@ macro(append_common_sanitizer_flags)
     if (CMAKE_LINKER MATCHES "lld-link.exe")
       # Use DWARF debug info with LLD.
       append("-gdwarf" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
+      # Pass /MANIFEST:NO so that CMake doesn't run mt.exe on our binaries.
+      # Adding manifests with mt.exe breaks LLD's symbol tables. See PR24476.
+      append("/MANIFEST:NO"
+        CMAKE_EXE_LINKER_FLAGS CMAKE_MODULE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS)
     else()
       # Enable codeview otherwise.
       append("/Z7" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)