Hi samsonov,
"check-asan" passes all the tests with both MT and MD with this patch applied
and COMPILER_RT_BUILD_SHARED_ASAN set to ON
(PR20214)
http://reviews.llvm.org/D5051
Files:
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/test/Driver/cl-link.c
compiler-rt/trunk/lib/asan/CMakeLists.txt
compiler-rt/trunk/lib/asan/asan_uar_thunk.cc
Index: cfe/trunk/lib/Driver/Tools.cpp
===================================================================
--- cfe/trunk/lib/Driver/Tools.cpp
+++ cfe/trunk/lib/Driver/Tools.cpp
@@ -7820,7 +7820,10 @@
CmdArgs.push_back(Args.MakeArgString("-debug"));
CmdArgs.push_back(Args.MakeArgString("-incremental:no"));
// FIXME: Handle 64-bit.
- if (DLL) {
+ if (Args.hasArg(options::OPT__SLASH_MD, options::OPT__SLASH_MDd)) {
+ addSanitizerRTWindows(getToolChain(), Args, CmdArgs, "asan_dynamic-i386");
+ addSanitizerRTWindows(getToolChain(), Args, CmdArgs, "asan_uar_thunk-i386");
+ } else if (DLL) {
addSanitizerRTWindows(getToolChain(), Args, CmdArgs,
"asan_dll_thunk-i386");
} else {
Index: cfe/trunk/test/Driver/cl-link.c
===================================================================
--- cfe/trunk/test/Driver/cl-link.c
+++ cfe/trunk/test/Driver/cl-link.c
@@ -19,6 +19,14 @@
// ASAN: "{{.*}}clang_rt.asan_cxx-i386.lib"
// ASAN: "{{.*}}cl-link{{.*}}.obj"
+// RUN: %clang_cl /MD /Tc%s -### -fsanitize=address 2>&1 | FileCheck --check-prefix=ASAN-MD %s
+// ASAN-MD: link.exe
+// ASAN-MD: "-debug"
+// ASAN-MD: "-incremental:no"
+// ASAN-MD: "{{.*}}clang_rt.asan_dynamic-i386.lib"
+// ASAN-MD: "{{.*}}clang_rt.asan_uar_thunk-i386.lib"
+// ASAN-MD: "{{.*}}cl-link{{.*}}.obj"
+
// RUN: %clang_cl /LD -### /Tc%s 2>&1 | FileCheck --check-prefix=DLL %s
// RUN: %clang_cl /LDd -### /Tc%s 2>&1 | FileCheck --check-prefix=DLL %s
// DLL: link.exe
Index: compiler-rt/trunk/lib/asan/CMakeLists.txt
===================================================================
--- compiler-rt/trunk/lib/asan/CMakeLists.txt
+++ compiler-rt/trunk/lib/asan/CMakeLists.txt
@@ -187,6 +187,11 @@
CFLAGS ${ASAN_CFLAGS} -DASAN_DLL_THUNK
DEFS ${ASAN_COMMON_DEFINITIONS})
add_dependencies(asan clang_rt.asan_dll_thunk-${arch})
+ add_compiler_rt_runtime(clang_rt.asan_uar_thunk-${arch} ${arch} STATIC
+ SOURCES asan_uar_thunk.cc
+ CFLAGS ${ASAN_CFLAGS} -DASAN_UAR_THUNK
+ DEFS ${ASAN_COMMON_DEFINITIONS})
+ add_dependencies(asan clang_rt.asan_uar_thunk-${arch})
endif()
endforeach()
endif()
Index: compiler-rt/trunk/lib/asan/asan_uar_thunk.cc
===================================================================
--- compiler-rt/trunk/lib/asan/asan_uar_thunk.cc
+++ compiler-rt/trunk/lib/asan/asan_uar_thunk.cc
@@ -0,0 +1,30 @@
+//===-- asan_uar_thunk.cc -------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file is a part of AddressSanitizer, an address sanity checker.
+//
+// This file defines a copy of __asan_option_detect_stack_use_after_return that
+// should be used when linking an MD runtime with a set of object files.
+//
+// An MD runtime dllexports this variable, so normally we would dllimport it in
+// each TU. Unfortunately, in general we don't know if a given TU is going to
+// be used with a MT or MD runtime.
+//===----------------------------------------------------------------------===//
+
+// Only compile this code when buidling asan_uar_thunk.lib
+// Using #ifdef rather than relying on Makefiles etc.
+// simplifies the build procedure.
+#ifdef ASAN_UAR_THUNK
+extern "C" {
+__declspec(dllimport) int __asan_should_detect_stack_use_after_return();
+
+int __asan_option_detect_stack_use_after_return =
+ __asan_should_detect_stack_use_after_return();
+}
+#endif // ASAN_DLL_THUNK
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits