Index: cmake/config-ix.cmake =================================================================== --- cmake/config-ix.cmake +++ cmake/config-ix.cmake @@ -144,7 +144,7 @@ if (SANITIZER_COMMON_SUPPORTED_ARCH AND NOT LLVM_USE_SANITIZER AND (OS_NAME MATCHES "Android|Darwin|Linux|FreeBSD" OR - (OS_NAME MATCHES "Windows" AND MSVC AND CMAKE_SIZEOF_VOID_P EQUAL 4))) + (OS_NAME MATCHES "Windows" AND CMAKE_SIZEOF_VOID_P EQUAL 4))) set(COMPILER_RT_HAS_SANITIZER_COMMON TRUE) else() set(COMPILER_RT_HAS_SANITIZER_COMMON FALSE) Index: lib/asan/CMakeLists.txt =================================================================== --- lib/asan/CMakeLists.txt +++ lib/asan/CMakeLists.txt @@ -193,10 +193,17 @@ CFLAGS ${ASAN_CFLAGS} -DASAN_DLL_THUNK DEFS ${ASAN_COMMON_DEFINITIONS}) add_dependencies(asan clang_rt.asan_dll_thunk-${arch}) + + if(MSVC) + set(OMIT_DEFAULT_LIB_NAME_FLAG "-Zl") + else() + set(OMIT_DEFAULT_LIB_NAME_FLAG "") + endif() + add_compiler_rt_runtime(clang_rt.asan_dynamic_runtime_thunk-${arch} ${arch} STATIC SOURCES asan_win_dynamic_runtime_thunk.cc - CFLAGS ${ASAN_CFLAGS} -DASAN_DYNAMIC_RUNTIME_THUNK -Zl + CFLAGS ${ASAN_CFLAGS} -DASAN_DYNAMIC_RUNTIME_THUNK ${OMIT_DEFAULT_LIB_NAME_FLAG} DEFS ${ASAN_COMMON_DEFINITIONS}) add_dependencies(asan clang_rt.asan_dynamic_runtime_thunk-${arch}) endif() Index: lib/asan/asan_win_dll_thunk.cc =================================================================== --- lib/asan/asan_win_dll_thunk.cc +++ lib/asan/asan_win_dll_thunk.cc @@ -23,6 +23,12 @@ #include "asan_init_version.h" #include "sanitizer_common/sanitizer_interception.h" +#ifdef _MSC_VER +#define DEBUG_BREAK __debugbreak() +#else +#define DEBUG_BREAK __asm__ __volatile__("int $3") +#endif + // ---------- Function interception helper functions and macros ----------- {{{1 extern "C" { void *__stdcall GetModuleHandleA(const char *module_name); @@ -77,7 +83,7 @@ #define INTERFACE_FUNCTION(name) \ extern "C" __declspec(noinline) void name() { \ volatile int prevent_icf = (__LINE__ << 8); (void)prevent_icf; \ - __debugbreak(); \ + DEBUG_BREAK; \ } \ INTERCEPT_WHEN_POSSIBLE(#name, name)